The repository contains the Price Adapter contracts for the assets, in which prices are correlated with different token rather than the pool's base one.
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.
The same approach could be used for ETH-correlated assets on USD-based pools, for example, stETH / ETH
and ETH / USD
feeds could be used to calculate the stETH
price.
This repository also contains the proposal smart contracts for using price adapters for stablecoins on the Aave v2 Ethereum and Aave Arc pool.
Affected smart contract is AaveOracle
, where currently all asset sources are set to Chainlink Data Feeds for pairs
Proposal is to deploy CLSynchronicityPriceAdapterBaseToPeg
for all stablecoin assets, which will calculate the price of Asset / ETH
by querying Chainlink Data Feeds for pairs Asset / USD
and ETH / USD
, using the formula:
Proposal is to change asset source for all stablecoin assets to be CLSynchronicityPriceAdapter
which calculates price by querying Chainlink Data Feeds for pairs Asset / USD
and ETH / USD
.
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 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 18 decimals.
CLwstETHSynchronicityPriceAdapter
- Price adapter smart contract which calculates
wstETH / USD
price based onstETH / ETH
andETH / USD
feeds. - Returning price is calculated with 18 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.
List of affected Aave v2 Ethereum stablecoin assets and used Chainlink Data Feeds for Asset / USD
pair.
Asset | Asset address | Chainlink Data Feed address |
---|---|---|
USDT | 0xdAC17F958D2ee523a2206206994597C13D831ec7 | 0x3E7d1eAB13ad0104d2750B8863b489D65364e32D |
BUSD | 0x4Fabb145d64652a948d72533023f6E7A623C7C53 | 0x833D8Eb16D306ed1FbB5D7A2E019e106B960965A |
DAI | 0x6B175474E89094C44Da98b954EedeAC495271d0F | 0xAed0c38402a5d19df6E4c03F4E2DceD6e29c1ee9 |
SUSD | 0x57Ab1ec28D129707052df4dF418D58a2D46d5f51 | 0xad35Bd71b9aFE6e4bDc266B345c198eaDEf9Ad94 |
tUSD | 0x0000000000085d4780B73119b644AE5ecd22b376 | 0xec746eCF986E2927Abd291a2A1716c940100f8Ba |
USDC | 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 | 0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6 |
GUSD | 0x056Fd409E1d7A124BD7017459dFEa2F387b6d5Cd | 0xa89f5d2365ce98B3cD68012b6f503ab1416245Fc |
USDP | 0x8E870D67F660D95d5be530380D0eC0bd388289E1 | 0x09023c0DA49Aaf8fc3fA3ADF34C6A7016D38D5e3 |
FRAX | 0x853d955aCEf822Db058eb8505911ED77F175b99e | 0xB9E1E3A9feFf48998E45Fa90847ed4D467E8BcfD |
LUSD | 0x5f98805A4E8be255a32880FDeC7F6728C6568bA0 | 0x3D7aE7E594f2f2091Ad8798313450130d0Aba3a0 |
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 |
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.
TBD
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
2022 BGD Labs