Typescript SDK
State
Markets
Markets information is accessible through zoUser as well:
const markets = zoUser.markets
const solMarket = zoUser.markets['SOL-PERP']
{
symbol: 'SOL-PERP',
pubKey: PublicKey,
indexPrice: new Num(50,...),
indexTwap: new Num(50,...),
markTwap: new Num(50,...),
markPrice: new Num(50,...),
baseImf: 0.1,
pmmf: 0.05,
fundingIndex: 988.533629,
marketType: 0,
assetDecimals: 9,
assetLotSize: 7,
quoteLotSize: 2,
strike: 0
}
symbol: market symbol
pubKey: market address
indexPrice - index price
indexTwap - index twap
markPrice - mark price
markTwap - mark twap
baseImf - base initial margin fraction
pmmf- position maintenance margin fraction
fundingIndex - last funding index recorded
marketType - market type differentiating between perps, powers and evers
assetDecimals - asset decimals
assetLotSize - asset lot size
quoteLotSize - quote lot size
strike - related to powers and everlasting options
Assets
const assets = zoUser.assets
const solAsset = zoUser.assets['SOL']
console.log(solAsset)
{
mint: PublicKey,
oracleSymbol: 'SOL',
decimals: 9,
weight: 900,
liqFee: 25,
isBorrowable: true,
optimalUtil: 700,
optimalRate: 64,
maxRate: 1064,
ogFee: 0,
isSwappable: true,
serumOpenOrders: PublicKey,
maxDeposit: 1000,
dustThreshold: new Num(...,...),
symbol: 'SOL',
indexPrice: new Num(...,...),
vault: PublicKey,
supply: 65775.830278919,
borrows: 59.038039678,
supplyApy: 0.0000073656845170352596,
borrowsApy: 0.008206302535162111
}
mint - mint address
oracleSymbol - oracle symbol
decimals - decimals
weight - weight of the asset when collateral is calculated
liqFee - fee given to the liquidators during liquidations
isBorrowable - if asset is borrowable
optimalUtil - optimal utilization
optimalRate - optimal rate
maxRate - max rate
ogFee - origination fee
isSwappable - if asset is swappable
serumOpenOrders - serum oo address
maxDeposit - maximum depositable amount
dustThreshold - dust threshold, used in bankruptcy calculations
symbol - symbol
indexPrice - index price
vault - vault address
supply - total supplied
borrows - total borrowed
supplyApy - supply earned each hour in bps
borrowsApy - paid by borrowers each hour in bps
Orderbook
Orderbooks are not loaded by default to make the load experience faster.
However, it is possible to load the specific orderbook, or subscribe to the changes.
const {asks, bids} = await zoUser.getOrderbook('SOL-PERP')
console.log(asks)
[
[ 40.43, 0.01 ],
[ 40.48, 1.65 ],
...
]
console.log(bids)
[
[ 40.38, 31.76 ],
[ 40.24, 1.65 ],
...
]
bids, asks array of arrays where each entry represents [price, size]
here is a simple way to make sure that orderbook data remains up to date
await zoUser.state.subscribeToOrderbook('SOL-PERP')
await zoUser.state.subscribeToAllOrderbooks()
await zoUser.state.unsubscribeFromAllOrderbooks()