Calculate

Calculate on Math

Ethereum
Ethereum
Base
Base

Reads onchain state

Ready to run on Base

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.

Plug lets you combine onchain actions like this one into a single transaction, without writing a smart contract. Use in App opens a new plug with this action already in it.

Get Chainlink Token Value (USD)

plug
math
5actions
  1. 1·Take

    Opening with a declared parameter, token is left for the caller to supply at execution time, naming the asset to be valued.

  2. 2·Take

    A second parameter, amount, is declared as caller-supplied, giving the quantity that the price will be applied to.

  3. 3·Use

    Composing the Get Chainlink Price (USD) plug pulls its price-reading logic into this one, returning the token's USD rate.

  4. 4·Calculate

    Multiplying the composed price by amount converts the supplied quantity into its USD value.

  5. 5·Bubble

    Surfacing that product returns the computed USD value as the output of this plug.

Take
Take
Use where
tokenis
Calculate
Bubble

More plugs on Base

Borrow on Base · 7 plugs

Stake on Base · 9 plugs

Provide liquidity on Base · 6 plugs

Dollar-cost average on Base · 4 plugs

Posts · 15

More on Math · 3