Skip to Content
docs

Aave V4 Exchange Rates

Exchange rates in Aave are provided by Oracles using Chainlink price feeds.

AaveKit provides current conversion rates between ERC-20 tokens, native tokens, and supported currencies: USD, EUR, and GBP. For smart-contract integrations, query USD reserve prices directly from the spoke oracle.

Fetching Exchange Rates

  • React: Use the useExchangeRate hook for live exchange rates with automatic polling every 10 seconds, or the imperative useExchangeRateAction hook for on-demand exchange rates.
  • TypeScript: Use the exchangeRate action, and in GraphQL, the exchangeRate query to fetch conversion rates.
import { type ExchangeRateRequest, useExchangeRate } from "@aave/react";

function ExchangeRate({ request }: { request: ExchangeRateRequest }) {
  const { data, loading, error } = useExchangeRate(request);

  if (loading) return <div>Loading…</div>;

  if (error) return <div>Error: {error.message}</div>;

  // data: ExchangeAmount
  return (
    <span>
      {data.symbol}
      {data.value.toFixed(2)}
    </span>
  );
}

Example request objects for React and GraphQL:

import { evmAddress, chainId, Currency } from "@aave/react";

const request: ExchangeRateRequest = {
  from: {
    erc20: {
      chainId: chainId(1),
      address: evmAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),
    },
  },
  to: Currency.Usd,
};

In Solidity, start with the spoke address:

Spoke Address
address spokeAddress = 0x123…;

Then, get the oracle address from the spoke and query the price.

import { ISpoke } from "aave-v4/src/spoke/interfaces/ISpoke.sol";
import { IAaveOracle } from "aave-v4/src/spoke/interfaces/IAaveOracle.sol";

address oracleAddress = ISpoke(spokeAddress).ORACLE();
IAaveOracle oracle = IAaveOracle(oracleAddress);

uint256 reserveId = 1;
uint256 price = oracle.getReservePrice(reserveId);