Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v1 source pure

Functions 5

func AmountIn

1func AmountIn(amountOut, reserveIn, virtualIn, reserveOut, virtualOut, feeBps int64) int64
source

AmountIn is the ugnot/token that must be paid so AmountOut >= amountOut. Rounded up so ExactOut does not underpay.

func AmountOut

1func AmountOut(amountIn, reserveIn, virtualIn, reserveOut, virtualOut, feeBps int64) int64
source

AmountOut is Uniswap-v2 getAmountOut against effective (real+virtual) reserves. Payout is capped by the real reserveOut — virtual offsets only affect price.

func MulDiv

1func MulDiv(a, b, d int64) int64
source

MulDiv returns floor(a * b / d) for non-negative a, b and d > 0. Fast path uses int64 product. Overflow path is 128-bit (a*b)/d — same as int64((bigint(a)*bigint(b))/bigint(d)) — and panics only if the quotient does not fit int64. Gno has no typed bigint(int64) conversion.

func MulDivCeil

1func MulDivCeil(a, b, d int64) int64
source

MulDivCeil is ceil(a * b / d) for non-negative a, b and d > 0. Ceil only when remainder != 0.

func Sqrt

1func Sqrt(n int64) int64
source

Sqrt returns floor(sqrt(n)) for n >= 0 (Babylonian method).

Imports 3

  • math stdlib
  • math/bits stdlib
  • math/overflow stdlib

Source Files 2