Skip to content

Commit

Permalink
Merge pull request #45 from bgd-labs/feat/wstETH-bnb
Browse files Browse the repository at this point in the history
feat: add capo for wstETH on bnb
  • Loading branch information
brotherlymite authored Oct 2, 2024
2 parents 62d3bc8 + 7a80cf6 commit 485f762
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ deploy-susds-mainnet :
forge script scripts/DeployEthereum.s.sol:DeployUSDSEthereum --rpc-url mainnet $(common-flags)
forge script scripts/DeployEthereum.s.sol:DeploysUSDSEthereum --rpc-url mainnet $(common-flags)

deploy-wsteth-bnb :; forge script scripts/DeployBnb.s.sol:DeployWstEthBnb --rpc-url bnb $(common-flags)

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

| Capped wstETH / stETH(ETH) / USD | ETH / USD | Diff | Date | 7-day growth in yearly % |
| --- | --- | --- | --- | --- |
| 3133.78741239 | 2655.02535327 | 16.54% | 29 Sept 2024 | 3.41% |
| 3081.12278712 | 2610.195 | 16.55% | 30 Sept 2024 | 3.38% |
| 2965.32175918 | 2511.8853 | 16.56% | 01 Oct 2024 | 3.36% |


* 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.68% | 5.60% | 3.41% |


* Max day-to-day yearly % indicates the maximum growth between two emissions as an annualized percentage.
39 changes: 39 additions & 0 deletions scripts/DeployBnb.s.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.0;

import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol';
import {BNBScript} from 'aave-helpers/ScriptUtils.sol';
import {AaveV3BNB, AaveV3BNBAssets} from 'aave-address-book/AaveV3BNB.sol';

import {CLRatePriceCapAdapter, IPriceCapAdapter, IACLManager} from '../src/contracts/CLRatePriceCapAdapter.sol';

library CapAdaptersCodeBNB {
address public constant wstETH_stETH_AGGREGATOR = 0x4c75d01cfa4D998770b399246400a6dc40FB9645;

function wstETHAdapterCode() internal pure returns (bytes memory) {
return
abi.encodePacked(
type(CLRatePriceCapAdapter).creationCode,
abi.encode(
IPriceCapAdapter.CapAdapterParams({
aclManager: AaveV3BNB.ACL_MANAGER,
baseAggregatorAddress: AaveV3BNBAssets.ETH_ORACLE,
ratioProviderAddress: wstETH_stETH_AGGREGATOR,
pairDescription: 'Capped wstETH / stETH(ETH) / USD',
minimumSnapshotDelay: 7 days,
priceCapParams: IPriceCapAdapter.PriceCapUpdateParams({
snapshotRatio: 1179619475032439052,
snapshotTimestamp: 1727049059, // Sep-22-2024
maxYearlyRatioGrowthPercent: 9_68
})
})
)
);
}
}

contract DeployWstEthBnb is BNBScript {
function run() external broadcast {
GovV3Helpers.deployDeterministic(CapAdaptersCodeBNB.wstETHAdapterCode());
}
}
22 changes: 22 additions & 0 deletions tests/bnb/wstETHPriceCapAdapterTest.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import '../BaseTest.sol';
import {CapAdaptersCodeBNB, CLRatePriceCapAdapter} from '../../scripts/DeployBnb.s.sol';

contract wstETHPriceCapAdapterTest is BaseTest {
constructor()
BaseTest(
CapAdaptersCodeBNB.wstETHAdapterCode(),
9,
ForkParams({network: 'bnb', blockNumber: 42738754}),
'wstETH_BNB'
)
{}

function _createAdapter(
IPriceCapAdapter.CapAdapterParams memory capAdapterParams
) internal override returns (IPriceCapAdapter) {
return new CLRatePriceCapAdapter(capAdapterParams);
}
}
17 changes: 17 additions & 0 deletions tests/utils/GetExchangeRatesTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {CapAdaptersCodeEthereum} from '../../scripts/DeployEthereum.s.sol';
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';

contract ExchangeRatesEth is Test {
function setUp() public {
Expand Down Expand Up @@ -226,3 +227,19 @@ contract ExchangeRatesScroll is Test {
console.log(block.timestamp);
}
}

contract ExchangeRatesBNB is Test {
function setUp() public {
vm.createSelectFork(vm.rpcUrl('bnb'), 42490000); // Sep-22-2024
}

function test_getExchangeRate() public view {
uint256 wstEthRate = uint256(
IChainlinkAggregator(CapAdaptersCodeBNB.wstETH_stETH_AGGREGATOR).latestAnswer()
);

console.log('BNB');
console.log('wstEthRate', wstEthRate);
console.log(block.timestamp);
}
}

0 comments on commit 485f762

Please sign in to comment.