-
Notifications
You must be signed in to change notification settings - Fork 108
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: Patrick McKelvy <[email protected]>
- Loading branch information
Showing
5 changed files
with
214 additions
and
0 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
119 changes: 119 additions & 0 deletions
119
scripts/deployment/phase2-assets/collaterals/deploy_convex_paypool_collateral.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,119 @@ | ||
import fs from 'fs' | ||
import hre, { ethers } from 'hardhat' | ||
import { getChainId } from '../../../../common/blockchain-utils' | ||
import { networkConfig } from '../../../../common/configuration' | ||
import { bn } from '../../../../common/numbers' | ||
import { expect } from 'chai' | ||
import { CollateralStatus, ONE_ADDRESS } from '../../../../common/constants' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
getDeploymentFilename, | ||
fileExists, | ||
} from '../../common' | ||
import { CurveStableCollateral } from '../../../../typechain' | ||
import { revenueHiding } from '../../utils' | ||
import { | ||
CurvePoolType, | ||
pyUSD_ORACLE_ERROR, | ||
pyUSD_ORACLE_TIMEOUT, | ||
pyUSD_USD_FEED, | ||
DEFAULT_THRESHOLD, | ||
DELAY_UNTIL_DEFAULT, | ||
MAX_TRADE_VOL, | ||
PRICE_TIMEOUT, | ||
PayPool, | ||
PayPool_POOL_ID, | ||
USDC_ORACLE_ERROR, | ||
USDC_ORACLE_TIMEOUT, | ||
USDC_USD_FEED, | ||
} from '../../../../test/plugins/individual-collateral/curve/constants' | ||
|
||
// Convex Stable Plugin: paypool | ||
|
||
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 Convex Stable Pool for 3pool **************************/ | ||
|
||
const CurveStableCollateralFactory = await hre.ethers.getContractFactory('CurveStableCollateral') | ||
const ConvexStakingWrapperFactory = await ethers.getContractFactory('ConvexStakingWrapper') | ||
|
||
const payPool = await ConvexStakingWrapperFactory.deploy() | ||
await payPool.deployed() | ||
await (await payPool.initialize(PayPool_POOL_ID)).wait() | ||
|
||
console.log( | ||
`Deployed wrapper for Convex Stable PayPool on ${hre.network.name} (${chainId}): ${payPool.address} ` | ||
) | ||
|
||
const collateral = <CurveStableCollateral>await CurveStableCollateralFactory.connect( | ||
deployer | ||
).deploy( | ||
{ | ||
erc20: payPool.address, | ||
targetName: ethers.utils.formatBytes32String('USD'), | ||
priceTimeout: PRICE_TIMEOUT, | ||
chainlinkFeed: ONE_ADDRESS, // unused but cannot be zero | ||
oracleError: bn('1'), // unused but cannot be zero | ||
oracleTimeout: USDC_ORACLE_TIMEOUT, // max of oracleTimeouts | ||
maxTradeVolume: MAX_TRADE_VOL, | ||
defaultThreshold: DEFAULT_THRESHOLD, | ||
delayUntilDefault: DELAY_UNTIL_DEFAULT, | ||
}, | ||
revenueHiding.toString(), | ||
{ | ||
nTokens: 2, | ||
curvePool: PayPool, | ||
poolType: CurvePoolType.Plain, | ||
feeds: [[pyUSD_USD_FEED], [USDC_USD_FEED]], | ||
oracleTimeouts: [[pyUSD_ORACLE_TIMEOUT], [USDC_ORACLE_TIMEOUT]], | ||
oracleErrors: [[pyUSD_ORACLE_ERROR], [USDC_ORACLE_ERROR]], | ||
lpToken: PayPool, | ||
} | ||
) | ||
await collateral.deployed() | ||
await (await collateral.refresh()).wait() | ||
expect(await collateral.status()).to.equal(CollateralStatus.SOUND) | ||
|
||
console.log( | ||
`Deployed Convex Stable Collateral for PayPool to ${hre.network.name} (${chainId}): ${collateral.address}` | ||
) | ||
|
||
assetCollDeployments.collateral.cvxPayPool = collateral.address | ||
assetCollDeployments.erc20s.cvxPayPool = payPool.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 | ||
}) |
92 changes: 92 additions & 0 deletions
92
scripts/verification/collateral-plugins/verify_convex_paypool.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,92 @@ | ||
import hre, { ethers } from 'hardhat' | ||
import { getChainId } from '../../../common/blockchain-utils' | ||
import { developmentChains, networkConfig } from '../../../common/configuration' | ||
import { bn } from '../../../common/numbers' | ||
import { ONE_ADDRESS } from '../../../common/constants' | ||
import { | ||
getDeploymentFile, | ||
getAssetCollDeploymentFilename, | ||
IAssetCollDeployments, | ||
} from '../../deployment/common' | ||
import { verifyContract } from '../../deployment/utils' | ||
import { revenueHiding } from '../../deployment/utils' | ||
import { | ||
CurvePoolType, | ||
pyUSD_ORACLE_ERROR, | ||
pyUSD_ORACLE_TIMEOUT, | ||
pyUSD_USD_FEED, | ||
DEFAULT_THRESHOLD, | ||
DELAY_UNTIL_DEFAULT, | ||
MAX_TRADE_VOL, | ||
PRICE_TIMEOUT, | ||
PayPool, | ||
USDC_ORACLE_ERROR, | ||
USDC_ORACLE_TIMEOUT, | ||
USDC_USD_FEED, | ||
} from '../../../test/plugins/individual-collateral/curve/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) | ||
|
||
const w3PoolCollateral = await ethers.getContractAt( | ||
'CurveStableCollateral', | ||
deployments.collateral.cvxPayPool as string | ||
) | ||
|
||
/******** Verify ConvexStakingWrapper **************************/ | ||
|
||
await verifyContract( | ||
chainId, | ||
await w3PoolCollateral.erc20(), | ||
[], | ||
'contracts/plugins/assets/curve/cvx/vendor/ConvexStakingWrapper.sol:ConvexStakingWrapper' | ||
) | ||
|
||
/******** Verify PayPool plugin **************************/ | ||
await verifyContract( | ||
chainId, | ||
deployments.collateral.cvxPayPool, | ||
[ | ||
{ | ||
erc20: await w3PoolCollateral.erc20(), | ||
targetName: ethers.utils.formatBytes32String('USD'), | ||
priceTimeout: PRICE_TIMEOUT, | ||
chainlinkFeed: ONE_ADDRESS, // unused but cannot be zero | ||
oracleError: bn('1'), // unused but cannot be zero | ||
oracleTimeout: USDC_ORACLE_TIMEOUT, // max of oracleTimeouts | ||
maxTradeVolume: MAX_TRADE_VOL, | ||
defaultThreshold: DEFAULT_THRESHOLD, | ||
delayUntilDefault: DELAY_UNTIL_DEFAULT, | ||
}, | ||
revenueHiding.toString(), | ||
{ | ||
nTokens: 2, | ||
curvePool: PayPool, | ||
poolType: CurvePoolType.Plain, | ||
feeds: [[pyUSD_USD_FEED], [USDC_USD_FEED]], | ||
oracleTimeouts: [[pyUSD_ORACLE_TIMEOUT], [USDC_ORACLE_TIMEOUT]], | ||
oracleErrors: [[pyUSD_ORACLE_ERROR], [USDC_ORACLE_ERROR]], | ||
lpToken: PayPool, | ||
}, | ||
], | ||
'contracts/plugins/assets/curve/CurveStableCollateral.sol:CurveStableCollateral' | ||
) | ||
} | ||
|
||
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