Skip to content

Commit

Permalink
Aerodrome usdz-usdc plugin (#1224)
Browse files Browse the repository at this point in the history
Co-authored-by: Taylor Brent <[email protected]>
Co-authored-by: Akshat Mittal <[email protected]>
Co-authored-by: Patrick McKelvy <[email protected]>
  • Loading branch information
4 people authored Nov 6, 2024
1 parent c727c40 commit bfc32a0
Show file tree
Hide file tree
Showing 11 changed files with 690 additions and 389 deletions.
10 changes: 7 additions & 3 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,13 @@ export interface ITokens {
USDM?: string
wUSDM?: string

// Aerodrome
AERO?: string
USDz?: string

// Sky
USDS?: string
sUSDS?: string

// Aerodrome
AERO?: string
}

export type ITokensKeys = Array<keyof ITokens>
Expand Down Expand Up @@ -153,6 +154,7 @@ export interface IPools {
crvMIM3Pool?: string
sdUSDCUSDCPlus?: string
aeroUSDCeUSD?: string
aeroUSDzUSDC?: string
}

interface INetworkConfig {
Expand Down Expand Up @@ -531,6 +533,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
wstETH: '0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452',
STG: '0xE3B53AF74a4BF62Ae5511055290838050bf764Df',
eUSD: '0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4',
USDz: '0x04D5ddf5f3a8939889F11E97f8c4BB48317F1938',
meUSD: '0xbb819D845b573B5D7C538F5b85057160cfb5f313',
AERO: '0x940181a94A35A4569E4529A3CDfB74e38FD98631',
},
Expand All @@ -550,6 +553,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
ETHUSD: '0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70', // 0.15%, 20min
wstETHstETH: '0xB88BAc61a4Ca37C43a3725912B1f472c9A5bc061', // 0.5%, 24h
eUSD: '0x9b2C948dbA5952A1f5Ab6fA16101c1392b8da1ab', // 0.5%, 24h
USDz: '0xe25969e2Fa633a0C027fAB8F30Fc9C6A90D60B48', // 0.5%, 24h
AERO: '0x4EC5970fC728C5f65ba413992CD5fF6FD70fcfF0', // 0.5%, 24h
},
GNOSIS_EASY_AUCTION: '0xb1875Feaeea32Bbb02DE83D81772e07E37A40f02', // mock
Expand Down
8 changes: 5 additions & 3 deletions scripts/addresses/8453-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"cUSDCv3": "0xf7a9D27c3B60c78c6F6e2c2d6ED6E8B94b352461",
"wstETH": "0x8b4374005291B8FCD14C4E947604b2FB3C660A73",
"meUSD": "0x0f1e10871e6a2D3A5Aa696b85b39d61a22A9e8C3",
"aeroUSDCeUSD": "0x9216CD5cA133aBBd23cc6F873bB4a95A78032db0"
"aeroUSDCeUSD": "0x9216CD5cA133aBBd23cc6F873bB4a95A78032db0",
"aeroUSDzUSDC": "0x8AAdfbea33146e28170F99D031B7747EAa87DDD4"
},
"erc20s": {
"COMP": "0x9e1028F5F1D5eDE59748FFceE5532509976840E0",
Expand All @@ -29,6 +30,7 @@
"wstETH": "0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452",
"meUSD": "0xbb819D845b573B5D7C538F5b85057160cfb5f313",
"aeroUSDCeUSD": "0xDB5b8cead52f77De0f6B5255f73F348AAf2CBb8D",
"AERO": "0x940181a94A35A4569E4529A3CDfB74e38FD98631"
"AERO": "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
"aeroUSDzUSDC": "0x246Df11B856E9fD6120494F168475e1b41321c61"
}
}
}
6 changes: 4 additions & 2 deletions scripts/addresses/base-4.0.0/8453-tmp-assets-collateral.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
},
"collateral": {
"meUSD": "0x0f1e10871e6a2D3A5Aa696b85b39d61a22A9e8C3",
"aeroUSDCeUSD": "0x9216CD5cA133aBBd23cc6F873bB4a95A78032db0"
"aeroUSDCeUSD": "0x9216CD5cA133aBBd23cc6F873bB4a95A78032db0",
"aeroUSDzUSDC": "0x8AAdfbea33146e28170F99D031B7747EAa87DDD4"
},
"erc20s": {
"meUSD": "0xbb819D845b573B5D7C538F5b85057160cfb5f313",
"aeroUSDCeUSD": "0xDB5b8cead52f77De0f6B5255f73F348AAf2CBb8D",
"AERO": "0x940181a94A35A4569E4529A3CDfB74e38FD98631"
"AERO": "0x940181a94A35A4569E4529A3CDfB74e38FD98631",
"aeroUSDzUSDC": "0x246Df11B856E9fD6120494F168475e1b41321c61"
}
}
3 changes: 2 additions & 1 deletion scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ async function main() {
'phase2-assets/collaterals/deploy_cbeth_collateral.ts',
'phase2-assets/assets/deploy_stg.ts',
'phase2-assets/collaterals/deploy_morphoeUSD.ts',
'phase2-assets/collaterals/deploy_aerodrome_usdc_eusd.ts'
'phase2-assets/collaterals/deploy_aerodrome_usdc_eusd.ts',
'phase2-assets/collaterals/deploy_aerodrome_usdz_usdc.ts'
)
} else if (chainId == '42161' || chainId == '421614') {
// Arbitrum One
Expand Down
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 scripts/verification/collateral-plugins/verify_aerodrome_usdz_usdc.ts
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
})
3 changes: 2 additions & 1 deletion scripts/verify_etherscan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ async function main() {
'collateral-plugins/verify_cbeth.ts',
'assets/verify_stg.ts',
'collateral-plugins/verify_morphoeUSD.ts',
'collateral-plugins/verify_aerodrome_usdc_eusd.ts'
'collateral-plugins/verify_aerodrome_usdc_eusd.ts',
'collateral-plugins/verify_aerodrome_usdz_usdc.ts'
)
} else if (chainId == '42161' || chainId == '421614') {
// Arbitrum One
Expand Down
Loading

0 comments on commit bfc32a0

Please sign in to comment.