Module 0xc1b23ac8ce67df6361b241bfa30a22c9b177fe39c471334a514eea977e6673a9::oracle
@title Oracle @author Aave @notice Provides price feed functionality for the Aave protocol
- Enum
AdapterType
- Struct
AssetPriceFeedUpdated
- Struct
AssetCustomPriceUpdated
- Struct
AssetMaximumPriceAgeUpdated
- Struct
AssetPriceFeedRemoved
- Struct
AssetCustomPriceRemoved
- Struct
PriceCapUpdated
- Struct
PriceCapRemoved
- Struct
CapParametersUpdated
- Resource
CappedAssetData
- Resource
PriceOracleData
- Constants
- Function
is_asset_price_capped
- Function
is_custom_price_set
- Function
get_asset_price
- Function
get_stable_price_cap
- Function
get_max_asset_price_age
- Function
get_assets_prices
- Function
get_asset_price_and_timestamp
- Function
get_asset_prices_and_timestamps
- Function
oracle_address
- Function
get_asset_price_decimals
- Function
set_susde_price_adapter
- Function
set_price_cap_stable_adapter
- Function
remove_price_cap_stable_adapter
- Function
set_asset_feed_id
- Function
set_asset_custom_price
- Function
set_max_asset_price_age
- Function
batch_set_asset_feed_ids
- Function
batch_set_asset_custom_prices
- Function
remove_asset_feed_id
- Function
remove_asset_custom_price
- Function
batch_remove_asset_feed_ids
- Function
batch_remove_asset_custom_prices
use 0x1::account;
use 0x1::event;
use 0x1::option;
use 0x1::signer;
use 0x1::smart_table;
use 0x1::timestamp;
use 0x1::vector;
use 0x24e01fa503119e76bf9eea69eec59884fc3da82f5ea23bf5f20f8ce358a4606::acl_manage;
use 0xa888dd108ea636a234c973b8b72b9cadf0c7ae94d6f355c64dde9fdc275724ee::error_config;
use 0xd63343bff7977cb364b17dcdcdeb64e77b7bc9b4ec252f481ace51b6de3bbd96::math_utils;
use 0xe93d203a3ece4208d5b91a7615f49f759a709cc10899a4dfc2faf551d9a90459::registry;
use 0xe93d203a3ece4208d5b91a7615f49f759a709cc10899a4dfc2faf551d9a90459::router;
Enum AdapterType
@notice The type of adapter for retrieving the price
enum AdapterType has copy, drop, store
Struct AssetPriceFeedUpdated
#[event]
struct AssetPriceFeedUpdated has drop, store
Struct AssetCustomPriceUpdated
@notice Emitted when an asset custom price is updated
#[event]
struct AssetCustomPriceUpdated has drop, store
Struct AssetMaximumPriceAgeUpdated
@notice Emitted when an asset maximum price age is updated
#[event]
struct AssetMaximumPriceAgeUpdated has drop, store
Struct AssetPriceFeedRemoved
@notice Emitted when an asset price feed is removed
#[event]
struct AssetPriceFeedRemoved has drop, store
Struct AssetCustomPriceRemoved
@notice Emitted when an asset custom price is removed
#[event]
struct AssetCustomPriceRemoved has drop, store
Struct PriceCapUpdated
@notice Emitted when a price cap is updated for an asset
#[event]
struct PriceCapUpdated has drop, store
Struct PriceCapRemoved
@notice Emitted when a price cap is removed for an asset
#[event]
struct PriceCapRemoved has drop, store
Struct CapParametersUpdated
@notice Emitted when the cap parameters are updated for an asset
#[event]
struct CapParametersUpdated has drop, store
Resource CappedAssetData
@notice Main storage for multiple capped asset data
struct CappedAssetData has copy, drop, store, key
Resource PriceOracleData
@notice Main storage for oracle data
struct PriceOracleData has key
Constants
@notice Seed for the resource account
const AAVE_ORACLE_SEED: vector<u8> = [65, 65, 86, 69, 95, 79, 82, 65, 67, 76, 69];
@notice Decimal precision for Chainlink asset prices @dev Reference: https://docs.chain.link/data-feeds/price-feeds/addresses?network=aptos&page=1
const CHAINLINK_ASSET_DECIMAL_PRECISION: u8 = 18;
@notice Default maximum age for an oracle price - in seconds @dev Set for 10 mins for all assets
const DEFAULT_MAX_PRICE_AGE_SECS: u64 = 600;
@notice Maximum value for a 192-bit signed integer (192-th bit is sign bit) @dev All positive values are in [0, 2^191 - 1]
const I192_MAX: u256 = 3138550867693340381917894711603833208051177722232017256447;
@notice Minimal ratio increase lifetime in years for overflow protection @dev This constant defines the minimum acceptable timeframe (3 years) before a ratio could potentially overflow due to compound growth in the SUSDE price adapter. It serves as a critical safety mechanism to prevent mathematical overflow in ratio calculations.
The 3-year timeframe balances safety (preventing immediate overflow risks) with flexibility (allowing reasonable growth parameters for liquid staking rewards). This is particularly important for SUSDE where the ratio represents the appreciation of staked USDe over time.
const MINIMAL_RATIO_INCREASE_LIFETIME: u256 = 3;
@notice Test maximum age for an oracle price - in seconds @dev Set to one hour for all assets
const TEST_MAX_PRICE_AGE_SECS: u64 = 3600;
Function is_asset_price_capped
@notice Checks if an asset's price is capped (actual price exceeds cap) @param asset Address of the asset to check @return True if the asset's actual price exceeds its cap
#[view]
public fun is_asset_price_capped(asset: address): bool
Function is_custom_price_set
@notice Returns true if a custom price is set for an asset @param asset Address of the asset
#[view]
public fun is_custom_price_set(asset: address): bool
Function get_asset_price
@notice Gets the current price of an asset, respecting any price cap @param asset Address of the asset @return The asset price (capped if applicable)
#[view]
public fun get_asset_price(asset: address): u256
Function get_stable_price_cap
@notice Gets the price cap for an asset if it exists @param asset Address of the asset @return The price cap if it exists, none otherwise
#[view]
public fun get_stable_price_cap(asset: address): option::Option<u256>
Function get_max_asset_price_age
@notice Gets the asset max price age for an asset if it exists @param asset Address of the asset @return The max price age if it exists, none otherwise
#[view]
public fun get_max_asset_price_age(asset: address): option::Option<u64>
Function get_assets_prices
@notice Gets prices for multiple assets at once @param assets Vector of asset addresses @return Vector of corresponding asset prices
#[view]
public fun get_assets_prices(assets: vector<address>): vector<u256>
Function get_asset_price_and_timestamp
@notice Gets the current price of an asset and its timestamp, respecting any price cap @param asset Address of the asset @return The asset price and its timestamp as a tuple (capped if applicable)
#[view]
public fun get_asset_price_and_timestamp(asset: address): (u256, u256)
Function get_asset_prices_and_timestamps
@notice Gets prices and timestamps for multiple assets at once @param assets Vector of asset addresses @return Vectors of corresponding asset prices with their timestamps
#[view]
public fun get_asset_prices_and_timestamps(assets: vector<address>): (vector<u256>, vector<u256>)
Function oracle_address
@notice Gets the oracle's resource account address @return The oracle's address
#[view]
public fun oracle_address(): address
Function get_asset_price_decimals
@notice Gets the decimal precision used for asset prices @return The number of decimal places (always 18)
#[view]
public fun get_asset_price_decimals(): u8
Function set_susde_price_adapter
@notice Sets up a SUSDE price adapter for an asset with ratio growth parameters @param account Admin account that sets the adapter (must be risk or pool admin) @param asset Address of the asset to configure @param minimum_snapshot_delay Minimum delay required between snapshots in seconds @param snapshot_timestamp Initial timestamp for the snapshot in seconds @param max_yearly_ratio_growth_percent Maximum yearly ratio growth percentage @param snapshot_ratio Initial snapshot ratio value @param mapped_asset_ratio_multiplier Mapped asset ration multiplier
public entry fun set_susde_price_adapter(account: &signer, asset: address, minimum_snapshot_delay: u256, snapshot_timestamp: u256, max_yearly_ratio_growth_percent: u256, snapshot_ratio: u256, mapped_asset_ratio_multiplier: option::Option<address>)
Function set_price_cap_stable_adapter
@notice Sets a price cap for an asset @param account Admin account that sets the cap @param asset Address of the asset @param price_cap Maximum price value for the asset
public entry fun set_price_cap_stable_adapter(account: &signer, asset: address, stable_price_cap: u256)
Function remove_price_cap_stable_adapter
@notice Removes a price cap for an asset @param account Admin account that removes the cap @param asset Address of the asset
public entry fun remove_price_cap_stable_adapter(account: &signer, asset: address)
Function set_asset_feed_id
@notice Sets a Chainlink feed ID for an asset @param account Admin account that sets the feed @param asset Address of the asset @param feed_id Chainlink feed ID for the asset
public entry fun set_asset_feed_id(account: &signer, asset: address, feed_id: vector<u8>)
Function set_asset_custom_price
@notice Sets a custom price for an asset @param account Admin account that sets the price @param asset Address of the asset @param custom_price Custom price value
public entry fun set_asset_custom_price(account: &signer, asset: address, custom_price: u256)
Function set_max_asset_price_age
@notice Sets the max price age for an asset @param account Admin account that sets the price @param asset Address of the asset @param max_asset_price_age Maximum asset price age
public entry fun set_max_asset_price_age(account: &signer, asset: address, max_asset_price_age: u64)
Function batch_set_asset_feed_ids
@notice Sets Chainlink feed IDs for multiple assets at once @param account Admin account that sets the feeds @param assets Vector of asset addresses @param feed_ids Vector of corresponding feed IDs
public entry fun batch_set_asset_feed_ids(account: &signer, assets: vector<address>, feed_ids: vector<vector<u8>>)
Function batch_set_asset_custom_prices
@notice Sets custom prices for multiple assets at once @param account Admin account that sets the prices @param assets Vector of asset addresses @param custom_prices Vector of corresponding custom prices
public entry fun batch_set_asset_custom_prices(account: &signer, assets: vector<address>, custom_prices: vector<u256>)
Function remove_asset_feed_id
@notice Removes a Chainlink feed ID for an asset @param account Admin account that removes the feed @param asset Address of the asset
public entry fun remove_asset_feed_id(account: &signer, asset: address)
Function remove_asset_custom_price
@notice Removes a custom price for an asset @param account Admin account that removes the price @param asset Address of the asset
public entry fun remove_asset_custom_price(account: &signer, asset: address)
Function batch_remove_asset_feed_ids
@notice Removes Chainlink feed IDs for multiple assets at once @param account Admin account that removes the feeds @param assets Vector of asset addresses
public entry fun batch_remove_asset_feed_ids(account: &signer, assets: vector<address>)
Function batch_remove_asset_custom_prices
@notice Removes custom prices for multiple assets at once @param account Admin account that removes the prices @param assets Vector of asset addresses
public entry fun batch_remove_asset_custom_prices(account: &signer, assets: vector<address>)