func AllLimits
ActionAllLimits lists one page of pending orders for the keeper to scan, ';'-joined: id,ticker,L|S,limit,mark. The keeper triggers the ones whose condition holds.
Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.
Package lastcall is a synthetic stocks desk on gno.land.
Package lastcall is a synthetic stocks desk on gno.land.
It is self-contained: it runs its own price feed (an off-chain bot pushes quotes from the updater 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.
AllLimits lists one page of pending orders for the keeper to scan, ';'-joined: id,ticker,L|S,limit,mark. The keeper triggers the ones whose condition holds.
AllLiquidatable lists, within one page of open positions, the ids at or below maintenance on a fresh quote, ';'-joined, for the keeper.
AllStops lists, within one page of open positions, those with 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.
AvgEntry returns the owner's average entry price for ticker in micro-USD per share, or 0 if they hold none.
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.
CancelLimit refunds a pending order's locked margin + fee to its owner.
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.
ClosePerp closes the caller's own position at the current mark and settles.
DeskReserveUSD is the desk's own tUSD balance.
FaucetUSD mints 10,000 tUSD to the caller. Open faucet — demo only.
GetPrice returns the last quote for a ticker. Panics if unknown.
IsFresh reports whether a ticker has a quote young enough to trade against.
IsMarketOpen reports whether the stock market is open, as last pushed by the updater. While it is false the leverage cap is closedMaxLeverage.
LastCallAt is the time after which the stored quote no longer allows a trade, or 0 before the first quote.
LimitsOf returns an owner's pending orders, ';'-joined, fields comma-separated: id,ticker,L|S,size,margin,limit,mark (size/money micro, 6 dp).
Liquidate closes an underwater position. Permissionless: anyone (the desk's keeper bot, or the UI) may call it once the position is at maintenance.
LockedUSD is the part of the reserve owed back as margin and limit escrow.
OIOf returns a market's open-interest state, comma-separated: oiLong,oiShort,capPerSide,maxLev (notional micro-USD; maxLev a plain integer).
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.
OpenPerpCount and LimitCount tell the keeper how many pages to read.
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.
PlaceLimit locks `margin` + the open fee and queues an order to open a perp when the oracle price reaches `limit`. Returns the order id.
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.
PoolInfo returns pool-wide figures, comma-separated: totalShares,poolAssets,feesAll,deskReserve (all micro, 6 dp).
PoolOf returns one depositor's position, comma-separated: shares,assets where assets is the current tUSD micro value of those shares.
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.
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.
QuoteBuy / QuoteSell are read-only helpers for the UI: the tUSD cost/proceeds of trading stockAmount units at the current price.
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.
Sell burns stockAmount units of sTicker from the caller and pays tUSD at the desk price minus fee, from the desk reserve.
SetMarketOpen is pushed by the off-chain updater (bot) from the live market state.
SetMaxLev lowers (never raises) the max leverage for a market. 0 restores the global default.
SetOICap sets the per-side open-interest cap for a market (micro-USD). 0 restores the default.
SetPrices stores several quotes in one transaction so the keeper pays one fee per cycle. quotes is "TICKER:microUSD" pairs joined by ','.
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.
TriggerLimit executes a ready order at the current oracle price, using the locked margin + prepaid fee. Permissionless (keeper / UI). Requires the trigger reached, including any skew impact on the entry, and while the market is closed a leverage within closedMaxLeverage; panics otherwise so the keeper retries later.
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.