Skip to content

Commit

Permalink
make code cleaner
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-woof-software committed May 12, 2024
1 parent 3cdb263 commit 8c57bb8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default migration('1713283675_configurate_and_ens', {
timelock,
governor
} = await govDeploymentManager.getContracts();
// console.log(await govDeploymentManager.getContracts());

const configuration = await getConfigurationStruct(deploymentManager);
const setFactoryCalldata = await calldata(
configurator.populateTransaction.setFactory(comet.address, cometFactory.address)
Expand Down Expand Up @@ -155,7 +155,7 @@ export default migration('1713283675_configurate_and_ens', {
}
];

const description = "# Initialize cUSDCv3 on Polygon\n\nThis proposal takes the governance steps recommended and necessary to initialize a Compound III USDC market on Polygon; upon execution, cUSDCv3 will be ready for use. Simulations have confirmed the market\u2019s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). Although real tests have also been run over the Goerli/Mumbai bridge, this will be the first proposal to actually bridge from Ethereum mainnet to another chain, and therefore includes risks not present in previous proposals.\n\nAlthough the proposal sets the entire configuration in the Configurator, the initial deployment already has most of these same parameters already set. The new parameters include setting the pause guardian to a Gnosis [multisig](https://app.safe.global/matic:0x8Ab717CAC3CbC4934E63825B88442F5810aAF6e5/home), which has been created on Polygon to match the same set of signers as currently on Ethereum mainnet. They also include risk parameters based off of the [recommendations from Gauntlet](https://www.comp.xyz/t/initialize-compound-iii-usdc-on-polygon-pos/3611/12). Finally, the parameters include a modest reallocation of some of the v2 USDT COMP rewards to borrowers in the new market.\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/672) and [forum discussion](https://www.comp.xyz/t/initialize-compound-iii-usdc-on-polygon-pos/3611/11).\n\n\n## Proposal Actions\n\nThe first proposal action sets the Comet configuration and deploys a new Comet implementation on Polygon. This sends the encoded `setConfiguration` and `deployAndUpgradeTo` calls across the bridge to the governance receiver on Polygon.\n\nThe second action approves Polygon's ERC20Predicate to take Timelock's USDC, in order to seed the market reserves through the bridge.\n\nThe third action deposits USDC from mainnet to the Polygon RootChainManager contract to bridge to Comet.\n\nThe fourth action approves Polygon's ERC20Predicate to take Timelock's COMP, in order to seed the rewards contract through the bridge.\n\nThe fifth action deposits COMP from mainnet to the Polygon RootChainManager contract to bridge to CometRewards. \n\nThe sixth action sets up the ENS subdomain `v3-additional-grants.compound-community-licenses.eth`, with the Timelock as the owner.\n\nThe seventh action writes the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, containing the official markets JSON.\n\nThe eighth action migrates the COMP distribution for v2 cUSDT suppliers, so as to keep the total COMP distribution constant.\n";
const description = "# Initialize cUSDTv3 on Polygon\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes the deployment of Compound III to the Polygon network. This proposal takes the governance steps recommended and necessary to initialize a Compound III USDT market on Polygon; upon execution, cUSDTv3 will be ready for use. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario). The new parameters include setting the risk parameters based on the [recommendations from Gauntlet](https://www.comp.xyz/t/add-market-usdt-on-polygon/5190/3).\n\nFurther detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/850) and [forum discussion](https://www.comp.xyz/t/add-market-usdt-on-polygon/5190).\n\n\n## Proposal Actions\n\nThe first proposal action sets the Comet configuration and deploys a new Comet implementation on Polygon. This sends the encoded `setFactory`, `setConfiguration` and `deployAndUpgradeTo` calls across the bridge to the governance receiver on Polygon. It also calls `setRewardConfig` on the Polygon rewards contract, to establish Polygon’s bridged version of COMP as the reward token for the deployment and set the initial supply speed to be 8 COMP/day and borrow speed to be 4 COMP/day.\n\nThe second action reduces Compound [cUSDT](https://etherscan.io/address/0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9) reserves to Timelock, in order to seed the market reserves through the Polygon RootChainManager.\n\nThe third action approves Polygon’s [RootChainManager](https://etherscan.io/address/0xA0c68C638235ee32657e8f720a23ceC1bFc77C77) to take Timelock's USDT, in order to seed the reserves through the bridge.\n\nThe fourth action deposits 10K USDT from mainnet to the Polygon RootChainManager contract to bridge to Comet.\n\nThe fifth action updates the ENS TXT record `v3-official-markets` on `v3-additional-grants.compound-community-licenses.eth`, updating the official markets JSON to include the new Polygon cUSDTv3 market";
const txn = await govDeploymentManager.retry(async () =>
trace(await governor.propose(...(await proposal(mainnetActions, description))))
);
Expand Down Expand Up @@ -207,8 +207,8 @@ export default migration('1713283675_configurate_and_ens', {
// WBTC: {
// supplyCap: exp(90, 8)
// },
// baseTrackingSupplySpeed: exp(5 / 86400, 15, 18),
// baseTrackingBorrowSpeed: exp(5 / 86400, 15, 18),
// baseTrackingSupplySpeed: exp(8 / 86400, 15, 18),
// baseTrackingBorrowSpeed: exp(4 / 86400, 15, 18),
// });

const config = await rewards.rewardConfig(comet.address);
Expand Down
1 change: 0 additions & 1 deletion deployments/polygon/usdt/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default {
}
}
},
// InitializableImmutableAdminUpgradeabilityProxy: {
aPolMATICX: {
artifact: 'contracts/ERC20.sol:ERC20',
delegates: {
Expand Down
8 changes: 4 additions & 4 deletions scenario/WithdrawScenario.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { CometContext, scenario } from './context/CometContext';
import { expect } from 'chai';
import { expectApproximately, expectRevertCustom, hasMinBorrowGreaterThanOne, isTriviallySourceable, isValidAssetIndex, MAX_ASSETS } from './utils';
import { ContractReceipt } from 'ethers';
import { ethers } from 'hardhat';
import { ContractReceipt, BigNumber } from 'ethers';

async function testWithdrawCollateral(context: CometContext, assetNum: number): Promise<void | ContractReceipt> {
const comet = await context.getComet();
Expand All @@ -23,20 +22,21 @@ async function testWithdrawCollateral(context: CometContext, assetNum: number):
return txn; // return txn to measure gas
}

// some dust left in case of maticx asset
async function testWithdrawCollateralMaticxSpecific(context: CometContext, assetNum: number): Promise<void | ContractReceipt> {
const comet = await context.getComet();
const { albert } = context.actors;
const { asset: assetAddress, scale: scaleBN } = await comet.getAssetInfo(assetNum);
const collateralAsset = context.getAssetByAddress(assetAddress);
const scale = scaleBN.toBigInt();

expect(await collateralAsset.balanceOf(albert.address)).to.be.closeTo(0n, ethers.BigNumber.from(10).pow(ethers.BigNumber.from(await collateralAsset.decimals()).div(2)).toBigInt());
expect(await collateralAsset.balanceOf(albert.address)).to.be.closeTo(0n, BigNumber.from(10).pow(BigNumber.from(await collateralAsset.decimals()).div(2)).toBigInt());
expect(await comet.collateralBalanceOf(albert.address, collateralAsset.address)).to.be.equal(100n * scale);

// Albert withdraws 100 units of collateral from Comet
const txn = await albert.withdrawAsset({ asset: collateralAsset.address, amount: 100n * scale });

expect(await collateralAsset.balanceOf(albert.address)).to.be.closeTo(100n * scale, ethers.BigNumber.from(10).pow(ethers.BigNumber.from(await collateralAsset.decimals()).div(2)).toBigInt());
expect(await collateralAsset.balanceOf(albert.address)).to.be.closeTo(100n * scale, BigNumber.from(10).pow(BigNumber.from(await collateralAsset.decimals()).div(2)).toBigInt());
expect(await comet.collateralBalanceOf(albert.address, collateralAsset.address)).to.be.equal(0n);

return txn; // return txn to measure gas
Expand Down
2 changes: 0 additions & 2 deletions scenario/constraints/ProposalConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,11 @@ export class ProposalConstraint<T extends CometContext> implements StaticConstra
// Execute the proposal
debug(`${label} Processing pending proposal ${proposal.id}`);
if (isBridged) {
if(![246, 247].includes(proposal.id.toNumber())){
await executeOpenProposalAndRelay(

Check failure on line 69 in scenario/constraints/ProposalConstraint.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected indentation of 12 spaces but found 14
governanceDeploymentManager,

Check failure on line 70 in scenario/constraints/ProposalConstraint.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected indentation of 14 spaces but found 16
ctx.world.deploymentManager,

Check failure on line 71 in scenario/constraints/ProposalConstraint.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected indentation of 14 spaces but found 16
proposal

Check failure on line 72 in scenario/constraints/ProposalConstraint.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected indentation of 14 spaces but found 16
);

Check failure on line 73 in scenario/constraints/ProposalConstraint.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Expected indentation of 12 spaces but found 14
}
} else {
await executeOpenProposal(governanceDeploymentManager, proposal);
}
Expand Down

0 comments on commit 8c57bb8

Please sign in to comment.