LoadingPreparing the Explorer shell…
Skip to contentRealm detail
zdex
gno.land/r/g1mv0052e7r6s09f5t9xsqf00nj3tqsgt9dg52jr/zdex/v2
Indexed deployment identity with independently loaded latest RPC source, functions, and Render.
Indexed deployment
Identity
- Package path
- gno.land/r/g1mv0052e7r6s09f5t9xsqf00nj3tqsgt9dg52jr/zdex/v2
- Deployed (UTC)
package zdex
import (
"gno.land/p/demo/tokens/grc20"
"gno.land/p/nt/seqid/v0"
"gno.land/r/demo/defi/grc20reg"
)
type tokenRec struct {
token *grc20.Token
ledger *grc20.PrivateLedger
}
var nextTok seqid.ID
func getTok(symbol string) *tokenRec {
v := tokens.Get(symbol)
if v == nil {
panic("zdex: unknown token " + symbol)
}
return v.(*tokenRec)
}
func tryTok(symbol string) *tokenRec {
v := tokens.Get(symbol)
if v == nil {
return nil
}
return v.(*tokenRec)
}
func mintInternal(cur realm, name, symbol string, decimals, amount int64, to address) string {
require(tryTok(symbol) == nil, "zdex: symbol taken")
require(decimals >= 0 && decimals <= 18, "zdex: decimals")
tok, led := grc20.NewToken(name, symbol, int(decimals), nextTok.Next(), cur)
if amount > 0 {
checkErr(led.Mint(to, amount))
}
tokens.Set(symbol, &tokenRec{token: tok, ledger: led})
return grc20reg.Register(cross(cur), tok, "")
}
func tokenPullKey(tokenKey, symbol string) string {
if tryTok(symbol) != nil {
return symbol
}
if tokenKey != "" {
return tokenKey
}
return symbol
}
func poolTokRef(p *Pool) string {
if p.Internal || p.Token == "" {
return p.Symbol
}
return p.Token
}
func pullUserToken(_ int, rlm realm, symbol string, from address, amount int64) {
require(amount > 0, "zdex: amount")
if !rlm.IsCurrent() {
panic("zdex: spoofed realm")
}
require(from == rlm.Previous().Address(), "zdex: from must be caller")
rec := tryTok(symbol)
if rec != nil {
checkErr(rec.ledger.CallerTeller().Transfer(0, rlm, thisAddr(), amount))
return
}
// Pearl grc20reg write wrappers are non-crossing: rlm must be this
// realm's live cur. cross() would debit the registry instead.
grc20reg.TransferFrom(0, rlm, symbol, from, thisAddr(), amount)
}
func pushToken(_ int, rlm realm, symbol string, to address, amount int64) {
require(amount > 0, "zdex: amount")
if !rlm.IsCurrent() {
panic("zdex: spoofed realm")
}
rec := tryTok(symbol)
if rec != nil {
checkErr(rec.ledger.Transfer(thisAddr(), to, amount))
return
}
grc20reg.Transfer(0, rlm, symbol, to, amount)
}
func tokenBalance(symbol string, owner address) int64 {
rec := tryTok(symbol)
if rec != nil {
return rec.token.BalanceOf(owner)
}
t := grc20reg.Get(symbol)
if t == nil {
return 0
}
return t.BalanceOf(owner)
}
// Transfer moves an internally minted token. External GRC20s are transferred
// on their own realm.
func Transfer(cur realm, symbol string, to address, amount int64) {
rec := getTok(symbol)
checkErr(rec.ledger.CallerTeller().Transfer(0, cur, to, amount))
}
func Approve(cur realm, symbol string, spender address, amount int64) {
rec := getTok(symbol)
checkErr(rec.ledger.CallerTeller().Approve(0, cur, spender, amount))
}
func TransferFrom(cur realm, symbol string, from, to address, amount int64) {
rec := getTok(symbol)
checkErr(rec.ledger.CallerTeller().TransferFrom(0, cur, from, to, amount))
}
func BalanceOf(symbol string, owner address) int64 {
return tokenBalance(symbol, owner)
}
func TotalSupply(symbol string) int64 {
rec := tryTok(symbol)
if rec == nil {
t := grc20reg.Get(symbol)
if t == nil {
return 0
}
return t.TotalSupply()
}
return rec.token.TotalSupply()
}
func TokenKey(symbol string) string {
rec := tryTok(symbol)
if rec == nil {
return ""
}
return rec.token.ID()
}
Latest RPC state
Exported functions
- SetPaused(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, v bool)
- ProposeAdmin(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, next string)
- AcceptAdmin(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string})
- TransferAdmin(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, next string)
- Admin() string
- RealmAddr() string
- PendingAdmin() string
- Paused() bool
- CollectFees(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string) (int64, int64)
- PlaceBid(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string, giveU int64, wantAmt int64, expireH int64, allOrNone bool) uint64
- PlaceAsk(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string, giveT int64, wantU int64, expireH int64, allOrNone bool) uint64
Latest RPC state · Realm Render
zdex v2
GNOT-native AMM generation 2. Two-sided pools, native ugnot (no wrap), escrow limit orders.
Swap fee 0.30% default (tiers 0.05% / 0.30% / 1.00%). Protocol ~1/6 of the fee.
- Version: 2
- Package:
gno.land/r/g1mv0052e7r6s09f5t9xsqf00nj3tqsgt9dg52jr/zdex/v2
- Pools: 1
- Open orders: 0
- Admin:
g1mv0052e7r6s09f5t9xsqf00nj3tqsgt9dg52jr
Pools
| Pair | ugnot | token | virtual | fee | launch |
|---|---:|---:|---:|---:|---|
| ZDEX | 300000000 | 300000000000 | 0 | 30 bps | no |
Swap
Create a pool
Two-sided ugnot/GRC20. Min 1 GNOT. Fee tiers 5 / 30 / 100 bps. Protocol takes ~1/6 of the swap fee; the rest stays as LP.
Order book
FillOrder(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, orderID uint64, giveAmt int64) (int64, int64)CancelOrder(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, orderID uint64)OrderCount() intLaunch(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, name string, symbol string, decimals int64, totalSupply int64, creatorKeepBps int64, virtualUgnot int64, vestBlocks int64, lockBlocks int64, snipeBlocks int64, snipeMaxBps int64) stringClaimVest(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, symbol string) int64VestingOf(symbol string, owner string) (int64, int64, int64)MulDiv(a int64, b int64, d int64) int64Sqrt(n int64) int64MulDivCeil(a int64, b int64, d int64) int64AmountOut(amountIn int64, reserveIn int64, virtualIn int64, reserveOut int64, virtualOut int64, feeBps int64) int64AmountIn(amountOut int64, reserveIn int64, virtualIn int64, reserveOut int64, virtualOut int64, feeBps int64) int64HarvestPoints(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string) int64ClaimFeeShare(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}) int64PointsOf(owner string) (int64, int64, int64)ClaimableFeeShare(owner string) int64EpochInfo() (int64, int64, int64, int64, int64, int64, int64)SetEpochBlocks(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, n int64)SetFeeShareBps(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, bps int64)CreatePool(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, tokenKey string, symbol string, amountU int64, amountT int64, feeBps int64) stringAddLiquidity(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string, amountU int64, maxToken int64, minLP int64) int64RemoveLiquidity(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string, lp int64, minU int64, minT int64) (int64, int64)PoolInfo(poolID string) (int64, int64, int64, int64, int64)PositionOf(poolID string, owner string) int64PoolCount() intHeight() int64PoolList() stringPoolSnapshot(poolID string) stringOrderList() stringPointsSnapshot(owner string) stringEpochSnapshot() stringTokenCatalog() stringLookupToken(ref string) stringRender(path string) stringQuote(poolID string, tokenIn string, amountIn int64) int64QuoteIn(poolID string, tokenOut string, amountOut int64) int64SwapExactIn(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string, tokenIn string, amountIn int64, minOut int64, maxHeight int64) int64SwapExactOut(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, poolID string, tokenOut string, amountOut int64, maxIn int64, maxHeight int64) int64SpotPrice(poolID string) int64Transfer(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, symbol string, to string, amount int64)Approve(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, symbol string, spender string, amount int64)TransferFrom(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, symbol string, from string, to string, amount int64)BalanceOf(symbol string, owner string) int64TotalSupply(symbol string) int64TokenKey(symbol string) stringVersion() stringCaps() stringThisPkg() stringNextPkg() stringSetNextPkg(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, path string)ModuleOf(name string) stringSetModule(cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, name string, pkg string)Modules() stringHubSnapshot() string