From 5702cb231d8ed79ecca985f6338b69817a6817a7 Mon Sep 17 00:00:00 2001 From: Rozengarden Date: Wed, 12 Feb 2025 23:53:12 +0100 Subject: [PATCH] feat: new capo for sUSDe --- reports/sUSDe_Ethereum.md | 44 +++---------- reports/sUSDe_ZkSync.md | 61 ++++++++++--------- scripts/DeployEthereum.s.sol | 27 ++++++++ scripts/DeployZkSync.s.sol | 26 ++++++++ .../newSUSDePriceCapAdapterTest.t.sol | 27 ++++++++ tests/utils/GetExchangeRatesTest.t.sol | 2 +- .../newSUSDePriceCapAdapterZkSyncTest.t.sol | 24 ++++++++ 7 files changed, 147 insertions(+), 64 deletions(-) create mode 100644 tests/ethereum/newSUSDePriceCapAdapterTest.t.sol create mode 100644 tests/zksync/newSUSDePriceCapAdapterZkSyncTest.t.sol diff --git a/reports/sUSDe_Ethereum.md b/reports/sUSDe_Ethereum.md index 68dcde5..06147b6 100644 --- a/reports/sUSDe_Ethereum.md +++ b/reports/sUSDe_Ethereum.md @@ -1,39 +1,15 @@ # Capo Report -| Capped sUSDe / USDe / USD | USDe / USD | Diff | Date | 14-day growth in yearly % | -| ------------------------- | ---------- | ----- | ----------- | ------------------------- | -| 1.06740177 | 1.00071299 | 6.45% | 24 May 2024 | 16.51% | -| 1.06849836 | 1.0012 | 6.50% | 25 May 2024 | 16.95% | -| 1.06910159 | 1.00123811 | 6.56% | 26 May 2024 | 17.37% | -| 1.06870457 | 1.00035492 | 6.61% | 27 May 2024 | 17.77% | -| 1.06913533 | 1.00027573 | 6.65% | 28 May 2024 | 18.11% | -| 1.07019291 | 1.00079999 | 6.70% | 29 May 2024 | 18.41% | -| 1.0711417 | 1.0012 | 6.75% | 30 May 2024 | 18.80% | -| 1.07086374 | 1.00026953 | 6.82% | 31 May 2024 | 18.73% | -| 1.07236343 | 1.00101011 | 6.88% | 02 Jun 2024 | 18.90% | -| 1.07443411 | 1.00229077 | 6.95% | 03 Jun 2024 | 19.16% | -| 1.07405507 | 1.0013 | 7.01% | 04 Jun 2024 | 19.41% | -| 1.07459565 | 1.00118766 | 7.07% | 05 Jun 2024 | 19.75% | -| 1.07560529 | 1.00152598 | 7.13% | 06 Jun 2024 | 20.15% | -| 1.07588396 | 1.0012 | 7.19% | 07 Jun 2024 | 20.58% | -| 1.07662251 | 1.0013 | 7.25% | 08 Jun 2024 | 20.57% | -| 1.07710193 | 1.00116583 | 7.31% | 09 Jun 2024 | 20.67% | -| 1.07774761 | 1.0012 | 7.36% | 10 Jun 2024 | 20.77% | -| 1.07737127 | 1.0003 | 7.42% | 11 Jun 2024 | 20.87% | -| 1.07886983 | 1.00114966 | 7.47% | 12 Jun 2024 | 21.02% | -| 1.07923393 | 1.00095561 | 7.53% | 13 Jun 2024 | 21.20% | -| 1.07983889 | 1.00103499 | 7.57% | 14 Jun 2024 | 21.18% | -| 1.08002659 | 1.0008 | 7.61% | 15 Jun 2024 | 20.51% | -| 1.08025288 | 1.00060214 | 7.66% | 16 Jun 2024 | 19.85% | -| 1.0804717 | 1.0004 | 7.70% | 17 Jun 2024 | 19.22% | -| 1.08177218 | 1.0012 | 7.74% | 18 Jun 2024 | 18.62% | -| 1.0818935 | 1.00090962 | 7.78% | 19 Jun 2024 | 18.06% | -| 1.0821223 | 1.00072229 | 7.82% | 20 Jun 2024 | 17.54% | +| Capped sUSDe / USDT / USD | Capped USDT/USD | Diff | Date | 14-day growth in yearly % | +| --- | --- | --- | --- | --- | -- 14-day growth is calculated as an annualized percentage relative to the value of the rate 14 days prior. -| Max Yearly % | Max Day-to-day yearly % | Max 14-day yearly % | -| ------------ | ----------------------- | ------------------- | -| 50.00% | 24.99% | 21.20% | +* 14-day growth is calculated as an annualized percentage relative to the value of the rate 14 days prior. -- Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. + +| Max Yearly % | Max Day-to-day yearly % | Max 14-day yearly % | +| --- | --- | --- | +| 50.00% | 9.99% | 0.00% | + + +* Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. diff --git a/reports/sUSDe_ZkSync.md b/reports/sUSDe_ZkSync.md index 7cc97f7..ac820aa 100644 --- a/reports/sUSDe_ZkSync.md +++ b/reports/sUSDe_ZkSync.md @@ -1,34 +1,37 @@ # Capo Report -| Capped sUSDe / USDe / USD | USDe / USD | Diff | Date | 14-day growth in yearly % | -| ------------------------- | ---------- | ------ | ----------- | ------------------------- | -| 1.13915887 | 1.00138517 | 12.87% | 17 Dec 2024 | 20.18% | -| 1.1392623 | 1.00090979 | 12.93% | 18 Dec 2024 | 20.25% | -| 1.13971794 | 1.00074615 | 12.99% | 19 Dec 2024 | 20.32% | -| 1.13824518 | 0.99903811 | 13.03% | 20 Dec 2024 | 19.91% | -| 1.13952316 | 0.99984088 | 13.06% | 21 Dec 2024 | 19.21% | -| 1.13948181 | 0.99948517 | 13.09% | 22 Dec 2024 | 18.59% | -| 1.13926999 | 0.99897902 | 13.12% | 23 Dec 2024 | 18.02% | -| 1.14016954 | 0.99944642 | 13.15% | 25 Dec 2024 | 17.39% | -| 1.14034987 | 0.99928359 | 13.19% | 26 Dec 2024 | 16.75% | -| 1.14015408 | 0.99878992 | 13.22% | 27 Dec 2024 | 16.10% | -| 1.14011168 | 0.99846533 | 13.25% | 28 Dec 2024 | 15.33% | -| 1.14030142 | 0.99836233 | 13.27% | 29 Dec 2024 | 14.47% | -| 1.14020669 | 0.99773917 | 13.33% | 30 Dec 2024 | 14.37% | -| 1.13906244 | 0.99646683 | 13.35% | 31 Dec 2024 | 13.57% | -| 1.14060928 | 0.99754753 | 13.38% | 01 Jan 2025 | 12.70% | -| 1.14195688 | 0.99845291 | 13.41% | 02 Jan 2025 | 11.90% | -| 1.14177223 | 0.99803087 | 13.44% | 03 Jan 2025 | 11.06% | -| 1.14271005 | 0.99859855 | 13.46% | 04 Jan 2025 | 10.56% | -| 1.14370646 | 0.99921679 | 13.49% | 05 Jan 2025 | 10.40% | -| 1.14393329 | 0.99916297 | 13.51% | 06 Jan 2025 | 10.28% | -| 1.1436677 | 0.99867932 | 13.54% | 07 Jan 2025 | 10.15% | -| 1.14478206 | 0.99939999 | 13.56% | 08 Jan 2025 | 10.04% | +| Capped sUSDe / USDT / USD | Capped USDT/USD | Diff | Date | 14-day growth in yearly % | +| --- | --- | --- | --- | --- | +| 1.14760099 | 0.99869 | 13.88% | 20 Jan 2025 | 9.50% | +| 1.14826053 | 0.99905 | 13.90% | 21 Jan 2025 | 9.39% | +| 1.14950317 | 0.99991679 | 13.92% | 22 Jan 2025 | 9.24% | +| 1.14982625 | 0.99998396 | 13.94% | 23 Jan 2025 | 9.09% | +| 1.15024406 | 1.00009186 | 13.97% | 24 Jan 2025 | 8.99% | +| 1.15036601 | 0.99987 | 14.00% | 25 Jan 2025 | 9.07% | +| 1.15079717 | 0.99991735 | 14.03% | 26 Jan 2025 | 9.17% | +| 1.15138828 | 1.00010315 | 14.06% | 27 Jan 2025 | 9.31% | +| 1.15149104 | 0.99986373 | 14.10% | 29 Jan 2025 | 9.38% | +| 1.15156217 | 0.99960015 | 14.13% | 30 Jan 2025 | 9.39% | +| 1.15227843 | 0.9999 | 14.16% | 31 Jan 2025 | 9.35% | +| 1.15303821 | 1.00000496 | 14.22% | 01 Feb 2025 | 9.94% | +| 1.15308472 | 0.99978 | 14.24% | 02 Feb 2025 | 10.02% | +| 1.15467117 | 1.00088961 | 14.27% | 03 Feb 2025 | 10.15% | +| 1.15488418 | 1.00080525 | 14.30% | 04 Feb 2025 | 10.25% | +| 1.15470542 | 1.00038 | 14.32% | 05 Feb 2025 | 10.33% | +| 1.15489527 | 1.00027126 | 14.35% | 06 Feb 2025 | 10.41% | +| 1.15548011 | 1.00056992 | 14.37% | 08 Feb 2025 | 10.34% | +| 1.15488946 | 0.9999 | 14.39% | 09 Feb 2025 | 9.96% | +| 1.15558244 | 1.000178 | 14.42% | 10 Feb 2025 | 9.85% | +| 1.15566133 | 1.000084 | 14.43% | 11 Feb 2025 | 9.41% | +| 1.15572619 | 0.99998 | 14.45% | 12 Feb 2025 | 8.90% | -- 14-day growth is calculated as an annualized percentage relative to the value of the rate 14 days prior. -| Max Yearly % | Max Day-to-day yearly % | Max 14-day yearly % | -| ------------ | ----------------------- | ------------------- | -| 50.00% | 21.10% | 20.32% | +* 14-day growth is calculated as an annualized percentage relative to the value of the rate 14 days prior. -- Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. + +| Max Yearly % | Max Day-to-day yearly % | Max 14-day yearly % | +| --- | --- | --- | +| 50.00% | 17.24% | 10.41% | + + +* Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. diff --git a/scripts/DeployEthereum.s.sol b/scripts/DeployEthereum.s.sol index 00a0bc1..0b487e0 100644 --- a/scripts/DeployEthereum.s.sol +++ b/scripts/DeployEthereum.s.sol @@ -227,6 +227,27 @@ library CapAdaptersCodeEthereum { ) ); } + + function newSUSDeAdapterCode() internal pure returns (bytes memory) { + return + abi.encodePacked( + type(SUSDePriceCapAdapter).creationCode, + abi.encode( + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3Ethereum.ACL_MANAGER, + baseAggregatorAddress: AaveV3EthereumAssets.USDT_ORACLE, + ratioProviderAddress: sUSDe, + pairDescription: 'Capped sUSDe / USDT / USD', + minimumSnapshotDelay: 14 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1150485992969698694, + snapshotTimestamp: 1737789743, + maxYearlyRatioGrowthPercent: 50_00 + }) + }) + ) + ); + } } contract DeployWeEthEthereum is EthereumScript { @@ -288,3 +309,9 @@ contract DeployRsEthEthereum is EthereumScript { GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.rsETHAdapterCode()); } } + +contract DeployNewSUSDeEthereum is EthereumScript { + function run() external broadcast { + GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.newSUSDeAdapterCode()); + } +} diff --git a/scripts/DeployZkSync.s.sol b/scripts/DeployZkSync.s.sol index 7558ec8..7431a1c 100644 --- a/scripts/DeployZkSync.s.sol +++ b/scripts/DeployZkSync.s.sol @@ -59,6 +59,24 @@ library CapAdaptersCodeZkSync { }) ); } + + function newSUSDeAdapterParams() internal pure returns (bytes memory) { + return + abi.encode( + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + baseAggregatorAddress: AaveV3ZkSyncAssets.USDT_ORACLE, + ratioProviderAddress: sUSDe_USDe_AGGREGATOR, + pairDescription: 'Capped sUSDe / USDT / USD', + minimumSnapshotDelay: 14 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1150485992969698694, + snapshotTimestamp: 1737789743, + maxYearlyRatioGrowthPercent: 50_00 + }) + }) + ); + } } contract DeployWeEthZkSync is ZkSyncScript { @@ -77,6 +95,14 @@ contract DeploySUSDeZkSync is ZkSyncScript { } } +contract DeployNewSUSDeZkSync is ZkSyncScript { + function run() external broadcast { + new CLRatePriceCapAdapter( + abi.decode(CapAdaptersCodeZkSync.newSUSDeAdapterParams(), (IPriceCapAdapter.CapAdapterParams)) + ); + } +} + contract DeployUSDeZkSync is ZkSyncScript { function run() external broadcast { new PriceCapAdapterStable( diff --git a/tests/ethereum/newSUSDePriceCapAdapterTest.t.sol b/tests/ethereum/newSUSDePriceCapAdapterTest.t.sol new file mode 100644 index 0000000..7578034 --- /dev/null +++ b/tests/ethereum/newSUSDePriceCapAdapterTest.t.sol @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseTest.sol'; + +import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; + +import {SUSDePriceCapAdapter} from '../../src/contracts/lst-adapters/SUSDePriceCapAdapter.sol'; +import {CapAdaptersCodeEthereum} from '../../scripts/DeployEthereum.s.sol'; + +// was tested with USDe / USD feed for a longer period +contract sUSDePriceCapAdapterTest is BaseTest { + constructor() + BaseTest( + CapAdaptersCodeEthereum.newSUSDeAdapterCode(), + 8, + ForkParams({network: 'mainnet', blockNumber: 21833121}), + 'sUSDe_Ethereum' + ) + {} + + function _createAdapter( + IPriceCapAdapter.CapAdapterParams memory capAdapterParams + ) internal override returns (IPriceCapAdapter) { + return new SUSDePriceCapAdapter(capAdapterParams); + } +} diff --git a/tests/utils/GetExchangeRatesTest.t.sol b/tests/utils/GetExchangeRatesTest.t.sol index 9aa94a7..fea2ffd 100644 --- a/tests/utils/GetExchangeRatesTest.t.sol +++ b/tests/utils/GetExchangeRatesTest.t.sol @@ -42,7 +42,7 @@ import {CapAdaptersCodeLinea} from '../../scripts/DeployLinea.s.sol'; contract ExchangeRatesEth is Test { function setUp() public { - vm.createSelectFork(vm.rpcUrl('mainnet'), 21010101); // Oct-20-2024 + vm.createSelectFork(vm.rpcUrl('mainnet'), 21700000); // Jan-25-2025 } function test_getExchangeRate() public view { diff --git a/tests/zksync/newSUSDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/newSUSDePriceCapAdapterZkSyncTest.t.sol new file mode 100644 index 0000000..98b828f --- /dev/null +++ b/tests/zksync/newSUSDePriceCapAdapterZkSyncTest.t.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseTest.sol'; + +import {CLRatePriceCapAdapter} from '../../src/contracts/CLRatePriceCapAdapter.sol'; +import {CapAdaptersCodeZkSync} from '../../scripts/DeployZkSync.s.sol'; + +contract sUSDePriceCapAdapterZkSyncTest is BaseTest { + constructor() + BaseTest( + CapAdaptersCodeZkSync.newSUSDeAdapterParams(), + 35, + ForkParams({network: 'zksync', blockNumber: 55822451}), + 'sUSDe_ZkSync' + ) + {} + + function _createAdapter( + IPriceCapAdapter.CapAdapterParams memory capAdapterParams + ) internal override returns (IPriceCapAdapter) { + return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); + } +}