Get price
Get price

Aave · Reads onchain state

Reads the price the market's own oracle assigns to an asset. Every Aave market prices assets through its own oracle, and that number is the one the pool uses when it decides what your collateral is worth and when it liquidates. Reading it here gives you the exact figure the protocol is about to act on, inside the same transaction that acts on it, not a screenshot from a price site or a number that was true a block ago. Reach for it whenever a strategy has to convert between a dollar amount and a token amount before it does something: sizing a supply so it lands at a target health factor, capping a repay at what the debt is actually worth, deciding whether a position has drifted far enough to rebalance. Anywhere the words "worth" or "value" appear in a plan, this is the read that makes the rest of the plan arithmetic.

Value to Token Amount

plug
aave
math
7actions
  1. 1·Take

    The plug takes the token it should price, so the same logic runs for any asset a market lists.

  2. 2·Take

    It takes the Aave market to read against: the oracle is the market's, so the price is the one that market will enforce.

  3. 3·Get price

    One oracle read: what the market says one unit of the token is worth right now.

  4. 4·Take

    It takes the dollar value the caller wants to convert into tokens.

  5. 5·Calculate

    Value divided by price is the token amount, done onchain, in the same transaction, on the price just read.

  6. 6·Set

    The result is written to a named slot so later steps can refer to it by name.

  7. 7·Bubble

    And bubbled out, so any plug that uses this one gets the token amount as an output it can wire straight into a supply or a repay.

Take
Take
Get price of in
Take
Calculate
Set to
Bubble
  • Value to Token Amount

    plug
    aave
    math
  • Wind or Unwind to Maintain Target HF

    plug
    aave
    math
  • Loop WETH/USDC at Target HF

    aave
    evm
    boolean
  • Swarm: Loop WETH/USDC at Target HF

    boolean
    aave
    evm
  • Loop at Target HF + Trailing Stop Loss

    database
    boolean
    aave
  • Loop at Target HF + Borrow Rate Exit Guard

    database
    boolean
    aave
  • Stop Loss (WETH/USDC Loop)

    boolean
    aave
    evm
  • Take Profit (WETH/USDC Loop)

    boolean
    aave
    evm
  • Trailing Stop Loss (WETH/USDC Loop)

    boolean
    aave
    evm
  • Loop at Target HF + Borrow Rate Entry & Exit Guard

    aave
    boolean
    evm

On other protocols · 8