Aave V4 Spoke-scoped oracle reads.
V4 has no protocol-wide oracle. Each Spoke owns an IAaveOracle (resolved
via ISpoke.ORACLE()), and prices are keyed by Spoke reserve id, not
underlying asset address. Pass a Spoke address instead of a network.
V3 BASE_CURRENCY / BASE_CURRENCY_UNIT / getFallbackOracle have no
V4 equivalent — decimals/2 is the price scale (V4 oracles are 8 decimals).
Direct Chainlink / IPriceFeed reads take a feed address, not a Spoke.
Error Format
Errors pass through from the underlying module that failed:
| Source | Error Shape |
|---|---|
Onchain.Address.validate/1 | {:error, {:invalid_address, input}} |
Onchain.Contract.call/5 | {:error, {:encode_error, ...}}, {:error, {:rpc_error, ...}}, {:error, {:decode_error, ...}} |
Functions
| Function | Purpose |
|---|---|
oracle_address/2 | Spoke's IAaveOracle via ISpoke.ORACLE() |
get_reserve_price/3 | Price of one reserve (getReservePrice) |
get_reserve_prices/3 | Batch prices (getReservesPrices) |
get_reserve_source/3 | IPriceFeed for a reserve (getReserveSource) |
decimals/2 | Oracle price decimals |
get_spoke/2 | Spoke this oracle is bound to (spoke()) |
get_asset_price/3 | V3-shaped alias of get_reserve_price/3 |
get_asset_prices/3 | V3-shaped alias of get_reserve_prices/3 |
get_source_of_asset/3 | V3-shaped alias of get_reserve_source/3 |
get_latest_round_data/2 | Chainlink aggregator latestRoundData |
get_latest_answer/2 | IPriceFeed.latestAnswer (what V4 AaveOracle reads) |
API Functions
| Function | Arity | Description | Param Kinds |
|---|---|---|---|
get_latest_answer! | 2 | Latest IPriceFeed answer. Raises on error. | feed: value, opts: value |
get_latest_answer | 2 | Latest IPriceFeed answer (the call V4 AaveOracle uses). | feed: value, opts: value |
get_latest_round_data! | 2 | Latest Chainlink round data. Raises on error. | aggregator: value, opts: value |
get_latest_round_data | 2 | Latest round data from a Chainlink aggregator. | aggregator: value, opts: value |
get_source_of_asset! | 3 | V3-shaped alias of get_reserve_source!/3. Raises on error. | spoke: value, reserve_id: value, opts: value |
get_source_of_asset | 3 | V3-shaped alias of get_reserve_source/3. The second argument is a Spoke reserve id, not an asset address. | spoke: value, reserve_id: value, opts: value |
get_asset_prices! | 3 | V3-shaped alias of get_reserve_prices!/3. Raises on error. | spoke: value, reserve_ids: value, opts: value |
get_asset_prices | 3 | V3-shaped alias of get_reserve_prices/3. Arguments are Spoke reserve ids, not asset addresses. | spoke: value, reserve_ids: value, opts: value |
get_asset_price! | 3 | V3-shaped alias of get_reserve_price!/3. Raises on error. | spoke: value, reserve_id: value, opts: value |
get_asset_price | 3 | V3-shaped alias of get_reserve_price/3. The second argument is a Spoke reserve id, not an asset address. | spoke: value, reserve_id: value, opts: value |
get_spoke! | 2 | Spoke this oracle is bound to. Raises on error. | spoke: value, opts: value |
get_spoke | 2 | Spoke address this IAaveOracle is bound to. | spoke: value, opts: value |
decimals! | 2 | Oracle price decimals. Raises on error. | spoke: value, opts: value |
decimals | 2 | Number of decimals used to return Spoke oracle prices. | spoke: value, opts: value |
get_reserve_source! | 3 | IPriceFeed address for a Spoke reserve. Raises on error. | spoke: value, reserve_id: value, opts: value |
get_reserve_source | 3 | IPriceFeed (Chainlink-style) address for a Spoke reserve. | spoke: value, reserve_id: value, opts: value |
get_reserve_prices! | 3 | Prices for multiple Spoke reserves. Raises on error. | spoke: value, reserve_ids: value, opts: value |
get_reserve_prices | 3 | Prices for multiple Spoke reserves in one call. | spoke: value, reserve_ids: value, opts: value |
get_reserve_price! | 3 | Price of a Spoke reserve. Raises on error. | spoke: value, reserve_id: value, opts: value |
get_reserve_price | 3 | Price of a Spoke reserve in oracle base units. | spoke: value, reserve_id: value, opts: value |
oracle_address! | 2 | Resolve a Spoke's IAaveOracle. Raises on error. | spoke: value, opts: value |
oracle_address | 2 | Resolve a Spoke's IAaveOracle via ISpoke.ORACLE(). | spoke: value, opts: value |
Summary
Functions
Number of decimals used to return Spoke oracle prices.
Oracle price decimals. Raises on error.
V3-shaped alias of get_reserve_price/3. The second argument is a Spoke reserve id, not an asset address.
V3-shaped alias of get_reserve_price!/3. Raises on error.
V3-shaped alias of get_reserve_prices/3. Arguments are Spoke reserve ids, not asset addresses.
V3-shaped alias of get_reserve_prices!/3. Raises on error.
Latest IPriceFeed answer (the call V4 AaveOracle uses).
Latest IPriceFeed answer. Raises on error.
Latest round data from a Chainlink aggregator.
Latest Chainlink round data. Raises on error.
Price of a Spoke reserve in oracle base units.
Price of a Spoke reserve. Raises on error.
Prices for multiple Spoke reserves in one call.
Prices for multiple Spoke reserves. Raises on error.
IPriceFeed (Chainlink-style) address for a Spoke reserve.
IPriceFeed address for a Spoke reserve. Raises on error.
V3-shaped alias of get_reserve_source/3. The second argument is a Spoke reserve id, not an asset address.
V3-shaped alias of get_reserve_source!/3. Raises on error.
Spoke address this IAaveOracle is bound to.
Spoke this oracle is bound to. Raises on error.
Resolve a Spoke's IAaveOracle via ISpoke.ORACLE().
Resolve a Spoke's IAaveOracle. Raises on error.
Functions
@spec decimals( String.t() | binary(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Number of decimals used to return Spoke oracle prices.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Price decimals (8 on V4) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Price decimals (8 on V4)"
}
}
@spec decimals!( String.t() | binary(), keyword() ) :: non_neg_integer()
Oracle price decimals. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Price decimals (non_neg_integer)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{type: :non_neg_integer, description: "Price decimals"}
}
@spec get_asset_price(String.t() | binary(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
V3-shaped alias of get_reserve_price/3. The second argument is a Spoke reserve id, not an asset address.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Price in oracle decimals ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Price in oracle decimals"
}
}
@spec get_asset_price!(String.t() | binary(), non_neg_integer(), keyword()) :: non_neg_integer()
V3-shaped alias of get_reserve_price!/3. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Price in oracle decimals (non_neg_integer)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{type: :non_neg_integer, description: "Price in oracle decimals"}
}
@spec get_asset_prices(String.t() | binary(), [non_neg_integer()], keyword()) :: {:ok, [non_neg_integer()]} | {:error, term()}
V3-shaped alias of get_reserve_prices/3. Arguments are Spoke reserve ids, not asset addresses.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_ids- List of Spoke reserve identifiers (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
List of prices ({:ok, [non_neg_integer()]} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_ids: %{
description: "List of Spoke reserve identifiers",
kind: :value
}
},
returns: %{
type: "{:ok, [non_neg_integer()]} | {:error, term()}",
description: "List of prices"
}
}
@spec get_asset_prices!(String.t() | binary(), [non_neg_integer()], keyword()) :: [ non_neg_integer() ]
V3-shaped alias of get_reserve_prices!/3. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_ids- List of Spoke reserve identifiers (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
List of prices ([non_neg_integer()])
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_ids: %{
description: "List of Spoke reserve identifiers",
kind: :value
}
},
returns: %{type: "[non_neg_integer()]", description: "List of prices"}
}
Latest IPriceFeed answer (the call V4 AaveOracle uses).
Parameters
feed- IPriceFeed / Chainlink aggregator address (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Signed price answer in feed decimals ({:ok, integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
feed: %{
description: "IPriceFeed / Chainlink aggregator address",
kind: :value
}
},
returns: %{
type: "{:ok, integer()} | {:error, term()}",
description: "Signed price answer in feed decimals"
}
}
Latest IPriceFeed answer. Raises on error.
Parameters
feed- IPriceFeed / Chainlink aggregator address (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Signed price answer (integer)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
feed: %{
description: "IPriceFeed / Chainlink aggregator address",
kind: :value
}
},
returns: %{type: :integer, description: "Signed price answer"}
}
Latest round data from a Chainlink aggregator.
Parameters
aggregator- Chainlink aggregator / IPriceFeed address (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Map with :round_id, :answer, :started_at, :updated_at, :answered_in_round ({:ok, map()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
aggregator: %{
description: "Chainlink aggregator / IPriceFeed address",
kind: :value
}
},
returns: %{
type: "{:ok, map()} | {:error, term()}",
description: "Map with :round_id, :answer, :started_at, :updated_at, :answered_in_round"
}
}
Latest Chainlink round data. Raises on error.
Parameters
aggregator- Chainlink aggregator / IPriceFeed address (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Round data map (map)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
aggregator: %{
description: "Chainlink aggregator / IPriceFeed address",
kind: :value
}
},
returns: %{type: :map, description: "Round data map"}
}
@spec get_reserve_price(String.t() | binary(), non_neg_integer(), keyword()) :: {:ok, non_neg_integer()} | {:error, term()}
Price of a Spoke reserve in oracle base units.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Price in oracle decimals (8 for V4) ({:ok, non_neg_integer()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{
type: "{:ok, non_neg_integer()} | {:error, term()}",
description: "Price in oracle decimals (8 for V4)"
}
}
@spec get_reserve_price!(String.t() | binary(), non_neg_integer(), keyword()) :: non_neg_integer()
Price of a Spoke reserve. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Price in oracle decimals (non_neg_integer)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{type: :non_neg_integer, description: "Price in oracle decimals"}
}
@spec get_reserve_prices(String.t() | binary(), [non_neg_integer()], keyword()) :: {:ok, [non_neg_integer()]} | {:error, term()}
Prices for multiple Spoke reserves in one call.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_ids- List of Spoke reserve identifiers (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Prices in oracle decimals, same order as reserve_ids ({:ok, [non_neg_integer()]} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_ids: %{
description: "List of Spoke reserve identifiers",
kind: :value
}
},
returns: %{
type: "{:ok, [non_neg_integer()]} | {:error, term()}",
description: "Prices in oracle decimals, same order as reserve_ids"
}
}
@spec get_reserve_prices!(String.t() | binary(), [non_neg_integer()], keyword()) :: [ non_neg_integer() ]
Prices for multiple Spoke reserves. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_ids- List of Spoke reserve identifiers (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
List of prices ([non_neg_integer()])
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_ids: %{
description: "List of Spoke reserve identifiers",
kind: :value
}
},
returns: %{type: "[non_neg_integer()]", description: "List of prices"}
}
@spec get_reserve_source(String.t() | binary(), non_neg_integer(), keyword()) :: {:ok, String.t()} | {:error, term()}
IPriceFeed (Chainlink-style) address for a Spoke reserve.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed price-feed address ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Checksummed price-feed address"
}
}
@spec get_reserve_source!(String.t() | binary(), non_neg_integer(), keyword()) :: String.t()
IPriceFeed address for a Spoke reserve. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed price-feed address (string)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{type: :string, description: "Checksummed price-feed address"}
}
@spec get_source_of_asset(String.t() | binary(), non_neg_integer(), keyword()) :: {:ok, String.t()} | {:error, term()}
V3-shaped alias of get_reserve_source/3. The second argument is a Spoke reserve id, not an asset address.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed price-feed address ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Checksummed price-feed address"
}
}
@spec get_source_of_asset!(String.t() | binary(), non_neg_integer(), keyword()) :: String.t()
V3-shaped alias of get_reserve_source!/3. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)reserve_id- Spoke reserve identifier (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed price-feed address (string)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
},
reserve_id: %{description: "Spoke reserve identifier", kind: :value}
},
returns: %{type: :string, description: "Checksummed price-feed address"}
}
Spoke address this IAaveOracle is bound to.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed Spoke address from IPriceOracle.spoke() ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Checksummed Spoke address from IPriceOracle.spoke()"
}
}
Spoke this oracle is bound to. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed Spoke address (string)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{type: :string, description: "Checksummed Spoke address"}
}
Resolve a Spoke's IAaveOracle via ISpoke.ORACLE().
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed IAaveOracle address ({:ok, String.t()} | {:error, term()})
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{
type: "{:ok, String.t()} | {:error, term()}",
description: "Checksummed IAaveOracle address"
}
}
Resolve a Spoke's IAaveOracle. Raises on error.
Parameters
spoke- Spoke address as 0x hex string or 20-byte binary (value)opts- Options: :rpc_url, :timeout, :block (default:[], value)
Returns
Checksummed IAaveOracle address (string)
# descripex:contract
%{
params: %{
opts: %{
default: [],
description: "Options: :rpc_url, :timeout, :block",
kind: :value
},
spoke: %{
description: "Spoke address as 0x hex string or 20-byte binary",
kind: :value
}
},
returns: %{type: :string, description: "Checksummed IAaveOracle address"}
}