This documentation describes the steps required to add a new price cap adapter for LST or stablecoin asset.
As a first step, contact risk providers for recommendations on capo parameters:
maxYearlyGrowthPercent
andminimumSnapshotDelay
parameters in case of an LST asset- fixed capo value for the stablecoin asset
Deploying a new cap adapter consists of three simple steps:
- (optional) add a specific adapter for the new asset
- write a deployment script
- add and run tests
There are situations, when the sync adapter should be used together with the cap adapter. Detailed description is in the separate section.
Depending on the asset type and data source, two options are possible:
When an LST asset adapter is added and the native contract specifies a rate:
-
Determine which method of which contract provides the rate, and add a simplified version of the interface to the
interfaces
folder. For example, forweETH
this is thegetRate()
method on the token contract, and for [osETH
] this isconvertToAssets(uint256 shares)
on a separate vault controller. -
Add the specific adapter contract to the
lst-adapters
folder. The contract must inherit fromPriceCapAdapterBase
and implement only onegetRatio()
method.
If there is no native contract providing an exchange rate and the Chainlink feed will be used, there is no need to add a new adapter as the generic `CLRatePriceCapAdapter should be used.
As risk entities only provide growth rate and snapshot delay while snapshotRatio
and snapshotTimestamp
are flexible, you need to get them by yourself to use in deployment.
- The first option is to use GetExchangeRatesTest:
- Add a method to get the rate and console log for the corresponding network test. Example for
osETH
- set the block number to approximately
now - minimumSnapshotDelay
and run the test contract with output to the console.
- Add a method to get the rate and console log for the corresponding network test. Example for
- The second option is to do it any other way you want.
Alter the appropriate deployment script:
-
Add a function that will return the deployment code to the library. Example for
weETH
. The following parameters should be specified:aclManager
: ACL manager of he poolbaseAggregatorAddress
: the address of the base asset feed, for ETH-based LSTs it should beETH / USD
oracleratioProviderAddress
: the address of the contract, which provides the exchange ratiopairDescription
: description of the adapterminimumSnapshotDelay
: the delay provided by the risk entity, typically 7 or 14 dayssnapshotRatio
: the value of the exchange ratio X days agosnapshotTimestamp
: timestamp of the snapshot ratiomaxYearlyRatioGrowthPercent
: the maximum possible annual LST growth percentage
-
Add the deployment script and command to the Makefile.
To test the adapter:
- Add the test to the destination network folder inside
tests
. - Inherit it from
BaseTest
and implement the simple_createAdapter()
method, when the specific adapter is created. Or just inherit the test from CLAdapterBaseTest.sol when Chainlink oracle is used. - Specify the following test parameters:
- adapter code
- number of days for retrospective testing (default is 90). Check that with the specified parameters the adapter has not been capped for the last X days. A report comparing prices with the base aggregator is also generated.
- fork parameters: network and block number
- name for the report (something like
osETH_Ethereum
)
No need to add a specific adapter, existing PriceCapAdapterStable
should be used.
-
Add a function that will return the deployment code to the library in the appropriate network's deployment script. The following parameters should be specified:
aclManager
: the ACL manager of the poolassetToUsdAggregator
: the address of theasset / USD
feedadapterDescription
: description of the adapterpriceCap
: the value of the price cap, for example for 4% it would beint256(1.04 * 1e8)
-
Add the deployment script and command to the Makefile.
Base test for stables would be added soon. Stay tuned.
When you need to cap the asset which is not pegged to the base asset of the pool (to USD
), such as agEUR
, then you need to use a combination of adapters:
- Cap adapter for
agEUR / EUR
asagEUR
should be capped againstEUR
. - CLSynchronicityPriceAdapterPegToBase to combine capped adapter with
EUR / USD
feed to create cappedagEUR / EUR / USD
.