Skip to content
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

[ACI] Capo for sFRAX #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ deploy-pk := --sender $(SENDER) --private-key ${PRIVATE_KEY} --verify -vvvv --sl

# Deploy
deploy-weeth-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployWeEthEthereum --rpc-url mainnet $(common-flags)
deploy-usde-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployUSDeEthereum --rpc-url mainnet $(common-flags)
deploy-weeth-arbitrum :; forge script scripts/DeployArbitrumWeEth.s.sol:DeployWeEthArbitrum --rpc-url arbitrum $(common-flags)
deploy-weeth-scroll :; forge script scripts/DeployScroll.s.sol:DeployWeEthScroll --rpc-url scroll $(common-flags)
deploy-weeth-base :; forge script scripts/DeployBase.s.sol:DeployWeEthBase --rpc-url base $(deploy-pk)
Expand All @@ -24,8 +23,11 @@ deploy-oseth-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployOsEthEth

deploy-ethx-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployEthXEthereum --rpc-url mainnet $(common-flags)

deploy-usde-mainnet :; forge script scripts/DeployEthereum.s.sol:DeployUSDeEthereum --rpc-url mainnet $(common-flags)
deploy-susde-mainnet :; forge script scripts/DeployEthereum.s.sol:DeploySUSDeEthereum --rpc-url mainnet $(common-flags)

deploy-sfrax-mainnet :; forge script scripts/DeployEthereum.s.sol:DeploysFRAXeEthereum --rpc-url mainnet $(common-flags)

# Utilities
download :; cast etherscan-source --chain ${chain} -d src/etherscan/${chain}_${address} ${address}
git-diff :
Expand Down
139 changes: 139 additions & 0 deletions reports/sFRAX_Ethereum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Capo Report

| Capped sFRAX / FRAX / USD | Capped FRAX/USD | Diff | Date | 7-day growth in yearly % |
| --- | --- | --- | --- | --- |
| 1.02181841 | 0.99760062 | 2.40% | 01 Apr 2024 | 5.25% |
| 1.02210725 | 0.9977354 | 2.41% | 02 Apr 2024 | 5.25% |
| 1.02232625 | 0.9978024 | 2.43% | 03 Apr 2024 | 5.25% |
| 1.02226857 | 0.99763415 | 2.44% | 04 Apr 2024 | 5.08% |
| 1.02299958 | 0.99820053 | 2.45% | 05 Apr 2024 | 5.08% |
| 1.02295211 | 0.99800754 | 2.47% | 06 Apr 2024 | 5.08% |
| 1.02293874 | 0.9978473 | 2.48% | 07 Apr 2024 | 5.08% |
| 1.02365384 | 0.99839767 | 2.50% | 08 Apr 2024 | 5.08% |
| 1.02300948 | 0.99762236 | 2.51% | 09 Apr 2024 | 5.08% |
| 1.02327005 | 0.99772982 | 2.53% | 10 Apr 2024 | 5.08% |
| 1.02310464 | 0.99653103 | 2.63% | 11 Apr 2024 | 9.82% |
| 1.02670306 | 0.99890189 | 2.74% | 12 Apr 2024 | 14.87% |
| 1.02286748 | 0.99404274 | 2.86% | 13 Apr 2024 | 19.90% |
| 1.02885185 | 0.99877057 | 2.97% | 14 Apr 2024 | 24.72% |
| 1.03007425 | 0.99890141 | 3.07% | 16 Apr 2024 | 29.39% |
| 1.03085078 | 0.99867127 | 3.17% | 17 Apr 2024 | 33.67% |
| 1.03199096 | 0.99885234 | 3.26% | 18 Apr 2024 | 37.66% |
| 1.0317374 | 0.99797598 | 3.33% | 19 Apr 2024 | 35.57% |
| 1.03294803 | 0.99849694 | 3.39% | 20 Apr 2024 | 33.09% |
| 1.03421055 | 0.99907891 | 3.46% | 21 Apr 2024 | 30.57% |
| 1.03430562 | 0.99852986 | 3.52% | 22 Apr 2024 | 28.29% |
| 1.03512501 | 0.99869699 | 3.58% | 23 Apr 2024 | 26.08% |
| 1.03578373 | 0.99871939 | 3.64% | 24 Apr 2024 | 24.19% |
| 1.03618728 | 0.99853912 | 3.70% | 25 Apr 2024 | 22.37% |
| 1.03728787 | 0.99910721 | 3.75% | 26 Apr 2024 | 21.65% |
| 1.03717798 | 0.99851712 | 3.80% | 27 Apr 2024 | 20.80% |
| 1.03799847 | 0.9988231 | 3.85% | 28 Apr 2024 | 20.01% |
| 1.03836961 | 0.99869216 | 3.90% | 29 Apr 2024 | 19.22% |
| 1.0398274 | 0.99961287 | 3.94% | 30 Apr 2024 | 18.49% |
| 1.03905105 | 0.99839535 | 3.99% | 01 May 2024 | 17.76% |
| 1.03898789 | 0.9979159 | 4.03% | 02 May 2024 | 17.00% |
| 1.03995285 | 0.99842984 | 4.07% | 03 May 2024 | 16.59% |
| 1.04044831 | 0.9984869 | 4.12% | 04 May 2024 | 16.26% |
| 1.04091233 | 0.99853805 | 4.16% | 05 May 2024 | 15.80% |
| 1.04122608 | 0.99845411 | 4.19% | 06 May 2024 | 15.27% |
| 1.04188765 | 0.99870223 | 4.23% | 07 May 2024 | 14.78% |
| 1.04168811 | 0.99813129 | 4.27% | 08 May 2024 | 14.32% |
| 1.04217517 | 0.99821545 | 4.31% | 09 May 2024 | 14.12% |
| 1.04266181 | 0.99829204 | 4.35% | 10 May 2024 | 14.00% |
| 1.04307307 | 0.99829814 | 4.39% | 11 May 2024 | 13.85% |
| 1.04363904 | 0.99845331 | 4.43% | 12 May 2024 | 13.81% |
| 1.04350994 | 0.99794395 | 4.46% | 13 May 2024 | 13.81% |
| 1.04391799 | 0.99795163 | 4.50% | 14 May 2024 | 13.80% |
| 1.04499484 | 0.99860391 | 4.54% | 15 May 2024 | 13.78% |
| 1.04518285 | 0.99843874 | 4.57% | 16 May 2024 | 13.59% |
| 1.0468761 | 0.99972269 | 4.61% | 17 May 2024 | 13.30% |
| 1.04584161 | 0.99840006 | 4.64% | 18 May 2024 | 13.02% |
| 1.04615222 | 0.9983613 | 4.68% | 19 May 2024 | 12.76% |
| 1.04624577 | 0.99811168 | 4.71% | 20 May 2024 | 12.52% |
| 1.04665242 | 0.99814806 | 4.74% | 21 May 2024 | 12.36% |
| 1.04697961 | 0.99809772 | 4.78% | 22 May 2024 | 12.29% |
| 1.04691224 | 0.99773361 | 4.81% | 23 May 2024 | 12.06% |
| 1.04768782 | 0.99812255 | 4.85% | 24 May 2024 | 12.15% |
| 1.0478802 | 0.99795105 | 4.88% | 25 May 2024 | 12.26% |
| 1.04808964 | 0.99779299 | 4.92% | 26 May 2024 | 12.37% |
| 1.04851892 | 0.99784226 | 4.95% | 27 May 2024 | 12.48% |
| 1.04866027 | 0.99761923 | 4.99% | 28 May 2024 | 12.51% |
| 1.0488624 | 0.99744736 | 5.03% | 29 May 2024 | 12.52% |
| 1.04949437 | 0.9977084 | 5.06% | 30 May 2024 | 12.73% |
| 1.04965345 | 0.99743769 | 5.10% | 31 May 2024 | 13.10% |
| 1.05019911 | 0.99752817 | 5.14% | 01 Jun 2024 | 13.48% |
| 1.05098144 | 0.997845 | 5.19% | 02 Jun 2024 | 13.83% |
| 1.0512576 | 0.99768126 | 5.23% | 04 Jun 2024 | 14.17% |
| 1.05209739 | 0.99805545 | 5.27% | 05 Jun 2024 | 14.51% |
| 1.05222603 | 0.99777473 | 5.31% | 06 Jun 2024 | 14.71% |
| 1.05274414 | 0.99802654 | 5.34% | 07 Jun 2024 | 14.20% |
| 1.0533113 | 0.99812181 | 5.38% | 08 Jun 2024 | 14.30% |
| 1.0534888 | 0.9978667 | 5.42% | 09 Jun 2024 | 14.28% |
| 1.05412569 | 0.99805264 | 5.46% | 10 Jun 2024 | 14.23% |
| 1.05397157 | 0.99746087 | 5.51% | 11 Jun 2024 | 14.33% |
| 1.05460609 | 0.99760021 | 5.56% | 12 Jun 2024 | 14.53% |
| 1.05541687 | 0.99794414 | 5.60% | 13 Jun 2024 | 14.63% |
| 1.05589452 | 0.99798315 | 5.64% | 14 Jun 2024 | 15.52% |
| 1.05604442 | 0.99774173 | 5.68% | 15 Jun 2024 | 15.21% |
| 1.05656703 | 0.99785228 | 5.72% | 16 Jun 2024 | 15.00% |
| 1.0576124 | 0.99846173 | 5.75% | 17 Jun 2024 | 14.80% |
| 1.05739369 | 0.99788208 | 5.79% | 18 Jun 2024 | 14.42% |
| 1.05820134 | 0.9982763 | 5.83% | 19 Jun 2024 | 13.93% |
| 1.05805942 | 0.99783793 | 5.86% | 20 Jun 2024 | 13.32% |
| 1.05783482 | 0.99732753 | 5.89% | 21 Jun 2024 | 12.74% |
| 1.05831983 | 0.99748409 | 5.92% | 22 Jun 2024 | 12.32% |
| 1.05866395 | 0.99750902 | 5.95% | 23 Jun 2024 | 11.89% |
| 1.059577 | 0.99807101 | 5.98% | 24 Jun 2024 | 11.48% |
| 1.05975426 | 0.99794106 | 6.01% | 25 Jun 2024 | 11.09% |
| 1.05958373 | 0.99748606 | 6.04% | 26 Jun 2024 | 10.72% |
| 1.06014727 | 0.99774827 | 6.06% | 27 Jun 2024 | 10.54% |
| 1.06008075 | 0.99744408 | 6.09% | 28 Jun 2024 | 10.25% |
| 1.05979468 | 0.99693304 | 6.11% | 29 Jun 2024 | 9.95% |
| 1.06044385 | 0.99730156 | 6.14% | 30 Jun 2024 | 9.66% |
| 1.06057113 | 0.99717945 | 6.16% | 01 Jul 2024 | 9.37% |
| 1.06123142 | 0.9975514 | 6.19% | 02 Jul 2024 | 9.13% |
| 1.06102881 | 0.99711156 | 6.21% | 03 Jul 2024 | 8.89% |
| 1.06109814 | 0.99696751 | 6.23% | 04 Jul 2024 | 8.59% |
| 1.06241549 | 0.99800144 | 6.25% | 05 Jul 2024 | 8.40% |
| 1.06175742 | 0.99717719 | 6.27% | 06 Jul 2024 | 8.21% |
| 1.06179666 | 0.99700671 | 6.29% | 07 Jul 2024 | 8.04% |
| 1.06232921 | 0.99729886 | 6.31% | 08 Jul 2024 | 7.86% |
| 1.06193896 | 0.99672392 | 6.34% | 09 Jul 2024 | 7.65% |
| 1.06221896 | 0.99677961 | 6.36% | 10 Jul 2024 | 7.44% |
| 1.06279115 | 0.99713052 | 6.38% | 11 Jul 2024 | 7.32% |
| 1.06323178 | 0.997345 | 6.39% | 12 Jul 2024 | 7.29% |
| 1.06251465 | 0.9964814 | 6.41% | 13 Jul 2024 | 7.21% |
| 1.06291797 | 0.99666853 | 6.43% | 14 Jul 2024 | 7.13% |
| 1.06357995 | 0.99709812 | 6.45% | 15 Jul 2024 | 7.05% |
| 1.06384259 | 0.99715289 | 6.47% | 16 Jul 2024 | 6.96% |
| 1.06379291 | 0.99691392 | 6.49% | 17 Jul 2024 | 6.89% |
| 1.063936 | 0.99689271 | 6.51% | 18 Jul 2024 | 6.73% |
| 1.06419175 | 0.99693639 | 6.53% | 19 Jul 2024 | 6.71% |
| 1.06440522 | 0.99693828 | 6.55% | 20 Jul 2024 | 6.75% |
| 1.06498061 | 0.9972756 | 6.57% | 21 Jul 2024 | 6.81% |
| 1.06488368 | 0.99697867 | 6.59% | 22 Jul 2024 | 6.88% |
| 1.06480842 | 0.99670262 | 6.61% | 23 Jul 2024 | 6.96% |
| 1.06462196 | 0.99632109 | 6.63% | 24 Jul 2024 | 7.03% |
| 1.06522177 | 0.99671284 | 6.65% | 26 Jul 2024 | 7.10% |
| 1.06570107 | 0.99695381 | 6.67% | 27 Jul 2024 | 7.16% |
| 1.06528257 | 0.99635513 | 6.69% | 28 Jul 2024 | 7.21% |
| 1.06525806 | 0.99612454 | 6.71% | 29 Jul 2024 | 7.24% |
| 1.06586617 | 0.99648389 | 6.73% | 30 Jul 2024 | 7.26% |
| 1.06603021 | 0.99642709 | 6.75% | 31 Jul 2024 | 7.28% |
| 1.06553555 | 0.99576963 | 6.77% | 01 Aug 2024 | 7.22% |
| 1.06639015 | 0.99636586 | 6.79% | 02 Aug 2024 | 7.39% |
| 1.06647818 | 0.99624562 | 6.81% | 03 Aug 2024 | 7.36% |
| 1.06618018 | 0.99576446 | 6.83% | 04 Aug 2024 | 7.34% |
| 1.06796513 | 0.99723064 | 6.85% | 05 Aug 2024 | 7.31% |


* 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 % |
| --- | --- | --- |
| 50.00% | 40.54% | 37.66% |


* Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage.
29 changes: 29 additions & 0 deletions scripts/DeployEthereum.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import {WeETHPriceCapAdapter} from '../src/contracts/lst-adapters/WeETHPriceCapA
import {OsETHPriceCapAdapter} from '../src/contracts/lst-adapters/OsETHPriceCapAdapter.sol';
import {EthXPriceCapAdapter} from '../src/contracts/lst-adapters/EthXPriceCapAdapter.sol';
import {SUSDePriceCapAdapter} from '../src/contracts/lst-adapters/SUSDePriceCapAdapter.sol';
import {sFRAXPriceCapAdapter} from '../src/contracts/lst-adapters/sFRAXPriceCapAdapter.sol';

library CapAdaptersCodeEthereum {
address public constant weETH = 0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee;
address public constant osETH_VAULT_CONTROLLER = 0x2A261e60FB14586B474C208b1B7AC6D0f5000306;
address public constant USDe_PRICE_FEED = 0xa569d910839Ae8865Da8F8e70FfFb0cBA869F961;
address public constant STADER_STAKE_POOLS_MANAGER = 0xcf5EA1b38380f6aF39068375516Daf40Ed70D299;
address public constant sUSDe = 0x9D39A5DE30e57443BfF2A8307A4256c8797A3497;
address public constant sFRAX = 0xA663B02CF0a4b149d2aD41910CB81e23e1c41c32;

function weETHAdapterCode() internal pure returns (bytes memory) {
return
Expand Down Expand Up @@ -117,6 +119,27 @@ library CapAdaptersCodeEthereum {
)
);
}

function sFRAXAdapterCode() internal pure returns (bytes memory) {
return
abi.encodePacked(
type(sFRAXPriceCapAdapter).creationCode,
abi.encode(
IPriceCapAdapter.CapAdapterParams({
aclManager: AaveV3Ethereum.ACL_MANAGER,
baseAggregatorAddress: AaveV3EthereumAssets.FRAX_ORACLE,
ratioProviderAddress: sFRAX,
pairDescription: 'Capped sFRAX / FRAX / USD',
minimumSnapshotDelay: 7 days,
priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({
snapshotRatio: 1069128743204736813,
snapshotTimestamp: 1722108827,
maxYearlyRatioGrowthPercent: 50_00
})
})
)
);
}
}

contract DeployWeEthEthereum is EthereumScript {
Expand Down Expand Up @@ -148,3 +171,9 @@ contract DeploySUSDeEthereum is EthereumScript {
GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.sUSDeAdapterCode());
}
}

contract DeploysFRAXEthereum is EthereumScript {
function run() external broadcast {
GovV3Helpers.deployDeterministic(CapAdaptersCodeEthereum.sFRAXAdapterCode());
}
}
39 changes: 39 additions & 0 deletions src/contracts/lst-adapters/sFRAXPriceCapAdapter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.19;

import {IACLManager} from 'aave-address-book/AaveV3.sol';
import {IERC4626} from 'forge-std/interfaces/IERC4626.sol';

import {PriceCapAdapterBase, IPriceCapAdapter} from '../PriceCapAdapterBase.sol';

/**
* @title sFRAX
* @author Aave-chan Initiative
* @notice Price capped adapter to calculate price of (sFRAX / USD) pair by using
* @notice Chainlink data feed for (FRAX / USD) and (sFRAX / FRAX) ratio.
*/
contract sFRAXPriceCapAdapter 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));
}
}
26 changes: 26 additions & 0 deletions tests/ethereum/sFRAXPriceCapAdapterTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import '../BaseTest.sol';

import {AaveV3Ethereum, AaveV3EthereumAssets} from 'aave-address-book/AaveV3Ethereum.sol';

import {sFRAXPriceCapAdapter} from '../../src/contracts/lst-adapters/sFRAXPriceCapAdapter.sol';
import {CapAdaptersCodeEthereum} from '../../scripts/DeployEthereum.s.sol';

contract sFRAXPriceCapAdapterTest is BaseTest {
constructor()
BaseTest(
CapAdaptersCodeEthereum.sFRAXAdapterCode(),
130, // apy spike was a while ago
ForkParams({network: 'mainnet', blockNumber: 20460072}),
'sFRAX_Ethereum'
)
{}

function _createAdapter(
IPriceCapAdapter.CapAdapterParams memory capAdapterParams
) internal override returns (IPriceCapAdapter) {
return new sFRAXPriceCapAdapter(capAdapterParams);
}
}
4 changes: 3 additions & 1 deletion tests/utils/GetExchangeRatesTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {CapAdaptersCodeScroll} from '../../scripts/DeployScroll.s.sol';

contract ExchangeRatesEth is Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 20024431); // 5th of June
vm.createSelectFork(vm.rpcUrl('mainnet'), 20400000); // 27th of July
}

function test_getExchangeRate() public view {
Expand All @@ -52,6 +52,7 @@ contract ExchangeRatesEth is Test {
.convertToAssets(10 ** 18);
uint256 ethXRate = IEthX(CapAdaptersCodeEthereum.STADER_STAKE_POOLS_MANAGER).getExchangeRate();
uint256 sUSDeRate = IERC4626(CapAdaptersCodeEthereum.sUSDe).convertToAssets(10 ** 18);
uint256 sFRAXRate = IERC4626(CapAdaptersCodeEthereum.sFRAX).convertToAssets(10 ** 18);

console.log('cbEthRate', cbEthRate);
console.log('rEthRate', rEthRate);
Expand All @@ -62,6 +63,7 @@ contract ExchangeRatesEth is Test {
console.log('osEthRate', osEthRate);
console.log('ethXRate', ethXRate);
console.log('usUSDe', sUSDeRate);
console.log('sFRAX', sFRAXRate);

console.log(block.timestamp);
}
Expand Down