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

dex state

Back to all declarations

Pool

type

Pool represents a liquidity pool for token A / token B

Value

dex.Pool

SwapResult

type

SwapResult represents the result of a swap

Value

dex.SwapResult

feeBps

untyped bigint

Fee in basis points (0.3% = 30 bps)

Value

(30 <untyped> bigint)

AddLiquidity

func(amountA int64, amountB int64) int64

AddLiquidity adds token A and B to the pool, returns LP shares

Open
OID
02a5d5…f752:6
AddLiquidity details

Inspect func

RemoveLiquidity

func(shares int64) (int64, int64)

RemoveLiquidity removes liquidity and returns token amounts

Open
OID
02a5d5…f752:7
RemoveLiquidity details

Inspect func

SwapAForB

func(amountIn int64) int64

SwapAForB swaps token A for token B

Open
OID
02a5d5…f752:8
SwapAForB details

Inspect func

SwapBForA

func(amountIn int64) int64

SwapBForA swaps token B for token A

Open
OID
02a5d5…f752:9
SwapBForA details

Inspect func

GetReserves

func() (int64, int64)

GetReserves returns current pool reserves

Open
OID
02a5d5…f752:10
GetReserves details

Inspect func

GetPrice

func() string

GetPrice returns the price of A in terms of B

Open
OID
02a5d5…f752:11
GetPrice details

Inspect func

GetLPShares

func(addr string) int64

GetLPShares returns LP shares for an address

Open
OID
02a5d5…f752:12
GetLPShares details

Inspect func

TotalLiquidity

func() int64

TotalLiquidity returns total LP shares

Open
OID
02a5d5…f752:13
TotalLiquidity details

Inspect func

GetAmountOut

func(amountIn int64, isAForB bool) int64

GetAmountOut calculates expected output for a given input (read-only)

Open
OID
02a5d5…f752:14
GetAmountOut details

Inspect func

sqrtApprox

func(n int64) int64

sqrtApprox returns an approximate square root using Newton's method

Open
OID
02a5d5…f752:16
sqrtApprox details

Inspect func
Pool : type =dex.Pool
SwapResult : type =dex.SwapResult
pool : *dex.Pool Inspect
feeBps : untyped bigint =(30 <untyped> bigint)
init.4 : func() Inspect
AddLiquidity : func(amountA int64, amountB int64) int64 Inspect
RemoveLiquidity : func(shares int64) (int64, int64) Inspect
SwapAForB : func(amountIn int64) int64 Inspect
SwapBForA : func(amountIn int64) int64 Inspect
GetReserves : func() (int64, int64) Inspect
GetPrice : func() string Inspect
GetLPShares : func(addr string) int64 Inspect
TotalLiquidity : func() int64 Inspect
GetAmountOut : func(amountIn int64, isAForB bool) int64 Inspect
Render : func(string) string Inspect
sqrtApprox : func(n int64) int64 Inspect