Skip to content Search Apps Documentation Source Content 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.

arena source realm

Package arena is a SocialFi realm: profiles, posts, follows, GNOT tips, and creator tickets priced on a quadratic bon...

Overview

Package arena is a SocialFi realm: profiles, posts, follows, GNOT tips, and creator tickets priced on a quadratic bonding curve.

Ticket collateral sits in this realm as totalReserve. Trade fees are forwarded out of that collateral, and Sweep only sends coins above it.

Constants 1

const CreatorFeeBps, ProtocolFeeBps, ReferralFeeBps, TicketUnit, MaxSupply, MaxTrade, MaxBodyRunes, ProtocolVersion, maxHandle, minHandle, maxNameRunes, maxNameBytes, maxBioRunes, maxBioBytes, maxBodyBytes

 1const (
 2	// CreatorFeeBps is the creator's cut of each ticket trade.
 3	CreatorFeeBps int64 = 500
 4	// ProtocolFeeBps is forwarded to the treasury on each ticket trade.
 5	ProtocolFeeBps int64 = 500
 6	// ReferralFeeBps is paid to the creator's referrer when they have one.
 7	ReferralFeeBps int64 = 100
 8	// TicketUnit is the ugnot price of ticket number 1. Ticket i costs i² units.
 9	TicketUnit int64 = 10_000
10	// MaxSupply is the most tickets one creator can have outstanding.
11	MaxSupply = 2000
12	// MaxTrade is the most tickets one buy or sell can move.
13	MaxTrade = 20
14	// MaxBodyRunes is the longest post, counted in runes.
15	MaxBodyRunes = 280
16	// ProtocolVersion is the immutable revision of this package.
17	// A later package is announced with SetSuccessor. It does not hold this reserve.
18	ProtocolVersion = "1"
19
20	maxHandle    = 16
21	minHandle    = 3
22	maxNameRunes = 32
23	maxNameBytes = 128
24	maxBioRunes  = 160
25	maxBioBytes  = 640
26	maxBodyBytes = 1120
27)
source

Functions 43

func Buy

crossing Action
1func Buy(cur realm, handle string, amount int)
source

Buy mints amount tickets of handle. Attach exactly QuoteBuy's due in ugnot.

func Delete

crossing Action
1func Delete(cur realm, id int)
source

Delete soft-deletes the caller's post and clears its body from current state. The original transaction still holds the text in chain history.

func FeedCount

Action
1func FeedCount() int
source

FeedCount is the number of live top-level posts still in the feed index.

func Follow

crossing Action
1func Follow(cur realm, handle string)
source

Follow records that the caller follows handle.

func Following

Action
1func Following(from address, handle string) bool
source

Following reports whether from follows the handle.

func GatedBody

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

GatedBody returns a gated post's text for the author or a current ticket holder. Chain storage is public; this only gates the convenience call and Render.

func LatestID

Action
1func LatestID() int
source

LatestID is the newest post id, or 0 when nothing has been posted.

func Like

crossing Action
1func Like(cur realm, id int)
source

Like adds the caller's like. One like per account.

func Liked

Action
1func Liked(who address, id int) bool
source

Liked reports whether who liked the post.

func Paused

Action
1func Paused() bool
source

Paused reports whether new posts, replies, tips, and ticket buys are frozen. Sells stay open so ticket collateral can still exit.

func Post

crossing Action
1func Post(cur realm, body, gated string) int
source

Post publishes a top-level post and returns its id. gated is yes/1/true/khoa to withhold the body from Render. The body is still public chain state. Pass an empty gated value for a public post.

func QuoteBuy

Action
1func QuoteBuy(handle string, amount int) (due, curve, creatorFee, protocolFee, referralFee int64)
source

QuoteBuy is the exact ugnot a buyer must attach to mint amount tickets. due = curve + creator fee + protocol fee + referral fee. curve is what stays in the reserve. Fees are paid on top and forwarded.

func QuoteSell

Action
1func QuoteSell(handle string, amount int) (proceeds, curve, creatorFee, protocolFee, referralFee int64)
source

QuoteSell is what a seller receives, and the fees taken out of the curve refund. The reserve drops by the full curve amount, so later sells stay solvent.

func Register

crossing Action
1func Register(cur realm, handle, name, bio, referrer string)
source

Register opens a profile for the calling account. handle is 3–16 chars of a-z, 0-9 and underscore. referrer may be empty or the bech32 address of an existing member. A member can register once.

func Render

1func Render(path string) string
source

Render is the short gnoweb page for this fund realm. The long client and Sheet live in the view realm. A realm has to declare Render, and the storage deposit of this package cannot hold both the curve and the full client.

func Reply

crossing Action
1func Reply(cur realm, parent int, body string) int
source

Reply publishes a reply to parent and returns the new id. Replies are public.

func Sell

crossing Action
1func Sell(cur realm, handle string, amount int)
source

Sell burns amount tickets and pays the caller from the reserve, minus fees. Sells stay available while the realm is paused.

func SetPaused

crossing Action
1func SetPaused(cur realm, on string)
source

SetPaused freezes posts, replies, tips, and ticket buys when on is true/1/yes. Pass false/0/no to reopen. Ticket sells are never paused.

func SetSuccessor

crossing Action
1func SetSuccessor(cur realm, next string)
source

SetSuccessor records the package path of a later realm. An empty path clears it. This does not move coins or shares.

func SetTreasury

crossing Action
1func SetTreasury(cur realm, next address)
source

SetTreasury moves future protocol fees and surplus sweeps to next.

func SharesOf

Action
1func SharesOf(holder address, handle string) int
source

SharesOf returns how many tickets holder has of the creator's handle.

func Successor

Action
1func Successor() string
source

Successor is the package path of a later realm, or empty. The later realm does not receive this realm's ticket reserve.

func SupplyOf

Action
1func SupplyOf(handle string) (supply int, reserve int64, holders int)
source

SupplyOf returns tickets outstanding, ugnot locked in that curve, and holders.

func Sweep

crossing Action
1func Sweep(cur realm, confirm string)
source

Sweep sends this realm's ugnot above TotalReserve to the treasury. confirm must be the word "sweep". Ticket collateral is not included.

func Tip

crossing Action
1func Tip(cur realm, id int)
source

Tip forwards the attached ugnot to the post's author. The realm does not keep it.

func Unlike

crossing Action
1func Unlike(cur realm, id int)
source

Unlike removes the caller's like.

func UpdateProfile

crossing Action
1func UpdateProfile(cur realm, name, bio string)
source

UpdateProfile replaces the display name and bio. The handle stays.

func Feed

Action
1func Feed(before, limit int) []Article
source

Feed lists newest top-level posts with id < before. before 0 starts at the newest.

func GetPost

Action
1func GetPost(id int) (Article, bool)
source

GetPost returns a copy of the post. The copy does not alias storage.

func Hot

Action
1func Hot(limit int) []Article
source

Hot ranks the newest window the same way Render does. It is not a global index.

func PostsBy

Action
1func PostsBy(addr address, before, limit int) []Article
source

PostsBy lists one member's newest top-level posts with id < before.

func Replies

Action
1func Replies(parent, after, limit int) []Article
source

Replies lists direct replies of parent with id > after, oldest first.

func Holdings

Action
1func Holdings(holder, after address, limit int) []Holding
source

Holdings lists ticket balances of holder, after the given creator address.

func FollowerList

Action
1func FollowerList(who, after address, limit int) []Profile
source

FollowerList lists profiles that follow `who`, in address order, after `after`.

func FollowingList

Action
1func FollowingList(who, after address, limit int) []Profile
source

FollowingList lists profiles `who` follows, in address order, after `after`.

func Handles

Action
1func Handles(after string, limit int) []Profile
source

Handles lists profiles in handle order, strictly after the given handle.

func ProfileByHandle

Action
1func ProfileByHandle(handle string) (Profile, bool)
source

ProfileByHandle returns a copy of the profile, or false when the handle is unknown.

func ProfileOf

Action
1func ProfileOf(addr address) (Profile, bool)
source

ProfileOf returns a copy of the profile bound to addr.

Types 3

type Article

struct
 1type Article struct {
 2	ID      int
 3	Author  address
 4	Body    string
 5	Height  int64
 6	ReplyTo int
 7	Likes   int
 8	Replies int
 9	Tips    int64
10	Gated   bool
11	Deleted bool
12}
source

Article is a copy of one post. Gated bodies are still stored on chain; Render withholds them, and GatedBody checks the caller.

type Holding

struct
1type Holding struct {
2	Creator address
3	Handle  string
4	Amount  int
5}
source

Holding is one creator's tickets in a wallet. It is a copy.

type Profile

struct
 1type Profile struct {
 2	Addr      address
 3	Handle    string
 4	Name      string
 5	Bio       string
 6	Referrer  address
 7	Joined    int64
 8	Posts     int
 9	Followers int
10	Following int
11	TipsIn    int64
12	TipsOut   int64
13}
source

Profile is a copy of a member's public record.

Dependencies

Source Files 8