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

v1 source realm

Package market trades Launchpad NFTs: fixed-price listings and funded offers. A sale pays the seller, the treasury an...

Overview

Package market trades Launchpad NFTs: fixed-price listings and funded offers. A sale pays the seller, the treasury and the collection's royalty receivers inside the same transaction. The realm holds only the escrow of open offers, which their buyers can always take back, and has no admin. It keeps open orders only: a closed one is deleted, so its storage deposit is released, and its history is the event log.

Constants 2

const marketPath, StatusFilled, StatusCancelled, StatusReplaced, StatusExpired, maxSecondaryFeeBPS, maxLifetime, graceToClose, maxOrders

 1const (
 2	marketPath = "gno.land/r/samcrew/launchpad/market/v1"
 3
 4	// Why an order closed, as its closing event says.
 5	StatusFilled    = "filled"
 6	StatusCancelled = "cancelled"
 7	StatusReplaced  = "replaced"
 8	StatusExpired   = "expired"
 9
10	// Hard limits, fixed for the life of this realm.
11	maxSecondaryFeeBPS = 200 // 2% of a sale price
12	maxLifetime        = 90 * 24 * 60 * 60
13	// How long after its expiry an order is still its owner's alone to close.
14	// The chain returns the storage deposit of the bytes a call frees to that
15	// call's sender (while ugnot is not a restricted denomination): the grace
16	// keeps a stranger from taking a closed order's deposit at the very second
17	// it expires, and leaves abandoned orders to whoever cleans them up.
18	graceToClose = 7 * 24 * 60 * 60
19	maxOrders    = 9_999_999_999
20)
source

Functions 22

func AcceptOffer

crossing Action
1func AcceptOffer(cur realm, id string, number int64, proof, currencyKey string, price int64)
source

AcceptOffer sells the caller's token number to an open offer. proof is the comma-separated Merkle path of the token's trait for a trait offer, and empty otherwise. currencyKey and price are the terms the seller read: an offer on other terms, such as an ID the seller never saw, buys nothing. The caller must first approve this realm in the NFT ledger.

func Buy

crossing Action
1func Buy(cur realm, id, currencyKey string, price int64)
source

Buy pays a listing's exact price and moves the token to the caller. currencyKey and price are the terms the buyer read: a listing on other terms, such as an ID the buyer never saw, takes nothing.

func BuyerOffersJSON

Action
1func BuyerOffersJSON(buyer, afterID string, size int64) string
source

BuyerOffersJSON reads an account's open offers, oldest first, starting after the offer ID afterID ("" starts from the oldest).

func Cancel

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

Cancel withdraws a listing. The seller can always do it, paused market or not. Anyone can clear a listing whose seller no longer owns the token, or one that expired more than graceToClose ago; the chain returns the storage deposit of what a call frees to its caller, so clearing pays whoever does it.

func CancelOffer

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

CancelOffer takes back the caller's own open offer, expired or not.

func CollectionListingsJSON

Action
1func CollectionListingsJSON(collection string, afterNumber, size int64) string
source

CollectionListingsJSON reads a collection's open listings in token number order, starting after the token number afterNumber (0 starts from the first).

func CollectionOffersJSON

Action
1func CollectionOffersJSON(collection, afterID string, size int64) string
source

CollectionOffersJSON reads a collection's open offers of every kind, oldest first, starting after the offer ID afterID ("" starts from the oldest).

func EscrowOf

Action
1func EscrowOf(currencyKey string) int64
source

EscrowOf is the total of open offers in a currency.

func ExpireOffer

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

ExpireOffer returns to its buyer the escrow of an offer that expired more than graceToClose ago. Anyone may call it: the price goes to the buyer, and the chain pays the caller the storage deposit of the bytes the offer occupied, so for a week after expiry only the buyer, with CancelOffer, takes its own offer back.

func List

crossing Action
1func List(cur realm, collection string, number, price, expiresAt int64,
2	currencyKey string, maxFeeBPS int64) string
source

List offers the caller's token for sale and returns the listing ID. The caller must first approve this realm in the NFT ledger, and names the highest protocol fee it accepts; the fee in force is pinned on the listing. A new listing replaces the token's previous one.

func ListingJSON

Action
1func ListingJSON(id string) string
source

ListingJSON is an open listing, or "null" once it is closed.

func ListingsJSON

Action
1func ListingsJSON(before string, size int64) string
source

ListingsJSON reads every open listing, newest first, starting below the listing ID before ("" starts from the newest).

func MakeOffer

crossing Action
1func MakeOffer(cur realm, kind, collection string, number int64, trait string,
2	price, expiresAt int64, currencyKey string, maxFeeBPS int64) string
source

MakeOffer escrows price and returns the offer ID. kind selects what the offer is for: number is set for a token offer, trait for a trait offer, and both are zero and empty otherwise. A trait offer needs a collection whose creator committed its traits. The protocol fee in force is pinned on the offer; it comes out of what the seller receives, never on top of the price, and maxFeeBPS is the highest the buyer lets a seller be charged.

func OfferJSON

Action
1func OfferJSON(id string) string
source

OfferJSON is an open offer, or "null" once it is closed. An open offer can be past its expiry: it then only waits for its refund.

func OffersJSON

Action
1func OffersJSON(before string, size int64) string
source

OffersJSON reads every open offer, newest first, starting below the offer ID before ("" starts from the newest).

func SellerListingsJSON

Action
1func SellerListingsJSON(seller, afterID string, size int64) string
source

SellerListingsJSON reads an account's open listings, oldest first, starting after the listing ID afterID ("" starts from the oldest).

func TermsJSON

Action
1func TermsJSON(collection string, price int64) string
source

TermsJSON is what a sale costs now: the protocol fee a new listing would pin, and how a price would split for the collection. A fee of -1 means the lane is closed; config's ActionStatusJSON tells whether the market lane accepts new orders right now.

func TokenListingJSON

Action
1func TokenListingJSON(collection string, number int64) string
source

TokenListingJSON is the open listing of a token, or "null".

func TraitLeaf

Action
1func TraitLeaf(collection string, number int64, trait string) merkle.Hash
source

TraitLeaf is the Merkle leaf that proves a token carries a trait, as committed by the collection's creator in the NFT ledger.

func GetListing

Action
1func GetListing(id string) Listing
source

GetListing returns an open listing; a closed or unknown ID aborts.

func GetOffer

Action
1func GetOffer(id string) Offer
source

GetOffer returns an open offer; a closed or unknown ID aborts.

Types 2

type Listing

struct
 1type Listing struct {
 2	ID         string // "L<n>"
 3	Collection string
 4	Number     int64
 5	Seller     address
 6	Price      int64
 7	Currency   string
 8	CreatedAt  int64
 9	ExpiresAt  int64
10	FeeBPS     int64  // protocol fee, pinned when the seller signed
11	key        string // its key in listings
12	epoch      int64  // the token's custody epoch when it was listed
13}
source

Listing offers one token at a fixed price. The seller keeps the token and approves this realm; nothing is held here. A listing exists while it is open and no longer, and can be bought only within the token's custody epoch it was made in.

type Offer

struct
 1type Offer struct {
 2	ID         string // "O<n>"
 3	Kind       string
 4	Collection string
 5	Number     int64  // token offers only
 6	Trait      string // trait offers only: "<type>=<value>"
 7	Buyer      address
 8	Price      int64
 9	Currency   string
10	CreatedAt  int64
11	ExpiresAt  int64
12	FeeBPS     int64 // protocol fee, pinned when the buyer funded the offer
13}
source

Offer is a bid whose full price sits in this realm until it is accepted, cancelled by its buyer or returned after expiry. An offer exists while it is open and no longer.

Imports 14

Source Files 5