feeNum
untyped bigintValue
(997 <untyped> bigint)
feeDen
untyped bigintValue
(1000 <untyped> bigint)
maxReserve
untyped bigint// 9223372036854775
Value
(9223372036854775 <untyped> bigint)
pool
typepool is one token pair. keyA \< keyB always holds: the pair is canonicalised on the way in, so (X,Y) and (Y,X) address the same pool.
Value
v0.pool
pools
v0.Treepools maps the pool id "keyA~keyB" -> \*pool. "~" cannot occur in a grc20reg key, and unlike "|" it does not break a markdown table cell.
- OID
- 0fed64…7ec1:4
pools details
lpSeq
v0.IDlpSeq numbers the LP tokens. It is never reset, so a symbol is never reused and grc20reg's one-token-per-realm-and-symbol rule is never tripped.
Value
<zero>
AddLiquidity
func(keyA string, keyB string, maxA int64, maxB int64) int64AddLiquidity deposits up to maxA of keyA and maxB of keyB and mints LP shares to the caller. It creates the pool if this is its first deposit, in which case the caller's amounts set the starting price and the whole of maxA and maxB is taken. On an existing pool the deposit is trimmed to the current reserve ratio: only one side is consumed in full and the remainder of the richer side is left untouched, so pass the amounts you are willing to spend, not the amounts you insist on spending. The caller must first Approve this realm's address on BOTH tokens for at least the amounts that will be taken. Returns the shares minted.
- OID
- 0fed64…7ec1:6
AddLiquidity details
RemoveLiquidity
func(keyA string, keyB string, shares int64) (int64, int64)RemoveLiquidity burns shares held by the caller and returns the proportional amounts of both tokens, in the caller's (keyA, keyB) argument order. Burning the pool's entire share supply pays out the whole reserve, so the last provider out leaves nothing unclaimable behind and the pool can be reseeded at a fresh price.
- OID
- 0fed64…7ec1:8
RemoveLiquidity details
Swap
func(keyIn string, keyOut string, amountIn int64, minOut int64) int64Swap sells amountIn of keyIn for keyOut and aborts unless at least minOut comes back. The caller must first Approve this realm's address on keyIn. minOut is the only protection against being sandwiched or against the pool moving between quoting and execution. Pass a real bound; passing 0 means accepting any price at all.
- OID
- 0fed64…7ec1:9
Swap details
TransferLP
func(keyA string, keyB string, to .uverse.address, amount int64)TransferLP moves amount of the caller's LP position to \`to\`. The LP token lives in this realm, so a signing user cannot reach it through the token's own entry points the way they would for any other GRC20: there are none. These four wrappers are that entry point. A REALM holding LP does not need them and can go through grc20reg instead: grc20reg.Transfer(0, cur, amm.LPToken(keyA, keyB), to, n)
- OID
- 0fed64…7ec1:10
TransferLP details
ApproveLP
func(keyA string, keyB string, spender .uverse.address, amount int64)ApproveLP lets spender move up to amount of the caller's LP position. Same approve race as any GRC20: an allowance changed from a non-zero value can be spent at both the old and the new one if the holder is unlucky with ordering. Set it to 0 first when lowering it.
- OID
- 0fed64…7ec1:11
ApproveLP details
TransferFromLP
func(keyA string, keyB string, from .uverse.address, to .uverse.address, amount int64)TransferFromLP spends an allowance the owner granted to the caller.
- OID
- 0fed64…7ec1:12
TransferFromLP details
lpCheck
func(err .uverse.error)- OID
- 0fed64…7ec1:13
lpCheck details
AmountOut
func(amountIn int64, reserveIn int64, reserveOut int64) int64AmountOut is the pricing function, fee included, as a pure function of the two reserves. Exported so a caller can quote off-chain against reserves it already holds, and so the arithmetic is testable on its own.
- OID
- 0fed64…7ec1:14
AmountOut details
Quote
func(keyIn string, keyOut string, amountIn int64) int64Quote prices amountIn of keyIn against the pool's live reserves. It is the number Swap would return right now, which is not a promise about the next block.
- OID
- 0fed64…7ec1:15
Quote details
Reserves
func(keyA string, keyB string) (int64, int64)Reserves returns the two reserves in the caller's argument order.
- OID
- 0fed64…7ec1:16
Reserves details
SharesOf
func(keyA string, keyB string, owner .uverse.address) int64SharesOf returns owner's LP shares, i.e. their LP token balance.
- OID
- 0fed64…7ec1:17
SharesOf details
TotalShares
func(keyA string, keyB string) int64TotalShares returns the pool's LP token total supply.
- OID
- 0fed64…7ec1:18
TotalShares details
LPToken
func(keyA string, keyB string) stringLPToken returns the grc20reg key of the pool's LP token. Hand it to any realm that should read or move these positions without importing this one.
- OID
- 0fed64…7ec1:19
LPToken details
AllowanceLP
func(keyA string, keyB string, owner .uverse.address, spender .uverse.address) int64AllowanceLP reports how much of owner's LP position spender may move.
- OID
- 0fed64…7ec1:20
AllowanceLP details
PoolCount
func() intPoolCount returns how many pools exist.
- OID
- 0fed64…7ec1:21
PoolCount details
Render
func(path string) stringRender lists every pool, or one pool's detail when path is a "keyA~keyB" pool id.
- OID
- 0fed64…7ec1:22
Render details
canon
func(first string, second string) (a string, b string, flipped bool)canon sorts a caller's token pair into the pool's canonical order and reports whether the caller's order was reversed.
- OID
- 0fed64…7ec1:23
canon details
newPool
func(int, rlm .uverse.realm, a string, b string) *v0.poolnewPool resolves both tokens, mints this pool's LP token and registers it. Non-crossing (\`\_ int, rlm realm\`): grc20.NewToken binds the token's origRealm to rlm.PkgPath() under an IsCurrent assertion, and grc20reg keys off the registering caller, so rlm has to stay AddLiquidity's own live frame rather than a fresh one. The LP unit is token A at seed time, so the LP token mirrors token A's decimals. The symbol is LP\<n> because grc20 caps a symbol at 11 chars, which "LP-" plus two 11-char symbols would blow past; the human-readable pair lives in the name instead.
- OID
- 0fed64…7ec1:24
newPool details
poolID
func(a string, b string) stringpoolID is the storage and render key for a canonicalised pair.
- OID
- 0fed64…7ec1:25
poolID details
getPool
func(a string, b string) *v0.pool- OID
- 0fed64…7ec1:26
getPool details
mustPool
func(a string, b string) *v0.pool- OID
- 0fed64…7ec1:27
mustPool details
pull
func(int, rlm .uverse.realm, tok *v0.Token, from .uverse.address, to .uverse.address, amount int64)pull moves amount of tok from \`from\` into this realm, spending the allowance \`from\` granted to this realm's address. Non-crossing on purpose: \`\_ int, rlm realm\` is the only shape that keeps rlm the caller's own live frame. RealmTeller binds the spender eagerly to rlm.Address(), which is this realm.
- OID
- 0fed64…7ec1:28
pull details
push
func(int, rlm .uverse.realm, tok *v0.Token, to .uverse.address, amount int64)push sends amount of tok from this realm to \`to\`.
- OID
- 0fed64…7ec1:29
push details
mulDiv
func(a int64, b int64, c int64) int64mulDiv returns floor(a\*b/c) through a 128-bit intermediate, which plain int64 arithmetic cannot do: a\*b is routinely wider than 63 bits here even when the quotient is small.
- OID
- 0fed64…7ec1:30
mulDiv details
cmpProd
func(a int64, b int64, c int64, d int64) intcmpProd compares a\*b with c\*d exactly, in 128 bits, and returns -1, 0 or 1.
- OID
- 0fed64…7ec1:31
cmpProd details
min64
func(a int64, b int64) int64- OID
- 0fed64…7ec1:32
min64 details
itoa
func(v int64) string- OID
- 0fed64…7ec1:33