-
-
Save ajb413/2fd7caf7afff73c5f37e401cc56e621a to your computer and use it in GitHub Desktop.
Example Comet migration script.
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
import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; | |
import { migration } from '../../../../plugins/deployment_manager/Migration'; | |
import { exp, proposal } from '../../../../src/deploy'; | |
interface Vars {}; | |
export default migration('1666716251_add_zrx_collateral', { | |
prepare: async (deploymentManager: DeploymentManager) => { | |
return {}; | |
}, | |
enact: async (governanceDeploymentManager: DeploymentManager, vars: Vars) => { | |
const trace = governanceDeploymentManager.tracer(); | |
const ethers = governanceDeploymentManager.hre.ethers; | |
const zrx = await governanceDeploymentManager.existing('ZRX', '0xE41d2489571d322189246DaFA5ebDe1F4699F498'); | |
const zrxPricefeed = await governanceDeploymentManager.existing('ZRX:priceFeed', '0x2885d15b8Af22648b98B122b22FDF4D2a56c6023'); | |
const { | |
governor, | |
comet, | |
configurator, | |
cometAdmin, | |
} = await governanceDeploymentManager.getContracts(); | |
const newAssetConfig = { | |
asset: zrx.address, | |
priceFeed: zrxPricefeed.address, | |
decimals: await zrx.decimals(), | |
borrowCollateralFactor: exp(0.8, 18), | |
liquidateCollateralFactor: exp(0.85, 18), | |
liquidationFactor: exp(0.95, 18), | |
supplyCap: exp(10000000, 18), | |
}; | |
const actions = [ | |
// 1. Call the add asset function on the configurator contract | |
{ | |
contract: configurator, | |
signature: 'addAsset(address,(address,address,uint8,uint64,uint64,uint64,uint128))', | |
args: [comet.address, newAssetConfig], | |
}, | |
// 2. Deploy and upgrade to a new version of Comet | |
{ | |
contract: cometAdmin, | |
signature: 'deployAndUpgradeTo(address,address)', | |
args: [configurator.address, comet.address], | |
}, | |
]; | |
const description = "# Add ZRX as Collateral to cUSDCv3 Mainnet\nThis proposal adds ZRX as collateral.\n"; | |
const txn = await governanceDeploymentManager.retry( | |
async () => governor.propose(...await proposal(actions, description)) | |
); | |
trace(txn); | |
const event = (await txn.wait()).events.find(event => event.event === 'ProposalCreated'); | |
const [proposalId] = event.args; | |
trace(`Created proposal ${proposalId}.`); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment