Skip to content

Instantly share code, notes, and snippets.

@ajb413
Last active November 4, 2022 16:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Example Comet migration script.
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