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

ammmath source pure

Package ammmath implements integer bonding-curve and constant-product AMM helpers for the gnomemepad factory (Pump-st...

Overview

Package ammmath implements integer bonding-curve and constant-product AMM helpers for the gnomemepad factory (Pump-style virtual CPMM + real CPMM pool).

Functions 8

func BuyTokens

1func BuyTokens(virtualUgnot, virtualToken, ugnotIn int64) (tokensOut, newVU, newVT int64)
source

BuyTokens quotes a virtual constant-product buy (net ugnot in).

func CanGraduate

1func CanGraduate(raisedUgnot, threshold int64) bool
source

CanGraduate reports whether raised net ugnot meets the threshold.

func PoolSwapTokenForUgnot

1func PoolSwapTokenForUgnot(poolUgnot, poolToken, tokensIn int64) (ugnotOut, newPU, newPT int64)
source

PoolSwapTokenForUgnot swaps tokens for gross ugnot out.

func PoolSwapUgnotForToken

1func PoolSwapUgnotForToken(poolUgnot, poolToken, ugnotIn, remainderToPool int64) (tokensOut, newPU, newPT int64)
source

PoolSwapUgnotForToken swaps net ugnot for tokens; remainderToPool adds to ugnot reserve.

func SellTokens

1func SellTokens(virtualUgnot, virtualToken, tokensIn int64) (ugnotOut, newVU, newVT int64)
source

SellTokens quotes a virtual constant-product sell (gross ugnot out).

func SpotPriceUgnotPerToken

1func SpotPriceUgnotPerToken(ugnotReserve, tokenReserve int64) int64
source

SpotPriceUgnotPerToken returns ugnot per token scaled by 1e6 (display only).

func ApplyFee

1func ApplyFee(gross, feeBPS, creatorShareBPS, protocolShareBPS int64) FeeResult
source

ApplyFee takes gross quote paid by the user and feeBPS (e.g. 120 = 1.20%).

func ApplyFeeOnOutput

1func ApplyFeeOnOutput(grossOut, feeBPS, creatorShareBPS, protocolShareBPS int64) FeeResult
source

ApplyFeeOnOutput charges fee on assets leaving the pool/curve.

Types 1

type FeeResult

struct
1type FeeResult struct {
2	Gross     int64
3	Net       int64
4	Fee       int64
5	Creator   int64
6	Protocol  int64
7	Remainder int64
8}
source

FeeResult is the split of a gross trade fee.

Imports 1

  • math/overflow stdlib

Source Files 2