-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Morpho Gauntlet Prime Strategies for OUSD (#2317)
* Deploy script for Morpho Gauntlet Prime USDC Strategy to the OUSD Vault Refactored the exiting MetaMorpho deploy script and fork tests as there will be many Morpho strategies * Generalized4626Strategy now uses safeApprove as USDT is being used Added deploy script for Morpho Gauntlet Prime USDT Strategy * Add fork tests for Morpho Gauntlet USDT strategy * Fix typo in Natspec * Added Generalized4626USDTStrategy contract for Morpho Gauntlet Prime USDT strategy * Fixed typos in tests * Update OUSD Vault fork test * Fix Slither for IUSDT approve * Renamed fork test files
- Loading branch information
1 parent
fa077cd
commit f4bb1af
Showing
14 changed files
with
1,268 additions
and
113 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
36 changes: 36 additions & 0 deletions
36
contracts/contracts/strategies/Generalized4626USDTStrategy.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,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
|
||
interface IUSDT { | ||
// Tether's approve does not return a bool like standard IERC20 contracts | ||
// slither-disable-next-line erc20-interface | ||
function approve(address _spender, uint _value) external; | ||
} | ||
|
||
/** | ||
* @title Generalized 4626 Strategy when asset is Tether USD (USDT) | ||
* @notice Investment strategy for ERC-4626 Tokenized Vaults for the USDT asset. | ||
* @author Origin Protocol Inc | ||
*/ | ||
import { Generalized4626Strategy } from "./Generalized4626Strategy.sol"; | ||
|
||
contract Generalized4626USDTStrategy is Generalized4626Strategy { | ||
/** | ||
* @param _baseConfig Base strategy config with platformAddress (ERC-4626 Vault contract), eg sfrxETH or sDAI, | ||
* and vaultAddress (OToken Vault contract), eg VaultProxy or OETHVaultProxy | ||
* @param _assetToken Address of the ERC-4626 asset token. eg frxETH or DAI | ||
*/ | ||
constructor( | ||
BaseStrategyConfig memory _baseConfig, | ||
address _assetToken | ||
) Generalized4626Strategy(_baseConfig, _assetToken) {} | ||
|
||
/// @dev Override for Tether as USDT does not return a bool on approve. | ||
/// Using assetToken.approve will fail as it expects a bool return value | ||
function _approveBase() internal virtual override { | ||
// Approval the asset to be transferred to the ERC-4626 Tokenized Vault. | ||
// Used by the ERC-4626 deposit() and mint() functions | ||
// slither-disable-next-line unused-return | ||
IUSDT(address(assetToken)).approve(platformAddress, type(uint256).max); | ||
} | ||
} |
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,95 @@ | ||
const addresses = require("../../utils/addresses"); | ||
const { deploymentWithGovernanceProposal } = require("../../utils/deploy"); | ||
|
||
module.exports = deploymentWithGovernanceProposal( | ||
{ | ||
deployName: "112_ousd_morpho_gauntlet_usdc", | ||
forceDeploy: false, | ||
// forceSkip: true, | ||
// reduceQueueTime: true, | ||
deployerIsProposer: false, | ||
// proposalId: "", | ||
}, | ||
async ({ deployWithConfirmation, getTxOpts, withConfirmation }) => { | ||
// Current OUSD Vault contracts | ||
const cVaultProxy = await ethers.getContract("VaultProxy"); | ||
const cVaultAdmin = await ethers.getContractAt( | ||
"VaultAdmin", | ||
cVaultProxy.address | ||
); | ||
const cHarvesterProxy = await ethers.getContract("HarvesterProxy"); | ||
const cHarvester = await ethers.getContractAt( | ||
"Harvester", | ||
cHarvesterProxy.address | ||
); | ||
|
||
// Deployer Actions | ||
// ---------------- | ||
const { deployerAddr } = await getNamedAccounts(); | ||
const sDeployer = await ethers.provider.getSigner(deployerAddr); | ||
|
||
// 1. Deploy new Morpho Gauntlet Prime USDC Strategy proxy | ||
const dMorphoGauntletPrimeUSDCProxy = await deployWithConfirmation( | ||
"MorphoGauntletPrimeUSDCStrategyProxy" | ||
); | ||
const cMorphoGauntletPrimeUSDCProxy = await ethers.getContract( | ||
"MorphoGauntletPrimeUSDCStrategyProxy" | ||
); | ||
|
||
// 2. Deploy new Generalized4626Strategy contract as it has an immutable to the Morpho Vault contract | ||
const dGeneralized4626Strategy = await deployWithConfirmation( | ||
"Generalized4626Strategy", | ||
[ | ||
[addresses.mainnet.MorphoGauntletPrimeUSDCVault, cVaultProxy.address], | ||
addresses.mainnet.USDC, | ||
] | ||
); | ||
const cMorphoGauntletPrimeUSDC = await ethers.getContractAt( | ||
"Generalized4626Strategy", | ||
dMorphoGauntletPrimeUSDCProxy.address | ||
); | ||
|
||
// 3. Construct initialize call data to initialize and configure the new strategy | ||
const initData = cMorphoGauntletPrimeUSDC.interface.encodeFunctionData( | ||
"initialize()", | ||
[] | ||
); | ||
|
||
// 4. Init the proxy to point at the implementation, set the governor, and call initialize | ||
const initFunction = "initialize(address,address,bytes)"; | ||
await withConfirmation( | ||
cMorphoGauntletPrimeUSDCProxy.connect(sDeployer)[initFunction]( | ||
dGeneralized4626Strategy.address, | ||
addresses.mainnet.Timelock, // governor | ||
initData, // data for delegate call to the initialize function on the strategy | ||
await getTxOpts() | ||
) | ||
); | ||
|
||
// Governance Actions | ||
// ---------------- | ||
return { | ||
name: "Add Morpho Gauntlet Prime USDC Strategy to the OUSD Vault", | ||
actions: [ | ||
{ | ||
// Add the new strategy to the vault | ||
contract: cVaultAdmin, | ||
signature: "approveStrategy(address)", | ||
args: [cMorphoGauntletPrimeUSDC.address], | ||
}, | ||
{ | ||
// Add the new strategy to the Harvester | ||
contract: cHarvester, | ||
signature: "setSupportedStrategy(address,bool)", | ||
args: [cMorphoGauntletPrimeUSDC.address, true], | ||
}, | ||
{ | ||
// Set the Harvester in the new strategy | ||
contract: cMorphoGauntletPrimeUSDC, | ||
signature: "setHarvesterAddress(address)", | ||
args: [cHarvesterProxy.address], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
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,95 @@ | ||
const addresses = require("../../utils/addresses"); | ||
const { deploymentWithGovernanceProposal } = require("../../utils/deploy"); | ||
|
||
module.exports = deploymentWithGovernanceProposal( | ||
{ | ||
deployName: "113_ousd_morpho_gauntlet_usdt", | ||
forceDeploy: false, | ||
// forceSkip: true, | ||
// reduceQueueTime: true, | ||
deployerIsProposer: false, | ||
// proposalId: "", | ||
}, | ||
async ({ deployWithConfirmation, getTxOpts, withConfirmation }) => { | ||
// Current OUSD Vault contracts | ||
const cVaultProxy = await ethers.getContract("VaultProxy"); | ||
const cVaultAdmin = await ethers.getContractAt( | ||
"VaultAdmin", | ||
cVaultProxy.address | ||
); | ||
const cHarvesterProxy = await ethers.getContract("HarvesterProxy"); | ||
const cHarvester = await ethers.getContractAt( | ||
"Harvester", | ||
cHarvesterProxy.address | ||
); | ||
|
||
// Deployer Actions | ||
// ---------------- | ||
const { deployerAddr } = await getNamedAccounts(); | ||
const sDeployer = await ethers.provider.getSigner(deployerAddr); | ||
|
||
// 1. Deploy new Morpho Gauntlet Prime USDT Strategy proxy | ||
const dMorphoGauntletPrimeUSDTProxy = await deployWithConfirmation( | ||
"MorphoGauntletPrimeUSDTStrategyProxy" | ||
); | ||
const cMorphoGauntletPrimeUSDTProxy = await ethers.getContract( | ||
"MorphoGauntletPrimeUSDTStrategyProxy" | ||
); | ||
|
||
// 2. Deploy new Generalized4626USDTStrategy contract as it has an immutable to the Morpho Vault contract | ||
const dGeneralized4626USDTStrategy = await deployWithConfirmation( | ||
"Generalized4626USDTStrategy", | ||
[ | ||
[addresses.mainnet.MorphoGauntletPrimeUSDTVault, cVaultProxy.address], | ||
addresses.mainnet.USDT, | ||
] | ||
); | ||
const cMorphoGauntletPrimeUSDT = await ethers.getContractAt( | ||
"Generalized4626USDTStrategy", | ||
dMorphoGauntletPrimeUSDTProxy.address | ||
); | ||
|
||
// 3. Construct initialize call data to initialize and configure the new strategy | ||
const initData = cMorphoGauntletPrimeUSDT.interface.encodeFunctionData( | ||
"initialize()", | ||
[] | ||
); | ||
|
||
// 4. Init the proxy to point at the implementation, set the governor, and call initialize | ||
const initFunction = "initialize(address,address,bytes)"; | ||
await withConfirmation( | ||
cMorphoGauntletPrimeUSDTProxy.connect(sDeployer)[initFunction]( | ||
dGeneralized4626USDTStrategy.address, | ||
addresses.mainnet.Timelock, // governor | ||
initData, // data for delegate call to the initialize function on the strategy | ||
await getTxOpts() | ||
) | ||
); | ||
|
||
// Governance Actions | ||
// ---------------- | ||
return { | ||
name: "Add Morpho Gauntlet Prime USDT Strategy to the OUSD Vault", | ||
actions: [ | ||
{ | ||
// Add the new strategy to the vault | ||
contract: cVaultAdmin, | ||
signature: "approveStrategy(address)", | ||
args: [cMorphoGauntletPrimeUSDT.address], | ||
}, | ||
{ | ||
// Add the new strategy to the Harvester | ||
contract: cHarvester, | ||
signature: "setSupportedStrategy(address,bool)", | ||
args: [cMorphoGauntletPrimeUSDT.address, true], | ||
}, | ||
{ | ||
// Set the Harvester in the new strategy | ||
contract: cMorphoGauntletPrimeUSDT, | ||
signature: "setHarvesterAddress(address)", | ||
args: [cHarvesterProxy.address], | ||
}, | ||
], | ||
}; | ||
} | ||
); |
Oops, something went wrong.