usd
*v0.TokentUSD 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.
- OID
- 0c7b0a…bdec:235
usd details
usdLedger
*v0.PrivateLedgertUSD 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.
- OID
- 0c7b0a…bdec:237
usdLedger details
initUSD
func()- OID
- 0c7b0a…bdec:5
initUSD details
FaucetUSD
func()FaucetUSD mints 10,000 tUSD to the caller. Open faucet — demo only.
- OID
- 0c7b0a…bdec:7
FaucetUSD details
BalanceUSD
func(owner .uverse.address) int64- OID
- 0c7b0a…bdec:8
BalanceUSD details
costKey
typeValue
v4.costKey
spotCost
map[v4.costKey]int64- OID
- 0c7b0a…bdec:10
spotCost details
addCost
func(owner .uverse.address, ticker string, paid int64)addCost records the tUSD notional (micro) a buyer paid toward their cost basis.
- OID
- 0c7b0a…bdec:11
addCost details
costOf
func(owner .uverse.address, ticker string) int64- OID
- 0c7b0a…bdec:13
costOf details
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.
- OID
- 0c7b0a…bdec:14
reduceCost details
AvgEntry
func(ticker string, owner .uverse.address) int64AvgEntry returns the owner's average entry price for ticker in micro-USD per share, or 0 if they hold none.
- OID
- 0c7b0a…bdec:15
AvgEntry details
AddMargin
func(id uint64, amount int64)AddMargin adds \`amount\` tUSD micro from the caller to their own position, lowering its leverage. It trades nothing, so it applies at once.
- OID
- 0c7b0a…bdec:16
AddMargin details
overLeveraged
func(p *v4.perp, mark int64) bool- OID
- 0c7b0a…bdec:18
overLeveraged details
Delever
func(id uint64)Delever cuts a position held above closedMaxLeverage while the market is closed, at the desk price, to the size its margin carries at that leverage. Permissionless.
- OID
- 0c7b0a…bdec:19
Delever details
deleverSize
func(p *v4.perp, mark int64, now int64) int64- OID
- 0c7b0a…bdec:20
deleverSize details
cutToMargin
func(p *v4.perp, sz int64, mark int64)- OID
- 0c7b0a…bdec:21
cutToMargin details
Overleveraged
func(offset int, count int) stringOverleveraged lists, within one page of open positions, the ids Delever would cut now, ';'-joined, for the keeper. Empty while the market is open.
- OID
- 0c7b0a…bdec:22
Overleveraged details
admin
.uverse.addressValue
<gnolang.StringValue>
deskAddr
.uverse.addressValue
<gnolang.StringValue>
nextTokID
v0.IDValue
<zero>
init.20
func()- OID
- 0c7b0a…bdec:26
init.20 details
SetAdmin
func(a .uverse.address)- OID
- 0c7b0a…bdec:28
SetAdmin details
Admin
func() .uverse.address- OID
- 0c7b0a…bdec:29
Admin details
DeskAddress
func() .uverse.address- OID
- 0c7b0a…bdec:30
DeskAddress details
assertAdmin
func()- OID
- 0c7b0a…bdec:31
assertAdmin details
Render
func(path string) string- OID
- 0c7b0a…bdec:32
Render details
usdFmt
func(micro int64) stringusdFmt formats micro-USD as a dollar string with two decimals.
- OID
- 0c7b0a…bdec:33
usdFmt details
sharesFmt
func(units int64) stringsharesFmt formats a 6-decimal token amount as a share count.
- OID
- 0c7b0a…bdec:34
sharesFmt details
num
func(v int64) string- OID
- 0c7b0a…bdec:35
num details
ref
func(v uint64) string- OID
- 0c7b0a…bdec:37
ref details
sideOf
func(isLong bool) string- OID
- 0c7b0a…bdec:38
sideOf details
emitSpot
func(kind string, owner .uverse.address, ticker string, size int64, price int64, usd int64)- OID
- 0c7b0a…bdec:39
emitSpot details
emitPerpOpen
func(p *v4.perp)- OID
- 0c7b0a…bdec:40
emitPerpOpen details
emitPerpClose
func(p *v4.perp, kind string, size int64, mark int64, payout int64)- OID
- 0c7b0a…bdec:41
emitPerpClose details
emitOrder
func(kind string, o *v4.order, extra []string)- OID
- 0c7b0a…bdec:42
emitOrder details
emitPerp
func(kind string, p *v4.perp, extra []string)- OID
- 0c7b0a…bdec:43
emitPerp details
emitPool
func(kind string, owner .uverse.address, usd int64, shares int64)- OID
- 0c7b0a…bdec:44
emitPool details
Price
typePrice is quoted in micro-USD per whole share.
Value
v4.Price
maxPriceAge
untyped bigintValue
(600 <untyped> bigint)
maxClockSkew
untyped bigintValue
(60 <untyped> bigint)
maxPrice
untyped bigintValue
(1000000000000 <untyped> bigint)
quoteWindow
untyped bigintValue
(120 <untyped> bigint)
agreeBps
untyped bigintValue
(100 <untyped> bigint)
maxUpdaters
untyped bigintValue
(7 <untyped> bigint)
updaters
[].uverse.address- OID
- 0c7b0a…bdec:286
updaters details
quorum
intValue
2
prices
map[string]v4.Price- OID
- 0c7b0a…bdec:48
prices details
submitted
map[string]map[.uverse.address]v4.Price- OID
- 0c7b0a…bdec:50
submitted details
openVotes
map[.uverse.address]bool- OID
- 0c7b0a…bdec:52
openVotes details
marketOpen
boolValue
false
openedAt
int64Value
0
AddUpdater
func(u .uverse.address)- OID
- 0c7b0a…bdec:55
AddUpdater details
RemoveUpdater
func(u .uverse.address)- OID
- 0c7b0a…bdec:57
RemoveUpdater details
SetQuorum
func(n int)- OID
- 0c7b0a…bdec:58
SetQuorum details
Updaters
func() stringUpdaters lists the updater addresses, comma-separated.
- OID
- 0c7b0a…bdec:59
Updaters details
Quorum
func() int- OID
- 0c7b0a…bdec:60
Quorum details
isUpdater
func(a .uverse.address) bool- OID
- 0c7b0a…bdec:61
isUpdater details
assertUpdater
func() .uverse.address- OID
- 0c7b0a…bdec:62
assertUpdater details
SetPrices
func(quotes string, observedAt int64)SetPrices records the caller's quotes, "TICKER:microUSD" pairs joined by ',', all observed at observedAt, and forms a desk price where a quorum agrees. A stamp ahead of the block time is lowered to it, so no price is ever dated after a request that could already see it.
- OID
- 0c7b0a…bdec:63
SetPrices details
submit
func(from .uverse.address, ticker string, value int64, observedAt int64)- OID
- 0c7b0a…bdec:64
submit details
aggregate
func(ticker string)- OID
- 0c7b0a…bdec:65
aggregate details
median
func(vals []int64) int64- OID
- 0c7b0a…bdec:66
median details
GetPrice
func(ticker string) (int64, int64)GetPrice returns the desk price for a ticker and its observation time. Panics if unknown.
- OID
- 0c7b0a…bdec:67
GetPrice details
IsFresh
func(ticker string) boolIsFresh reports whether a ticker has a price young enough to trade against.
- OID
- 0c7b0a…bdec:68
IsFresh details
LastCallAt
func(ticker string) int64LastCallAt is the time after which the stored price no longer allows a trade, or 0 before the first price.
- OID
- 0c7b0a…bdec:69
LastCallAt details
freshPrice
func(ticker string) int64- OID
- 0c7b0a…bdec:70
freshPrice details
pricedAfter
func(ticker string, t int64) boolpricedAfter reports whether the ticker's price was observed after t, so a request made at t may fill on it.
- OID
- 0c7b0a…bdec:71
pricedAfter details
SetMarketOpen
func(open bool)SetMarketOpen records the caller's view of the US stock market.
- OID
- 0c7b0a…bdec:72
SetMarketOpen details
MarketVoteOf
func(u .uverse.address) stringMarketVoteOf returns an updater's recorded view of the market: "open", "closed" or "none".
- OID
- 0c7b0a…bdec:73
MarketVoteOf details
tallyMarket
func()- OID
- 0c7b0a…bdec:74
tallyMarket details
IsMarketOpen
func() boolIsMarketOpen reports whether a quorum of updaters say the stock market is open. While it is not, new perps are held to closedMaxLeverage and positions above it can be cut down to it (Delever). A limit above that leverage fills only on a price observed after the open, never on the last pre-open quote.
- OID
- 0c7b0a…bdec:75
IsMarketOpen details
maxPage
untyped bigintValue
(200 <untyped> bigint)
perps
*v0.Tree- OID
- 0c7b0a…bdec:77
perps details
ownerPerps
*v0.Tree- OID
- 0c7b0a…bdec:80
ownerPerps details
orders
*v0.Tree- OID
- 0c7b0a…bdec:83
orders details
ownerOrders
*v0.Tree- OID
- 0c7b0a…bdec:86
ownerOrders details
idKey
func(id uint64) string- OID
- 0c7b0a…bdec:88
idKey details
ownerTree
func(index *v0.Tree, owner .uverse.address) *v0.Tree- OID
- 0c7b0a…bdec:90
ownerTree details
putItem
func(all *v0.Tree, index *v0.Tree, owner .uverse.address, id uint64, item interface{...})- OID
- 0c7b0a…bdec:91
putItem details
dropItem
func(all *v0.Tree, index *v0.Tree, owner .uverse.address, id uint64)- OID
- 0c7b0a…bdec:92
dropItem details
eachOwned
func(index *v0.Tree, owner .uverse.address, cb func(...))- OID
- 0c7b0a…bdec:93
eachOwned details
eachPage
func(all *v0.Tree, offset int, count int, cb func(...))- OID
- 0c7b0a…bdec:94
eachPage details
joinRow
func(out string, row string) string- OID
- 0c7b0a…bdec:95
joinRow details
OpenPerpCount
func() intOpenPerpCount and OrderCount tell the keeper how many pages to read.
- OID
- 0c7b0a…bdec:96
OpenPerpCount details
OrderCount
func() int- OID
- 0c7b0a…bdec:97
OrderCount details
maxInt64
uint64Value
9223372036854775807
mulDiv
func(a int64, b int64, c int64) int64- OID
- 0c7b0a…bdec:98
mulDiv details
marketBandBps
untyped bigintValue
(200 <untyped> bigint)
orderTTL
untyped bigintValue
(900 <untyped> bigint)
order
typeValue
v4.order
nextOrderID
uint64Value
2
results
*v0.Tree- OID
- 0c7b0a…bdec:102
results details
mustOrder
func(id uint64) *v4.order- OID
- 0c7b0a…bdec:104
mustOrder details
isPerpOrder
func(o *v4.order) bool- OID
- 0c7b0a…bdec:106
isPerpOrder details
bandPrice
func(mark int64, worseUp bool) int64- OID
- 0c7b0a…bdec:107
bandPrice details
pull
func(from .uverse.address, amount int64)- OID
- 0c7b0a…bdec:108
pull details
pay
func(to .uverse.address, amount int64)- OID
- 0c7b0a…bdec:109
pay details
queue
func(o *v4.order) uint64- OID
- 0c7b0a…bdec:110
queue details
OpenPerp
func(ticker string, isLong bool, size int64, margin int64) uint64OpenPerp places a market order for a long or short of \`size\` stock units (6 dp) backed by \`margin\` tUSD micro, plus the open fee. It fills on the next price if that is within marketBandBps of the price now, else it is refunded. Returns the order id; the position id comes with the OrderFill event.
- OID
- 0c7b0a…bdec:111
OpenPerp details
openMarket
func(owner .uverse.address, ticker string, isLong bool, size int64, margin int64) uint64- OID
- 0c7b0a…bdec:112
openMarket details
PlaceLimit
func(ticker string, isLong bool, size int64, margin int64, limit int64) uint64PlaceLimit places an order to open a perp once the desk price reaches \`limit\` (long: at or below, short: at or above). Returns the order id.
- OID
- 0c7b0a…bdec:113
PlaceLimit details
placePerp
func(owner .uverse.address, kind string, ticker string, isLong bool, size int64, margin int64, limit int64, ref int64, lev int64) uint64- OID
- 0c7b0a…bdec:114
placePerp details
Buy
func(ticker string, stockAmount int64) uint64Buy places an order for stockAmount units (6 dp) of sTicker. It locks the cost at the worst price it accepts and refunds the difference when it fills. Returns the order id.
- OID
- 0c7b0a…bdec:115
Buy details
Sell
func(ticker string, stockAmount int64) uint64Sell places an order to sell stockAmount units of sTicker. The shares are burned now and minted back if the order is refunded. Returns the order id.
- OID
- 0c7b0a…bdec:116
Sell details
CancelOrder
func(id uint64)CancelOrder refunds the caller's pending limit order. Market orders, buys and sells cannot be cancelled: they fill or are refunded on the next price.
- OID
- 0c7b0a…bdec:117
CancelOrder details
FillOrder
func(id uint64) uint64FillOrder executes an order on the first price observed after it was placed, or refunds a market order, buy or sell that the price moved past or that waited longer than orderTTL. Permissionless. Returns the new position id for a perp order that filled, otherwise 0.
- OID
- 0c7b0a…bdec:118
FillOrder details
fillOrder
func(id uint64) uint64- OID
- 0c7b0a…bdec:119
fillOrder details
limitReady
func(o *v4.order, mark int64) bool- OID
- 0c7b0a…bdec:120
limitReady details
waitsForOpen
func(o *v4.order) bool- OID
- 0c7b0a…bdec:121
waitsForOpen details
perpFill
typeValue
v4.perpFill
quotePerp
func(o *v4.order, mark int64) (v4.perpFill, string)- OID
- 0c7b0a…bdec:122
quotePerp details
fillable
func(o *v4.order) bool- OID
- 0c7b0a…bdec:123
fillable details
fillPerp
func(o *v4.order, mark int64) uint64- OID
- 0c7b0a…bdec:124
fillPerp details
fillSize
func(o *v4.order, mark int64) int64- OID
- 0c7b0a…bdec:125
fillSize details
limitFill
func(o *v4.order, mark int64) (size int64, margin int64, fee int64, refund int64)- OID
- 0c7b0a…bdec:126
limitFill details
fillBuy
func(o *v4.order, mark int64)- OID
- 0c7b0a…bdec:127
fillBuy details
fillSell
func(o *v4.order, mark int64)- OID
- 0c7b0a…bdec:128
fillSell details
refund
func(o *v4.order, reason string)- OID
- 0c7b0a…bdec:129
refund details
done
func(o *v4.order, result string)- OID
- 0c7b0a…bdec:130
done details
OrderStatus
func(id uint64) stringOrderStatus is "pending", "filled", "filled:\<position id>" for a perp order, "refunded:\<reason>", or "unknown".
- OID
- 0c7b0a…bdec:131
OrderStatus details
OrdersOf
func(owner .uverse.address) stringOrdersOf returns an owner's pending orders, ';'-joined, fields comma-separated: id,kind,ticker,L|S,size,margin,limit,mark,placedAt (money and size at 6 dp).
- OID
- 0c7b0a…bdec:132
OrdersOf details
ReadyOrders
func(offset int, count int) stringReadyOrders lists, within one page of pending orders, the ids FillOrder would act on now, ';'-joined, for the keeper.
- OID
- 0c7b0a…bdec:133
ReadyOrders details
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 bigintValue
(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
typeValue
v4.perp
nextPerpID
uint64Value
2
mustPerp
func(id uint64) *v4.perp- OID
- 0c7b0a…bdec:135
mustPerp details
perpPnL
func(p *v4.perp, mark int64) int64perpPnL is size \* (mark - entry) / 1e6 for a long, negated for a short.
- OID
- 0c7b0a…bdec:137
perpPnL details
perpEquity
func(p *v4.perp, mark int64) int64equity is the position's margin plus unrealized PnL.
- OID
- 0c7b0a…bdec:138
perpEquity details
liquidatable
func(p *v4.perp, mark int64) boolliquidatable: equity net of the accrued borrow fee has fallen to the maintenance fraction of the margin.
- OID
- 0c7b0a…bdec:139
liquidatable details
liqPrice
func(p *v4.perp) int64liqPrice is the mark price at which the position becomes liquidatable.
- OID
- 0c7b0a…bdec:140
liqPrice details
assertPerpSize
func(size int64)assertPerpSize bounds the size so price\*size stays inside int64.
- OID
- 0c7b0a…bdec:141
assertPerpSize details
assertMargin
func(margin int64)- OID
- 0c7b0a…bdec:142
assertMargin details
openPositionCore
func(owner .uverse.address, ticker string, isLong bool, size int64, margin int64, price int64, fee int64) uint64openPositionCore validates and creates a perp, assuming \`margin\`+\`fee\` tUSD are ALREADY in the desk reserve and not locked. Called when a perp order fills (FillOrder). A panic here reverts the whole tx, so nothing is stranded.
- OID
- 0c7b0a…bdec:143
openPositionCore details
ClosePerp
func(id uint64)ClosePerp asks to close the caller's whole position. It closes on the first price observed after the request (FillClose).
- OID
- 0c7b0a…bdec:144
ClosePerp details
ClosePartial
func(id uint64, closeSize int64)ClosePartial asks to close \`closeSize\` units (6 dp) of the caller's position on the first price observed after the request. Allowed while the market is closed.
- OID
- 0c7b0a…bdec:145
ClosePartial details
requestClose
func(owner .uverse.address, id uint64, size int64)- OID
- 0c7b0a…bdec:146
requestClose details
closingSize
func(p *v4.perp) int64- OID
- 0c7b0a…bdec:147
closingSize details
FillClose
func(id uint64)FillClose closes a requested position on the first price observed after the request, or drops a request that waited longer than orderTTL. Permissionless.
- OID
- 0c7b0a…bdec:148
FillClose details
fillClose
func(id uint64)- OID
- 0c7b0a…bdec:149
fillClose details
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.
- OID
- 0c7b0a…bdec:150
Liquidate details
holdingFee
func(p *v4.perp, now int64) int64holdingFee 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.
- OID
- 0c7b0a…bdec:151
holdingFee details
sliceSettle
func(p *v4.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.
- OID
- 0c7b0a…bdec:152
sliceSettle details
collectedFee
func(p *v4.perp, sz int64, mark int64, marginSlice int64, owed int64) int64collectedFee caps a close's fees at the equity the closed slice still had.
- OID
- 0c7b0a…bdec:153
collectedFee details
closePortion
func(p *v4.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).
- OID
- 0c7b0a…bdec:154
closePortion details
settlePerp
func(p *v4.perp, mark int64, kind string)settlePerp fully closes and removes the position.
- OID
- 0c7b0a…bdec:155
settlePerp details
PerpsOf
func(owner .uverse.address) stringPerpsOf returns the caller's open positions, one per line, fields comma- separated: id,ticker,L|S,size,entry,margin,mark,pnl,liq,stopLoss,takeProfit,closing. Money and size are integers at 6 dp; mark/pnl/liq are computed live. Stop prices are 0 when unset; closing is the size of a close waiting for the next price.
- OID
- 0c7b0a…bdec:156
PerpsOf details
AllLiquidatable
func(offset int, count int) stringAllLiquidatable lists, within one page of open positions, the ids at or below maintenance on a fresh quote, ';'-joined, for the keeper.
- OID
- 0c7b0a…bdec:157
AllLiquidatable details
ReadyCloses
func(offset int, count int) stringReadyCloses lists, within one page of open positions, the ids FillClose would act on now, ';'-joined, for the keeper.
- OID
- 0c7b0a…bdec:158
ReadyCloses details
lockedUSD
int64lockedUSD 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
lock
func(amount int64)- OID
- 0c7b0a…bdec:160
lock details
unlock
func(amount int64)- OID
- 0c7b0a…bdec:162
unlock details
freeReserve
func() int64- OID
- 0c7b0a…bdec:163
freeReserve details
LockedUSD
func() int64LockedUSD is the part of the reserve owed back as margin and limit escrow.
- OID
- 0c7b0a…bdec:164
LockedUSD details
defaultOICap
untyped bigint// $250,000 of open notional per side, per market
Value
(250000000000 <untyped> bigint)
closedMaxLeverage
untyped bigintValue
(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
- OID
- 0c7b0a…bdec:166
oiLong details
oiShort
map[string]int64// open short notional per ticker
- OID
- 0c7b0a…bdec:168
oiShort details
oiCapOv
map[string]int64// per-ticker per-side cap override; 0 => default
- OID
- 0c7b0a…bdec:170
oiCapOv details
maxLevOv
map[string]int64// per-ticker max leverage override; 0 => global maxLeverage
- OID
- 0c7b0a…bdec:172
maxLevOv details
oiCap
func(ticker string) int64- OID
- 0c7b0a…bdec:173
oiCap details
openLevOf
func(ticker string) int64openLevOf 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.
- OID
- 0c7b0a…bdec:175
openLevOf details
maxLevOf
func(ticker string) int64maxLevOf 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.
- OID
- 0c7b0a…bdec:176
maxLevOf details
sideOI
func(ticker string, isLong bool) int64- OID
- 0c7b0a…bdec:177
sideOI details
addOI
func(ticker string, isLong bool, notional int64)- OID
- 0c7b0a…bdec:178
addOI details
subOI
func(ticker string, isLong bool, notional int64)- OID
- 0c7b0a…bdec:179
subOI details
SetOICap
func(ticker string, perSide int64)SetOICap sets the per-side open-interest cap for a market (micro-USD). 0 restores the default.
- OID
- 0c7b0a…bdec:180
SetOICap details
SetMaxLev
func(ticker string, lev int64)SetMaxLev lowers (never raises) the max leverage for a market. 0 restores the global default.
- OID
- 0c7b0a…bdec:181
SetMaxLev details
OIOf
func(ticker string) stringOIOf returns a market's open-interest state, comma-separated: oiLong,oiShort,capPerSide,maxLev (notional micro-USD; maxLev a plain integer).
- OID
- 0c7b0a…bdec:182
OIOf details
skewImpactBps
func(ticker string, isLong bool, notional int64) int64skewImpactBps 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.
- OID
- 0c7b0a…bdec:183
skewImpactBps details
skewEntry
func(price int64, impBps int64, isLong bool) int64skewEntry 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).
- OID
- 0c7b0a…bdec:184
skewEntry details
stock
typeA 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
v4.stock
stocks
map[string]*v4.stock- OID
- 0c7b0a…bdec:186
stocks details
tickers
[]string// insertion order, for Render
- OID
- 0c7b0a…bdec:281
tickers details
defaultMarkets
[]struct{...}- OID
- 0c7b0a…bdec:190
defaultMarkets details
initStocks
func()- OID
- 0c7b0a…bdec:196
initStocks details
listStock
func(ticker string, name string)- OID
- 0c7b0a…bdec:198
listStock details
mustStock
func(ticker string) *v4.stock- OID
- 0c7b0a…bdec:199
mustStock details
StockBalance
func(ticker string, owner .uverse.address) int64- OID
- 0c7b0a…bdec:200
StockBalance details
StockSupply
func(ticker string) int64- OID
- 0c7b0a…bdec:201
StockSupply details
validateStops
func(p *v4.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.
- OID
- 0c7b0a…bdec:202
validateStops details
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.
- OID
- 0c7b0a…bdec:204
SetStops details
stopFillable
func(p *v4.perp) bool- OID
- 0c7b0a…bdec:205
stopFillable details
stopReady
func(p *v4.perp, mark int64) boolstopReady 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.
- OID
- 0c7b0a…bdec:206
stopReady details
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.
- OID
- 0c7b0a…bdec:207
TriggerStop details
ReadyStops
func(offset int, count int) stringReadyStops lists, within one page of open positions, the ids whose stop TriggerStop would act on now, ';'-joined, for the keeper.
- OID
- 0c7b0a…bdec:208
ReadyStops details
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) int64notionalMicroUSD returns price \* stockAmount / 1e6 — the micro-USD value of stockAmount units (6 dp) of a stock quoted at \`price\` micro-USD per share.
- OID
- 0c7b0a…bdec:209
notionalMicroUSD details
assertTradeSize
func(stockAmount int64)- OID
- 0c7b0a…bdec:211
assertTradeSize details
QuoteBuy
func(ticker string, stockAmount int64) int64QuoteBuy / QuoteSell are read-only helpers for the UI: the tUSD cost/proceeds of trading stockAmount units at the current price.
- OID
- 0c7b0a…bdec:212
QuoteBuy details
QuoteSell
func(ticker string, stockAmount int64) int64- OID
- 0c7b0a…bdec:213
QuoteSell details
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.
- OID
- 0c7b0a…bdec:214
SeedUSD details
DeskReserveUSD
func() int64DeskReserveUSD is the desk's own tUSD balance.
- OID
- 0c7b0a…bdec:215
DeskReserveUSD details
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 bigintValue
(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
- OID
- 0c7b0a…bdec:220
poolBals details
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- OID
- 0c7b0a…bdec:224
releasedFees details
drip
func(now int64)- OID
- 0c7b0a…bdec:226
drip details
assetsNow
func() int64- OID
- 0c7b0a…bdec:227
assetsNow details
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.
- OID
- 0c7b0a…bdec:228
accrueFee details
PoolDeposit
func(amount int64) int64PoolDeposit pulls \`amount\` tUSD micro from the caller into the desk reserve and mints pool shares at the current share price. Returns the shares minted.
- OID
- 0c7b0a…bdec:229
PoolDeposit details
PoolWithdraw
func(shares int64) int64PoolWithdraw 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.
- OID
- 0c7b0a…bdec:230
PoolWithdraw details
PoolSharePrice
func() int64PoolSharePrice 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.
- OID
- 0c7b0a…bdec:231
PoolSharePrice details
PoolInfo
func() stringPoolInfo returns pool-wide figures, comma-separated: totalShares,poolAssets,feesAll,deskReserve (all micro, 6 dp).
- OID
- 0c7b0a…bdec:232
PoolInfo details
PoolOf
func(owner .uverse.address) stringPoolOf returns one depositor's position, comma-separated: shares,assets where assets is the current tUSD micro value of those shares.
- OID
- 0c7b0a…bdec:233