Skip to content

Commit

Permalink
migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Wang committed Aug 3, 2023
1 parent dac0aed commit 1668d08
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 89 deletions.
8 changes: 4 additions & 4 deletions deployments/goerli/usdt/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Compound USDT",
"symbol": "cUSDTv3",
"baseToken": "USDT",
"baseTokenAddress": "0xfad6367E97217cC51b4cd838Cc086831f81d38C2",
"baseTokenAddress": "0x79C950C7446B234a6Ad53B908fBF342b01c4d446",
"baseTokenPriceFeed": "0xAb5c49580294Aff77670F839ea425f5b78ab3Ae7",
"borrowMin": "10e6",
"governor": "0x8Fa336EB4bF58Cfc508dEA1B0aeC7336f55B1399",
Expand All @@ -22,9 +22,9 @@
"rewardToken": "COMP",
"tracking": {
"indexScale": "1e15",
"baseSupplySpeed": "447916666666e0",
"baseBorrowSpeed": "0e15",
"baseMinForRewards": "1000e18"
"baseSupplySpeed": "0.000402083333333e15",
"baseBorrowSpeed": "0.000402083333333e15",
"baseMinForRewards": "10000e6"
},
"assets": {
"COMP": {
Expand Down
2 changes: 1 addition & 1 deletion deployments/goerli/usdt/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function deployContracts(deploymentManager: DeploymentManager, deploySpec:
const signer = await deploymentManager.getSigner();

// Declare existing assets as aliases
const USDT = await deploymentManager.existing('USDT', '0xfad6367E97217cC51b4cd838Cc086831f81d38C2', 'goerli');
const USDT = await deploymentManager.existing('USDT', '0x79C950C7446B234a6Ad53B908fBF342b01c4d446', 'goerli');
const COMP = await deploymentManager.existing('COMP', '0x3587b2F7E0E2D6166d6C14230e7Fe160252B0ba4', 'goerli');
const WBTC = await deploymentManager.existing('WBTC', '0xAAD4992D949f9214458594dF92B44165Fb84dC19', 'goerli');
const WETH = await deploymentManager.existing('WETH', '0x42a71137C09AE83D8d05974960fd607d40033499', 'goerli');
Expand Down
114 changes: 30 additions & 84 deletions deployments/goerli/usdt/migrations/1691022234_configurate_and_ens.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DeploymentManager, migration } from '../../../../plugins/deployment_manager';
import { exp, getConfigurationStruct, proposal } from '../../../../src/deploy';

import { diffState, getCometConfig } from '../../../../plugins/deployment_manager/DiffState';
import { expect } from 'chai';

const COMPAddress = '0x3587b2F7E0E2D6166d6C14230e7Fe160252B0ba4';
Expand All @@ -10,6 +10,7 @@ const ENSSubdomain = ENSSubdomainLabel + '.' + ENSName;
const ENSResolverAddress = '0x19c2d5D0f035563344dBB7bE5fD09c8dad62b001';
const ENSRegistryAddress = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e';
const ENSTextRecordKey = 'v3-official-markets';
const USDCAmountToSeed = exp(5, 6);

export default migration('1691022234_configurate_and_ens', {
prepare: async (deploymentManager: DeploymentManager) => {
Expand All @@ -28,6 +29,7 @@ export default migration('1691022234_configurate_and_ens', {
configurator,
cometAdmin,
rewards,
USDT,
} = await deploymentManager.getContracts();

const configuration = await getConfigurationStruct(deploymentManager);
Expand Down Expand Up @@ -81,8 +83,17 @@ export default migration('1691022234_configurate_and_ens', {
['bytes32', 'string', 'string'],
[subdomainHash, ENSTextRecordKey, officialMarketsJSON]
)
}
},

// 6. Send USDT from Timelock to Comet
// XXX assert that funds have been transferred by diffing the balances before and after
{
contract: USDT,
signature: "transfer(address,uint256)",
args: [comet.address, exp(5, 6)],
},
];

const description = "# Initialize cUSDTv3 on Goerli"
const txn = await deploymentManager.retry(
async () => trace((await governor.propose(...await proposal(actions, description))))
Expand All @@ -106,90 +117,25 @@ export default migration('1691022234_configurate_and_ens', {

// 1. Verify state changes
const stateChanges = await diffState(comet, getCometConfig, preMigrationBlockNumber);
expect(stateChanges).to.deep.equal({
LINK: {
supplyCap: exp(5_000_000, 18)
},
WETH: {
supplyCap: exp(5_000, 18)
},
WBTC: {
supplyCap: exp(300, 8)
},
baseTrackingSupplySpeed: exp(34.74 / 86400, 15, 18),
baseTrackingBorrowSpeed: exp(34.74 / 86400, 15, 18),
});

expect(config.token).to.be.equal(arbitrumCOMPAddress);
// expect(stateChanges).to.deep.equal({
// COMP: {
// supplyCap: exp(500_000, 18)
// },
// WBTC: {
// supplyCap: exp(35_000, 8)
// },
// WETH: {
// supplyCap: exp(1_000_000, 18)
// },
// baseTrackingSupplySpeed: exp(34.74 / 86400, 15, 18),
// baseTrackingBorrowSpeed: exp(34.74 / 86400, 15, 18),
// });

expect(config.token).to.be.equal(COMPAddress);
expect(config.rescaleFactor).to.be.equal(exp(1, 12));
expect(config.shouldUpscale).to.be.equal(true);
// Ensure proposal has set usdce market to 0
expect(await usdceComet.baseTrackingSupplySpeed()).to.be.equal(0);
expect(await usdceComet.baseTrackingBorrowSpeed()).to.be.equal(0);

// 2. & 3. Verify the seeded USDC reaches Comet reserve
expect(await comet.getReserves()).to.be.equal(exp(10, 6));

// 4. Verify the official markets are updated
const ENSResolver = await govDeploymentManager.existing('ENSResolver', ENSResolverAddress);
const subdomainHash = ethers.utils.namehash(ENSSubdomain);
const officialMarketsJSON = await ENSResolver.text(subdomainHash, ENSTextRecordKey);
const officialMarkets = JSON.parse(officialMarketsJSON);

expect(officialMarkets).to.deep.equal({
5: [
{
baseSymbol: 'USDC',
cometAddress: '0x3EE77595A8459e93C2888b13aDB354017B198188',
},
{
baseSymbol: 'WETH',
cometAddress: '0x9A539EEc489AAA03D588212a164d0abdB5F08F5F',
},
],

420: [
{
baseSymbol: 'USDC',
cometAddress: '0xb8F2f9C84ceD7bBCcc1Db6FB7bb1F19A9a4adfF4'
}
],

421613: [
{
baseSymbol: 'USDC.e',
cometAddress: '0x1d573274E19174260c5aCE3f2251598959d24456',
},
{
baseSymbol: 'USDC',
cometAddress: comet.address
},
],

59140: [
{
baseSymbol: 'USDC',
cometAddress: '0xa84b24A43ba1890A165f94Ad13d0196E5fD1023a'
}
],

84531: [
{
baseSymbol: 'USDC',
cometAddress: '0xe78Fc55c884704F9485EDa042fb91BfE16fD55c1'
},
{
baseSymbol: 'WETH',
cometAddress: '0xED94f3052638620fE226a9661ead6a39C2a265bE'
}
],

80001: [
{
baseSymbol: 'USDC',
cometAddress: '0xF09F0369aB0a875254fB565E52226c88f10Bc839'
},
]
});
// 6. Verify the seeded USDT reaches Comet reserve
expect(await comet.getReserves()).to.be.equal(exp(5, 6));
}
});

0 comments on commit 1668d08

Please sign in to comment.