-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72b2ec4
commit 80f5257
Showing
16 changed files
with
1,556 additions
and
1 deletion.
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
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,88 @@ | ||
/* | ||
This file is part of the Enzyme Protocol. | ||
(c) Enzyme Council <council@enzyme.finance> | ||
For the full license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
*/ | ||
|
||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity >=0.6.0 <0.9.0; | ||
|
||
/// @title IMorphoBlue Interface | ||
/// @author Enzyme Council <security@enzyme.finance> | ||
interface IMorphoBlue { | ||
struct MarketParams { | ||
address loanToken; | ||
address collateralToken; | ||
address oracle; | ||
address irm; | ||
uint256 lltv; | ||
} | ||
|
||
struct Position { | ||
uint256 supplyShares; | ||
uint128 borrowShares; | ||
uint128 collateral; | ||
} | ||
|
||
struct Market { | ||
uint128 totalSupplyAssets; | ||
uint128 totalSupplyShares; | ||
uint128 totalBorrowAssets; | ||
uint128 totalBorrowShares; | ||
uint128 lastUpdate; | ||
uint128 fee; | ||
} | ||
|
||
function supply( | ||
MarketParams memory _marketParams, | ||
uint256 _assets, | ||
uint256 _shares, | ||
address _onBehalf, | ||
bytes memory _data | ||
) external returns (uint256 assetsSupplied_, uint256 sharesSupplied_); | ||
|
||
function withdraw( | ||
MarketParams memory _marketParams, | ||
uint256 _assets, | ||
uint256 _shares, | ||
address _onBehalf, | ||
address _receiver | ||
) external returns (uint256 assetsWithdrawn_, uint256 sharesWithdrawn_); | ||
|
||
function borrow( | ||
MarketParams memory _marketParams, | ||
uint256 _assets, | ||
uint256 _shares, | ||
address _onBehalf, | ||
address _receiver | ||
) external returns (uint256 assetsBorrowed_, uint256 sharesBorrowed_); | ||
|
||
function repay( | ||
MarketParams memory _marketParams, | ||
uint256 _assets, | ||
uint256 _shares, | ||
address _onBehalf, | ||
bytes memory _data | ||
) external returns (uint256 assetsRepaid_, uint256 sharesRepaid_); | ||
|
||
function supplyCollateral(MarketParams memory _marketParams, uint256 _assets, address _onBehalf, bytes memory _data) | ||
external; | ||
|
||
function withdrawCollateral( | ||
MarketParams memory _marketParams, | ||
uint256 _assets, | ||
address _onBehalf, | ||
address _receiver | ||
) external; | ||
|
||
function accrueInterest(MarketParams memory _marketParams) external; | ||
|
||
function idToMarketParams(bytes32 _id) external view returns (MarketParams memory marketParams_); | ||
|
||
function market(bytes32 _id) external view returns (Market memory market_); | ||
|
||
function position(bytes32 _id, address _user) external view returns (Position memory position_); | ||
} |
27 changes: 27 additions & 0 deletions
27
...tensions/external-position-manager/external-positions/morpho-blue/IMorphoBluePosition.sol
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,27 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
/* | ||
This file is part of the Enzyme Protocol. | ||
(c) Enzyme Foundation <council@enzyme.finance> | ||
For the full license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
*/ | ||
|
||
import {IExternalPosition} from "../../IExternalPosition.sol"; | ||
|
||
pragma solidity >=0.6.0 <0.9.0; | ||
|
||
/// @title IMorphoBluePosition Interface | ||
/// @author Enzyme Foundation <security@enzyme.finance> | ||
interface IMorphoBluePosition is IExternalPosition { | ||
enum Actions { | ||
Lend, | ||
Redeem, | ||
AddCollateral, | ||
RemoveCollateral, | ||
Borrow, | ||
Repay | ||
} | ||
|
||
function getMarketIds() external view returns (bytes32[] memory marketIds_); | ||
} |
69 changes: 69 additions & 0 deletions
69
...xternal-position-manager/external-positions/morpho-blue/MorphoBluePositionDataDecoder.sol
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,69 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
|
||
/* | ||
This file is part of the Enzyme Protocol. | ||
(c) Enzyme Foundation <council@enzyme.finance> | ||
For the full license information, please view the LICENSE | ||
file that was distributed with this source code. | ||
*/ | ||
|
||
pragma solidity 0.8.19; | ||
|
||
/// @title MorphoBluePositionDataDecoder Contract | ||
/// @author Enzyme Foundation <security@enzyme.finance> | ||
/// @notice Abstract contract containing data decodings for IMorphoBluePosition payloads | ||
abstract contract MorphoBluePositionDataDecoder { | ||
/// @dev Helper to decode args used during the AddCollateral action | ||
function __decodeAddCollateralActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (bytes32 marketId_, uint256 collateralAmount_) | ||
{ | ||
return abi.decode(_actionArgs, (bytes32, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Borrow action | ||
function __decodeBorrowActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (bytes32 marketId_, uint256 borrowAmount_) | ||
{ | ||
return abi.decode(_actionArgs, (bytes32, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Lend action | ||
function __decodeLendActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (bytes32 marketId_, uint256 lendAmount_) | ||
{ | ||
return abi.decode(_actionArgs, (bytes32, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Redeem action | ||
function __decodeRedeemActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (bytes32 marketId_, uint256 sharesAmount_) | ||
{ | ||
return abi.decode(_actionArgs, (bytes32, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the RemoveCollateral action | ||
function __decodeRemoveCollateralActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (bytes32 marketId_, uint256 collateralAmount_) | ||
{ | ||
return abi.decode(_actionArgs, (bytes32, uint256)); | ||
} | ||
|
||
/// @dev Helper to decode args used during the Repay action | ||
function __decodeRepayActionArgs(bytes memory _actionArgs) | ||
internal | ||
pure | ||
returns (bytes32 marketId_, uint256 repayAmount_) | ||
{ | ||
return abi.decode(_actionArgs, (bytes32, uint256)); | ||
} | ||
} |
Oops, something went wrong.