From e34f8e1d50547b401b3570e80ede5a8d0611406f Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Wed, 30 Oct 2024 21:07:29 +0530 Subject: [PATCH 01/11] feat: add sDAI capo --- Makefile | 3 ++ reports/sDAI_Ethereum.md | 26 ++++++++++++ reports/sDAI_Gnosis.md | 26 ++++++++++++ scripts/DeployEthereum.s.sol | 30 ++++++++++++++ scripts/DeployGnosis.s.sol | 40 +++++++++++++++++++ .../sDAIGnosisPriceCapAdapter.sol | 37 +++++++++++++++++ .../sDAIMainnetPriceCapAdapter.sol | 37 +++++++++++++++++ .../sDAIMainnetPriceCapAdapterTest.t.sol | 23 +++++++++++ tests/gnosis/sDAIGnosisPriceCapAdapter.t.sol | 23 +++++++++++ tests/utils/GetExchangeRatesTest.t.sol | 4 +- 10 files changed, 247 insertions(+), 2 deletions(-) create mode 100644 reports/sDAI_Ethereum.md create mode 100644 reports/sDAI_Gnosis.md create mode 100644 scripts/DeployGnosis.s.sol create mode 100644 src/contracts/lst-adapters/sDAIGnosisPriceCapAdapter.sol create mode 100644 src/contracts/lst-adapters/sDAIMainnetPriceCapAdapter.sol create mode 100644 tests/ethereum/sDAIMainnetPriceCapAdapterTest.t.sol create mode 100644 tests/gnosis/sDAIGnosisPriceCapAdapter.t.sol diff --git a/Makefile b/Makefile index 6a7a6d9..4616388 100644 --- a/Makefile +++ b/Makefile @@ -34,6 +34,9 @@ deploy-wsteth-bnb :; forge script scripts/DeployBnb.s.sol:DeployWstEthBnb --rpc- deploy-ezeth-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployEzEthEthereum --rpc-url mainnet $(common-flags) +deploy-sdai-mainnet :; forge script scripts/DeployEthereum.s.sol:DeploySDaiEthereum --rpc-url mainnet $(common-flags) +deploy-sdai-gnosis :; forge script scripts/DeployGnosis.s.sol:DeploySDaiGnosis --rpc-url gnosis $(common-flags) + # Utilities download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address} git-diff : diff --git a/reports/sDAI_Ethereum.md b/reports/sDAI_Ethereum.md new file mode 100644 index 0000000..9d9152d --- /dev/null +++ b/reports/sDAI_Ethereum.md @@ -0,0 +1,26 @@ +# Capo Report + +| Capped sDAI / DAI / USD | DAI / USD | Diff | Date | 7-day growth in yearly % | +| ----------------------- | ---------- | ------ | ----------- | ------------------------ | +| 1.11334971 | 0.99966482 | 10.76% | 17 Oct 2024 | 5.38% | +| 1.1136328 | 0.99977 | 10.78% | 18 Oct 2024 | 5.35% | +| 1.11383086 | 0.99979973 | 10.79% | 19 Oct 2024 | 5.35% | +| 1.11414282 | 0.99992865 | 10.81% | 20 Oct 2024 | 5.37% | +| 1.11434215 | 0.99995926 | 10.82% | 21 Oct 2024 | 5.35% | +| 1.11428835 | 0.99976 | 10.83% | 22 Oct 2024 | 5.35% | +| 1.11442294 | 0.99973188 | 10.85% | 23 Oct 2024 | 5.35% | +| 1.11455532 | 0.99970131 | 10.86% | 24 Oct 2024 | 5.35% | +| 1.11485537 | 0.99982108 | 10.88% | 25 Oct 2024 | 5.35% | +| 1.11484808 | 0.99966494 | 10.89% | 26 Oct 2024 | 5.36% | +| 1.11510009 | 0.99974234 | 10.91% | 27 Oct 2024 | 5.35% | +| 1.11544634 | 0.99990409 | 10.92% | 28 Oct 2024 | 5.35% | +| 1.11556526 | 0.99986 | 10.94% | 29 Oct 2024 | 5.35% | +| 1.1158962 | 1.00000876 | 10.95% | 30 Oct 2024 | 5.34% | + +- 7-day growth is calculated as an annualized percentage relative to the value of the rate 7 days prior. + +| Max Yearly % | Max Day-to-day yearly % | Max 7-day yearly % | +| ------------ | ----------------------- | ------------------ | +| 9.69% | 5.53% | 5.38% | + +- Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. diff --git a/reports/sDAI_Gnosis.md b/reports/sDAI_Gnosis.md new file mode 100644 index 0000000..c7d3739 --- /dev/null +++ b/reports/sDAI_Gnosis.md @@ -0,0 +1,26 @@ +# Capo Report + +| Capped sDAI / DAI / USD | DAI / USD | Diff | Date | 7-day growth in yearly % | +| ----------------------- | ---------- | ------ | ----------- | ------------------------ | +| 1.11779532 | 0.99971365 | 11.15% | 17 Oct 2024 | 6.96% | +| 1.1179241 | 0.99966346 | 11.17% | 18 Oct 2024 | 6.74% | +| 1.11822501 | 0.99976211 | 11.19% | 19 Oct 2024 | 6.70% | +| 1.11832166 | 0.999735 | 11.20% | 20 Oct 2024 | 6.31% | +| 1.1187078 | 0.99978507 | 11.23% | 21 Oct 2024 | 7.31% | +| 1.11896805 | 0.99984 | 11.24% | 22 Oct 2024 | 6.84% | +| 1.11914493 | 0.99979999 | 11.26% | 23 Oct 2024 | 6.78% | +| 1.119103 | 0.99966681 | 11.27% | 24 Oct 2024 | 6.23% | +| 1.11942566 | 0.99966508 | 11.30% | 25 Oct 2024 | 6.88% | +| 1.11978946 | 0.99980639 | 11.32% | 26 Oct 2024 | 6.94% | +| 1.11996144 | 0.99981308 | 11.34% | 27 Oct 2024 | 7.11% | +| 1.1201338 | 0.99974778 | 11.36% | 28 Oct 2024 | 6.71% | +| 1.12047981 | 0.99987 | 11.38% | 29 Oct 2024 | 6.74% | +| 1.12103936 | 1.00018123 | 11.40% | 30 Oct 2024 | 6.69% | + +- 7-day growth is calculated as an annualized percentage relative to the value of the rate 7 days prior. + +| Max Yearly % | Max Day-to-day yearly % | Max 7-day yearly % | +| ------------ | ----------------------- | ------------------ | +| 9.69% | 10.69% | 7.31% | + +- 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 d00f7aa..58bb919 100644 --- a/scripts/DeployEthereum.s.sol +++ b/scripts/DeployEthereum.s.sol @@ -1,9 +1,11 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; + import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; import {EthereumScript} from 'solidity-utils/contracts/utils/ScriptUtils.sol'; import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol'; import {AaveV3EthereumLido, AaveV3EthereumLidoAssets} from 'aave-address-book/AaveV3EthereumLido.sol'; +import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {PriceCapAdapterStable} from '../src/contracts/PriceCapAdapterStable.sol'; import {IPriceCapAdapter, IChainlinkAggregator} from '../src/interfaces/IPriceCapAdapter.sol'; @@ -14,6 +16,7 @@ import {EthXPriceCapAdapter} from '../src/contracts/lst-adapters/EthXPriceCapAda import {SUSDePriceCapAdapter} from '../src/contracts/lst-adapters/SUSDePriceCapAdapter.sol'; import {sUSDSPriceCapAdapter} from '../src/contracts/lst-adapters/sUSDSPriceCapAdapter.sol'; import {EzETHPriceCapAdapter} from '../src/contracts/lst-adapters/EzETHPriceCapAdapter.sol'; +import {sDAIMainnetPriceCapAdapter} from '../src/contracts/lst-adapters/sDAIMainnetPriceCapAdapter.sol'; library CapAdaptersCodeEthereum { address public constant weETH = 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee; @@ -124,6 +127,27 @@ library CapAdaptersCodeEthereum { ); } + function sDAIAdapterCode() internal pure returns (bytes memory) { + return + abi.encodePacked( + type(sDAIMainnetPriceCapAdapter).creationCode, + abi.encode( + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3Ethereum.ACL_MANAGER, + baseAggregatorAddress: DAI_PRICE_FEED, + ratioProviderAddress: MiscEthereum.sDAI_POT, + pairDescription: 'Capped sDAI / DAI / USD', + minimumSnapshotDelay: 7 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1_114312383890349337561189736, + snapshotTimestamp: 1729467251, + maxYearlyRatioGrowthPercent: 9_69 + }) + }) + ) + ); + } + function USDSAdapterCode() internal pure returns (bytes memory) { return abi.encodePacked( @@ -229,3 +253,9 @@ contract DeployEzEthEthereum is EthereumScript { GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.ezETHAdapterCode()); } } + +contract DeploySDaiEthereum is EthereumScript { + function run() external broadcast { + GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.sDAIAdapterCode()); + } +} diff --git a/scripts/DeployGnosis.s.sol b/scripts/DeployGnosis.s.sol new file mode 100644 index 0000000..24db28a --- /dev/null +++ b/scripts/DeployGnosis.s.sol @@ -0,0 +1,40 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {GnosisScript} from 'solidity-utils/contracts/utils/ScriptUtils.sol'; +import {AaveV3Gnosis, AaveV3GnosisAssets} from 'aave-address-book/AaveV3Gnosis.sol'; + +import {sDAIGnosisPriceCapAdapter} from '../src/contracts/lst-adapters/sDAIGnosisPriceCapAdapter.sol'; +import {IPriceCapAdapter} from '../src/interfaces/IPriceCapAdapter.sol'; + +library CapAdaptersCodeGnosis { + address public constant DAI_PRICE_FEED = 0x678df3415fc31947dA4324eC63212874be5a82f8; + + function sDAIAdapterCode() internal pure returns (bytes memory) { + return + abi.encodePacked( + type(sDAIGnosisPriceCapAdapter).creationCode, + abi.encode( + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3Gnosis.ACL_MANAGER, + baseAggregatorAddress: DAI_PRICE_FEED, + ratioProviderAddress: AaveV3GnosisAssets.sDAI_UNDERLYING, + pairDescription: 'Capped sDAI / DAI / USD', + minimumSnapshotDelay: 7 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1_118618102334074883, + snapshotTimestamp: 1729423540, + maxYearlyRatioGrowthPercent: 9_69 + }) + }) + ) + ); + } +} + +contract DeploySDaiGnosis is GnosisScript { + function run() external broadcast { + GovV3Helpers.deployDeterministic(CapAdaptersCodeGnosis.sDAIAdapterCode()); + } +} diff --git a/src/contracts/lst-adapters/sDAIGnosisPriceCapAdapter.sol b/src/contracts/lst-adapters/sDAIGnosisPriceCapAdapter.sol new file mode 100644 index 0000000..0856fa4 --- /dev/null +++ b/src/contracts/lst-adapters/sDAIGnosisPriceCapAdapter.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.19; + +import {IERC4626} from 'forge-std/interfaces/IERC4626.sol'; +import {PriceCapAdapterBase, IPriceCapAdapter} from '../PriceCapAdapterBase.sol'; + +/** + * @title sDAIGnosisPriceCapAdapter + * @author BGD Labs + * @notice Price capped adapter to calculate price of (sDAI / USD) pair by using + * @notice Chainlink data feed for (DAI / USD) and (sDAI / DAI) ratio on Gnosis network. + */ +contract sDAIGnosisPriceCapAdapter is PriceCapAdapterBase { + /** + * @param capAdapterParams parameters to create cap adapter + */ + constructor( + CapAdapterParams memory capAdapterParams + ) + PriceCapAdapterBase( + CapAdapterBaseParams({ + aclManager: capAdapterParams.aclManager, + baseAggregatorAddress: capAdapterParams.baseAggregatorAddress, + ratioProviderAddress: capAdapterParams.ratioProviderAddress, + pairDescription: capAdapterParams.pairDescription, + ratioDecimals: 18, + minimumSnapshotDelay: capAdapterParams.minimumSnapshotDelay, + priceCapParams: capAdapterParams.priceCapParams + }) + ) + {} + + /// @inheritdoc IPriceCapAdapter + function getRatio() public view override returns (int256) { + return int256(IERC4626(RATIO_PROVIDER).convertToAssets(10 ** RATIO_DECIMALS)); + } +} diff --git a/src/contracts/lst-adapters/sDAIMainnetPriceCapAdapter.sol b/src/contracts/lst-adapters/sDAIMainnetPriceCapAdapter.sol new file mode 100644 index 0000000..946ceaf --- /dev/null +++ b/src/contracts/lst-adapters/sDAIMainnetPriceCapAdapter.sol @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.19; + +import {PriceCapAdapterBase, IPriceCapAdapter} from '../PriceCapAdapterBase.sol'; +import {IPot} from 'cl-synchronicity-price-adapter/interfaces/IPot.sol'; + +/** + * @title sDAIMainnetPriceCapAdapter + * @author BGD Labs + * @notice Price capped adapter to calculate price of (sDAI / USD) pair by using + * @notice Chainlink data feed for (DAI / USD) and (sDAI / DAI) ratio on Ethereum network. + */ +contract sDAIMainnetPriceCapAdapter is PriceCapAdapterBase { + /** + * @param capAdapterParams parameters to create cap adapter + */ + constructor( + CapAdapterParams memory capAdapterParams + ) + PriceCapAdapterBase( + CapAdapterBaseParams({ + aclManager: capAdapterParams.aclManager, + baseAggregatorAddress: capAdapterParams.baseAggregatorAddress, + ratioProviderAddress: capAdapterParams.ratioProviderAddress, + pairDescription: capAdapterParams.pairDescription, + ratioDecimals: 27, + minimumSnapshotDelay: capAdapterParams.minimumSnapshotDelay, + priceCapParams: capAdapterParams.priceCapParams + }) + ) + {} + + /// @inheritdoc IPriceCapAdapter + function getRatio() public view override returns (int256) { + return int256(IPot(RATIO_PROVIDER).chi()); + } +} diff --git a/tests/ethereum/sDAIMainnetPriceCapAdapterTest.t.sol b/tests/ethereum/sDAIMainnetPriceCapAdapterTest.t.sol new file mode 100644 index 0000000..dc233a3 --- /dev/null +++ b/tests/ethereum/sDAIMainnetPriceCapAdapterTest.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseTest.sol'; +import {sDAIMainnetPriceCapAdapter} from '../../src/contracts/lst-adapters/sDAIMainnetPriceCapAdapter.sol'; +import {CapAdaptersCodeEthereum} from '../../scripts/DeployEthereum.s.sol'; + +contract sDAIMainnetPriceCapAdapterTest is BaseTest { + constructor() + BaseTest( + CapAdaptersCodeEthereum.sDAIAdapterCode(), + 20, + ForkParams({network: 'mainnet', blockNumber: 21079105}), + 'sDAI_Ethereum' + ) + {} + + function _createAdapter( + IPriceCapAdapter.CapAdapterParams memory capAdapterParams + ) internal override returns (IPriceCapAdapter) { + return new sDAIMainnetPriceCapAdapter(capAdapterParams); + } +} diff --git a/tests/gnosis/sDAIGnosisPriceCapAdapter.t.sol b/tests/gnosis/sDAIGnosisPriceCapAdapter.t.sol new file mode 100644 index 0000000..5de4245 --- /dev/null +++ b/tests/gnosis/sDAIGnosisPriceCapAdapter.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseTest.sol'; +import {sDAIGnosisPriceCapAdapter} from '../../src/contracts/lst-adapters/sDAIGnosisPriceCapAdapter.sol'; +import {CapAdaptersCodeGnosis} from '../../scripts/DeployGnosis.s.sol'; + +contract sDAIGnosisPriceCapAdapterTest is BaseTest { + constructor() + BaseTest( + CapAdaptersCodeGnosis.sDAIAdapterCode(), + 20, + ForkParams({network: 'gnosis', blockNumber: 36769758}), + 'sDAI_Gnosis' + ) + {} + + function _createAdapter( + IPriceCapAdapter.CapAdapterParams memory capAdapterParams + ) internal override returns (IPriceCapAdapter) { + return new sDAIGnosisPriceCapAdapter(capAdapterParams); + } +} diff --git a/tests/utils/GetExchangeRatesTest.t.sol b/tests/utils/GetExchangeRatesTest.t.sol index 95420c1..3808e45 100644 --- a/tests/utils/GetExchangeRatesTest.t.sol +++ b/tests/utils/GetExchangeRatesTest.t.sol @@ -38,7 +38,7 @@ import {CapAdaptersCodeBNB} from '../../scripts/DeployBnb.s.sol'; contract ExchangeRatesEth is Test { function setUp() public { - vm.createSelectFork(vm.rpcUrl('mainnet'), 20870886); // 1st of October + vm.createSelectFork(vm.rpcUrl('mainnet'), 21010101); // Oct-20-2024 } function test_getExchangeRate() public view { @@ -143,7 +143,7 @@ contract ExchangeRatesBase is Test { contract ExchangeRatesGnosis is Test { function setUp() public { - vm.createSelectFork(vm.rpcUrl('gnosis'), 32462055); // 15th of February + vm.createSelectFork(vm.rpcUrl('gnosis'), 36600000); // Oct-20-2024 } function test_getExchangeRate() public view { From 927d2fa1783c8016bbda8ce09b8dd7fc16391ed3 Mon Sep 17 00:00:00 2001 From: ianflexa Date: Mon, 4 Nov 2024 05:55:44 -0400 Subject: [PATCH 02/11] feat: weETH, sUSDS, USDSe capo --- scripts/DeployZkSync.s.sol | 90 +++++++++++++++++++ src/contracts/CLRatePriceCapAdapter.sol | 2 +- tests/utils/GetExchangeRatesTest.t.sol | 22 +++++ .../USDePriceCapAdapterZkSyncTest.t.sol | 32 +++++++ .../sUSDePriceCapAdapterZkSyncTest.t.sol | 46 ++++++++++ .../weETHPriceCapAdapterZkSyncTest.t.sol | 46 ++++++++++ 6 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 scripts/DeployZkSync.s.sol create mode 100644 tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol create mode 100644 tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol create mode 100644 tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol diff --git a/scripts/DeployZkSync.s.sol b/scripts/DeployZkSync.s.sol new file mode 100644 index 0000000..b6c94ec --- /dev/null +++ b/scripts/DeployZkSync.s.sol @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {ZkSyncScript} from 'solidity-utils/contracts/utils/ScriptUtils.sol'; +import {CLRatePriceCapAdapter} from '../src/contracts/CLRatePriceCapAdapter.sol'; +import {AaveV3ZkSync, AaveV3ZkSyncAssets} from 'aave-address-book/AaveV3ZkSync.sol'; +import {PriceCapAdapterStable} from '../src/contracts/PriceCapAdapterStable.sol'; +import {IPriceCapAdapterStable} from '../src/interfaces/IPriceCapAdapterStable.sol'; +import {IPriceCapAdapter, IChainlinkAggregator} from '../src/interfaces/IPriceCapAdapter.sol'; + +library CapAdaptersCodeZkSync { + address public constant weETH_eETH_AGGREGATOR = 0x8D3184a992f93729b249407C33F1e78abE0d650e; + address public constant sUSDe_USDe_AGGREGATOR = 0x97920183c36B022B46D6C14b9dA36c5f31A98C6A; + address public constant USDe_PRICE_FEED = 0x4899faF0b6c36620168D00e3DbD4CB9361244c4d; + + function weETHAdapterCode() internal pure returns (bytes memory) { + return + abi.encode( + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + baseAggregatorAddress: AaveV3ZkSyncAssets.WETH_ORACLE, + ratioProviderAddress: weETH_eETH_AGGREGATOR, + pairDescription: 'Capped weETH / eETH(ETH) / USD', + minimumSnapshotDelay: 7 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1_050999130243073606, + snapshotTimestamp: 1729748180, // 24th of October 2024 + maxYearlyRatioGrowthPercent: 8_75 + }) + }) + ); + } + + function sUSDeAdapterCode() internal pure returns (bytes memory) { + return + abi.encode( + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + baseAggregatorAddress: USDe_PRICE_FEED, + ratioProviderAddress: sUSDe_USDe_AGGREGATOR, + pairDescription: 'Capped sUSDe / USDe / USD', + minimumSnapshotDelay: 14 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1_108087487354065863, + snapshotTimestamp: 1729101653, // 16th of October 2024 + maxYearlyRatioGrowthPercent: 50_00 + }) + }) + ); + } + + function USDeAdapterCode() internal pure returns (bytes memory) { + return + abi.encode( + IPriceCapAdapterStable.CapAdapterStableParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + assetToUsdAggregator: IChainlinkAggregator(USDe_PRICE_FEED), + adapterDescription: 'Capped USDe / USD', + priceCap: int256(1.04 * 1e8) + }) + ); + } +} + +contract DeployWeEthZkSync is ZkSyncScript { + function run() external broadcast { + new CLRatePriceCapAdapter{salt: 'capo'}( + abi.decode(CapAdaptersCodeZkSync.weETHAdapterCode(), (IPriceCapAdapter.CapAdapterParams)) + ); + } +} + +contract DeploySUSDeZkSync is ZkSyncScript { + function run() external broadcast { + new CLRatePriceCapAdapter{salt: 'capo'}( + abi.decode(CapAdaptersCodeZkSync.sUSDeAdapterCode(), (IPriceCapAdapter.CapAdapterParams)) + ); + } +} + +contract DeployUSDeZkSync is ZkSyncScript { + function run() external broadcast { + new PriceCapAdapterStable{salt: 'capo'}( + abi.decode( + CapAdaptersCodeZkSync.USDeAdapterCode(), + (IPriceCapAdapterStable.CapAdapterStableParams) + ) + ); + } +} diff --git a/src/contracts/CLRatePriceCapAdapter.sol b/src/contracts/CLRatePriceCapAdapter.sol index d4e6a54..95cef2d 100644 --- a/src/contracts/CLRatePriceCapAdapter.sol +++ b/src/contracts/CLRatePriceCapAdapter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.19; +pragma solidity 0.8.19; import {IACLManager} from 'aave-address-book/AaveV3.sol'; import {IChainlinkAggregator} from 'cl-synchronicity-price-adapter/interfaces/IChainlinkAggregator.sol'; diff --git a/tests/utils/GetExchangeRatesTest.t.sol b/tests/utils/GetExchangeRatesTest.t.sol index 6f28bdc..3fa331a 100644 --- a/tests/utils/GetExchangeRatesTest.t.sol +++ b/tests/utils/GetExchangeRatesTest.t.sol @@ -37,6 +37,7 @@ import {CapAdaptersCodeArbitrum} from '../../scripts/DeployArbitrumWeEth.s.sol'; import {CapAdaptersCodeBase} from '../../scripts/DeployBase.s.sol'; import {CapAdaptersCodeScroll} from '../../scripts/DeployScroll.s.sol'; import {CapAdaptersCodeBNB} from '../../scripts/DeployBnb.s.sol'; +import {CapAdaptersCodeZkSync} from '../../scripts/DeployZkSync.s.sol'; contract ExchangeRatesEth is Test { function setUp() public { @@ -259,3 +260,24 @@ contract ExchangeRatesBNB is Test { console.log(block.timestamp); } } + +contract ExchangeRatesZKSync is Test { + function setUp() public { + vm.createSelectFork(vm.rpcUrl('zksync'), 47270341); // Oct-16-2024 + } + + function test_getExchangeRate() public view { + uint256 weETHRate = uint256( + IChainlinkAggregator(CapAdaptersCodeZkSync.weETH_eETH_AGGREGATOR).latestAnswer() + ); + + uint256 sUSDeRate = uint256( + IChainlinkAggregator(CapAdaptersCodeZkSync.sUSDe_USDe_AGGREGATOR).latestAnswer() + ); + + console.log('ZkSync'); + console.log('weETHRate', weETHRate); + console.log('sUSDeRate', sUSDeRate); + console.log(block.timestamp); + } +} diff --git a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol new file mode 100644 index 0000000..38cd0df --- /dev/null +++ b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../BaseStableTest.sol'; +import {PriceCapAdapterStable, IChainlinkAggregator} from '../../src/contracts/PriceCapAdapterStable.sol'; +import {CapAdaptersCodeZkSync} from '../../scripts/DeployZkSync.s.sol'; +import {AaveV3ZkSync} from 'aave-address-book/AaveV3ZkSync.sol'; + +contract USDePriceCapAdapterZKSyncTest is BaseStableTest { + constructor() + BaseStableTest( + CapAdaptersCodeZkSync.USDeAdapterCode(), + 10, + ForkParams({network: 'zksync', blockNumber: 47910214}) + ) + {} + + function _capAdapterParams() + internal + pure + override + returns (IPriceCapAdapterStable.CapAdapterStableParams memory) + { + return + IPriceCapAdapterStable.CapAdapterStableParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + assetToUsdAggregator: IChainlinkAggregator(CapAdaptersCodeZkSync.USDe_PRICE_FEED), + adapterDescription: 'Capped USDe / USD', + priceCap: int256(1.04 * 1e8) + }); + } +} diff --git a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol new file mode 100644 index 0000000..1122907 --- /dev/null +++ b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol @@ -0,0 +1,46 @@ +// 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'; +import {AaveV3ZkSync} from 'aave-address-book/AaveV3ZkSync.sol'; + +contract sUSDePriceCapAdapterZkSyncTest is BaseTest { + constructor() + BaseTest( + CapAdaptersCodeZkSync.sUSDeAdapterCode(), + 8, + ForkParams({network: 'zksync', blockNumber: 47910214}), + 'sUSDe_ZkSync' + ) + {} + + function _createAdapter( + IPriceCapAdapter.CapAdapterParams memory capAdapterParams + ) internal override returns (IPriceCapAdapter) { + return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); + } + + function _capAdapterParams() + internal + pure + override + returns (IPriceCapAdapter.CapAdapterParams memory) + { + return + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + baseAggregatorAddress: CapAdaptersCodeZkSync.USDe_PRICE_FEED, + ratioProviderAddress: CapAdaptersCodeZkSync.sUSDe_USDe_AGGREGATOR, + pairDescription: 'Capped sUSDe / USDe / USD', + minimumSnapshotDelay: 14 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1_108087487354065863, + snapshotTimestamp: 1729101653, // 16th of October 2024 + maxYearlyRatioGrowthPercent: 50_00 + }) + }); + } +} diff --git a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol new file mode 100644 index 0000000..3c9dd37 --- /dev/null +++ b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol @@ -0,0 +1,46 @@ +// 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'; +import {AaveV3ZkSync, AaveV3ZkSyncAssets} from 'aave-address-book/AaveV3ZkSync.sol'; + +contract weETHPriceCapAdapterZkSyncTest is BaseTest { + constructor() + BaseTest( + CapAdaptersCodeZkSync.weETHAdapterCode(), + 8, + ForkParams({network: 'zksync', blockNumber: 47840214}), + 'weETH_ZkSync' + ) + {} + + function _createAdapter( + IPriceCapAdapter.CapAdapterParams memory capAdapterParams + ) internal override returns (IPriceCapAdapter) { + return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); + } + + function _capAdapterParams() + internal + pure + override + returns (IPriceCapAdapter.CapAdapterParams memory) + { + return + IPriceCapAdapter.CapAdapterParams({ + aclManager: AaveV3ZkSync.ACL_MANAGER, + baseAggregatorAddress: AaveV3ZkSyncAssets.WETH_ORACLE, + ratioProviderAddress: CapAdaptersCodeZkSync.weETH_eETH_AGGREGATOR, + pairDescription: 'Capped weETH / eETH(ETH) / USD', + minimumSnapshotDelay: 7 days, + priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ + snapshotRatio: 1_050999130243073606, + snapshotTimestamp: 1729748180, // 24th of October 2024 + maxYearlyRatioGrowthPercent: 8_75 + }) + }); + } +} From 063a72b7fb61a93a29340417a9a6ae5cb2026cba Mon Sep 17 00:00:00 2001 From: ianflexa Date: Tue, 5 Nov 2024 07:56:43 -0400 Subject: [PATCH 03/11] fix: script and tests naming --- scripts/DeployZkSync.s.sol | 12 +++++----- .../USDePriceCapAdapterZkSyncTest.t.sol | 17 ++------------ .../sUSDePriceCapAdapterZkSyncTest.t.sol | 23 ++----------------- .../weETHPriceCapAdapterZkSyncTest.t.sol | 23 ++----------------- 4 files changed, 12 insertions(+), 63 deletions(-) diff --git a/scripts/DeployZkSync.s.sol b/scripts/DeployZkSync.s.sol index b6c94ec..f279a09 100644 --- a/scripts/DeployZkSync.s.sol +++ b/scripts/DeployZkSync.s.sol @@ -13,7 +13,7 @@ library CapAdaptersCodeZkSync { address public constant sUSDe_USDe_AGGREGATOR = 0x97920183c36B022B46D6C14b9dA36c5f31A98C6A; address public constant USDe_PRICE_FEED = 0x4899faF0b6c36620168D00e3DbD4CB9361244c4d; - function weETHAdapterCode() internal pure returns (bytes memory) { + function weETHAdapterParams() internal pure returns (bytes memory) { return abi.encode( IPriceCapAdapter.CapAdapterParams({ @@ -31,7 +31,7 @@ library CapAdaptersCodeZkSync { ); } - function sUSDeAdapterCode() internal pure returns (bytes memory) { + function sUSDeAdapterParams() internal pure returns (bytes memory) { return abi.encode( IPriceCapAdapter.CapAdapterParams({ @@ -49,7 +49,7 @@ library CapAdaptersCodeZkSync { ); } - function USDeAdapterCode() internal pure returns (bytes memory) { + function USDeAdapterParams() internal pure returns (bytes memory) { return abi.encode( IPriceCapAdapterStable.CapAdapterStableParams({ @@ -65,7 +65,7 @@ library CapAdaptersCodeZkSync { contract DeployWeEthZkSync is ZkSyncScript { function run() external broadcast { new CLRatePriceCapAdapter{salt: 'capo'}( - abi.decode(CapAdaptersCodeZkSync.weETHAdapterCode(), (IPriceCapAdapter.CapAdapterParams)) + abi.decode(CapAdaptersCodeZkSync.weETHAdapterParams(), (IPriceCapAdapter.CapAdapterParams)) ); } } @@ -73,7 +73,7 @@ contract DeployWeEthZkSync is ZkSyncScript { contract DeploySUSDeZkSync is ZkSyncScript { function run() external broadcast { new CLRatePriceCapAdapter{salt: 'capo'}( - abi.decode(CapAdaptersCodeZkSync.sUSDeAdapterCode(), (IPriceCapAdapter.CapAdapterParams)) + abi.decode(CapAdaptersCodeZkSync.sUSDeAdapterParams(), (IPriceCapAdapter.CapAdapterParams)) ); } } @@ -82,7 +82,7 @@ contract DeployUSDeZkSync is ZkSyncScript { function run() external broadcast { new PriceCapAdapterStable{salt: 'capo'}( abi.decode( - CapAdaptersCodeZkSync.USDeAdapterCode(), + CapAdaptersCodeZkSync.USDeAdapterParams(), (IPriceCapAdapterStable.CapAdapterStableParams) ) ); diff --git a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol index 38cd0df..e2c2fbd 100644 --- a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol @@ -9,24 +9,11 @@ import {AaveV3ZkSync} from 'aave-address-book/AaveV3ZkSync.sol'; contract USDePriceCapAdapterZKSyncTest is BaseStableTest { constructor() BaseStableTest( - CapAdaptersCodeZkSync.USDeAdapterCode(), + CapAdaptersCodeZkSync.USDeAdapterParams(), 10, ForkParams({network: 'zksync', blockNumber: 47910214}) ) {} - function _capAdapterParams() - internal - pure - override - returns (IPriceCapAdapterStable.CapAdapterStableParams memory) - { - return - IPriceCapAdapterStable.CapAdapterStableParams({ - aclManager: AaveV3ZkSync.ACL_MANAGER, - assetToUsdAggregator: IChainlinkAggregator(CapAdaptersCodeZkSync.USDe_PRICE_FEED), - adapterDescription: 'Capped USDe / USD', - priceCap: int256(1.04 * 1e8) - }); - } + } diff --git a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol index 1122907..bf559b3 100644 --- a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol @@ -10,7 +10,7 @@ import {AaveV3ZkSync} from 'aave-address-book/AaveV3ZkSync.sol'; contract sUSDePriceCapAdapterZkSyncTest is BaseTest { constructor() BaseTest( - CapAdaptersCodeZkSync.sUSDeAdapterCode(), + CapAdaptersCodeZkSync.sUSDeAdapterParams(), 8, ForkParams({network: 'zksync', blockNumber: 47910214}), 'sUSDe_ZkSync' @@ -23,24 +23,5 @@ contract sUSDePriceCapAdapterZkSyncTest is BaseTest { return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); } - function _capAdapterParams() - internal - pure - override - returns (IPriceCapAdapter.CapAdapterParams memory) - { - return - IPriceCapAdapter.CapAdapterParams({ - aclManager: AaveV3ZkSync.ACL_MANAGER, - baseAggregatorAddress: CapAdaptersCodeZkSync.USDe_PRICE_FEED, - ratioProviderAddress: CapAdaptersCodeZkSync.sUSDe_USDe_AGGREGATOR, - pairDescription: 'Capped sUSDe / USDe / USD', - minimumSnapshotDelay: 14 days, - priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ - snapshotRatio: 1_108087487354065863, - snapshotTimestamp: 1729101653, // 16th of October 2024 - maxYearlyRatioGrowthPercent: 50_00 - }) - }); - } + } diff --git a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol index 3c9dd37..9976fef 100644 --- a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol @@ -10,7 +10,7 @@ import {AaveV3ZkSync, AaveV3ZkSyncAssets} from 'aave-address-book/AaveV3ZkSync.s contract weETHPriceCapAdapterZkSyncTest is BaseTest { constructor() BaseTest( - CapAdaptersCodeZkSync.weETHAdapterCode(), + CapAdaptersCodeZkSync.weETHAdapterParams(), 8, ForkParams({network: 'zksync', blockNumber: 47840214}), 'weETH_ZkSync' @@ -23,24 +23,5 @@ contract weETHPriceCapAdapterZkSyncTest is BaseTest { return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); } - function _capAdapterParams() - internal - pure - override - returns (IPriceCapAdapter.CapAdapterParams memory) - { - return - IPriceCapAdapter.CapAdapterParams({ - aclManager: AaveV3ZkSync.ACL_MANAGER, - baseAggregatorAddress: AaveV3ZkSyncAssets.WETH_ORACLE, - ratioProviderAddress: CapAdaptersCodeZkSync.weETH_eETH_AGGREGATOR, - pairDescription: 'Capped weETH / eETH(ETH) / USD', - minimumSnapshotDelay: 7 days, - priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ - snapshotRatio: 1_050999130243073606, - snapshotTimestamp: 1729748180, // 24th of October 2024 - maxYearlyRatioGrowthPercent: 8_75 - }) - }); - } + } From 07283cf8ece685eeaf2e3176a7ff21b97912b60e Mon Sep 17 00:00:00 2001 From: ianflexa Date: Tue, 5 Nov 2024 07:59:47 -0400 Subject: [PATCH 04/11] chore: cleanup --- scripts/DeployZkSync.s.sol | 1 - tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol | 5 +---- tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol | 3 --- tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol | 3 --- 4 files changed, 1 insertion(+), 11 deletions(-) diff --git a/scripts/DeployZkSync.s.sol b/scripts/DeployZkSync.s.sol index f279a09..c51cd98 100644 --- a/scripts/DeployZkSync.s.sol +++ b/scripts/DeployZkSync.s.sol @@ -1,6 +1,5 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.0; -import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; import {ZkSyncScript} from 'solidity-utils/contracts/utils/ScriptUtils.sol'; import {CLRatePriceCapAdapter} from '../src/contracts/CLRatePriceCapAdapter.sol'; import {AaveV3ZkSync, AaveV3ZkSyncAssets} from 'aave-address-book/AaveV3ZkSync.sol'; diff --git a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol index e2c2fbd..4025c34 100644 --- a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol @@ -2,9 +2,8 @@ pragma solidity ^0.8.0; import '../BaseStableTest.sol'; -import {PriceCapAdapterStable, IChainlinkAggregator} from '../../src/contracts/PriceCapAdapterStable.sol'; +import {PriceCapAdapterStable} from '../../src/contracts/PriceCapAdapterStable.sol'; import {CapAdaptersCodeZkSync} from '../../scripts/DeployZkSync.s.sol'; -import {AaveV3ZkSync} from 'aave-address-book/AaveV3ZkSync.sol'; contract USDePriceCapAdapterZKSyncTest is BaseStableTest { constructor() @@ -14,6 +13,4 @@ contract USDePriceCapAdapterZKSyncTest is BaseStableTest { ForkParams({network: 'zksync', blockNumber: 47910214}) ) {} - - } diff --git a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol index bf559b3..02f607e 100644 --- a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol @@ -5,7 +5,6 @@ import '../BaseTest.sol'; import {CLRatePriceCapAdapter} from '../../src/contracts/CLRatePriceCapAdapter.sol'; import {CapAdaptersCodeZkSync} from '../../scripts/DeployZkSync.s.sol'; -import {AaveV3ZkSync} from 'aave-address-book/AaveV3ZkSync.sol'; contract sUSDePriceCapAdapterZkSyncTest is BaseTest { constructor() @@ -22,6 +21,4 @@ contract sUSDePriceCapAdapterZkSyncTest is BaseTest { ) internal override returns (IPriceCapAdapter) { return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); } - - } diff --git a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol index 9976fef..c15cdb4 100644 --- a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol @@ -5,7 +5,6 @@ import '../BaseTest.sol'; import {CLRatePriceCapAdapter} from '../../src/contracts/CLRatePriceCapAdapter.sol'; import {CapAdaptersCodeZkSync} from '../../scripts/DeployZkSync.s.sol'; -import {AaveV3ZkSync, AaveV3ZkSyncAssets} from 'aave-address-book/AaveV3ZkSync.sol'; contract weETHPriceCapAdapterZkSyncTest is BaseTest { constructor() @@ -22,6 +21,4 @@ contract weETHPriceCapAdapterZkSyncTest is BaseTest { ) internal override returns (IPriceCapAdapter) { return new CLRatePriceCapAdapter{salt: 'test'}(capAdapterParams); } - - } From ff3502f3f8a854956691a72c2e28a27b39baf86d Mon Sep 17 00:00:00 2001 From: ianflexa Date: Tue, 19 Nov 2024 08:41:58 -0400 Subject: [PATCH 05/11] chore: update weETH and sUSDe snapshots + fork block tests --- scripts/DeployZkSync.s.sol | 8 ++++---- tests/BaseTest.sol | 2 +- tests/utils/GetExchangeRatesTest.t.sol | 2 +- tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol | 4 ++-- tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol | 4 ++-- tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/DeployZkSync.s.sol b/scripts/DeployZkSync.s.sol index c51cd98..e66055b 100644 --- a/scripts/DeployZkSync.s.sol +++ b/scripts/DeployZkSync.s.sol @@ -22,8 +22,8 @@ library CapAdaptersCodeZkSync { pairDescription: 'Capped weETH / eETH(ETH) / USD', minimumSnapshotDelay: 7 days, priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ - snapshotRatio: 1_050999130243073606, - snapshotTimestamp: 1729748180, // 24th of October 2024 + snapshotRatio: 1_052574497679413779, + snapshotTimestamp: 1731404006, // 12th of November 2024 maxYearlyRatioGrowthPercent: 8_75 }) }) @@ -40,8 +40,8 @@ library CapAdaptersCodeZkSync { pairDescription: 'Capped sUSDe / USDe / USD', minimumSnapshotDelay: 14 days, priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({ - snapshotRatio: 1_108087487354065863, - snapshotTimestamp: 1729101653, // 16th of October 2024 + snapshotRatio: 1_114017044432046603, + snapshotTimestamp: 1730790353, // 05th of November 2024 maxYearlyRatioGrowthPercent: 50_00 }) }) diff --git a/tests/BaseTest.sol b/tests/BaseTest.sol index 479c983..eeb1134 100644 --- a/tests/BaseTest.sol +++ b/tests/BaseTest.sol @@ -87,7 +87,7 @@ abstract contract BaseTest is Test { uint256 snapshotDelayDays = uint256(adapter.MINIMUM_SNAPSHOT_DELAY()) / SECONDS_PER_DAY; // persist adapter - vm.makePersistent(address(adapter)); // does not work on zksync + vm.makePersistent(address(adapter)); // get step uint256 step = BlockUtils.getStep(RETROSPECTIVE_STEP, forkParams.network); diff --git a/tests/utils/GetExchangeRatesTest.t.sol b/tests/utils/GetExchangeRatesTest.t.sol index 3fa331a..56b81dc 100644 --- a/tests/utils/GetExchangeRatesTest.t.sol +++ b/tests/utils/GetExchangeRatesTest.t.sol @@ -263,7 +263,7 @@ contract ExchangeRatesBNB is Test { contract ExchangeRatesZKSync is Test { function setUp() public { - vm.createSelectFork(vm.rpcUrl('zksync'), 47270341); // Oct-16-2024 + vm.createSelectFork(vm.rpcUrl('zksync'), 48189193); // Nov-05-2024 } function test_getExchangeRate() public view { diff --git a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol index 4025c34..8a279ef 100644 --- a/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/USDePriceCapAdapterZkSyncTest.t.sol @@ -9,8 +9,8 @@ contract USDePriceCapAdapterZKSyncTest is BaseStableTest { constructor() BaseStableTest( CapAdaptersCodeZkSync.USDeAdapterParams(), - 10, - ForkParams({network: 'zksync', blockNumber: 47910214}) + 35, + ForkParams({network: 'zksync', blockNumber: 49309220}) ) {} } diff --git a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol index 02f607e..4c2c157 100644 --- a/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/sUSDePriceCapAdapterZkSyncTest.t.sol @@ -10,8 +10,8 @@ contract sUSDePriceCapAdapterZkSyncTest is BaseTest { constructor() BaseTest( CapAdaptersCodeZkSync.sUSDeAdapterParams(), - 8, - ForkParams({network: 'zksync', blockNumber: 47910214}), + 35, + ForkParams({network: 'zksync', blockNumber: 49309220}), 'sUSDe_ZkSync' ) {} diff --git a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol index c15cdb4..4c92966 100644 --- a/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol +++ b/tests/zksync/weETHPriceCapAdapterZkSyncTest.t.sol @@ -10,8 +10,8 @@ contract weETHPriceCapAdapterZkSyncTest is BaseTest { constructor() BaseTest( CapAdaptersCodeZkSync.weETHAdapterParams(), - 8, - ForkParams({network: 'zksync', blockNumber: 47840214}), + 35, + ForkParams({network: 'zksync', blockNumber: 49309193}), 'weETH_ZkSync' ) {} From b1f484569817cd71695a4e677864e3702b02b9f6 Mon Sep 17 00:00:00 2001 From: ianflexa Date: Tue, 19 Nov 2024 08:42:35 -0400 Subject: [PATCH 06/11] chore: weETH + sUSDe reports --- reports/sUSDe_ZkSync.md | 34 ++++++++++++++++++++++++++++++++++ reports/weETH_ZkSync.md | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 reports/sUSDe_ZkSync.md create mode 100644 reports/weETH_ZkSync.md diff --git a/reports/sUSDe_ZkSync.md b/reports/sUSDe_ZkSync.md new file mode 100644 index 0000000..feed1d3 --- /dev/null +++ b/reports/sUSDe_ZkSync.md @@ -0,0 +1,34 @@ +# Capo Report + +| Capped sUSDe / USDe / USD | USDe / USD | Diff | Date | 14-day growth in yearly % | +| ------------------------- | ---------- | ------ | ----------- | ------------------------- | +| 1.11195118 | 1.00024757 | 10.58% | 28 Oct 2024 | 9.33% | +| 1.1125614 | 1.0005 | 10.61% | 30 Oct 2024 | 9.62% | +| 1.11341766 | 1.00097941 | 10.64% | 31 Oct 2024 | 9.90% | +| 1.11371677 | 1.00096143 | 10.66% | 01 Nov 2024 | 10.17% | +| 1.11327601 | 1.00026341 | 10.69% | 02 Nov 2024 | 10.53% | +| 1.1143006 | 1.0008725 | 10.73% | 03 Nov 2024 | 10.58% | +| 1.11455263 | 1.00078891 | 10.76% | 04 Nov 2024 | 10.65% | +| 1.11468545 | 1.0006 | 10.79% | 05 Nov 2024 | 10.06% | +| 1.11526216 | 1.00081265 | 10.82% | 06 Nov 2024 | 10.14% | +| 1.11603128 | 1.0012 | 10.85% | 07 Nov 2024 | 10.25% | +| 1.11684814 | 1.00133096 | 10.91% | 08 Nov 2024 | 11.29% | +| 1.11737186 | 1.00150053 | 10.94% | 09 Nov 2024 | 11.33% | +| 1.11723336 | 1.00107996 | 10.97% | 10 Nov 2024 | 11.32% | +| 1.11791936 | 1.0014 | 11.00% | 11 Nov 2024 | 11.38% | +| 1.11884016 | 1.001938 | 11.02% | 12 Nov 2024 | 11.38% | +| 1.11835784 | 1.00150607 | 11.02% | 13 Nov 2024 | 10.69% | +| 1.11947894 | 1.00222841 | 11.05% | 14 Nov 2024 | 10.68% | +| 1.1193506 | 1.00183747 | 11.08% | 15 Nov 2024 | 10.68% | +| 1.12052337 | 1.0018 | 11.19% | 16 Nov 2024 | 12.67% | +| 1.12094851 | 1.00158273 | 11.25% | 17 Nov 2024 | 13.51% | +| 1.12129925 | 1.00131213 | 11.31% | 18 Nov 2024 | 14.25% | +| 1.12191947 | 1.0013 | 11.36% | 19 Nov 2024 | 14.93% | + +- 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% | 38.25% | 14.93% | + +- Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. diff --git a/reports/weETH_ZkSync.md b/reports/weETH_ZkSync.md new file mode 100644 index 0000000..8411a55 --- /dev/null +++ b/reports/weETH_ZkSync.md @@ -0,0 +1,41 @@ +# Capo Report + +| Capped weETH / eETH(ETH) / USD | ETH / USD | Diff | Date | 7-day growth in yearly % | +| ------------------------------ | ------------- | ----- | ----------- | ------------------------ | +| 2796.30214289 | 2661.02 | 4.96% | 21 Oct 2024 | 2.82% | +| 2754.66311811 | 2621.21 | 4.96% | 22 Oct 2024 | 2.81% | +| 2640.15185513 | 2512.04 | 4.97% | 23 Oct 2024 | 2.82% | +| 2649.8634455 | 2521.09862646 | 4.98% | 24 Oct 2024 | 2.86% | +| 2605.81459261 | 2479.02 | 4.99% | 25 Oct 2024 | 2.49% | +| 2619.25098808 | 2491.62 | 4.99% | 26 Oct 2024 | 2.51% | +| 2652.20026346 | 2522.79 | 5.00% | 27 Oct 2024 | 2.43% | +| 2697.10415893 | 2565.33062993 | 5.01% | 28 Oct 2024 | 2.49% | +| 2767.7168616 | 2632.31044615 | 5.02% | 30 Oct 2024 | 2.48% | +| 2793.03766059 | 2656.18 | 5.02% | 31 Oct 2024 | 2.48% | +| 2659.20135356 | 2528.75 | 5.03% | 01 Nov 2024 | 2.42% | +| 2646.76422145 | 2516.9136 | 5.03% | 02 Nov 2024 | 2.12% | +| 2583.38116131 | 2456.258022 | 5.04% | 03 Nov 2024 | 2.50% | +| 2587.57445769 | 2460.06324246 | 5.05% | 04 Nov 2024 | 2.54% | +| 2550.78265691 | 2424.9076 | 5.06% | 05 Nov 2024 | 2.57% | +| 2735.55463878 | 2600.36 | 5.07% | 06 Nov 2024 | 2.61% | +| 2954.92711115 | 2808.6694 | 5.08% | 07 Nov 2024 | 2.60% | +| 3052.44231365 | 2900.8948 | 5.09% | 08 Nov 2024 | 3.10% | +| 3213.70316926 | 3053.91 | 5.10% | 09 Nov 2024 | 3.45% | +| 3375.72482722 | 3207.6299 | 5.11% | 10 Nov 2024 | 3.10% | +| 3359.40506995 | 3191.871483 | 5.11% | 11 Nov 2024 | 3.16% | +| 3583.57362333 | 3404.579563 | 5.12% | 12 Nov 2024 | 3.25% | +| 3328.81126755 | 3162.5422 | 5.12% | 13 Nov 2024 | 2.88% | +| 3400.41654846 | 3230.37692177 | 5.13% | 14 Nov 2024 | 2.80% | +| 3204.02893756 | 3043.4155 | 5.14% | 15 Nov 2024 | 2.65% | +| 3270.47195073 | 3106.2683715 | 5.15% | 16 Nov 2024 | 2.69% | +| 3312.50919564 | 3145.9392 | 5.16% | 17 Nov 2024 | 2.72% | +| 3277.67047438 | 3112.67627839 | 5.16% | 18 Nov 2024 | 2.58% | +| 3271.89848866 | 3106.95 | 5.17% | 19 Nov 2024 | 2.53% | + +- 7-day growth is calculated as an annualized percentage relative to the value of the rate 7 days prior. + +| Max Yearly % | Max Day-to-day yearly % | Max 7-day yearly % | +| ------------ | ----------------------- | ------------------ | +| 8.75% | 5.76% | 3.45% | + +- Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage. From d4883f7742be034d5fbd5f2b308b589d7a6d7f37 Mon Sep 17 00:00:00 2001 From: ianflexa Date: Tue, 19 Nov 2024 08:53:10 -0400 Subject: [PATCH 07/11] fix: update solc on CLRatePriceCapAdapter --- src/contracts/CLRatePriceCapAdapter.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/contracts/CLRatePriceCapAdapter.sol b/src/contracts/CLRatePriceCapAdapter.sol index 95cef2d..f3a3119 100644 --- a/src/contracts/CLRatePriceCapAdapter.sol +++ b/src/contracts/CLRatePriceCapAdapter.sol @@ -1,5 +1,5 @@ // SPDX-License-Identifier: BUSL-1.1 -pragma solidity 0.8.19; +pragma solidity 0.8.20; import {IACLManager} from 'aave-address-book/AaveV3.sol'; import {IChainlinkAggregator} from 'cl-synchronicity-price-adapter/interfaces/IChainlinkAggregator.sol'; From 73b2a87d9dae2b05777871ff6b00777306e76597 Mon Sep 17 00:00:00 2001 From: ianflexa Date: Tue, 19 Nov 2024 09:00:44 -0400 Subject: [PATCH 08/11] fix: zksync ci test support --- .github/workflows/main.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b75a24e..c301ae9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,6 +8,16 @@ on: workflow_dispatch: jobs: - test: + test-sol: uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main secrets: inherit + with: + mode: "CHANGED" + + test-sol-zksync: + uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main + secrets: inherit + with: + mode: "CHANGED" + zksync: true + ROOT_DIR: "zksync" From 3e67d9b8c91ca3b532e13cf3d6922234fecc8ba7 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Fri, 22 Nov 2024 16:33:42 +0530 Subject: [PATCH 09/11] chore: update ci --- .env.example | 26 ------------------- .github/workflows/main.yml | 53 ++++++++++++++++++++++++++++---------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/.env.example b/.env.example index c12ce8f..fb11c5f 100644 --- a/.env.example +++ b/.env.example @@ -5,30 +5,4 @@ LEDGER_SENDER= # Deployment via private key PRIVATE_KEY= -# Test rpc_endpoints -RPC_MAINNET=https://eth.llamarpc.com -RPC_AVALANCHE=https://api.avax.network/ext/bc/C/rpc -RPC_OPTIMISM=https://optimism.llamarpc.com -RPC_POLYGON=https://polygon.llamarpc.com -RPC_ARBITRUM=https://arbitrum.llamarpc.com -RPC_FANTOM=https://rpc.ftm.tools -RPC_HARMONY=https://api.harmony.one -RPC_METIS=https://andromeda.metis.io/?owner=1088 -RPC_BASE=https://base.llamarpc.com -RPC_ZKEVM=https://zkevm-rpc.com -RPC_GNOSIS=https://rpc.ankr.com/gnosis -RPC_BNB=https://binance.llamarpc.com - -# Etherscan api keys for verification & download utils -ETHERSCAN_API_KEY_MAINNET= -ETHERSCAN_API_KEY_POLYGON= -ETHERSCAN_API_KEY_AVALANCHE= -ETHERSCAN_API_KEY_FANTOM= -ETHERSCAN_API_KEY_OPTIMISM= -ETHERSCAN_API_KEY_ARBITRUM= -ETHERSCAN_API_KEY_BASE= -ETHERSCAN_API_KEY_ZKEVM= -ETHERSCAN_API_KEY_GNOSIS= -ETHERSCAN_API_KEY_BNB= - diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c301ae9..f57f210 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,16 +8,43 @@ on: workflow_dispatch: jobs: - test-sol: - uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main - secrets: inherit - with: - mode: "CHANGED" - - test-sol-zksync: - uses: bgd-labs/github-workflows/.github/workflows/foundry-test.yml@main - secrets: inherit - with: - mode: "CHANGED" - zksync: true - ROOT_DIR: "zksync" + name: Foundry build n test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: bgd-labs/action-rpc-env@main + with: + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + + # we simply use foundry zk for all jobs in this repo + - name: Run Foundry setup + uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main + with: + ZKSYNC: "true" + + - name: Run Forge tests + id: test + uses: bgd-labs/github-workflows/.github/actions/foundry-test@main + with: + MODE: "CHANGED" + + - name: Run ZK tests + id: zktest + uses: bgd-labs/github-workflows/.github/actions/foundry-test@main + with: + MODE: "CHANGED" + ZKSYNC: true + ROOT_DIR: "zksync" + + - name: Run Forge tests + uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main + + # we let failing tests pass so we can log them in the comment, still we want the ci to fail + - name: Post test + if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }} + run: | + echo "tests failed" + exit 1 From 84a7c6e12c410bc458936d71d2538dd891bf43e8 Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Fri, 22 Nov 2024 16:38:40 +0530 Subject: [PATCH 10/11] fix: ci --- .github/workflows/main.yml | 81 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f57f210..77885e5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,43 +8,44 @@ on: workflow_dispatch: jobs: - name: Foundry build n test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - uses: bgd-labs/action-rpc-env@main - with: - ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} - - # we simply use foundry zk for all jobs in this repo - - name: Run Foundry setup - uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main - with: - ZKSYNC: "true" - - - name: Run Forge tests - id: test - uses: bgd-labs/github-workflows/.github/actions/foundry-test@main - with: - MODE: "CHANGED" - - - name: Run ZK tests - id: zktest - uses: bgd-labs/github-workflows/.github/actions/foundry-test@main - with: - MODE: "CHANGED" - ZKSYNC: true - ROOT_DIR: "zksync" - - - name: Run Forge tests - uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main - - # we let failing tests pass so we can log them in the comment, still we want the ci to fail - - name: Post test - if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }} - run: | - echo "tests failed" - exit 1 + test-sol: + name: Foundry build n test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: bgd-labs/action-rpc-env@main + with: + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + + # we simply use foundry zk for all jobs in this repo + - name: Run Foundry setup + uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main + with: + ZKSYNC: "true" + + - name: Run Forge tests + id: test + uses: bgd-labs/github-workflows/.github/actions/foundry-test@main + with: + MODE: "CHANGED" + + - name: Run ZK tests + id: zktest + uses: bgd-labs/github-workflows/.github/actions/foundry-test@main + with: + MODE: "CHANGED" + ZKSYNC: true + ROOT_DIR: "zksync" + + - name: Run Forge tests + uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main + + # we let failing tests pass so we can log them in the comment, still we want the ci to fail + - name: Post test + if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }} + run: | + echo "tests failed" + exit 1 From 9b5622434d0f58e5a0b6fccd69509b6e43d04d0c Mon Sep 17 00:00:00 2001 From: Harsh Pandey Date: Fri, 22 Nov 2024 16:48:36 +0530 Subject: [PATCH 11/11] fix: ci --- .github/workflows/main.yml | 78 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 77885e5..d077327 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,42 +10,42 @@ on: jobs: test-sol: name: Foundry build n test - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - uses: bgd-labs/action-rpc-env@main - with: - ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} - - # we simply use foundry zk for all jobs in this repo - - name: Run Foundry setup - uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main - with: - ZKSYNC: "true" - - - name: Run Forge tests - id: test - uses: bgd-labs/github-workflows/.github/actions/foundry-test@main - with: - MODE: "CHANGED" - - - name: Run ZK tests - id: zktest - uses: bgd-labs/github-workflows/.github/actions/foundry-test@main - with: - MODE: "CHANGED" - ZKSYNC: true - ROOT_DIR: "zksync" - - - name: Run Forge tests - uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main - - # we let failing tests pass so we can log them in the comment, still we want the ci to fail - - name: Post test - if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }} - run: | - echo "tests failed" - exit 1 + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - uses: bgd-labs/action-rpc-env@main + with: + ALCHEMY_API_KEY: ${{ secrets.ALCHEMY_API_KEY }} + + # we simply use foundry zk for all jobs in this repo + - name: Run Foundry setup + uses: bgd-labs/github-workflows/.github/actions/foundry-setup@main + with: + ZKSYNC: "true" + + - name: Run Forge tests + id: test + uses: bgd-labs/github-workflows/.github/actions/foundry-test@main + with: + MODE: "CHANGED" + + - name: Run ZK tests + id: zktest + uses: bgd-labs/github-workflows/.github/actions/foundry-test@main + with: + MODE: "CHANGED" + ZKSYNC: true + ROOT_DIR: "zksync" + + - name: Run Forge tests + uses: bgd-labs/github-workflows/.github/actions/comment-artifact@main + + # we let failing tests pass so we can log them in the comment, still we want the ci to fail + - name: Post test + if: ${{ steps.test.outputs.testStatus != 0 || steps.zktest.outputs.testStatus != 0 }} + run: | + echo "tests failed" + exit 1