-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a Morpho Blue integration (#1094)
* Implemented a basic version of the `addLiquidity` circuit breaker * Fixed `test_lp_withdrawal_long_and_short_maturity` * Fixed the remaining tests * add priceDiscoveryCheck to LPMath and also check it in initialize * use initial price * add tests and fix placement of check * remove lib from LPMath * remove comment * remove console import * remove console import * fix price discovery tests * fixed tests * commit test to investigate * add test_solvency_at_0_apr * add test_solvency_cross_checkpoint_long_short * address review feedback * Update test/integrations/hyperdrive/PriceDiscovery.t.sol * Added some testing examples * Minor updates * Updated `verifyPriceDiscovery` to `calculateSolvencyAfterMaxLong` * Cleaned up the tests * Increased the efficiency of the solvency check * Fixed the code size issue * Addressed Saw Mon's comment * Improved one of the price discovery tests * Updated the price discovery tests * Fixed the remaining tests * Addressed review feedback from @mcclurejt * Fixed the deployment scripts * Generated the code for the Aave integration * forge install: aave-v3-core v1.19.1 * Fixed codegen and compiler errors * Implemented `_convertToBase` and `_convertToShares` for AaveHyperdrive * Implemented the deposit functions for the AaveHyperdrive instance * Implemented the withdrawal logic for ATokens * Addressed most of the remaining FIXMEs * Reduced the code-size of the Aave integration * Copied over the instance test * Added a fourth target to fix the codesize issues * Started work on the AaveHyperdrive tests * Fixed some of the tests * Fixed more tests * Fixed the remaining Aave instance tests * Fixed the other instance tests * Addressed remaining FIXMEs and fixed the code generator * Fixed the publish scripts * Lowered the minimum share reserves * Addressed review feedback from @jrhea * Added conversion functions to the public interfaces for instances and deployer coordinators * Added the skeleton for `MorphoBlueHyperdrive` * Sketched out the implementation plan * forge install: morpho-blue v1.0.0 * Made some progress on the Morpho integration * Updated the Morpho Blue integration to use a struct in the constructors * Addressed the remaining FIXMEs in the Morpho Blue integration * Wrote the morpho tests * Updated some tests * "Fixed" the tests * Improved the Morpho Blue tests to add confidence in the integration * Fixed tests * Fixed the stETH tests * Addressed review feedback from @jrhea and @mcclurejt --------- Co-authored-by: jonny rhea <[email protected]> Co-authored-by: Jonny Rhea <[email protected]>
- Loading branch information
1 parent
c8b9ece
commit 2514eec
Showing
33 changed files
with
2,098 additions
and
133 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
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
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
62 changes: 62 additions & 0 deletions
62
contracts/src/deployers/morpho-blue/MorphoBlueHyperdriveCoreDeployer.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,62 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.20; | ||
|
||
import { IHyperdrive } from "../../interfaces/IHyperdrive.sol"; | ||
import { IHyperdriveCoreDeployer } from "../../interfaces/IHyperdriveCoreDeployer.sol"; | ||
import { IMorphoBlueHyperdrive } from "../../interfaces/IMorphoBlueHyperdrive.sol"; | ||
import { MorphoBlueHyperdrive } from "../../instances/morpho-blue/MorphoBlueHyperdrive.sol"; | ||
|
||
/// @author DELV | ||
/// @title MorphoBlueHyperdriveCoreDeployer | ||
/// @notice The core deployer for the MorphoBlueHyperdrive implementation. | ||
/// @custom:disclaimer The language used in this code is for coding convenience | ||
/// only, and is not intended to, and does not, have any | ||
/// particular legal or regulatory significance. | ||
contract MorphoBlueHyperdriveCoreDeployer is IHyperdriveCoreDeployer { | ||
/// @notice Deploys a Hyperdrive instance with the given parameters. | ||
/// @param __name The name of the Hyperdrive pool. | ||
/// @param _config The configuration of the Hyperdrive pool. | ||
/// @param _extraData The extra data for the Morpho instance. This contains | ||
/// the market parameters that weren't specified in the config. | ||
/// @param _target0 The target0 address. | ||
/// @param _target1 The target1 address. | ||
/// @param _target2 The target2 address. | ||
/// @param _target3 The target3 address. | ||
/// @param _target4 The target4 address. | ||
/// @param _salt The create2 salt used in the deployment. | ||
/// @return The address of the newly deployed MorphoBlueHyperdrive instance. | ||
function deployHyperdrive( | ||
string memory __name, | ||
IHyperdrive.PoolConfig memory _config, | ||
bytes memory _extraData, | ||
address _target0, | ||
address _target1, | ||
address _target2, | ||
address _target3, | ||
address _target4, | ||
bytes32 _salt | ||
) external returns (address) { | ||
IMorphoBlueHyperdrive.MorphoBlueParams memory params = abi.decode( | ||
_extraData, | ||
(IMorphoBlueHyperdrive.MorphoBlueParams) | ||
); | ||
return ( | ||
address( | ||
// NOTE: We hash the sender with the salt to prevent the | ||
// front-running of deployments. | ||
new MorphoBlueHyperdrive{ | ||
salt: keccak256(abi.encode(msg.sender, _salt)) | ||
}( | ||
__name, | ||
_config, | ||
_target0, | ||
_target1, | ||
_target2, | ||
_target3, | ||
_target4, | ||
params | ||
) | ||
) | ||
); | ||
} | ||
} |
Oops, something went wrong.