Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v1 source realm

Package market is the platform's immutable fixed-price market (design §2.5.4). It never holds a token: the seller app...

Overview

Package market is the platform's immutable fixed-price market (design §2.5.4). It never holds a token: the seller approves this realm in core, the token stays in the seller's wallet, and Buy moves it through core's official grc721 RealmTeller in the same transaction that pays everyone. It never holds coins either (I-3).

A token has at most one listing, addressed by (cid, tid). Stale listings (RA H-2) cannot be bought: a listing pins the token's move counter and core's approval nonces at listing time, and Buy requires owner == seller, the counter unchanged and the approval it was listed under still in place, unchanged (I-8). Once stale, a listing stays dead: approving the market again later never revives it (SA-L3). A stale listing never blocks the new owner: List overwrites it and anyone may CancelStale it.

Storage (storage-cost-analysis M1-M3): a listing is one packed string in `listings` (key cid:tid) plus one key in the price index `byCollection` (floor, collection pages). Per-seller history comes from the indexer ("Listed"/"Cancelled" events), not from an on-chain index.

Deposit return: gno refunds a freed storage deposit to the signer of the transaction that frees it, so a Buy hands the buyer the deposit the seller locked for the listing. Buy therefore charges the buyer that amount on top of the price and pays it to the seller (ListingDeposit, measured). It is exact up to a few bytes because every listing costs the same storage objects: a sentinel key keeps both trees non-empty (an avl insert into an empty tree creates one node, any later insert two). Net, the seller is whole and the buyer pays the price (the chain's refund cancels the extra). Not compensated: the deposit of a per-token Approve, which the sale's transfer clears (~0.1-0.2 GNOT to the buyer, depending on the collection's other pending approvals); an approval-for-all is not cleared, so listing under SetApprovalForAll leaves nothing behind.

Pause ("trade" in core) stops List and Buy only. Cancel, CancelStale and UpdatePrice are never paused (I-2).

Constants 1

const MaxPageSize, priceWidth, StoragePrice, ListingBytes, ListingDeposit, sentinel

 1const (
 2	MaxPageSize = 50
 3	priceWidth  = 16 // types.MaxUnitPrice has 16 digits
 4
 5	// Deposit-return estimate (ugnot), from the bytes measured in this
 6	// package's z_bytes_* filetests at gno.land's storage price of 100
 7	// ugnot/byte (vm param storage_price on Onyx and gnoland-1). Re-measure
 8	// before a deploy to a chain with another price.
 9	StoragePrice   = 100
10	ListingBytes   = 4_070 // one listing: a listings key + a byCollection key, two avl nodes each (measured 4,049-4,101 locked, 4,032-4,091 freed)
11	ListingDeposit = ListingBytes * StoragePrice
12
13	// sentinel is a key of both trees that is never a listing (it sorts
14	// after every "cid:" prefix range), so neither tree is ever empty.
15	sentinel = "~"
16)
source

Functions 12

func ActiveListing

Action
1func ActiveListing(cid, tid string) (id string, price int64, ok bool)
source

ActiveListing is the typed read for other realms: the live listing of a token, if any (id is the sequence id).

func Buy

crossing Action
1func Buy(cur realm, cid, tid string, expectedPrice int64)
source

Buy pays exactly expectedPrice for the token's listing, plus the listing's deposit return (see the package doc); excess attached ugnot is refunded. Order: checks, remove the listing, move the token, then pay — protocol fee to the treasury, royalty to the collection's sub-treasury (then distributed to its payees), the engine author's fee, the rest plus the deposit return to the seller. I-4: protocol + royalty + engine + seller + refund == attached.

func Cancel

crossing Action
1func Cancel(cur realm, cid, tid string)
source

Cancel removes the caller's listing (its storage deposit returns to the caller). Never paused.

func CancelStale

crossing Action
1func CancelStale(cur realm, cid, tid string)
source

CancelStale lets anyone remove a listing that can no longer be bought; the freed deposit goes to the caller (gno's rule), a cleanup bounty.

func Floor

Action
1func Floor(cid string) int64
source

Floor is the lowest live price in cid, or -1. It inspects at most MaxPageSize listings from the cheapest, so spam cannot make it unbounded.

func List

crossing Action
1func List(cur realm, cid, tid string, price int64) string
source

List offers a token of a Final collection at price (ugnot). The caller must own it and have approved this realm (Approve or SetApprovalForAll in core). A stale listing of the same token is replaced. Returns the listing's sequence id (events); the listing itself is addressed by (cid, tid).

func Listing

Action
1func Listing(cid, tid string) string
source

Listing is the token's listing as JSON, stale ones included with "live":false, or "null".

func ListingOf

Action
1func ListingOf(cid, tid string) string
source

ListingOf is the live listing of a token as JSON, or "null".

func ListingsByCollection

Action
1func ListingsByCollection(cid string, offset, limit int64) string
source

ListingsByCollection lists by ascending price. Stale listings are included with "live":false so pages stay stable; frontends hide them. Listings by seller: use the indexer (Listed / Cancelled events).

func Quote

Action
1func Quote(cid, tid string) string
source

Quote is what Buy(cid, tid, price) costs and pays now, as JSON: {live, id, seller, price, deposit, total (attach this), protocolFee, royalty, royaltyTo, engineFee, engineAuthor, sellerProceeds}; "null" if unlisted.

func UpdatePrice

crossing Action
1func UpdatePrice(cur realm, cid, tid string, price int64)
source

UpdatePrice changes the price of a live listing; Buy's expectedPrice protects buyers from a change racing their purchase (RA M-10).

Dependencies

Source Files 2