-
Notifications
You must be signed in to change notification settings - Fork 190
CAPO for cUSDCv3 on Scroll #1069
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MishaShWoof
wants to merge
51
commits into
compound-finance:main
Choose a base branch
from
woof-software:woof-software/capo-for-scroll-usdc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
ee65afb
current dev
MishaShWoof 7e08ec9
fix: working dev
MishaShWoof 2bb3587
fix: scenarios
MishaShWoof 9f5564c
fix
MishaShWoof 88fe803
fix
MishaShWoof 8b5ee76
Update index.ts
MishaShWoof 700a4c6
Update DeploymentManager.ts
MishaShWoof 4cbf863
fix: unit tests
MishaShWoof 2bc2dbf
fix: working linea scenarios and prepare workflow fix
MishaShWoof 0313418
Merge branch 'main' of github.com:woof-software/comet into develop
MishaShWoof 688d515
fix: remove linea markets from dev
MishaShWoof df8d724
fix: remove localhost deployment
MishaShWoof 0001bd6
fix: unify import
MishaShWoof d04a40d
Merge branch 'main' of github.com:woof-software/comet into develop
MishaShWoof ca5f5a9
feat: capo and oev upgrade
MishaShWoof 2621df6
Merge branch 'main' of github.com:woof-software/comet into develop
MishaShWoof aceaf43
fixes from recent prs
MishaShWoof 3f9caef
fix: change base rpc
MishaShWoof 68f6aab
fix: change rpc
MishaShWoof d2801ea
fix: replace ankr with quicknode
MishaShWoof 001b60c
Merge branch 'main' of github.com:woof-software/comet into develop
MishaShWoof 38a9d9e
fix: working tests
MishaShWoof 525e5a8
fix: working forge test
MishaShWoof d73df39
Update run-forge-tests.yaml
MishaShWoof 640d956
Update run-forge-tests.yaml
MishaShWoof 3579082
Merge branch 'develop' of github.com:woof-software/comet into woof-so…
MishaShWoof 2676283
fix: add exception in liquidation scenario
MishaShWoof e77593b
feat: new description
MishaShWoof 49ac136
Update run-scenarios.yaml
MishaShWoof a16813a
fix: env in scenario
MishaShWoof 0407aa6
fix: use different keys for etherscan
MishaShWoof 1a368d4
fix: strict order
MishaShWoof a34434f
fix: pass the prepared state
MishaShWoof 9d6c077
fix: remove matrix
MishaShWoof 58ed478
fix: pass node modules
MishaShWoof 0e67e92
fix: add contracts to cache before scenario run
MishaShWoof bc0871e
fix: cache path fix
MishaShWoof 5f4fc6f
fix: use hidden files
MishaShWoof 5a77147
fix: fuji
MishaShWoof b287ff2
feat: rotate apikeys and some arbitrum fixes
MishaShWoof 070fda2
Merge pull request #279 from woof-software/speed-up-scenarios
MishaShWoof 98e6783
fix: working arbitrum scenarios
MishaShWoof b2b05a2
fix: teth symbol fix
MishaShWoof a0fdad7
fix: add debug for spider
MishaShWoof ae96662
Merge branch 'develop' of github.com:woof-software/comet into woof-so…
MishaShWoof 0cf69cd
Merge branch 'main' of github.com:woof-software/comet into develop
MishaShWoof e7f8ce6
fix: ronin and forge test fixes
MishaShWoof b3456da
fix: working arbitrum scenarios
MishaShWoof 0e95ff9
Merge branch 'woof-software/capo-for-scroll-usdc' of https://github.c…
MishaShWoof fe1c1aa
fix
MishaShWoof ee45ccc
fix: review fix
MishaShWoof File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
165 changes: 165 additions & 0 deletions
165
deployments/base/aero/migrations/1761125221_upgrade_to_capo_price_feeds.ts
This file contains hidden or 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,165 @@ | ||
| import { expect } from 'chai'; | ||
| import { DeploymentManager } from '../../../../plugins/deployment_manager/DeploymentManager'; | ||
| import { migration } from '../../../../plugins/deployment_manager/Migration'; | ||
| import { calldata, proposal } from '../../../../src/deploy'; | ||
| import { utils } from 'ethers'; | ||
| import { Numeric } from '../../../../test/helpers'; | ||
| import { AggregatorV3Interface } from '../../../../build/types'; | ||
|
|
||
| export function exp(i: number, d: Numeric = 0, r: Numeric = 6): bigint { | ||
| return (BigInt(Math.floor(i * 10 ** Number(r))) * 10n ** BigInt(d)) / 10n ** BigInt(r); | ||
| } | ||
|
|
||
| const ETH_USD_PRICE_FEED = '0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70'; | ||
|
|
||
| const WSTETH_ADDRESS = '0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452'; | ||
| const WSTETH_STETH_PRICE_FEED_ADDRESS = '0xB88BAc61a4Ca37C43a3725912B1f472c9A5bc061'; | ||
|
|
||
| const FEED_DECIMALS = 8; | ||
| const blockToFetch = 36000000; | ||
|
|
||
| let newWstETHPriceFeed: string; | ||
| let oldWstETHPriceFeed: string; | ||
|
|
||
| export default migration('1761125221_upgrade_to_capo_price_feeds', { | ||
| async prepare(deploymentManager: DeploymentManager) { | ||
| const { timelock } = await deploymentManager.getContracts(); | ||
| const blockToFetchTimestamp = (await deploymentManager.hre.ethers.provider.getBlock(blockToFetch))!.timestamp; | ||
|
|
||
| //1. wstEth | ||
| const rateProviderWstEth = await deploymentManager.existing('wstEth:priceFeed', WSTETH_STETH_PRICE_FEED_ADDRESS, 'base', 'contracts/capo/contracts/interfaces/AggregatorV3Interface.sol:AggregatorV3Interface') as AggregatorV3Interface; | ||
| const [, currentRatioWstEth] = await rateProviderWstEth.latestRoundData({ blockTag: blockToFetch }); | ||
|
|
||
| const wstEthCapoPriceFeed = await deploymentManager.deploy( | ||
| 'wstETH:priceFeed', | ||
| 'capo/contracts/ChainlinkCorrelatedAssetsPriceOracle.sol', | ||
| [ | ||
| timelock.address, | ||
| ETH_USD_PRICE_FEED, | ||
| WSTETH_STETH_PRICE_FEED_ADDRESS, | ||
| 'wstETH / USD CAPO Price Feed', | ||
| FEED_DECIMALS, | ||
| 3600, | ||
| { | ||
| snapshotRatio: currentRatioWstEth, | ||
| snapshotTimestamp: blockToFetchTimestamp, | ||
| maxYearlyRatioGrowthPercent: exp(0.0404, 4) | ||
| } | ||
| ], | ||
| true | ||
| ); | ||
|
|
||
| return { | ||
| wstEthCapoPriceFeedAddress: wstEthCapoPriceFeed.address | ||
| }; | ||
| }, | ||
|
|
||
| async enact(deploymentManager: DeploymentManager, govDeploymentManager: DeploymentManager, { | ||
| wstEthCapoPriceFeedAddress | ||
| }) { | ||
| newWstETHPriceFeed = wstEthCapoPriceFeedAddress; | ||
|
|
||
| const trace = deploymentManager.tracer(); | ||
|
|
||
| const { | ||
| configurator, | ||
| comet, | ||
| bridgeReceiver, | ||
| cometAdmin | ||
| } = await deploymentManager.getContracts(); | ||
|
|
||
| const { | ||
| governor, | ||
| baseL1CrossDomainMessenger | ||
| } = await govDeploymentManager.getContracts(); | ||
|
|
||
| const updateWstEthPriceFeedCalldata = await calldata( | ||
| configurator.populateTransaction.updateAssetPriceFeed( | ||
| comet.address, | ||
| WSTETH_ADDRESS, | ||
| wstEthCapoPriceFeedAddress | ||
| ) | ||
| ); | ||
|
|
||
| const deployAndUpgradeToCalldata = await calldata( | ||
| cometAdmin.populateTransaction.deployAndUpgradeTo( | ||
| configurator.address, | ||
| comet.address | ||
| ) | ||
| ); | ||
|
|
||
| const l2ProposalData = utils.defaultAbiCoder.encode( | ||
| ['address[]', 'uint256[]', 'string[]', 'bytes[]'], | ||
| [ | ||
| [configurator.address, cometAdmin.address], | ||
| [0, 0], | ||
| ['updateAssetPriceFeed(address,address,address)', 'deployAndUpgradeTo(address,address)'], | ||
| [updateWstEthPriceFeedCalldata, deployAndUpgradeToCalldata], | ||
| ] | ||
| ); | ||
|
|
||
| [,, oldWstETHPriceFeed] = await comet.getAssetInfoByAddress(WSTETH_ADDRESS); | ||
|
|
||
| const mainnetActions = [ | ||
| { | ||
| contract: baseL1CrossDomainMessenger, | ||
| signature: 'sendMessage(address,bytes,uint32)', | ||
| args: [ | ||
| bridgeReceiver.address, | ||
| l2ProposalData, | ||
| 3_000_000 | ||
| ] | ||
| }, | ||
| ]; | ||
|
|
||
| const description = `# Update wstETH price feed in cAEROv3 on Base with CAPO implementation. | ||
|
|
||
| ## Proposal summary | ||
|
|
||
| This proposal updates existing price feeds for wstETH on the AERO market on Base. | ||
|
|
||
| ### CAPO summary | ||
|
|
||
| CAPO is a price oracle adapter designed to support assets that grow gradually relative to a base asset - such as liquid staking tokens that accumulate yield over time. It provides a mechanism to track this expected growth while protecting downstream protocol from sudden or manipulated price spikes. wstETH price feed is updated to their CAPO implementations. | ||
|
|
||
| Further detailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/1038) and [forum discussion for CAPO](https://www.comp.xyz/t/woof-correlated-assets-price-oracle-capo/6245). | ||
|
|
||
| ### CAPO audit | ||
|
|
||
| CAPO has been audited by [OpenZeppelin](https://www.comp.xyz/t/capo-price-feed-audit/6631, as well as the LST / LRT implementation [here](https://www.comp.xyz/t/capo-lst-lrt-audit/7118). | ||
|
|
||
| ## Proposal actions | ||
|
|
||
| The first action updates wstETH price feed to the CAPO implementation. This sends the encoded 'updateAssetPriceFeed' and 'deployAndUpgradeTo' calls across the bridge to the governance receiver on Base. | ||
| `; | ||
|
|
||
| const txn = await deploymentManager.retry(async () => | ||
| trace( | ||
| await governor.propose(...(await proposal(mainnetActions, description))) | ||
| ) | ||
| ); | ||
| const event = txn.events.find( | ||
| (event: { event: string }) => event.event === 'ProposalCreated' | ||
| ); | ||
| const [proposalId] = event.args; | ||
| trace(`Created proposal ${proposalId}.`); | ||
| }, | ||
|
|
||
| async enacted(deploymentManager: DeploymentManager): Promise<boolean> { | ||
| return true; | ||
| }, | ||
|
|
||
| async verify(deploymentManager: DeploymentManager) { | ||
| const { comet, configurator } = await deploymentManager.getContracts(); | ||
|
|
||
| const wstETHIndexInComet = await configurator.getAssetIndex(comet.address, WSTETH_ADDRESS); | ||
|
|
||
| // Check if the price feeds are set correctly. | ||
| const wstETHInCometInfo = await comet.getAssetInfoByAddress(WSTETH_ADDRESS); | ||
| const wstETHInConfiguratorInfoWETHComet = (await configurator.getConfiguration(comet.address)).assetConfigs[wstETHIndexInComet]; | ||
|
|
||
| expect(wstETHInCometInfo.priceFeed).to.eq(newWstETHPriceFeed); | ||
| expect(wstETHInConfiguratorInfoWETHComet.priceFeed).to.eq(newWstETHPriceFeed); | ||
| expect(await comet.getPrice(newWstETHPriceFeed)).to.equal(await comet.getPrice(oldWstETHPriceFeed)); | ||
| }, | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this function here/ I thought this was fixed in the previous commits.