Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
artemwoofsoftware committed Jan 29, 2025
1 parent ffef88b commit f79de73
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 128 deletions.
25 changes: 17 additions & 8 deletions deployments/ronin-saigon/usdc/configuration.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "Compound USDC",
"symbol": "cUSDCv3",
"baseToken": "USDC",
"baseTokenAddress": "0x7a7ab4ac45a5329198e818e1fa56c27b443f8e3d",
"borrowMin": "100e6",
"name": "Compound WETH",
"symbol": "cWETHv3",
"baseToken": "WETH",
"baseTokenAddress": "0x3eb007a52b5Ba013e65B787c04bF775b946115B1",
"rewardTokenAddress": "0xfF5C5b4e3Cbc5513b3Ef462f00E4477Ee16a8C56",
"borrowMin": "100e18",
"storeFrontPriceFactor": 0.6,
"targetReserves": "5_000_000e6",
"pauseGuardian": "",
"targetReserves": "5_000_000e18",
"pauseGuardian": "0xf6c14190474A96189aad3e931E20c92E62D965D1",
"rates": {
"borrowBase": 0.015,
"borrowSlopeLow": 0.0333,
Expand All @@ -21,7 +22,7 @@
"indexScale": "1e15",
"baseSupplySpeed": "46296296296e0",
"baseBorrowSpeed": "46296296296e0",
"baseMinForRewards": "1000e6"
"baseMinForRewards": "1000e18"
},
"assets": {
"WRON": {
Expand All @@ -31,6 +32,14 @@
"liquidateCF": 0.87,
"liquidationFactor": 0.93,
"supplyCap": "2800e18"
},
"COMP": {
"address": "0xfF5C5b4e3Cbc5513b3Ef462f00E4477Ee16a8C56",
"decimals": "18",
"borrowCF": 0.82,
"liquidateCF": 0.87,
"liquidationFactor": 0.93,
"supplyCap": "2800e18"
}
}
}
43 changes: 31 additions & 12 deletions deployments/ronin-saigon/usdc/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ async function deployContracts(
'ronin-saigon'
);

const USDC = await deploymentManager.existing(
'USDC',
'0x7a7ab4aC45A5329198e818e1fA56C27B443f8e3d',
const WETH = await deploymentManager.existing(
'WETH',
'0x3eb007a52b5Ba013e65B787c04bF775b946115B1',
'ronin-saigon'
);
// pre-deployed OptimismMintableERC20
// const COMP = await deploymentManager.existing(
// 'COMP',
// '0x52b7D8851d6CcBC6342ba0855Be65f7B82A3F17f',
// 'ronin-saigon'
// );
const COMP = await deploymentManager.existing(
'COMP',
'0xfF5C5b4e3Cbc5513b3Ef462f00E4477Ee16a8C56',
'ronin-saigon'
);

const l2CCIPRouter = await deploymentManager.existing(
'l2CCIPRouter',
Expand Down Expand Up @@ -106,8 +106,17 @@ async function deployContracts(
]
);

const COMPPriceFeed = await deploymentManager.deploy(
'COMP:simplePriceFeed',
'test/SimplePriceFeed.sol',
[
exp(0.97, 18),
8
]
);


const assetConfig = {
const assetConfig0 = {
asset: WRON.address,
priceFeed: WRONPriceFeed.address,
decimals: (18).toString(),
Expand All @@ -117,11 +126,22 @@ async function deployContracts(
supplyCap: (1000000e8).toString(),
};

const assetConfig1 = {
asset: COMP.address,
priceFeed: COMPPriceFeed.address,
decimals: (18).toString(),
borrowCollateralFactor: (0.9e18).toString(),
liquidateCollateralFactor: (0.91e18).toString(),
liquidationFactor: (0.95e18).toString(),
supplyCap: (1000000e8).toString(),
};



// Deploy all Comet-related contracts
const deployed = await deployComet(deploymentManager, deploySpec, {
baseTokenPriceFeed: USDCPriceFeed.address,
assetConfigs: [assetConfig],
assetConfigs: [assetConfig0, assetConfig1],
});
// Deploy Comet
const { comet } = deployed;
Expand All @@ -144,8 +164,7 @@ async function deployContracts(
bridgeReceiver,
l2CCIPRouter,
l2CCIPOffRamp,
bulker,
USDC
bulker
// COMP,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { expect } from "chai";

const SECONDS_PER_YEAR = 31_536_000n;
const roninSaigonCOMPAddress = "0x7e7d4467112689329f7E06571eD0E8CbAd4910eE";
const roninSaigonCOMPAddress = "0xfF5C5b4e3Cbc5513b3Ef462f00E4477Ee16a8C56";
const destinationChainSelector = "13116810400804392105";

export default migration("1707394874_configurate_and_ens", {
Expand Down Expand Up @@ -61,26 +61,24 @@ export default migration("1707394874_configurate_and_ens", {
const l2ProposalData = utils.defaultAbiCoder.encode(
["address[]", "uint256[]", "string[]", "bytes[]"],
[
// [configurator.address, cometAdmin.address, rewards.address],
[configurator.address, cometAdmin.address],
//[0, 0, 0],
[0, 0],
[configurator.address, cometAdmin.address, rewards.address],
[0, 0, 0],
[
"setConfiguration(address,(address,address,address,address,address,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint64,uint104,uint104,uint104,(address,address,uint8,uint64,uint64,uint64,uint128)[]))",
"deployAndUpgradeTo(address,address)",
// "setRewardConfig(address,address)",
"setRewardConfig(address,address)",
],
[
setConfigurationCalldata,
deployAndUpgradeToCalldata,
// setRewardConfigCalldata,
setRewardConfigCalldata,
],
]
);

const COMPAmountToBridge = exp(3_600, 18);
const USDCAmountToBridge = exp(10, 6);

const actions = [
// {
// contract: mainnetUSDC,
Expand Down Expand Up @@ -109,81 +107,23 @@ export default migration("1707394874_configurate_and_ens", {
]
),
value: utils.parseEther("0.1")
// args: [
// destinationChainSelector,
// {
// receiver: utils.defaultAbiCoder.encode(['address'], [bridgeReceiver.address]),
// data: l2ProposalData,
// tokenAmounts: [
// // {
// // token: mainnetUSDC.address,
// // amount: USDCAmountToBridge,
// // },
// // {
// // token: mainnetCOMP.address,
// // amount: COMPAmountToBridge,
// // },
// ],
// feeToken: ethers.constants.AddressZero,
// extraArgs: "0x",
// },
// ],
// value: utils.parseEther("0.1")
},
];

const description = "# Initialize cUSDCv3 on Ronin Saigon\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes deployment of Compound III to Optimism network. This proposal takes the governance steps recommended and necessary to initialize a Compound III USDC market on Optimism; upon execution, cUSDCv3 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 off of the [recommendations from Gauntlet](https://www.comp.xyz/t/deploy-compound-iii-on-optimism/4975/6).\n\nFurther detailed information can be found on the corresponding [deployment pull request](https://github.com/compound-finance/comet/pull/838), [proposal pull request](https://github.com/compound-finance/comet/pull/842), [deploy market GitHub action run](https://github.com/dmitriy-bergman-works/comet-optimism/actions/runs/8581592608) and [forum discussion](https://www.comp.xyz/t/deploy-compound-iii-on-optimism/4975).\n\n\n## Proposal Actions\n\nThe first proposal action sets the Comet configuration and deploys a new Comet implementation on Optimism. This sends the encoded `setConfiguration` and `deployAndUpgradeTo` calls across the bridge to the governance receiver on Optimism. It also calls `setRewardConfig` on the Optimism rewards contract, to establish Optimism’s bridged version of COMP as the reward token for the deployment and set the initial supply speed to be 5 COMP/day and borrow speed to be 5 COMP/day.\n\nThe second action approves Circle’s Cross-Chain Transfer Protocol (CCTP) [TokenMessenger](https://etherscan.io/address/0xbd3fa81b58ba92a82136038b25adec7066af3155) to take the Timelock's USDC on Mainnet, in order to seed the market reserves through the CCTP.\n\nThe third action deposits and burns 10K USDC from mainnet via depositForBurn function on CCTP’s TokenMessenger contract to mint native USDC to Comet on Optimism.\n\nThe fourth action approves Optimism’s [L1StandardBridge](https://etherscan.io/address/0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1) to take Timelock's COMP, in order to seed the rewards contract through the bridge.\n\nThe fifth action deposits 3.6K COMP from mainnet to the Optimism L1StandardBridge contract to bridge to CometRewards.\n\nThe sixth 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 Optimism cUSDCv3 market";

const { timelock } = await govDeploymentManager.getContracts();
// impersonate the timelock

await govDeploymentManager.hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [timelock.address],
});

// const signer = await govDeploymentManager.hre.ethers.provider.getSigner(timelock.address);

await govDeploymentManager.hre.network.provider.request({
method: 'hardhat_setBalance',
params: [timelock.address, '0x56bc75e2d63100000'],
});

// const tx0 = await signer.sendTransaction({
// to: l1CCIPRouter.address,
// value: utils.parseEther("0.1"),
// data: "0x96f4e9f9"+actions[0].calldata.slice(2),
// });

// await tx0.wait();

// console.log("0x96f4e9f9"+actions[0].calldata.slice(2));


// console.log("approve USDC");
// await mainnetUSDC.connect(signer).approve(l1CCIPRouter.address, USDCAmountToBridge);
// console.log("ccipSend");
// const tx = await l1CCIPRouter.connect(signer).ccipSend(
// destinationChainSelector,
// {
// receiver: utils.defaultAbiCoder.encode(['address'], [bridgeReceiver.address]),
// data: l2ProposalData,
// tokenAmounts: [
// // {
// // token: mainnetUSDC.address,
// // amount: USDCAmountToBridge,
// // },
// ],
// feeToken: ethers.constants.AddressZero,
// extraArgs: "0x",
// },
// { value: utils.parseEther("0.1") }
// );
// await tx.wait();
//console.log(await tx.wait());
// console.log("ccipSend done");



const txn = await govDeploymentManager.retry(async () =>
trace(await governor.propose(...(await proposal(actions, description))))
);
Expand All @@ -203,46 +143,5 @@ export default migration("1707394874_configurate_and_ens", {
govDeploymentManager: DeploymentManager,
preMigrationBlockNumber: number
) {
// const ethers = deploymentManager.hre.ethers;
// await deploymentManager.spider();

// const { comet, rewards, COMP, USDC } =
// await deploymentManager.getContracts();

// // 1.
// const stateChanges = await diffState(
// comet,
// getCometConfig,
// preMigrationBlockNumber
// );
// expect(stateChanges).to.deep.equal({
// storeFrontPriceFactor: exp(0.6, 18),
// baseTrackingSupplySpeed: exp(5 / 86400, 15, 18),
// baseTrackingBorrowSpeed: exp(5 / 86400, 15, 18),
// borrowPerSecondInterestRateSlopeLow: exp(0.061, 18) / SECONDS_PER_YEAR,
// borrowPerSecondInterestRateSlopeHigh: exp(3.2, 18) / SECONDS_PER_YEAR,
// supplyPerSecondInterestRateSlopeLow: exp(0.059, 18) / SECONDS_PER_YEAR,
// supplyPerSecondInterestRateSlopeHigh: exp(2.9, 18) / SECONDS_PER_YEAR,
// WETH: {
// supplyCap: exp(1600, 18),
// },
// OP: {
// supplyCap: exp(700000, 18),
// },
// WBTC: {
// supplyCap: exp(60, 8),
// }
// });

// const config = await rewards.rewardConfig(comet.address);
// expect(config.token).to.be.equal(COMP.address);
// expect(config.rescaleFactor).to.be.equal(exp(1, 12));
// expect(config.shouldUpscale).to.be.equal(true);

// // 2. & 3.
// expect(await USDC.balanceOf(comet.address)).to.be.equal(exp(10_000, 6));

// 4. & 5.
// expect(await COMP.balanceOf(rewards.address)).to.be.equal(exp(3_600, 18));
},
});
1 change: 1 addition & 0 deletions src/deploy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const WHALES = {
'0x524db930F0886CdE7B5FFFc920Aae85e98C2abfb', // FBTC whale
],
'ronin-saigon': [
'0x8E029cEDC7Daf4d9cFFe56AC6771dE266F3CCAdc',// WETH whale
'0x9d726a549824eb289c5495e65dd421e0a681842a', // RON whale
],
};
Expand Down

0 comments on commit f79de73

Please sign in to comment.