-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 19d03f0.
- Loading branch information
q1q0
committed
Nov 17, 2023
1 parent
70120e4
commit 5d5e489
Showing
6 changed files
with
4,061 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
Oops, something went wrong.