Get price
Get price

Chainlink · Reads onchain state

Reads the latest Chainlink price of a base asset in a quote asset, normalized to 18 decimals. The feed registry's latestRoundData is fetched for the pair, and the answer is rescaled from the feed's own decimals to 18 so every pair compares alike. The round's timestamps come back alongside, so staleness can be checked. Reach for it whenever a strategy needs a reference price independent of any pool: compare a DEX quote against it to bound slippage, convert a dollar target into a token amount, or coil the updated-at timestamp into a predicate that requires the feed is fresh.

Get Chainlink Price (USD)

plug
chainlink
4actions
  1. 1·Take

    Step one declares a named parameter called token, whose value the caller supplies when the plug runs, so nothing is fixed in advance here.

  2. 2·Get price

    Reading from Chainlink, this step takes the token in slot 0.0 and fetches its latest price quoted in 0x0000000000000000000000000000000000000348, which denotes USD, normalized to 18 decimals.

  3. 3·Bubble

    Surfacing the value from slot 1.7 makes the fetched price an output of this plug so callers can read it.

  4. 4·Use

    Composing another plug named swap inside this one lets its actions run as part of this transaction.

Take
Get price of in
Bubble
Use
  • Get Chainlink Price (USD)

    plug
    chainlink
  • Card: Buy $50 WBTC With USDC Once a Week

    time
    values
    math
  • Card: Buy an 18 Dec Token With X% of USDC

    plug
    evm
    math
  • Card: Sell X% of an 18 Dec Token for USDC

    plug
    evm
    math
  • Card: Sell 18 Dec Token for USDC

    plug
    chainlink
    math
  • Card: Sell 8 Dec Token for USDC

    plug
    chainlink
    math
  • Card: Buy 8 Dec Token With USDC

    plug
    chainlink
    values
  • Card: Buy 18 Dec Token With USDC

    plug
    chainlink
    values
  • Card: Sell 10% of ETH for USDC

    evm
    math
    chainlink
  • Card: Buy ETH With 10% of USDC

    evm
    math
    chainlink
  • Card: Sell $25 ETH for USDC

    values
    math
    chainlink
  • Card: Buy $25 ETH With USDC

    values
    math
    chainlink
  • Get Simple Moving Average

    plug
    time
    chainlink
  • Get Token Target

    plug
    database
    evm
  • Get Total Holdings Value

    plug
    evm
    boolean

On other protocols · 8