


Reads onchain state
Multiplies two values and divides by a third in one step, rounding up or down. Dividing after the multiply avoids the truncation of a separate divide-then-multiply, so fixed-point ratios like utilization stay wei-exact, while round-up matches protocol share math that rounds debt up. The x × y intermediate is a checked 256-bit product: the call reverts if it overflows uint256, and reverts on z = 0. 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. Reach for it to convert an amount across a price or rate, such as collateral times price divided by that price's own denominator, or to scale a balance by a share ratio without losing precision.
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.
Swap 0.005 ETH for weETH at the Ether.fi Rate



1·Get exchange rate
Reading the current ether.fi rate for weETH to learn how much eETH one whole weETH is worth right now.
2·Multiply then divide
Taking 0.005 and multiplying by 1, then dividing by that fetched rate and rounding down, converting the ETH amount into a weETH figure.
3·Multiply then divide
From that converted weETH figure, multiplying by 995 and dividing by 1000 rounded down, which trims the amount to allow a slippage margin.
4·Swap tokens
Finally swapping 0.005 ETH for at least that trimmed weETH amount through the solver, using the prior result as the minimum received.
Stake on Base · 9 plugs
Provide liquidity on Base · 6 plugs
Dollar-cost average on Base · 4 plugs
Posts · 2
More on Math · 3