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.

v3 state

Back to all declarations

usd

*v0.Token

tUSD is the test-USD collateral token. 6 decimals, so one tUSD unit is 1\_000000 and token amounts line up 1:1 with micro-USD price quotes.

Open
OID
0dd66f…cf46:184
usd details

Inspect pointer

usdLedger

*v0.PrivateLedger

tUSD is the test-USD collateral token. 6 decimals, so one tUSD unit is 1\_000000 and token amounts line up 1:1 with micro-USD price quotes.

Open
OID
0dd66f…cf46:186
usdLedger details

Inspect pointer

FaucetUSD

func()

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

Open
OID
0dd66f…cf46:7
FaucetUSD details

Inspect func

BalanceUSD

func(owner .uverse.address) int64
Open
OID
0dd66f…cf46:8
BalanceUSD details

Inspect func

costKey

type

Value

v3.costKey

spotCost

map[v3.costKey]int64
Open
OID
0dd66f…cf46:10
spotCost details

Inspect map

addCost

func(owner .uverse.address, ticker string, paid int64)

addCost records the tUSD notional (micro) a buyer paid toward their cost basis.

Open
OID
0dd66f…cf46:11
addCost details

Inspect func

reduceCost

func(owner .uverse.address, ticker string, sold int64, heldBefore int64)

reduceCost removes the cost of \`sold\` units from a holder whose balance BEFORE the sale was \`heldBefore\`, keeping the average per-share cost unchanged.

Open
OID
0dd66f…cf46:13
reduceCost details

Inspect func

AvgEntry

func(ticker string, owner .uverse.address) int64

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

Open
OID
0dd66f…cf46:14
AvgEntry details

Inspect func

admin

.uverse.address

Value

<gnolang.StringValue>

updater

.uverse.address

Value

<gnolang.StringValue>

deskAddr

.uverse.address

Value

<gnolang.StringValue>

nextTokID

v0.ID

Value

<zero>

SetAdmin

func(a .uverse.address)
Open
OID
0dd66f…cf46:21
SetAdmin details

Inspect func

SetUpdater

func(u .uverse.address)
Open
OID
0dd66f…cf46:22
SetUpdater details

Inspect func

DeskAddress

func() .uverse.address
Open
OID
0dd66f…cf46:25
DeskAddress details

Inspect func

Price

type

Price is quoted in micro-USD per whole share.

Value

v3.Price

SetPrices

func(quotes string, observedAt int64)

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

Open
OID
0dd66f…cf46:30
SetPrices details

Inspect func

storePrice

func(ticker string, value int64, observedAt int64)
Open
OID
0dd66f…cf46:31
storePrice details

Inspect func

GetPrice

func(ticker string) (int64, int64)

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

Open
OID
0dd66f…cf46:32
GetPrice details

Inspect func

maxPriceAge

untyped bigint

Value

(600 <untyped> bigint)

maxClockSkew

untyped bigint

Value

(60 <untyped> bigint)

maxPrice

untyped bigint

Value

(1000000000000 <untyped> bigint)

IsFresh

func(ticker string) bool

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

Open
OID
0dd66f…cf46:33
IsFresh details

Inspect func

LastCallAt

func(ticker string) int64

LastCallAt is the time after which the stored quote no longer allows a trade, or 0 before the first quote.

Open
OID
0dd66f…cf46:34
LastCallAt details

Inspect func

freshPrice

func(ticker string) int64
Open
OID
0dd66f…cf46:35
freshPrice details

Inspect func

usdFmt

func(micro int64) string

usdFmt formats micro-USD as a dollar string with two decimals.

Open
OID
0dd66f…cf46:37
usdFmt details

Inspect func

sharesFmt

func(units int64) string

sharesFmt formats a 6-decimal token amount as a share count.

Open
OID
0dd66f…cf46:38
sharesFmt details

Inspect func

emitSpot

func(kind string, owner .uverse.address, ticker string, size int64, price int64, usd int64)
Open
OID
0dd66f…cf46:43
emitSpot details

Inspect func

emitPerpOpen

func(p *v3.perp)
Open
OID
0dd66f…cf46:44
emitPerpOpen details

Inspect func

emitPerpClose

func(p *v3.perp, kind string, size int64, mark int64, payout int64)
Open
OID
0dd66f…cf46:45
emitPerpClose details

Inspect func

emitLimit

func(kind string, o *v3.limitOrder, extra []string)
Open
OID
0dd66f…cf46:46
emitLimit details

Inspect func

emitPool

func(kind string, owner .uverse.address, usd int64, shares int64)
Open
OID
0dd66f…cf46:47
emitPool details

Inspect func

maxPage

untyped bigint

Value

(200 <untyped> bigint)

ownerTree

func(index *v0.Tree, owner .uverse.address) *v0.Tree
Open
OID
0dd66f…cf46:62
ownerTree details

Inspect func

putItem

func(all *v0.Tree, index *v0.Tree, owner .uverse.address, id uint64, item interface{...})
Open
OID
0dd66f…cf46:63
putItem details

Inspect func

dropItem

func(all *v0.Tree, index *v0.Tree, owner .uverse.address, id uint64)
Open
OID
0dd66f…cf46:64
dropItem details

Inspect func

eachOwned

func(index *v0.Tree, owner .uverse.address, cb func(...))
Open
OID
0dd66f…cf46:65
eachOwned details

Inspect func

eachPage

func(all *v0.Tree, offset int, count int, cb func(...))
Open
OID
0dd66f…cf46:66
eachPage details

Inspect func

joinRow

func(out string, row string) string
Open
OID
0dd66f…cf46:67
joinRow details

Inspect func

OpenPerpCount

func() int

OpenPerpCount and LimitCount tell the keeper how many pages to read.

Open
OID
0dd66f…cf46:68
OpenPerpCount details

Inspect func

limitOrder

type

Value

v3.limitOrder

nextLimitID

uint64

Value

0

mustLimit

func(id uint64) *v3.limitOrder
Open
OID
0dd66f…cf46:71
mustLimit details

Inspect func

PlaceLimit

func(ticker string, isLong bool, size int64, margin int64, limit int64) uint64

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

Open
OID
0dd66f…cf46:73
PlaceLimit details

Inspect func

CancelLimit

func(id uint64)

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

Open
OID
0dd66f…cf46:74
CancelLimit details

Inspect func

limitReady

func(o *v3.limitOrder, mark int64) bool

limitReady reports whether an order's trigger condition holds at \`mark\`: a long fills at or below its limit, a short at or above.

Open
OID
0dd66f…cf46:75
limitReady details

Inspect func

fillSize

func(o *v3.limitOrder, mark int64) int64

fillSize shrinks an order whose notional at the fill price would exceed the leverage its margin allows, so a price gap past the limit still fills.

Open
OID
0dd66f…cf46:76
fillSize details

Inspect func

limitFill

func(o *v3.limitOrder, mark int64) (size int64, margin int64, fee int64, refund int64)

limitFill settles the open fee on what actually fills at \`mark\`. A surplus of the prepaid fee is refunded; a shortfall comes out of the margin, and the size is capped so the smaller margin still carries it.

Open
OID
0dd66f…cf46:77
limitFill details

Inspect func

TriggerLimit

func(id uint64) uint64

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.

Open
OID
0dd66f…cf46:78
TriggerLimit details

Inspect func

LimitsOf

func(owner .uverse.address) string

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

Open
OID
0dd66f…cf46:79
LimitsOf details

Inspect func

AllLimits

func(offset int, count int) string

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.

Open
OID
0dd66f…cf46:80
AllLimits details

Inspect func

marketOpen

bool

Value

false

SetMarketOpen

func(open bool)

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

Open
OID
0dd66f…cf46:82
SetMarketOpen details

Inspect func

IsMarketOpen

func() bool

IsMarketOpen reports whether the stock market is open, as last pushed by the updater. While it is false the leverage cap is closedMaxLeverage.

Open
OID
0dd66f…cf46:84
IsMarketOpen details

Inspect func

maxInt64

uint64

Value

9223372036854775807

mulDiv

func(a int64, b int64, c int64) int64
Open
OID
0dd66f…cf46:85
mulDiv details

Inspect func

perpFeeBps

untyped bigint

// 0.10% of notional, each side (open + close)

Value

(10 <untyped> bigint)

maxLeverage

untyped bigint

// 10x: notional \<= margin \* 10

Value

(10 <untyped> bigint)

maintBps

untyped bigint

// 10% maintenance: liquidatable when equity \<= 10% of margin

Value

(1000 <untyped> bigint)

minMargin

untyped bigint

// $1 minimum margin, blocks dust

Value

(1000000 <untyped> bigint)

perpMaxNotional

untyped bigint

// $1,000,000 notional cap

Value

(1000000000000 <untyped> bigint)

maxMargin

untyped bigint

Value

(1000000000000 <untyped> bigint)

holdRateBpsYear

untyped bigint

// 10%/yr borrow fee on notional while a position is open

Value

(1000 <untyped> bigint)

secondsYear

untyped bigint

// 365d, for prorating the borrow fee

Value

(31536000 <untyped> bigint)

perp

type

Value

v3.perp

nextPerpID

uint64

Value

2

mustPerp

func(id uint64) *v3.perp
Open
OID
0dd66f…cf46:88
mustPerp details

Inspect func

perpPnL

func(p *v3.perp, mark int64) int64

perpPnL is size \* (mark - entry) / 1e6 for a long, negated for a short.

Open
OID
0dd66f…cf46:90
perpPnL details

Inspect func

perpEquity

func(p *v3.perp, mark int64) int64

equity is the position's margin plus unrealized PnL.

Open
OID
0dd66f…cf46:91
perpEquity details

Inspect func

liquidatable

func(p *v3.perp, mark int64) bool

liquidatable: equity net of the accrued borrow fee has fallen to the maintenance fraction of the margin.

Open
OID
0dd66f…cf46:92
liquidatable details

Inspect func

liqPrice

func(p *v3.perp) int64

liqPrice is the mark price at which the position becomes liquidatable.

Open
OID
0dd66f…cf46:93
liqPrice details

Inspect func

assertPerpSize

func(size int64)

assertPerpSize bounds the size so price\*size stays inside int64.

Open
OID
0dd66f…cf46:94
assertPerpSize details

Inspect func

assertMargin

func(margin int64)
Open
OID
0dd66f…cf46:95
assertMargin details

Inspect func

OpenPerp

func(ticker string, isLong bool, size int64, margin int64) uint64

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.

Open
OID
0dd66f…cf46:96
OpenPerp details

Inspect func

openPositionCore

func(owner .uverse.address, ticker string, isLong bool, size int64, margin int64, price int64, fee int64) uint64

openPositionCore validates and creates a perp, assuming \`margin\`+\`fee\` tUSD are ALREADY in the desk reserve (pulled from the owner by the caller) and not locked. Shared by market opens (OpenPerp) and limit-order execution (TriggerLimit). A panic here reverts the whole tx, including the funds pull, so nothing is stranded.

Open
OID
0dd66f…cf46:97
openPositionCore details

Inspect func

ClosePerp

func(id uint64)

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

Open
OID
0dd66f…cf46:98
ClosePerp details

Inspect func

ClosePartial

func(id uint64, closeSize int64)

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.

Open
OID
0dd66f…cf46:99
ClosePartial details

Inspect func

Liquidate

func(id uint64)

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

Open
OID
0dd66f…cf46:100
Liquidate details

Inspect func

holdingFee

func(p *v3.perp, now int64) int64

holdingFee is the borrow fee owed to the pool for keeping a position open: holdRateBpsYear of the entry notional, prorated by seconds held. It prices the pool's directional risk over time — the honest substitute for funding on an oracle-mark desk (there is no perp-vs-spot basis to correct, but the pool is still carrying the position). Overflow-safe: perYear \<= 1e11, elapsed clamped.

Open
OID
0dd66f…cf46:101
holdingFee details

Inspect func

sliceSettle

func(p *v3.perp, sz int64, mark int64, now int64) (payout int64, fee int64, hold int64, marginSlice int64)

sliceSettle computes the numbers for closing \`sz\` units of a position at \`mark\`: pro-rata margin, the slice's PnL, the close fee and the borrow fee, and the owner payout (floored at 0). Pure — no transfers — so it is unit-tested directly.

Open
OID
0dd66f…cf46:102
sliceSettle details

Inspect func

collectedFee

func(p *v3.perp, sz int64, mark int64, marginSlice int64, owed int64) int64

collectedFee caps a close's fees at the equity the closed slice still had.

Open
OID
0dd66f…cf46:103
collectedFee details

Inspect func

closePortion

func(p *v3.perp, sz int64, mark int64, kind string)

closePortion closes \`sz\` units of the position at \`mark\`: pays the owner the slice payout, routes the fees to the pool, releases the slice's open interest, and shrinks the position (or removes it when \`sz\` is the whole size). Leverage, entry and liq price of the remainder are unchanged (margin and size shrink together).

Open
OID
0dd66f…cf46:104
closePortion details

Inspect func

settlePerp

func(p *v3.perp, mark int64, kind string)

settlePerp fully closes and removes the position.

Open
OID
0dd66f…cf46:105
settlePerp details

Inspect func

PerpsOf

func(owner .uverse.address) string

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.

Open
OID
0dd66f…cf46:106
PerpsOf details

Inspect func

AllLiquidatable

func(offset int, count int) string

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

Open
OID
0dd66f…cf46:107
AllLiquidatable details

Inspect func

lockedUSD

int64

lockedUSD is tUSD the reserve holds on behalf of open positions and pending limit orders. Payouts, spot sales and pool withdrawals may only spend the rest, so a margin or an escrow can always be returned to its owner.

Value

0

LockedUSD

func() int64

LockedUSD is the part of the reserve owed back as margin and limit escrow.

Open
OID
0dd66f…cf46:113
LockedUSD details

Inspect func

defaultOICap

untyped bigint

// $250,000 of open notional per side, per market

Value

(250000000000 <untyped> bigint)

closedMaxLeverage

untyped bigint

Value

(2 <untyped> bigint)

skewImpactMaxBps

untyped bigint

// max +/-1.00% skew price impact on entry

Value

(100 <untyped> bigint)

skewScaleK

untyped bigint

// $500,000: net skew at which impact reaches the max

Value

(500000000000 <untyped> bigint)

oiLong

map[string]int64

// open long notional (micro-USD, at entry) per ticker

Open
OID
0dd66f…cf46:115
oiLong details

Inspect map

oiShort

map[string]int64

// open short notional per ticker

Open
OID
0dd66f…cf46:117
oiShort details

Inspect map

oiCapOv

map[string]int64

// per-ticker per-side cap override; 0 => default

Open
OID
0dd66f…cf46:119
oiCapOv details

Inspect map

maxLevOv

map[string]int64

// per-ticker max leverage override; 0 => global maxLeverage

Open
OID
0dd66f…cf46:121
maxLevOv details

Inspect map

openLevOf

func(ticker string) int64

openLevOf is the leverage ceiling for a market while it trades: a per-asset override if set, otherwise the global maxLeverage. Overrides may only lower it.

Open
OID
0dd66f…cf46:124
openLevOf details

Inspect func

maxLevOf

func(ticker string) int64

maxLevOf is the ceiling a new position gets right now. While the stock market is closed the quote cannot move, but the next open can gap, so new exposure is held to closedMaxLeverage until then.

Open
OID
0dd66f…cf46:125
maxLevOf details

Inspect func

sideOI

func(ticker string, isLong bool) int64
Open
OID
0dd66f…cf46:126
sideOI details

Inspect func

addOI

func(ticker string, isLong bool, notional int64)
Open
OID
0dd66f…cf46:127
addOI details

Inspect func

subOI

func(ticker string, isLong bool, notional int64)
Open
OID
0dd66f…cf46:128
subOI details

Inspect func

SetOICap

func(ticker string, perSide int64)

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

Open
OID
0dd66f…cf46:129
SetOICap details

Inspect func

SetMaxLev

func(ticker string, lev int64)

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

Open
OID
0dd66f…cf46:130
SetMaxLev details

Inspect func

OIOf

func(ticker string) string

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

Open
OID
0dd66f…cf46:131
OIOf details

Inspect func

skewImpactBps

func(ticker string, isLong bool, notional int64) int64

skewImpactBps is the entry price impact in bps for opening \`notional\` on \`isLong\`: the opener pays when they deepen the skew and fills at the oracle price when they balance it. A rebate would let an instant round trip profit.

Open
OID
0dd66f…cf46:132
skewImpactBps details

Inspect func

skewEntry

func(price int64, impBps int64, isLong bool) int64

skewEntry applies a bps impact to the oracle price to get the fill/entry price: a long fills higher and a short fills lower by \`impBps\` (worse when impBps > 0).

Open
OID
0dd66f…cf46:133
skewEntry details

Inspect func

stock

type

A stock is one synthetic-equity market: a GRC20 token (6 decimals) whose ledger the desk owns, so the desk can mint on Buy and burn on Sell.

Value

v3.stock

listStock

func(ticker string, name string)
Open
OID
0dd66f…cf46:147
listStock details

Inspect func

mustStock

func(ticker string) *v3.stock
Open
OID
0dd66f…cf46:148
mustStock details

Inspect func

StockBalance

func(ticker string, owner .uverse.address) int64
Open
OID
0dd66f…cf46:149
StockBalance details

Inspect func

StockSupply

func(ticker string) int64
Open
OID
0dd66f…cf46:150
StockSupply details

Inspect func

validateStops

func(p *v3.perp, sl int64, tp int64)

validateStops rejects stop prices on the wrong side of the current mark, which would trigger instantly, and keeps SL below TP for a long / above TP for a short. A 0 clears that leg. Prices are micro-USD per share.

Open
OID
0dd66f…cf46:151
validateStops details

Inspect func

SetStops

func(id uint64, stopLoss int64, takeProfit int64)

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.

Open
OID
0dd66f…cf46:153
SetStops details

Inspect func

stopReady

func(p *v3.perp, mark int64) bool

stopReady reports whether a position's stop-loss or take-profit has been reached at \`mark\`. Long: SL when mark \<= SL, TP when mark >= TP. Short: mirrored.

Open
OID
0dd66f…cf46:154
stopReady details

Inspect func

TriggerStop

func(id uint64)

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.

Open
OID
0dd66f…cf46:155
TriggerStop details

Inspect func

AllStops

func(offset int, count int) string

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.

Open
OID
0dd66f…cf46:156
AllStops details

Inspect func

feeBps

untyped bigint

// 0.30% desk fee each side

Value

(30 <untyped> bigint)

bpsDenom

untyped bigint

//

Value

(10000 <untyped> bigint)

microUSD

untyped bigint

// 1 tUSD = 1\_000000 micro; 1 share = 1\_000000 units

Value

(1000000 <untyped> bigint)

minTradeUnits

untyped bigint

// 0.001 share minimum, blocks dust

Value

(1000 <untyped> bigint)

maxTradeUnits

untyped bigint

// 10,000 shares max, keeps price\*amount in int64

Value

(10000000000 <untyped> bigint)

notionalMicroUSD

func(price int64, stockAmount int64) int64

notionalMicroUSD returns price \* stockAmount / 1e6 — the micro-USD value of stockAmount units (6 dp) of a stock quoted at \`price\` micro-USD per share.

Open
OID
0dd66f…cf46:157
notionalMicroUSD details

Inspect func

assertTradeSize

func(stockAmount int64)
Open
OID
0dd66f…cf46:159
assertTradeSize details

Inspect func

Buy

func(ticker string, stockAmount int64)

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.

Open
OID
0dd66f…cf46:160
Buy details

Inspect func

Sell

func(ticker string, stockAmount int64)

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

Open
OID
0dd66f…cf46:161
Sell details

Inspect func

QuoteBuy

func(ticker string, stockAmount int64) int64

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

Open
OID
0dd66f…cf46:162
QuoteBuy details

Inspect func

QuoteSell

func(ticker string, stockAmount int64) int64
Open
OID
0dd66f…cf46:163
QuoteSell details

Inspect func

SeedUSD

func(amount int64)

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.

Open
OID
0dd66f…cf46:164
SeedUSD details

Inspect func

DeskReserveUSD

func() int64

DeskReserveUSD is the desk's own tUSD balance.

Open
OID
0dd66f…cf46:165
DeskReserveUSD details

Inspect func

minPoolDeposit

untyped bigint

// $1 minimum, blocks dust shares

Value

(1000000 <untyped> bigint)

minPoolShares

untyped bigint

// a holding is zero or at least 0.1 share, so a share cannot be inflated

Value

(100000 <untyped> bigint)

feeStreamSec

untyped bigint

Value

(86400 <untyped> bigint)

poolShares

int64

// total shares outstanding

Value

0

poolAssets

int64

// micro-USD the pool is entitled to in the reserve

Value

0

poolFeesAll

int64

// cumulative fees ever routed to the pool (metrics)

Value

0

poolBals

map[.uverse.address]int64

// shares held per depositor

Open
OID
0dd66f…cf46:170
poolBals details

Inspect map

pendingFees

int64

// fees not yet part of poolAssets

Value

0

streamAt

int64

// time up to which pendingFees have been released

Value

0

streamEnd

int64

// time at which the rest is fully released

Value

0

releasedFees

func(now int64) int64
Open
OID
0dd66f…cf46:174
releasedFees details

Inspect func

accrueFee

func(fee int64)

accrueFee routes a desk fee into the pool. Called by spot and perp trading. If no one has deposited yet (poolShares == 0) the fee simply stays in the reserve as it did before — there is no one to credit.

Open
OID
0dd66f…cf46:178
accrueFee details

Inspect func

PoolDeposit

func(amount int64) int64

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.

Open
OID
0dd66f…cf46:179
PoolDeposit details

Inspect func

PoolWithdraw

func(shares int64) int64

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.

Open
OID
0dd66f…cf46:180
PoolWithdraw details

Inspect func

PoolSharePrice

func() int64

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.

Open
OID
0dd66f…cf46:181
PoolSharePrice details

Inspect func

PoolInfo

func() string

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

Open
OID
0dd66f…cf46:182
PoolInfo details

Inspect func

PoolOf

func(owner .uverse.address) string

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

Open
OID
0dd66f…cf46:183
PoolOf details

Inspect func
usd : *v0.Token Inspect
usdLedger : *v0.PrivateLedger Inspect
initUSD : func() Inspect
FaucetUSD : func() Inspect
BalanceUSD : func(owner .uverse.address) int64 Inspect
costKey : type =v3.costKey
spotCost : map[v3.costKey]int64 Inspect
addCost : func(owner .uverse.address, ticker string, paid int64) Inspect
reduceCost : func(owner .uverse.address, ticker string, sold int64, heldBefore int64) Inspect
AvgEntry : func(ticker string, owner .uverse.address) int64 Inspect
admin : .uverse.address =<gnolang.StringValue>
updater : .uverse.address =<gnolang.StringValue>
deskAddr : .uverse.address =<gnolang.StringValue>
nextTokID : v0.ID =<zero>
init.14 : func() Inspect
SetAdmin : func(a .uverse.address) Inspect
SetUpdater : func(u .uverse.address) Inspect
Admin : func() .uverse.address Inspect
Updater : func() .uverse.address Inspect
DeskAddress : func() .uverse.address Inspect
assertAdmin : func() Inspect
assertUpdater : func() Inspect
Price : type =v3.Price
prices : map[string]v3.Price Inspect
SetPrices : func(quotes string, observedAt int64) Inspect
storePrice : func(ticker string, value int64, observedAt int64) Inspect
GetPrice : func(ticker string) (int64, int64) Inspect
maxPriceAge : untyped bigint =(600 <untyped> bigint)
maxClockSkew : untyped bigint =(60 <untyped> bigint)
maxPrice : untyped bigint =(1000000000000 <untyped> bigint)
IsFresh : func(ticker string) bool Inspect
LastCallAt : func(ticker string) int64 Inspect
freshPrice : func(ticker string) int64 Inspect
Render : func(path string) string Inspect
usdFmt : func(micro int64) string Inspect
sharesFmt : func(units int64) string Inspect
num : func(v int64) string Inspect
ref : func(v uint64) string Inspect
sideOf : func(isLong bool) string Inspect
emitSpot : func(kind string, owner .uverse.address, ticker string, size int64, price int64, usd int64) Inspect
emitPerpOpen : func(p *v3.perp) Inspect
emitPerpClose : func(p *v3.perp, kind string, size int64, mark int64, payout int64) Inspect
emitLimit : func(kind string, o *v3.limitOrder, extra []string) Inspect
emitPool : func(kind string, owner .uverse.address, usd int64, shares int64) Inspect
maxPage : untyped bigint =(200 <untyped> bigint)
perps : *v0.Tree Inspect
ownerPerps : *v0.Tree Inspect
limits : *v0.Tree Inspect
ownerLimits : *v0.Tree Inspect
idKey : func(id uint64) string Inspect
ownerTree : func(index *v0.Tree, owner .uverse.address) *v0.Tree Inspect
putItem : func(all *v0.Tree, index *v0.Tree, owner .uverse.address, id uint64, item interface{...}) Inspect
dropItem : func(all *v0.Tree, index *v0.Tree, owner .uverse.address, id uint64) Inspect
eachOwned : func(index *v0.Tree, owner .uverse.address, cb func(...)) Inspect
eachPage : func(all *v0.Tree, offset int, count int, cb func(...)) Inspect
joinRow : func(out string, row string) string Inspect
OpenPerpCount : func() int Inspect
LimitCount : func() int Inspect
limitOrder : type =v3.limitOrder
nextLimitID : uint64 =0
mustLimit : func(id uint64) *v3.limitOrder Inspect
PlaceLimit : func(ticker string, isLong bool, size int64, margin int64, limit int64) uint64 Inspect
CancelLimit : func(id uint64) Inspect
limitReady : func(o *v3.limitOrder, mark int64) bool Inspect
fillSize : func(o *v3.limitOrder, mark int64) int64 Inspect
limitFill : func(o *v3.limitOrder, mark int64) (size int64, margin int64, fee int64, refund int64) Inspect
TriggerLimit : func(id uint64) uint64 Inspect
LimitsOf : func(owner .uverse.address) string Inspect
AllLimits : func(offset int, count int) string Inspect
marketOpen : bool =false
SetMarketOpen : func(open bool) Inspect
IsMarketOpen : func() bool Inspect
maxInt64 : uint64 =9223372036854775807
mulDiv : func(a int64, b int64, c int64) int64 Inspect
perpFeeBps : untyped bigint =(10 <untyped> bigint)
maxLeverage : untyped bigint =(10 <untyped> bigint)
maintBps : untyped bigint =(1000 <untyped> bigint)
minMargin : untyped bigint =(1000000 <untyped> bigint)
perpMaxNotional : untyped bigint =(1000000000000 <untyped> bigint)
maxMargin : untyped bigint =(1000000000000 <untyped> bigint)
holdRateBpsYear : untyped bigint =(1000 <untyped> bigint)
secondsYear : untyped bigint =(31536000 <untyped> bigint)
perp : type =v3.perp
nextPerpID : uint64 =2
mustPerp : func(id uint64) *v3.perp Inspect
perpPnL : func(p *v3.perp, mark int64) int64 Inspect
perpEquity : func(p *v3.perp, mark int64) int64 Inspect
liquidatable : func(p *v3.perp, mark int64) bool Inspect
liqPrice : func(p *v3.perp) int64 Inspect
assertPerpSize : func(size int64) Inspect
assertMargin : func(margin int64) Inspect
OpenPerp : func(ticker string, isLong bool, size int64, margin int64) uint64 Inspect
openPositionCore : func(owner .uverse.address, ticker string, isLong bool, size int64, margin int64, price int64, fee int64) uint64 Inspect
ClosePerp : func(id uint64) Inspect
ClosePartial : func(id uint64, closeSize int64) Inspect
Liquidate : func(id uint64) Inspect
holdingFee : func(p *v3.perp, now int64) int64 Inspect
sliceSettle : func(p *v3.perp, sz int64, mark int64, now int64) (payout int64, fee int64, hold int64, marginSlice int64) Inspect
collectedFee : func(p *v3.perp, sz int64, mark int64, marginSlice int64, owed int64) int64 Inspect
closePortion : func(p *v3.perp, sz int64, mark int64, kind string) Inspect
settlePerp : func(p *v3.perp, mark int64, kind string) Inspect
PerpsOf : func(owner .uverse.address) string Inspect
AllLiquidatable : func(offset int, count int) string Inspect
lockedUSD : int64 =0
lock : func(amount int64) Inspect
unlock : func(amount int64) Inspect
freeReserve : func() int64 Inspect
LockedUSD : func() int64 Inspect
defaultOICap : untyped bigint =(250000000000 <untyped> bigint)
closedMaxLeverage : untyped bigint =(2 <untyped> bigint)
skewImpactMaxBps : untyped bigint =(100 <untyped> bigint)
skewScaleK : untyped bigint =(500000000000 <untyped> bigint)
oiLong : map[string]int64 Inspect
oiShort : map[string]int64 Inspect
oiCapOv : map[string]int64 Inspect
maxLevOv : map[string]int64 Inspect
oiCap : func(ticker string) int64 Inspect
openLevOf : func(ticker string) int64 Inspect
maxLevOf : func(ticker string) int64 Inspect
sideOI : func(ticker string, isLong bool) int64 Inspect
addOI : func(ticker string, isLong bool, notional int64) Inspect
subOI : func(ticker string, isLong bool, notional int64) Inspect
SetOICap : func(ticker string, perSide int64) Inspect
SetMaxLev : func(ticker string, lev int64) Inspect
OIOf : func(ticker string) string Inspect
skewImpactBps : func(ticker string, isLong bool, notional int64) int64 Inspect
skewEntry : func(price int64, impBps int64, isLong bool) int64 Inspect
stock : type =v3.stock
stocks : map[string]*v3.stock Inspect
tickers : []string (len=5) Inspect
defaultMarkets : []struct{...} (len=5) Inspect
initStocks : func() Inspect
listStock : func(ticker string, name string) Inspect
mustStock : func(ticker string) *v3.stock Inspect
StockBalance : func(ticker string, owner .uverse.address) int64 Inspect
StockSupply : func(ticker string) int64 Inspect
validateStops : func(p *v3.perp, sl int64, tp int64) Inspect
SetStops : func(id uint64, stopLoss int64, takeProfit int64) Inspect
stopReady : func(p *v3.perp, mark int64) bool Inspect
TriggerStop : func(id uint64) Inspect
AllStops : func(offset int, count int) string Inspect
feeBps : untyped bigint =(30 <untyped> bigint)
bpsDenom : untyped bigint =(10000 <untyped> bigint)
microUSD : untyped bigint =(1000000 <untyped> bigint)
minTradeUnits : untyped bigint =(1000 <untyped> bigint)
maxTradeUnits : untyped bigint =(10000000000 <untyped> bigint)
notionalMicroUSD : func(price int64, stockAmount int64) int64 Inspect
assertTradeSize : func(stockAmount int64) Inspect
Buy : func(ticker string, stockAmount int64) Inspect
Sell : func(ticker string, stockAmount int64) Inspect
QuoteBuy : func(ticker string, stockAmount int64) int64 Inspect
QuoteSell : func(ticker string, stockAmount int64) int64 Inspect
SeedUSD : func(amount int64) Inspect
DeskReserveUSD : func() int64 Inspect
minPoolDeposit : untyped bigint =(1000000 <untyped> bigint)
minPoolShares : untyped bigint =(100000 <untyped> bigint)
feeStreamSec : untyped bigint =(86400 <untyped> bigint)
poolShares : int64 =0
poolAssets : int64 =0
poolFeesAll : int64 =0
poolBals : map[.uverse.address]int64 Inspect
pendingFees : int64 =0
streamAt : int64 =0
streamEnd : int64 =0
releasedFees : func(now int64) int64 Inspect
drip : func(now int64) Inspect
assetsNow : func() int64 Inspect
accrueFee : func(fee int64) Inspect
PoolDeposit : func(amount int64) int64 Inspect
PoolWithdraw : func(shares int64) int64 Inspect
PoolSharePrice : func() int64 Inspect
PoolInfo : func() string Inspect
PoolOf : func(owner .uverse.address) string Inspect