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

pad source realm

Package pad is gnomemepad: a self-contained meme launchpad for gno.land.

Overview

Package pad is gnomemepad: a self-contained meme launchpad for gno.land.

Example
1CreateWithVenue (bond + venue-aware GNS escrow) -> GRC20 + WUGNOT curve -> Graduate
2  -> internal CPMM; then either:
3     gnoswap: RetryList / RetryListGnoswap (escrowed GNS + WUGNOT inventory)
4     zdex:    ReleaseListSeed -> EOA CreatePool -> ConfirmZdexList

Production: Buy/Sell/Swap* use WUGNOT (push-pay + prepaid credits). Payment: user wugnot.Transfer(pad, amount) then Buy. Create fee: gnoswap preference locks ListFeeGns; zdex preference locks 0. DefaultListVenue source = zdex; Pearl may SetDefaultListVenue(gnoswap) after deploy. Unit tests (testSkipBanker): OriginSend ugnot as collateral units. Tokens are real GRC20 (mint on buy, burn on sell).

Constants 2

const VenueGnoswap, VenueZdex

1const (
2	VenueGnoswap = "gnoswap"
3	VenueZdex    = "zdex"
4)
source

ListVenue IDs (compile-time switch in tryListVenue). Adding a new DEX means a new case + adapter file and a new pad version — Gno cannot dynamically import by path string.

const TotalSupply, CurveSupply, PoolSeed, VirtualUgnot0, VirtualToken0, GraduationThreshold, FeeBPS, CreatorFeeShareBPS, ProtocolFeeShareBPS, CreateBondUgnot, BondRefundBuyers, BondRefundMinRaised, BondRefundMaxHeights, AntiSnipeHeights, AntiSnipeMaxBuyBPS, StatusCurve, StatusGraduated, MaxTradeHistory, TradeSideBuy, TradeSideSell, TradeSideOpen, DenomUgnot, GnoswapFeeTier, GnoswapTickSpacing, GnoswapMinTick, GnoswapMaxTick, GnoswapMaxFeeWugnot, ListFeeGns

 1const (
 2	// Token economics
 3	TotalSupply int64 = 1_000_000_000
 4	CurveSupply int64 = 800_000_000 // sold on bonding curve
 5	// PoolSeed is legacy. Graduation sizes LP tokens to curve spot
 6	// (raised * VirtualToken / VirtualUgnot); unsold remainder = LeftoverTokens.
 7	PoolSeed int64 = 200_000_000
 8
 9	// Virtual constant-product seed (Pump-style).
10	// Max net raise when selling full CurveSupply:
11	//   R = VirtualUgnot0 * CurveSupply / (VirtualToken0 - CurveSupply)
12	// Pearl default: VU0=3.5e9 + VT0≈1.073e9 => max raise ≈10.2k GNOT so
13	// DefaultGraduationThreshold 10_000 GNOT is reachable before sold-out.
14	VirtualUgnot0 int64 = 102_375_071_625 // mainnet: max raise ≥ 300k GNOT
15	VirtualToken0 int64 = 1_073_000_191   // virtual token side
16
17	// Default graduation raise (ugnot). Live value starts here in Init;
18	// protocol may call SetGraduationThreshold afterward.
19	GraduationThreshold int64 = 300_000_000_000 // 300_000 GNOT (SetGraduationThreshold later)
20
21	// Fees: 1.20% total. Of the fee: 40% creator, 40% protocol, 20% LP/k remainder.
22	FeeBPS              int64 = 120
23	CreatorFeeShareBPS  int64 = 4000
24	ProtocolFeeShareBPS int64 = 4000
25
26	// Fallback create bond for unit tests / if bond realm unavailable.
27	// Production pad uses createbond.CurrentBondUgnot() (see bond package).
28	// Sapphire normal bond = 2 GNOT; promo ~ $20 in ugnot set on bond.StartPromo.
29	CreateBondUgnot      int64 = 150_000_000 // 150 GNOT fallback; live = bond realm
30	BondRefundBuyers     int   = 5
31	BondRefundMinRaised  int64 = 5_000_000 // >=5 GNOT raised
32	BondRefundMaxHeights int64 = 100_000
33
34	// Anti-snipe: first N heights, max cumulative tokens per address (BPS of TotalSupply).
35	AntiSnipeHeights   int64 = 20
36	AntiSnipeMaxBuyBPS int64 = 500 // 5% per address in window
37
38	// Status
39	StatusCurve     = 0
40	StatusGraduated = 1
41
42	// Trade history ring buffer.
43	MaxTradeHistory = 128
44	// Trade sides stored in history
45	TradeSideBuy  = 0
46	TradeSideSell = 1
47	TradeSideOpen = 2 // initial listing mark
48
49	DenomUgnot = "ugnot"
50
51	// --- Gnoswap auto-list (Sapphire) ---
52	// Curve collateral is WUGNOT (Buy TransferFrom). At graduate, pad already holds
53	// raised WUGNOT for LP - no realm self-wrap needed.
54	// CreatePool fee is fixed in GNS (typically 100e6 = 100 GNS):
55	//   Fee = pre-funded GNS on pad OR surplus WUGNOT (fees retained) ExactOut -> GNS
56	GnoswapFeeTier     uint32 = 3000 // 0.3% meme tier
57	GnoswapTickSpacing int32  = 60
58	GnoswapMinTick     int32  = -887272
59	GnoswapMaxTick     int32  = 887272
60	// Max WUGNOT used as ExactOut maxIn for fee buy (ceiling / slippage).
61	// Prefer pre-funding >=100 GNS on pad so LP depth stays = raised.
62	GnoswapMaxFeeWugnot int64 = 1_500_000_000 // 1500 GNOT
63
64	// Create-time GNS list fee escrow (padv20+).
65	// Creator must Transfer >= ListFeeGns free GNS to pad before Create.
66	// Locked per-launch until Gnoswap list consumes it, or ClaimListFee refunds creator.
67	// Matches typical gnspool.GetPoolCreationFee() (100 GNS, 6 decimals).
68	ListFeeGns int64 = 100_000_000
69)
source

Functions 76

func AdenaPathOf

Action
1func AdenaPathOf(id string) string
source

AdenaPathOf returns the grc20reg / Adena token key: packagePath.SYMBOL (Token.ID is packagePath.SYMBOL.seq - Adena rejects that form).

func AdminInfo

Action
1func AdminInfo() string
source

AdminInfo is a single-line dashboard snapshot for the ops UI:

Example
1protocolAddr|pendingFees|paidFees|reservedUgnot|launchCount|pointsOn|inited|padAddr

pointsOn/inited are 0|1.

func Approve

crossing Action
1func Approve(cur realm, id string, spender address, amount int64)
source

Approve sets GRC20 allowance so DEX/contracts can TransferFrom.

func Buy

crossing Action
1func Buy(cur realm, id string, amountWugnot, minTokensOut int64) int64
source

Buy spends WUGNOT on the bonding curve; credits tokens. amountWugnot: max to spend (may overpay). UI: Deposit + Transfer(pad, amt) + Buy. Overpay stays as claimable prepaid — ClaimWugnot anytime (incl. after list). minTokensOut: slippage floor (0 = disabled). Auto-graduates at threshold or sold-out.

Production: collateral is real WUGNOT on pad -> Graduate can auto-list Gnoswap. Tests (testSkipBanker): amountWugnot ignored; OriginSend ugnot is used as units.

Last-fill (no overshoot):

  1. Cap net so RaisedUgnot never exceeds graduationThreshold() (refund excess WUGNOT).
  2. Cap by remaining curve tokens (CurveSupply - RealSold).

If the curve is already sold out (or raise already filled), Buy refunds the full take and graduates when ready - no panic so users are not stuck mid-tx.

func ClaimCreatorFees

crossing Action
1func ClaimCreatorFees(cur realm, id string) int64
source

ClaimCreatorFees withdraws accrued creator fees for a launch. Only the token creator may claim. Fees stay on pad until claimed.

func ClaimListFee

crossing Action
1func ClaimListFee(cur realm, id string) int64
source

ClaimListFee refunds Create-time GNS escrow to the token creator if still unlisted. Use when graduate/list will not complete or creator abandons listing.

func ClaimProtocolFees

crossing Action
1func ClaimProtocolFees(cur realm) int64
source

ClaimProtocolFees withdraws pending protocol fees to protocolAddr. Only the current protocol treasury key may call (same wallet that Init'd, unless TransferProtocol was used).

func ClaimWugnot

crossing Action
1func ClaimWugnot(cur realm) int64
source

ClaimWugnot withdraws all of the caller's prepaid WUGNOT credit to their wallet. Safe after Buy overpay or after graduate/list — excess stays claimable until claimed.

func ConfirmZdexList

crossing Action
1func ConfirmZdexList(cur realm, id, poolId string)
source

ConfirmZdexList marks a launch listed on zdex after EOA CreatePool succeeded. poolId e.g. "ugnot|SYMBOL" (must be non-empty; no on-chain pool verify). Creator or protocol. Prefer ReleaseListSeed first when pad still holds LP seed.

func Create

crossing Action
1func Create(cur realm, name, symbol, uri string) string
source

Create deploys a fair-launch meme. Bond amount from bond realm (or fallback const). Also locks ListFeeGns free GNS (creator must Transfer GNS to pad first). No pre-mint; all tradeable float starts on the bonding curve.

func CreateWithVenue

crossing Action
1func CreateWithVenue(cur realm, name, symbol, uri, venueId string) string
source

CreateWithVenue is Create + PreferredVenue in one MsgCall (fee escrow follows venue). venueId: "zdex" → no GNS list escrow; "gnoswap" → ListFeeRequired GNS.

func FeeInfo

Action
1func FeeInfo() string
source

FeeInfo returns protocolAddr|pendingUgnot|paidUgnot for UIs.

func FreeGns

Action
1func FreeGns() string
source

FreeGns returns free|have|reserved for UI preflight (GNS list fee).

func FreeWugnot

Action
1func FreeWugnot() string
source

FreeWugnot is free|have|reserved|totalCredit for UI preflight.

func GRC20Bank

Action
1func GRC20Bank(id string) *grc20.Token
source

GRC20Bank returns the underlying *grc20.Token for interop (metadata / external DEX). Does not expose PrivateLedger - mint/burn stay pad-only.

func Graduate

crossing Action
1func Graduate(cur realm, id string)
source

Graduate permissionlessly moves a ready curve into a permanently locked CPMM. Ready when RaisedUgnot >= graduationThreshold(), or when RealSold >= CurveSupply with RaisedUgnot > 0 (sold-out before threshold - escape hatch for unreachable raise).

func Init

crossing Action
1func Init(cur realm)
source

Init sets the protocol treasury. First EOA caller becomes fee recipient (protocolAddr). Protocol trade fees accrue on-pad until ClaimProtocolFees (treasury only) or PushProtocolFees (anyone may push to treasury). Creator fees always need ClaimCreatorFees by the token creator.

Deploy note: call Init with the wallet that should receive protocol fees (or TransferProtocol later). Gnoswap CreatePool GNS fee is paid to Gnoswap, not to this treasury.

func IsProtocol

Action
1func IsProtocol(addr string) bool
source

IsProtocol reports whether addr is the current treasury (for UI gating).

func LaunchInfo

Action
1func LaunchInfo(id string) string
source

LaunchInfo returns a single-line pipe-delimited summary for UIs/indexers:

Example
1id|name|symbol|status|raised|sold|buyers|creatorFees|poolUgnot|poolToken|uri|creator|virtualUgnot|virtualToken|created|tokenID|gnoswapReady|gnoswapListed|gnoswapPoolPath|gnoswapNote|listVenue

status: 0=curve 1=graduated; gnoswapReady/listed: 0|1 gnoswapNote: optional (padv12+); pipes stripped for delimiter safety. listVenue: optional (padv23+); empty if unlisted.

func ListBuyers

Action
1func ListBuyers(id string) string
source

ListBuyers returns unique buyer addresses (one per line), capped for query size. Only addresses that bought at least once on this pad (UniqueBuyers). Not full GRC20 holders who received tokens via transfer.

func ListIDs

Action
1func ListIDs() string
source

ListIDs returns newline-separated launch IDs (sorted by AVL key / creation order).

func ListNeed

Action
1func ListNeed(id string) string
source

ListNeed is the public query for the Token list wizard (default venue).

func ListNeedFor

Action
1func ListNeedFor(id, venueId string) string
source

ListNeedFor is venue-aware; only gnoswap has a Need adapter today.

func ListVenueOf

Action
1func ListVenueOf(id string) string
source

ListVenueOf returns the venue id used for a successful list (or "").

func ListVenues

Action
1func ListVenues() string
source

ListVenues returns newline-separated "id|label|enabled|feeHint" (enabled 0|1).

func ListedOf

Action
1func ListedOf(id string) bool
source

ListedOf reports whether the launch is listed on any venue.

func PadAddress

Action
1func PadAddress() string
source

PadAddress returns this pad realm's bech32 package address (fund WUGNOT here).

func ParamsInfo

Action
1func ParamsInfo() string
source

ParamsInfo returns parameters for UI display. total|curve|poolSeed|gradThreshold|feeBps|createBond|listFeeGns createBond is live from bond realm when not in unit-test mode. listFeeGns: Create-time GNS escrow required (padv20+).

func PointsEnabled

Action
1func PointsEnabled() bool
source

PointsEnabled reports whether pad notifies pointsv2 after trades/creates.

func PrepaidBalance

crossing Action
1func PrepaidBalance(cur realm) int64
source

PrepaidBalance returns caller's claimable WUGNOT credit on this pad.

func PrepaidOf

Action
1func PrepaidOf(addr string) int64
source

PrepaidOf returns claimable credit for an address (read helper).

func PushProtocolFees

crossing Action
1func PushProtocolFees(cur realm) int64
source

PushProtocolFees sends pending protocol fees to protocolAddr. Permissionless: anyone may call so treasury can be paid without the protocol key signing (still only pays the configured protocolAddr).

func ReleaseListSeed

crossing Action
1func ReleaseListSeed(cur realm, id string)
source

ReleaseListSeed sends graduated internal-CPMM seed to the creator for EOA zdex CreatePool:

  • PoolUgnot as WUGNOT Transfer to creator (EOA may wugnot.Withdraw → ugnot OriginSend)
  • PoolToken minted as GRC20 to creator (was pad-accounting only)

PoolUgnot/PoolToken kept as listing-size record; reservedWugnot skips via ListSeedReleased. Disables internal SwapBuy/Sell. Creator or protocol may call; assets always go to creator.

func RemainingRaiseUgnot

Action
1func RemainingRaiseUgnot(id string) int64
source

RemainingRaiseUgnot is net ugnot still needed to hit graduationThreshold() (0 if met/over).

func Render

1func Render(path string) string
source

Render provides on-chain discovery (gnoweb). Read-only by convention.

Paths:

Example
1""              - home / list
2token/{id}      - launch detail
3help            - API help

func RetryList

crossing Action
1func RetryList(cur realm, id, venueId string) bool
source

RetryList lists a graduated launch on the chosen venue. Permissionless EOA MsgCall. Uses PoolUgnot / PoolToken (curve-spot sized). venueId: empty → PreferredVenue → DefaultListVenue(); unknown/disabled → soft-fail note.

func RetryListGnoswap

crossing Action
1func RetryListGnoswap(cur realm, id string) bool
source

RetryListGnoswap is the Gnoswap-specific wrapper (compat for existing UI).

func Sell

crossing Action
1func Sell(cur realm, id string, tokensIn, minWugnotOut int64) int64
source

Sell burns curve tokens and pays WUGNOT (fee on output). minWugnotOut: slippage floor (0 = disabled). User may wugnot.Withdraw to ugnot.

func SetDefaultListVenue

crossing Action
1func SetDefaultListVenue(cur realm, venueId string)
source

SetDefaultListVenue sets the default list venue (protocol only).

func SetGraduationThreshold

crossing Action
1func SetGraduationThreshold(cur realm, ugnot int64)
source

SetGraduationThreshold updates the live raise target (ugnot, 1 GNOT = 1e6). Protocol/deploy wallet only. Affects open curve launches (remaining raise / ready).

func SetListFeeGns

crossing Action
1func SetListFeeGns(cur realm, gns int64)
source

SetListFeeGns updates Create-time GNS escrow required for new launches. Protocol/deploy wallet only. Does not change already-escrowed launches.

func SetListVenue

crossing Action
1func SetListVenue(cur realm, id, label string, enabled bool, feeAssetHint string)
source

SetListVenue registers or updates venue metadata (protocol only). Does not add compile-time dispatch — unknown ids stay non-listable until tryListVenue gains a case in a future pad version.

func SetPointsEnabled

crossing Action
1func SetPointsEnabled(cur realm, on bool)
source

SetPointsEnabled toggles pointsv2 notifications (protocol admin only). pointsv2 must AllowPad(this package path) or OnTrade/OnCreate will panic and revert the trade.

func SetPreferredVenue

crossing Action
1func SetPreferredVenue(cur realm, id, venueId string)
source

SetPreferredVenue sets the DEX target used when RetryList(id, "") is called. Creator or protocol only; locked once listed. Syncs Create-time GNS escrow (gnoswap locks ListFeeRequired; zdex unlocks/refunds escrow).

func SwapBuy

crossing Action
1func SwapBuy(cur realm, id string, amountWugnot, minTokensOut int64) int64
source

SwapBuy buys tokens from the graduated internal pool with WUGNOT. amountWugnot: max to spend (Approve pad). minTokensOut: slippage (0 = off). Disabled when listed on Gnoswap (trade via router).

func SwapSell

crossing Action
1func SwapSell(cur realm, id string, tokensIn, minWugnotOut int64) int64
source

SwapSell sells tokens into the graduated pool for WUGNOT. minWugnotOut: slippage floor (0 = disabled).

func TokenIDOf

Action
1func TokenIDOf(id string) string
source

TokenIDOf returns the GRC20 Token.ID() for a launch.

func TradeCount

Action
1func TradeCount(id string) int
source

TradeCount returns number of stored chart samples for a launch.

func TradeHistory

Action
1func TradeHistory(id string) string
source

TradeHistory returns newline-separated chart points:

Example
1height|side|ugnot|tokens|priceScaled

side: 0=buy 1=sell 2=open/graduate. Ordered oldest -> newest.

func Transfer

crossing Action
1func Transfer(cur realm, id string, to address, amount int64)
source

Transfer moves GRC20 tokens between addresses (user-initiated).

func TransferFrom

crossing Action
1func TransferFrom(cur realm, id string, from, to address, amount int64)
source

TransferFrom spends allowance: spender = MsgCall EOA caller. Enables DEX / routers that hold allowance from Approve.

func TransferProtocol

crossing Action
1func TransferProtocol(cur realm, newAddr address)
source

TransferProtocol rotates the protocol fee recipient (current protocol only). Pending protocolFees stay on pad until claimed/pushed to the *new* address.

func WithdrawProtocolUgnot

crossing Action
1func WithdrawProtocolUgnot(cur realm, amount int64) int64
source

WithdrawProtocolUgnot lets the treasury pull free ugnot from the pad bank (e.g. raised backlog after Gnoswap list, to re-wrap as WUGNOT inventory). Capped by free balance; panics if amount > free.

Types 2

type Launch

struct
 1type Launch struct {
 2	ID      string
 3	Name    string
 4	Symbol  string
 5	URI     string
 6	Creator address
 7	Status  int
 8	Created int64 // block height
 9
10	// GRC20 (mint/burn only via pad-owned private ledger)
11	token   *grc20.Token
12	ledger  *grc20.PrivateLedger
13	TokenID string // Token.ID() - registry / Gnoswap identity
14
15	// Virtual curve reserves
16	VirtualUgnot int64
17	VirtualToken int64
18	RealSold     int64 // tokens sold on curve (<= CurveSupply)
19	RaisedUgnot  int64 // net ugnot collateral in curve (excl. fee vaults)
20
21	// Real pool (post-grad); LP permanently locked - no remove path
22	// PoolToken is pad-internal reserve sized to curve spot (not always all unsold).
23	// LeftoverTokens = (TotalSupply - RealSold) - PoolToken; minted to pad at list, not LP'd.
24	PoolUgnot      int64
25	PoolToken      int64
26	LeftoverTokens int64
27
28	CreatorFees  int64
29	BondUgnot    int64
30	BondRefunded bool
31	UniqueBuyers avl.Tree // address -> true
32	BuyerCount   int
33	// snipeBought: address -> cumulative tokens bought during anti-snipe window
34	snipeBought avl.Tree
35
36	// Gnoswap listing state
37	GnoswapReady      bool   // graduated; token is listable / listed
38	GnoswapListed     bool   // true when CreatePool+Mint succeeded on Gnoswap
39	GnoswapNote       string // human status / failure reason
40	GnoswapPoolPath   string
41	GnoswapPositionID uint64
42	// FeeWugnotSpent / LiqWugnotUsed: inventory spent at graduate (1:1 vs raised ugnot notionally)
43	FeeWugnotSpent int64
44	LiqWugnotUsed  int64
45
46	// ListFeeGns: Create-time GNS escrow for Gnoswap CreatePool fee (padv20+).
47	// Consumed on successful list; ClaimListFee refunds creator if still unlisted.
48	ListFeeGns      int64
49	ListFeeConsumed bool // true after list paid CreatePool fee from escrow
50
51	// ListVenue: which DEX adapter succeeded (e.g. "zdex" / "gnoswap"). Empty if unlisted.
52	ListVenue string
53	// PreferredVenue: chosen at Create (or SetPreferredVenue). Used when RetryList venueId == "".
54	PreferredVenue string
55	// ListSeedReleased: PoolUgnot (WUGNOT) + PoolToken (minted GRC20) sent to creator for EOA zdex CreatePool.
56	ListSeedReleased bool
57
58	// Chart history (ordered AVL keys)
59	Trades    avl.Tree // tradeKey -> *Trade
60	NextTrade int64
61}
source

Launch is one meme market: curve phase then locked pool phase. token/ledger are unexported so external packages cannot Mint/Burn via field access.

type Trade

struct
1type Trade struct {
2	Height int64
3	Side   int // TradeSideBuy | TradeSideSell | TradeSideOpen
4	Ugnot  int64
5	Tokens int64
6	Price  int64 // ugnot per token * 1e6 after the trade
7}
source

Trade is one price sample for charts (capped history per launch).

Imports 22

Source Files 7