Math

Calculate and calculate proportional value on Math

Ethereum
Ethereum
Base
Base
Scripting · Math · Calculation

Ready to run on Base

Math is the substrate every plan onchain is made of: the chain keeps its books in fixed point integers, and every rate, price, balance, and share that matters is a number some contract multiplied and divided at a scale no desk calculator was built for. Eighteen decimal WADs, twenty seven decimal RAYs, basis points, raw token units: this is the arithmetic the entire market already runs on, every block, without exception.

A plug computes in that native register directly. Sums, differences, products, quotients, remainders, powers, floors and caps over full width integers. Proportions taken in percent, basis points, WAD, or RAY without ever leaving the scale the protocol prices in. Multiplication fused with division so precision never dies in an intermediate value, with the rounding direction chosen deliberately rather than inherited by accident. Roots, logarithms, and exponentials for the curves that lending rates and AMM invariants are actually built from.

The numbers that matter are computed in the same transaction that acts on them. An order sized as a fraction of a balance the moment the balance is read, not the value it had when a person last looked. A repayment proportional to exactly how far a threshold was crossed. A yield split at precise basis points between destinations. Nothing copied out of a spreadsheet, nothing rounded by hand, nothing stale by the time it lands.

Every strategy that holds up under real money is arithmetic first and conviction second, and the arithmetic is the part a person gets wrong at four in the morning. A plug does not.

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

How to calculate and calculate proportional value on Math

  • Calculate

    Calculate on Math

    Ethereum
    Ethereum
    Base
    Base

    Applies a binary arithmetic operation to two values and returns the result.

    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.

  • Calculates a proportion of a value using percent, basis points, WAD, or RAY units.

    Reach for it to size a partial action: withdraw a fixed percentage of a position, repay a share of debt, or split a balance by basis points across two destinations.

  • Multiplies two values and divides by a third in one step, rounding up or down.

    All three operands are reconciled to eighteen decimals, so the divisor is the measured value you are dividing by and not a scale word: the WAD constant here is the number one and divides by nothing. Where a raw denominator really is wanted, write it as a literal.

  • Compute

    Compute on Math

    Ethereum
    Ethereum
    Base
    Base

    Applies a unary math operation to a value and returns the result.

    Reach for it to convert between per-second rates and annual growth, to take the geometric mean of two prices, or to normalize a signed delta to its magnitude before a comparison.

Posts · 20