Calculate
Calculate

Math · Reads onchain state

Applies a binary arithmetic operation to two values and returns the result. Operations are add, subtract, multiply, divide, modulo, power, minimum, and maximum. Operand decimals are reconciled so a token amount and a price combine correctly, and division truncates. Power returns a raw integer. Reach for it to derive the next step's input from earlier reads: a repay sized as debt minus a buffer, a min of a target and available liquidity, or a value split into a fraction.

Get Chainlink Token Value (USD)

plug
math
5actions
  1. 1·Take

    Step one declares a parameter named token, whose value the caller supplies when the plug runs.

  2. 2·Take

    Next comes a second parameter named amount, also filled in by the caller at execution time.

  3. 3·Use

    This step composes another plug, Get Chainlink Price (USD), pulling its price result into this transaction.

  4. 4·Calculate

    Multiplying the composed price from slot 3 by the caller supplied amount from slot 2 produces the total value.

  5. 5·Bubble

    Finally the product from slot 3 of the math step is surfaced as this plug's output.

Take
Take
Use where
tokenis
Calculate
Bubble
  • Get Chainlink Token Value (USD)

    plug
    math
  • 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
  • Expected Amount to Minimum Received

    plug
    math
    values
  • Raw Weights to Percents

    plug
    evm
    boolean
  • Get Simple Moving Average

    plug
    time
    chainlink
  • Get Price Running Total

    plug
    values
    math
  • Rebalance Holdings to Target

    plug
    values
    evm
  • Get Total Holdings Value

    plug
    evm
    boolean
  • Get Target Balance

    plug
    math
    evm
  • Get Holding Value

    plug
    evm
    math
  • Swap at Floor

    plug
    evm
    values
  • Morpho: Auto Leverage Trigger

    plug
    morpho
    math
  • Swap

    plug
    values
    evm
  • Check Required Amount

    plug
    math
    evm
  • Exit Morpho at Epoch End

    pendle
    time
    boolean
  • Morpho: Get Market Liquidity

    plug
    morpho
    math
  • Morpho: Get Borrow APR

    plug
    values
    math
  • Find Value Delta

    plug
    boolean
    evm
  • Morpho: Collateral Amount to Collateral Value

    plug
    math
  • Morpho: Borrow Shares to Borrow Assets

    plug
    math
    evm
  • Aave: Wind or Unwind Position

    plug
    boolean
    aave
  • Value to Token Amount

    plug
    aave
    math
  • Target Debt to Debt Delta

    plug
    aave
    boolean
  • Wind

    plug
    aave
    evm
  • Unwind

    plug
    aave
    evm
  • 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
  • Borrow + Term Repayment Schedule

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

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

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

    aave
    boolean
    evm