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.

lastcall source realm

Package lastcall is a fully-collateralized stocks desk on gno.land.

Overview

Package lastcall is a fully-collateralized stocks desk on gno.land.

It is self-contained: it runs its own price feed (an off-chain bot pushes quotes from the desk key, trusted by caller address), issues a test-USD collateral token and synthetic stock tokens, and lets users trade them spot against the desk. There is no external oracle and no external liquidity — the desk is always the counterparty at its own quoted price.

All amounts are integers. USD values are micro-USD (6 decimals): $190.42 -> 190420000. Token amounts use 6 decimals too, so one whole share is 1_000000 units and lines up 1:1 with the price scale.

Functions 42

func AllLimits

Action
1func AllLimits() string
source

AllLimits lists every pending order for the keeper to scan, ';'-joined: id,ticker,L|S,limit,mark. The keeper triggers the ones whose condition holds.

func AllLiquidatable

Action
1func AllLiquidatable() string
source

AllLiquidatable lists the ids of positions at or below maintenance on a fresh quote, ';'-joined, for the keeper.

func AllStops

Action
1func AllStops() string
source

AllStops lists every open position that has a stop set, for the keeper to scan, ';'-joined, fields comma-separated: id,ticker,L|S,stopLoss,takeProfit,mark. The keeper triggers the ones whose condition holds.

func AvgEntry

Action
1func AvgEntry(ticker string, owner address) int64
source

AvgEntry returns the owner's average entry price for ticker in micro-USD per share, or 0 if they hold none.

func Buy

crossing Action
1func Buy(cur realm, ticker string, stockAmount int64)
source

Buy mints stockAmount units (6 dp) of sTicker to the caller and charges tUSD at the desk price plus fee. Caller must already hold enough tUSD.

func CancelLimit

crossing Action
1func CancelLimit(cur realm, id uint64)
source

CancelLimit refunds a pending order's locked margin + fee to its owner.

func ClosePartial

crossing Action
1func ClosePartial(cur realm, id uint64, closeSize int64)
source

ClosePartial closes `closeSize` units (6 dp) of the caller's own position at the current mark, leaving the rest open. Always allowed, even when the market is closed. closeSize == the full size behaves like ClosePerp.

func ClosePerp

crossing Action
1func ClosePerp(cur realm, id uint64)
source

ClosePerp closes the caller's own position at the current mark and settles.

func FaucetUSD

crossing Action
1func FaucetUSD(cur realm)
source

FaucetUSD mints 10,000 tUSD to the caller. Open faucet — demo only.

func GetPrice

Action
1func GetPrice(ticker string) (int64, int64)
source

GetPrice returns the last quote for a ticker. Panics if unknown.

func IsFresh

Action
1func IsFresh(ticker string) bool
source

IsFresh reports whether a ticker has a quote young enough to trade against.

func LimitsOf

Action
1func LimitsOf(owner address) string
source

LimitsOf returns an owner's pending orders, ';'-joined, fields comma-separated: id,ticker,L|S,size,margin,limit,mark (size/money micro, 6 dp).

func Liquidate

crossing Action
1func Liquidate(cur realm, id uint64)
source

Liquidate closes an underwater position. Permissionless: anyone (the desk's keeper bot, or the UI) may call it once the position is at maintenance.

func OIOf

Action
1func OIOf(ticker string) string
source

OIOf returns a market's open-interest state, comma-separated: oiLong,oiShort,capPerSide,maxLev (notional micro-USD; maxLev a plain integer).

func OpenPerp

crossing Action
1func OpenPerp(cur realm, ticker string, isLong bool, size int64, margin int64) uint64
source

OpenPerp opens a long or short on `ticker` of `size` stock units (6 dp), backed by `margin` tUSD micro pulled from the caller (plus the open fee). Market order.

func PerpsOf

Action
1func PerpsOf(owner address) string
source

PerpsOf returns the caller's open positions, one per line, fields comma- separated: id,ticker,L|S,size,entry,margin,mark,pnl,liq,stopLoss,takeProfit. Money and size are integers at 6 dp; mark/pnl/liq are computed live. Stop prices are 0 when unset. Empty string if none.

func PlaceLimit

crossing Action
1func PlaceLimit(cur realm, ticker string, isLong bool, size, margin, limit int64) uint64
source

PlaceLimit locks `margin` + the open fee and queues an order to open a perp when the oracle price reaches `limit`. Returns the order id.

func PoolDeposit

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

PoolDeposit pulls `amount` tUSD micro from the caller into the desk reserve and mints pool shares at the current share price. Returns the shares minted.

func PoolInfo

Action
1func PoolInfo() string
source

PoolInfo returns pool-wide figures, comma-separated: totalShares,poolAssets,feesAll,deskReserve (all micro, 6 dp).

func PoolOf

Action
1func PoolOf(owner address) string
source

PoolOf returns one depositor's position, comma-separated: shares,assets where assets is the current tUSD micro value of those shares.

func PoolSharePrice

Action
1func PoolSharePrice() int64
source

PoolSharePrice is the value of one share in micro-USD, scaled by 1e6 (so a fresh pool reads 1_000000 == $1.000000 per share). Returns 1e6 when empty.

func PoolWithdraw

crossing Action
1func PoolWithdraw(cur realm, shares int64) int64
source

PoolWithdraw burns `shares` from the caller and pays their pro-rata slice of the pool in tUSD from the desk reserve. Returns the tUSD micro paid out.

func QuoteBuy

Action
1func QuoteBuy(ticker string, stockAmount int64) int64
source

QuoteBuy / QuoteSell are read-only helpers for the UI: the tUSD cost/proceeds of trading stockAmount units at the current price.

func SeedUSD

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

SeedUSD mints tUSD into the desk reserve so it can pay out on sells and in-the-money perps. Admin only — the desk's bootstrap liquidity.

func Sell

crossing Action
1func Sell(cur realm, ticker string, stockAmount int64)
source

Sell burns stockAmount units of sTicker from the caller and pays tUSD at the desk price minus fee, from the desk reserve.

func SetMarketOpen

crossing Action
1func SetMarketOpen(cur realm, open bool)
source

SetMarketOpen is pushed by the off-chain updater (bot) from the live market state.

func SetMaxLev

crossing Action
1func SetMaxLev(cur realm, ticker string, lev int64)
source

SetMaxLev lowers (never raises) the max leverage for a market. 0 restores the global default.

func SetOICap

crossing Action
1func SetOICap(cur realm, ticker string, perSide int64)
source

SetOICap sets the per-side open-interest cap for a market (micro-USD). 0 restores the default.

func SetPrice

crossing Action
1func SetPrice(cur realm, ticker string, value int64, observedAt int64)
source

SetPrice is pushed by the off-chain bot (updater key) for one ticker.

func SetPrices

crossing Action
1func SetPrices(cur realm, quotes string, observedAt int64)
source

SetPrices stores several quotes in one transaction so the keeper pays one fee per cycle. quotes is "TICKER:microUSD" pairs joined by ','.

func SetStops

crossing Action
1func SetStops(cur realm, id uint64, stopLoss, takeProfit int64)
source

SetStops sets, updates or clears the stop-loss and take-profit of the caller's own position. Each price is micro-USD per share; pass 0 to clear that leg.

func TriggerLimit

crossing Action
1func TriggerLimit(cur realm, id uint64) uint64
source

TriggerLimit executes a ready order at the current oracle price, using the locked margin + prepaid fee. Permissionless (keeper / UI). Requires the market open and the trigger reached; panics otherwise so the keeper simply retries later.

func TriggerStop

crossing Action
1func TriggerStop(cur realm, id uint64)
source

TriggerStop closes a position whose stop-loss or take-profit has been reached, at the current mark. Permissionless (keeper / UI); panics if no stop is set or not reached, so the keeper simply retries later.

Types 1

type Price

struct
1type Price struct {
2	Value      int64 // micro-USD per share
3	ObservedAt int64 // unix seconds observed off-chain by the bot
4}
source

Price is quoted in micro-USD per whole share.

Dependencies

Source Files 13

Directories 3