The repository contains the Price Adapter contracts for the assets, which prices are correlated with different token rather than the pool's base one. The primary focus of these adapters is to provide accurate and reliable pricing information for assets in relation to a reference token whether it is on ETH-based or USD-based pools.
These price adapters could be used for a simple 2-step price conversion using two underlying oracles. One of the use-cases is to provide WBTC / USD
price feed using Chainlink's WBTC / BTC
and BTC / USD
oracles. The same approach could be used for ETH-correlated assets, for example, stETH / ETH
and ETH / USD
feeds could be used to calculate the stETH / USD
price.
Another application of the adapter is to provide the reliable stablecoins prices on the ETH-based pools. For example, the Aave v2 pool on Ethereum uses ETH-based oracles to calculate the collateral value, debt value and health factor of a user. This, coupled with the delay at which different price feeds update, introduces unnecessary volatility in positions that involve stablecoins used both as collateral and as debt. Replacement of the current ETH-based oracles for stablecoins by using USD pairs instead will normalize the USD price using the ETH oracle and will reduce the volatility between stablecoins as all the stablecoin price feeds will update atomically when the ETH price changes.
This repository also contains the proposal smart contracts for using price adapters for stablecoins on the Aave v2 Ethereum and Aave Arc pool and deployment scripts for WBTC / USD
and wstETH / USD
adapters.
The proposed change is to deploy CLSynchronicityPriceAdapterBaseToPeg
for all stablecoin assets and utilize these adapters in the AaveOracle
smart contract, in order to accurately calculate the price of the asset in relation to ETH
.
This will be achieved by querying Chainlink Data Feeds for the pairs of Asset/USD
and ETH/USD
, then using the formula
To provide the WBTC / USD
price feed CLSynchronicityPriceAdapterPegToBase
contract utilizing WBTC / BTC
and BTC / USD
oracles is deployed.
General formula for this adapter is
Price adapter for Mainnet is deployed on the address 0x230e0321cf38f09e247e50afc7801ea2351fe56f.
To provide the cbETH / USD
price feed CLSynchronicityPriceAdapterPegToBase
contract utilizing cbETH / ETH
and ETH / USD
oracles is deployed.
Price adapter for Mainnet is deployed on the address 0x5f4d15d761528c57a5C30c43c1DAb26Fc5452731.
Special price adapter for wstETH / USD
is added as additionally to using stETH / ETH
and ETH / USD
price feeds it requires an extra step to get the ration between stETH
and wstETH
for the price calculation.
Mainnet Price adapter for wstETH is deployed on the address 0xa9f30e6ed4098e9439b2ac8aea2d3fc26bcebb45.
Price adapter for rETH / USD
uses ETH / USD
price feed along with the getExchangeRate()
method, which returns rETH / ETH
ratio, of the rETH contract itself.
Mainnet Price adapter for rETH is deployed on the address 0x05225Cd708bCa9253789C1374e4337a019e99D56.
To provide the LDO / USD
price feed CLSynchronicityPriceAdapterPegToBase
contract utilizing LDO / ETH
and ETH / USD
oracles is deployed.
Price adapter for Mainnet is deployed on the address 0xb01e6c9af83879b8e06a092f0dd94309c0d497e4.
To provide the wstETH / USD
price feed CLSynchronicityPriceAdapterPegToBase
contract utilizing wstETH / ETH
and ETH / USD
oracles is deployed.
Price adapter for Polygon is deployed on the address 0xa2508729b1282cc70dd33ed311d4a9a37383035b.
CLSynchronicityPriceAdapterBaseToPeg
- Price adapter smart contract where
ChainlinkAggregator
addresses forAsset / USD
andETH / USD
are set. - Feeds must have the same decimals value.
- Using this two feeds, it calculates the price for pair
Asset / ETH
. - Returning price is calculated with up to 18 decimals.
CLSynchronicityPriceAdapterPegToBase
- Price adapter smart contract where
ChainlinkAggregator
addresses forAsset / ETH
andETH / USD
are set. - Using this two feeds, it calculates the price for pair
Asset / USD
. - Returning price is calculated with up to 18 decimals.
CLwstETHSynchronicityPriceAdapter
- Price adapter smart contract which calculates
wstETH / USD
price based onstETH / ETH
andETH / USD
feeds. - Returning price is calculated with 8 decimals.
CLrETHSynchronicityPriceAdapter
- Price adapter smart contract which calculates
rETH / USD
price based onrETH / ETH
andETH / USD
feeds. - Returning price is calculated with 8 decimals.
ProposalPayloadStablecoinsPriceAdapter
- Proposal payload for the Aave v2 Ethereum pool.
- For all Aave v2 Ethereum stablecoin assets deploys
CLSynchronicityPriceAdapter
and sets it as an asset source by callingsetAssetSources
function on theAaveOracle
contract.
ArcProposalPayloadStablecoinsPriceAdapter
- Proposal payload for the Aave Arc pool.
- For all Aave Arc stablecoin assets deploys
CLSynchronicityPriceAdapter
and sets it as an asset source by callingsetAssetSources
function on theAaveOracle
contract.
DeployWBTCAdapter is used to deploy the price adapter for WBTC / USD
.
DeployWstETH is used to deploy adapter for wstETH / USD
.
List of affected Aave v2 Ethereum stablecoin assets and used Chainlink Data Feeds for Asset / USD
pair.
List of affected Aave v2 Arc stablecoin assets and used Chainlink Data Feeds for Asset / USD
pair.
Asset | Asset address | Chainlink Data Feed address |
---|---|---|
USDC | 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 | 0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6 |
Asset | Asset address | Chainlink Data Feed addresses |
---|---|---|
WBTC | 0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599 | WBTC/BTC: 0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23, BTC/USD: 0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c |
wstETH | 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 | stETH/ETH: 0x86392dC19c0b719886221c78AB11eb8Cf5c52812, ETH/USD: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 |
LDO | 0xb01e6c9af83879b8e06a092f0dd94309c0d497e4 | LDO/ETH: |
0x4e844125952D32AcdF339BE976c98E22F6F318dB | ETH/USD: 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419 |
Polygon
| ------ | --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | wstETH | 0xa2508729b1282cc70dd33ed311d4a9a37383035b | wstETH/ETH: 0x10f964234cae09cB6a9854B56FF7D4F38Cda5E6a, ETH/USD: 0xF9680D99D6C9589e2a93a78A04A279e509205945 |
CLSynchronicityPriceAdapterFormulaTest
- Validates that formula used in price adapter is correct.
- For
TESTS_NUM
number of tests, makes mock aggregator with price of asset ini-th
test set to$Price(ETH / USD) \over i$ . Validates that price returned from theCLSynchronicityPriceAdapter
is$1 ETHER /over i$ .
- Validates that price difference between price feed for pair
Asset / ETH
and price from the adapter is less than2%
.
CLSynchronicityPriceAdapterPegToBaseTest
- Validates that formula used in price adapter is correct.
CLwstETHSynchronicityPriceAdapterTest
- Validates that formula used in price adapter is correct.
ProposalPayloadStablecoinsPriceAdapterTest
- Validates that after proposal in Aave v2 Ethereum pool is accepted, all asset sources for stablecoin assets are changed.
ArcProposalPayloadStablecoinsPriceAdapterTest
- Validates that after proposal in Aave v2 Ethereum pool is accepted, all asset sources for stablecoin assets are changed.
To install and execute the project locally, you need:
npm install
: To install prettier for linting.forge install
: This project is made using Foundry so to run it you will need to install it, and then install its dependencies.
cp .env.example .env
forge build
forge test
2023 BGD Labs