-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create migration script to deploy a custom WBTC price feed and upgrad…
…e Comet to use it
- Loading branch information
1 parent
cec2870
commit 976e43a
Showing
6 changed files
with
97 additions
and
7 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
deployments/mainnet/usdc/migrations/1686950699_update_wbtc_price_feed.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,77 @@ | ||
import { expect } from 'chai'; | ||
import { diffState } from '../../../../plugins/deployment_manager'; | ||
import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; | ||
import { getCometConfig } from '../../../../plugins/deployment_manager/DiffState'; | ||
import { migration } from '../../../../plugins/deployment_manager/Migration'; | ||
import { proposal } from '../../../../src/deploy'; | ||
|
||
interface Vars { | ||
newWBTCPriceFeed: string | ||
}; | ||
|
||
export default migration('1686950699_update_wbtc_price_feed', { | ||
prepare: async (deploymentManager: DeploymentManager) => { | ||
// Deploy custom WBTC price feed | ||
const WBTCPriceFeed = await deploymentManager.deploy( | ||
'newWBTCPriceFeed', | ||
'pricefeeds/WBTCPriceFeed.sol', | ||
[ | ||
'0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23', // WBTCToBTCPriceFeed | ||
'0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c', // BTCToUSDPriceFeed | ||
8 // decimals | ||
] | ||
); | ||
return { newWBTCPriceFeed: WBTCPriceFeed.address }; | ||
}, | ||
|
||
enact: async (deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager, vars: Vars) => { | ||
const trace = deploymentManager.tracer(); | ||
|
||
const { | ||
governor, | ||
comet, | ||
configurator, | ||
cometAdmin, | ||
WBTC, | ||
} = await deploymentManager.getContracts(); | ||
|
||
const actions = [ | ||
// 1. Update WBTC price feed | ||
{ | ||
contract: configurator, | ||
signature: 'updateAssetPriceFeed(address,address,address)', | ||
args: [comet.address, WBTC.address, vars.newWBTCPriceFeed], | ||
}, | ||
|
||
// 2. Deploy and upgrade to a new version of Comet | ||
{ | ||
contract: cometAdmin, | ||
signature: 'deployAndUpgradeTo(address,address)', | ||
args: [configurator.address, comet.address], | ||
}, | ||
]; | ||
const description = 'TODO' | ||
const txn = await deploymentManager.retry( | ||
async () => trace((await governor.propose(...await proposal(actions, description)))) | ||
); | ||
|
||
const event = txn.events.find(event => event.event === 'ProposalCreated'); | ||
const [proposalId] = event.args; | ||
|
||
trace(`Created proposal ${proposalId}.`); | ||
}, | ||
|
||
async verify(deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager, preMigrationBlockNumber: number, vars: Vars) { | ||
const { | ||
comet, | ||
} = await deploymentManager.getContracts(); | ||
|
||
// 1. & 2. | ||
const stateChanges = await diffState(comet, getCometConfig, preMigrationBlockNumber); | ||
expect(stateChanges).to.deep.equal({ | ||
WBTC: { | ||
priceFeed: vars.newWBTCPriceFeed | ||
} | ||
}) | ||
} | ||
}); |
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
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