CurveEMAOracleUnderlying
Inherits: BaseAdapter
Title: CurveEMAOracleUnderlying
Author: Euler Labs (https://www.eulerlabs.com/)
Adapter utilizing the EMA price oracle in Curve pools.
Note: security-contact: security@euler.xyz
State Variables
name
Get the name of the oracle.
string public constant name = "CurveEMAOracleUnderlying"
pool
The address of the Curve pool.
address public immutable pool
base
The address of the base asset.
address public immutable base
quote
The address of the quote asset, must be pool.coins[0].
address public immutable quote
priceOracleIndex
The index in price_oracle corresponding to the base asset.
Note that indices in price_oracle are shifted by 1, i.e. 0 corresponds to coins[1].
uint256 public immutable priceOracleIndex
_scale
The scale factors used for decimal conversions.
Scale internal immutable _scale
Functions
constructor
Deploy a CurveEMAOracleUnderlying for a Curve pool.
IMPORTANT: The isBaseUnderlying and isQuoteUnderlying flags must match the pool's actual asset types. For example, in the sUSDE/sfrxUSD pool (0x3bd1017929b43c1414be2aca39892590fba4d6e2), both tokens are ERC4626-compatible, and the pool returns USDE/frxUSD prices. Curve pools with ERC4626-compatible tokens (like sUSDE/sfrxUSD) internally handle underlying asset conversions. The price_oracle() function returns the price in terms of the underlying assets (e.g., USDE/frxUSD). This behavior is pool-specific and depends on the pool's initialization parameters. WARNING: Incorrect configuration of isBaseUnderlying and isQuoteUnderlying will result in incorrect price calculations. Always verify the pool's asset types off-chain before deployment. WARNING: Some StableSwap-NG pools deployed before Dec-12-2023 have a known oracle vulnerability. See (https://docs.curve.fi/stableswap-exchange/stableswap-ng/pools/oracles/#price-oracles) for more details. Additionally, verify that the pool has enough liquidity before deploying this adapter.
constructor(
address _pool,
address _base,
address _quote,
uint256 _priceOracleIndex,
bool isBaseUnderlying,
bool isQuoteUnderlying
)
payable;
Parameters
| Name | Type | Description |
|---|---|---|
_pool | address | The address of the Curve pool. |
_base | address | The address of the base asset. |
_quote | address | The address of the quote asset, must match pool.coins[0]. |
_priceOracleIndex | uint256 | The index in price_oracle corresponding to the base asset. If type(uint256).max, then the adapter will call the non-indexed price method price_oracle(). |
isBaseUnderlying | bool | Whether the price oracle returns the price of the base asset in the underlying asset. |
isQuoteUnderlying | bool | Whether the price oracle returns the price of the quote asset in the underlying asset. |
_getQuote
Get a quote by calling the Curve oracle.
function _getQuote(uint256 inAmount, address _base, address _quote) internal view override returns (uint256);
Parameters
| Name | Type | Description |
|---|---|---|
inAmount | uint256 | The amount of base to convert. |
_base | address | The token that is being priced. |
_quote | address | The token that is the unit of account. |
Returns
| Name | Type | Description |
|---|---|---|
<none> | uint256 | The converted amount using the Curve EMA oracle. |
Errors
BaseAssetMismatch
error BaseAssetMismatch();
QuoteAssetMismatch
error QuoteAssetMismatch();