Skip to content

Commit

Permalink
Revert "update version"
Browse files Browse the repository at this point in the history
This reverts commit 19d03f0.
  • Loading branch information
q1q0 committed Nov 17, 2023
1 parent 70120e4 commit 5d5e489
Show file tree
Hide file tree
Showing 6 changed files with 4,061 additions and 567 deletions.
2 changes: 1 addition & 1 deletion contracts/mainnet/common/interfaces.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;
pragma abicoder v2;

interface TokenInterface {
function approve(address, uint256) external;
Expand Down
61 changes: 61 additions & 0 deletions contracts/mainnet/connectors/morpho-blue/events.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

contract Events {

event LogSupply(
address loanToken,
uint256 assets,
uint256 shares,
address onBehalf,
bytes data,
uint256 getId,
uint256 setId
);

event LogSupplyCollateral(
address loanToken,
address poolTokenAddress,
uint256 amount,
uint256 maxGasForMatching,
uint256 getId,
uint256 setId
);

event LogBorrow(
address loanToken,
uint256 amounts,
uint256 shares,
address onBehalf,
uint256 getId,
uint256 setId
);

event LogWithdraw(
address loanToken,
uint256 amounts,
uint256 shares,
address onBehalf,
uint256 getId,
uint256 setId
);

event LogWithdrawCollateral(
address loanToken,
uint256 amounts,
address onBehalf,
uint256 getId,
uint256 setId
);

event LogPayback(
address loanToken,
uint256 amounts,
uint256 shares,
address onBehalf,
bytes data,
uint256 getId,
uint256 setId
);
}
43 changes: 43 additions & 0 deletions contracts/mainnet/connectors/morpho-blue/helpers.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./interface.sol";
import "../../common/stores.sol";
import "../../common/basic.sol";
import "../../common/interfaces.sol";

abstract contract Helpers is Stores, Basic {

IMorpho public constant MORPHO_BLUE =
IMorpho(0x777777c9898D384F785Ee44Acfe945efDFf5f3E0);



function _performEthToWethConversion(
address _tokenAddress,
uint256 _amount,
uint256 _getId
) internal returns (TokenInterface _tokenContract, uint256 _amt, bool _isMax) {
_amt = getUint(_getId, _amount);
_isMax = _amt == uint256(-1);

if (_tokenAddress == ethAddr) {
_tokenContract = TokenInterface(wethAddr);
if (_amt == uint256(-1)) _amt = address(this).balance;
convertEthToWeth(true, _tokenContract, _amt);
} else {
_tokenContract = TokenInterface(_tokenAddress);
if (_amt == uint256(-1)) _amt = _tokenContract.balanceOf(address(this));
}
}

uint256 internal constant MARKET_PARAMS_BYTES_LENGTH = 5 * 32;

/// @notice Returns the id of the market `marketParams`.
function id(MarketParams memory marketParams) internal pure returns (bytes32 marketParamsId) {
assembly {
marketParamsId := keccak256(marketParams, MARKET_PARAMS_BYTES_LENGTH)
}
}
}
65 changes: 65 additions & 0 deletions contracts/mainnet/connectors/morpho-blue/interface.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

// type Id is bytes32;

struct MarketParams {
address loanToken;
address collateralToken;
address oracle;
address irm;
uint256 lltv;
}

/// @dev Warning: For `feeRecipient`, `supplyShares` does not contain the accrued shares since the last interest
/// accrual.
struct Position {
uint256 supplyShares;
uint128 borrowShares;
uint128 collateral;
}


interface IMorpho {
function createMarket(MarketParams memory marketParams) external;

function supply(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalf,
bytes calldata data
) external returns (uint256, uint256);

function withdraw(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalf,
address receiver
) external returns (uint256, uint256);

function borrow(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalf,
address receiver
) external returns (uint256, uint256);

function repay(
MarketParams memory marketParams,
uint256 assets,
uint256 shares,
address onBehalf,
bytes calldata data
) external returns (uint256, uint256);

function supplyCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, bytes calldata data) external;

function withdrawCollateral(MarketParams memory marketParams, uint256 assets, address onBehalf, address receiver) external;

function position(bytes32 id, address user) external view returns(Position memory);
}

Loading

0 comments on commit 5d5e489

Please sign in to comment.