-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Taylor Brent <[email protected]> Co-authored-by: Akshat Mittal <[email protected]> Co-authored-by: Patrick McKelvy <[email protected]>
- Loading branch information
1 parent
c727c40
commit bfc32a0
Showing
11 changed files
with
690 additions
and
389 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
138 changes: 138 additions & 0 deletions
138
scripts/deployment/phase2-assets/collaterals/deploy_aerodrome_usdz_usdc.ts
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,138 @@ | ||
import fs from 'fs' | ||
import hre, { ethers } from 'hardhat' | ||
import { getChainId } from '../../../../common/blockchain-utils' | ||
import { baseL2Chains, networkConfig } from '../../../../common/configuration' | ||
import { expect } from 'chai' | ||
import { CollateralStatus, ONE_ADDRESS } from '../../../../common/constants' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
getDeploymentFilename, | ||
fileExists, | ||
} from '../../common' | ||
import { AerodromeStableCollateral, AerodromeGaugeWrapper, IAeroPool } from '../../../../typechain' | ||
import { combinedError } from '../../utils' | ||
import { | ||
AerodromePoolType, | ||
DEFAULT_THRESHOLD, | ||
DELAY_UNTIL_DEFAULT, | ||
MAX_TRADE_VOL, | ||
PRICE_TIMEOUT, | ||
USDC_ORACLE_ERROR, | ||
USDC_ORACLE_TIMEOUT, | ||
USDC_USD_FEED, | ||
AERO_USDz_USDC_POOL, | ||
AERO_USDz_USDC_GAUGE, | ||
AERO, | ||
USDz_ORACLE_ERROR, | ||
USDz_ORACLE_TIMEOUT, | ||
USDz_USD_FEED, | ||
} from '../../../../test/plugins/individual-collateral/aerodrome/constants' | ||
|
||
// Convex Stable Plugin: crvUSD-USDC | ||
|
||
async function main() { | ||
// ==== Read Configuration ==== | ||
const [deployer] = await hre.ethers.getSigners() | ||
|
||
const chainId = await getChainId(hre) | ||
|
||
console.log(`Deploying Collateral to network ${hre.network.name} (${chainId}) | ||
with burner account: ${deployer.address}`) | ||
|
||
if (!networkConfig[chainId]) { | ||
throw new Error(`Missing network configuration for ${hre.network.name}`) | ||
} | ||
|
||
// Get phase1 deployment | ||
const phase1File = getDeploymentFilename(chainId) | ||
if (!fileExists(phase1File)) { | ||
throw new Error(`${phase1File} doesn't exist yet. Run phase 1`) | ||
} | ||
// Check previous step completed | ||
const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) | ||
const assetCollDeployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename) | ||
|
||
const deployedCollateral: string[] = [] | ||
|
||
/******** Deploy Aerodrome Stable Pool for USDz-USDC **************************/ | ||
|
||
let collateral: AerodromeStableCollateral | ||
let wusdzusdc: AerodromeGaugeWrapper | ||
|
||
// Only for Base | ||
if (baseL2Chains.includes(hre.network.name)) { | ||
const AerodromeStableCollateralFactory = await hre.ethers.getContractFactory( | ||
'AerodromeStableCollateral' | ||
) | ||
const AerodromeGaugeWrapperFactory = await ethers.getContractFactory('AerodromeGaugeWrapper') | ||
|
||
// Deploy gauge wrapper | ||
const pool = <IAeroPool>await ethers.getContractAt('IAeroPool', AERO_USDz_USDC_POOL) | ||
wusdzusdc = <AerodromeGaugeWrapper>( | ||
await AerodromeGaugeWrapperFactory.deploy( | ||
pool.address, | ||
'w' + (await pool.name()), | ||
'w' + (await pool.symbol()), | ||
AERO, | ||
AERO_USDz_USDC_GAUGE | ||
) | ||
) | ||
await wusdzusdc.deployed() | ||
|
||
console.log( | ||
`Deployed wrapper for Aerodrome Stable USDz-USDC pool on ${hre.network.name} (${chainId}): ${wusdzusdc.address} ` | ||
) | ||
|
||
const oracleError = combinedError(USDC_ORACLE_ERROR, USDz_ORACLE_ERROR) // 0.3% & 0.5% | ||
|
||
collateral = <AerodromeStableCollateral>await AerodromeStableCollateralFactory.connect( | ||
deployer | ||
).deploy( | ||
{ | ||
erc20: wusdzusdc.address, | ||
targetName: ethers.utils.formatBytes32String('USD'), | ||
priceTimeout: PRICE_TIMEOUT, | ||
chainlinkFeed: ONE_ADDRESS, // unused but cannot be zero | ||
oracleError: oracleError.toString(), // unused but cannot be zero | ||
oracleTimeout: USDC_ORACLE_TIMEOUT, // max of oracleTimeouts | ||
maxTradeVolume: MAX_TRADE_VOL, | ||
defaultThreshold: DEFAULT_THRESHOLD, | ||
delayUntilDefault: DELAY_UNTIL_DEFAULT, | ||
}, | ||
{ | ||
pool: AERO_USDz_USDC_POOL, | ||
poolType: AerodromePoolType.Stable, | ||
feeds: [[USDz_USD_FEED], [USDC_USD_FEED]], | ||
oracleTimeouts: [[USDz_ORACLE_TIMEOUT], [USDC_ORACLE_TIMEOUT]], | ||
oracleErrors: [[USDz_ORACLE_ERROR], [USDC_ORACLE_ERROR]], | ||
} | ||
) | ||
} else { | ||
throw new Error(`Unsupported chainId: ${chainId}`) | ||
} | ||
|
||
await collateral.deployed() | ||
await (await collateral.refresh()).wait() | ||
expect(await collateral.status()).to.equal(CollateralStatus.SOUND) | ||
|
||
console.log( | ||
`Deployed Aerodrome Stable Collateral for USDz-USDC to ${hre.network.name} (${chainId}): ${collateral.address}` | ||
) | ||
|
||
assetCollDeployments.collateral.aeroUSDzUSDC = collateral.address | ||
assetCollDeployments.erc20s.aeroUSDzUSDC = wusdzusdc.address | ||
deployedCollateral.push(collateral.address.toString()) | ||
|
||
fs.writeFileSync(assetCollDeploymentFilename, JSON.stringify(assetCollDeployments, null, 2)) | ||
|
||
console.log(`Deployed collateral to ${hre.network.name} (${chainId}) | ||
New deployments: ${deployedCollateral} | ||
Deployment file: ${assetCollDeploymentFilename}`) | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
102 changes: 102 additions & 0 deletions
102
scripts/verification/collateral-plugins/verify_aerodrome_usdz_usdc.ts
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,102 @@ | ||
import hre, { ethers } from 'hardhat' | ||
import { getChainId } from '../../../common/blockchain-utils' | ||
import { baseL2Chains, developmentChains, networkConfig } from '../../../common/configuration' | ||
import { ONE_ADDRESS } from '../../../common/constants' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
} from '../../deployment/common' | ||
import { verifyContract } from '../../deployment/utils' | ||
import { combinedError } from '../../deployment/utils' | ||
import { IAeroPool } from '@typechain/IAeroPool' | ||
import { | ||
AerodromePoolType, | ||
DEFAULT_THRESHOLD, | ||
DELAY_UNTIL_DEFAULT, | ||
MAX_TRADE_VOL, | ||
PRICE_TIMEOUT, | ||
AERO_USDz_USDC_POOL, | ||
AERO_USDz_USDC_GAUGE, | ||
AERO, | ||
USDC_ORACLE_ERROR, | ||
USDC_ORACLE_TIMEOUT, | ||
USDC_USD_FEED, | ||
USDz_ORACLE_ERROR, | ||
USDz_ORACLE_TIMEOUT, | ||
USDz_USD_FEED, | ||
} from '../../../test/plugins/individual-collateral/aerodrome/constants' | ||
|
||
let deployments: IAssetCollDeployments | ||
|
||
async function main() { | ||
// ********** Read config ********** | ||
const chainId = await getChainId(hre) | ||
if (!networkConfig[chainId]) { | ||
throw new Error(`Missing network configuration for ${hre.network.name}`) | ||
} | ||
|
||
if (developmentChains.includes(hre.network.name)) { | ||
throw new Error(`Cannot verify contracts for development chain ${hre.network.name}`) | ||
} | ||
|
||
const assetCollDeploymentFilename = getAssetCollDeploymentFilename(chainId) | ||
deployments = <IAssetCollDeployments>getDeploymentFile(assetCollDeploymentFilename) | ||
|
||
// Only on base, aways use wrapper | ||
if (baseL2Chains.includes(hre.network.name)) { | ||
const aeroUSDzUSDCPoolCollateral = await ethers.getContractAt( | ||
'AerodromeStableCollateral', | ||
deployments.collateral.aeroUSDzUSDC as string | ||
) | ||
|
||
/******** Verify Gauge Wrapper **************************/ | ||
|
||
const pool = <IAeroPool>await ethers.getContractAt('IAeroPool', AERO_USDz_USDC_POOL) | ||
await verifyContract( | ||
chainId, | ||
await aeroUSDzUSDCPoolCollateral.erc20(), | ||
[ | ||
pool.address, | ||
'w' + (await pool.name()), | ||
'w' + (await pool.symbol()), | ||
AERO, | ||
AERO_USDz_USDC_GAUGE, | ||
], | ||
'contracts/plugins/assets/aerodrome/AerodromeGaugeWrapper.sol:AerodromeGaugeWrapper' | ||
) | ||
|
||
/******** Verify USDz-USDC plugin **************************/ | ||
const oracleError = combinedError(USDC_ORACLE_ERROR, USDz_ORACLE_ERROR) // 0.3% & 0.5% | ||
await verifyContract( | ||
chainId, | ||
deployments.collateral.aeroUSDzUSDC, | ||
[ | ||
{ | ||
erc20: await aeroUSDzUSDCPoolCollateral.erc20(), | ||
targetName: ethers.utils.formatBytes32String('USD'), | ||
priceTimeout: PRICE_TIMEOUT, | ||
chainlinkFeed: ONE_ADDRESS, // unused but cannot be zero | ||
oracleError: oracleError.toString(), | ||
oracleTimeout: USDC_ORACLE_TIMEOUT, // max of oracleTimeouts | ||
maxTradeVolume: MAX_TRADE_VOL, | ||
defaultThreshold: DEFAULT_THRESHOLD, | ||
delayUntilDefault: DELAY_UNTIL_DEFAULT, | ||
}, | ||
{ | ||
pool: AERO_USDz_USDC_POOL, | ||
poolType: AerodromePoolType.Stable, | ||
feeds: [[USDz_USD_FEED], [USDC_USD_FEED]], | ||
oracleTimeouts: [[USDz_ORACLE_TIMEOUT], [USDC_ORACLE_TIMEOUT]], | ||
oracleErrors: [[USDz_ORACLE_ERROR], [USDC_ORACLE_ERROR]], | ||
}, | ||
], | ||
'contracts/plugins/assets/aerodrome/AerodromeStableCollateral.sol:AerodromeStableCollateral' | ||
) | ||
} | ||
} | ||
|
||
main().catch((error) => { | ||
console.error(error) | ||
process.exitCode = 1 | ||
}) |
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
Oops, something went wrong.