Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/certora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,27 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Install submodules
run: git submodule update --init --recursive
with:
submodules: recursive

- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install certora
run: pip install certora-cli
run: pip install certora-cli-beta

- name: Install solc
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.19/solc-static-linux
wget https://github.com/ethereum/solidity/releases/download/v0.8.21/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc8.19
sudo mv solc-static-linux /usr/local/bin/solc8.21

- name: Verify rule ${{ matrix.script }}
run: |
echo "key length" ${#CERTORAKEY}
bash certora/scripts/${{ matrix.script }} --solc solc8.19
bash certora/scripts/${{ matrix.script }} --solc solc8.21
env:
CERTORAKEY: ${{ secrets.CERTORAKEY }}

Expand Down
2 changes: 1 addition & 1 deletion certora/harness/MorphoHarness.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity 0.8.19;
pragma solidity 0.8.21;

import "../../src/Morpho.sol";
import "../../src/libraries/SharesMathLib.sol";
Expand Down
5 changes: 2 additions & 3 deletions certora/specs/Blue.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ methods {

function getMarketId(MorphoHarness.Market) external returns MorphoHarness.Id envfree;

// Temporary workaround a bug that requires to have address instead of an interface in the signature
function SafeTransferLib.tmpSafeTransfer(address token, address to, uint256 value) internal => summarySafeTransferFrom(token, currentContract, to, value);
function SafeTransferLib.tmpSafeTransferFrom(address token, address from, address to, uint256 value) internal => summarySafeTransferFrom(token, from, to, value);
function SafeTransferLib.safeTransfer(address token, address to, uint256 value) internal => summarySafeTransferFrom(token, currentContract, to, value);
function SafeTransferLib.safeTransferFrom(address token, address from, address to, uint256 value) internal => summarySafeTransferFrom(token, from, to, value);
}

ghost mapping(MorphoHarness.Id => mathint) sumSupplyShares
Expand Down
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const config: HardhatUserConfig = {
solidity: {
compilers: [
{
version: "0.8.19",
version: "0.8.21",
settings: {
optimizer: {
enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion src/Morpho.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.19;
pragma solidity 0.8.21;

import {Id, IMorpho, Market, Authorization, Signature} from "./interfaces/IMorpho.sol";
import {IFlashLender} from "./interfaces/IFlashLender.sol";
Expand Down
17 changes: 4 additions & 13 deletions src/libraries/SafeTransferLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,20 @@ import {IERC20} from "../interfaces/IERC20.sol";
/// @notice Library to manage tokens not fully ERC20 compliant:
/// not returning a boolean for `transfer` and `transferFrom` functions.
library SafeTransferLib {
function tmpSafeTransfer(address token, address to, uint256 value) internal {
(bool success, bytes memory returndata) =
address(token).call(abi.encodeCall(IERC20(token).transfer, (to, value)));
function safeTransfer(IERC20 token, address to, uint256 value) internal {
(bool success, bytes memory returndata) = address(token).call(abi.encodeCall(token.transfer, (to, value)));
require(
success && address(token).code.length > 0 && (returndata.length == 0 || abi.decode(returndata, (bool))),
ErrorsLib.TRANSFER_FAILED
);
}

function tmpSafeTransferFrom(address token, address from, address to, uint256 value) internal {
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
(bool success, bytes memory returndata) =
address(token).call(abi.encodeCall(IERC20(token).transferFrom, (from, to, value)));
address(token).call(abi.encodeCall(token.transferFrom, (from, to, value)));
require(
success && address(token).code.length > 0 && (returndata.length == 0 || abi.decode(returndata, (bool))),
ErrorsLib.TRANSFER_FROM_FAILED
);
}

function safeTransfer(IERC20 token, address to, uint256 value) internal {
tmpSafeTransfer(address(token), to, value);
}

function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
tmpSafeTransferFrom(address(token), from, to, value);
}
}