@somnia-chain/markets-sdk / index / PerpMaxOrderSize
Type Alias: PerpMaxOrderSize
PerpMaxOrderSize = {
priceable:false;asOfBlock:bigint; } | {priceable:true;asOfBlock:bigint;maxQuantity:bigint;unalignedMaxQuantity:bigint;increasingQuantity:bigint;reducingQuantity:bigint;lockAmount:bigint;topUpRequired:bigint;wallet: {balance:bigint;allowance:bigint; } |null;placeable:boolean;limitedBy:PerpMaxOrderSizeLimit;lotSize:bigint;minQuantity:bigint;maxPositionSize:bigint;positionSize:bigint;markPrice:bigint;effectiveImfBps:bigint; }
Defined in: packages/sdk/src/perp/margin.ts:2161
The largest order the account can actually place, or an unpriceable market.
Union Members
Type Literal
{ priceable: false; asOfBlock: bigint; }
priceable
priceable:
false
The pool's mark feed is stale or zero, so no size can be quoted.
asOfBlock
asOfBlock:
bigint
The block every read was pinned to.
Type Literal
{ priceable: true; asOfBlock: bigint; maxQuantity: bigint; unalignedMaxQuantity: bigint; increasingQuantity: bigint; reducingQuantity: bigint; lockAmount: bigint; topUpRequired: bigint; wallet: { balance: bigint; allowance: bigint; } | null; placeable: boolean; limitedBy: PerpMaxOrderSizeLimit; lotSize: bigint; minQuantity: bigint; maxPositionSize: bigint; positionSize: bigint; markPrice: bigint; effectiveImfBps: bigint; }
priceable
priceable:
true
asOfBlock
asOfBlock:
bigint
The block every read was pinned to.
A max size is a statement about THIS block. The adverse-gap term moves one-for-one with the mark, so a limit bid above a falling mark can afford less than quoted a block later. Re-quote near send time.
maxQuantity
maxQuantity:
bigint
The largest quantity that passes every placement gate, aligned down to the pool's lot grid — what a Max button should fill in.
0n when nothing can be placed. Check placeable before offering it:
a size below the pool's minQuantity is not a small order, it is a revert.
unalignedMaxQuantity
unalignedMaxQuantity:
bigint
maxQuantity before lot alignment. Diagnostic only — placing it would
revert InvalidQuantity.
increasingQuantity
increasingQuantity:
bigint
The part of maxQuantity that increases the position, and so locks.
reducingQuantity
reducingQuantity:
bigint
The part absorbed by existing exposure, which locks nothing.
This is why a max on the opposite side can exceed anything the collateral would fund: a reducing order trips neither gate, so the answer starts at the reducing capacity and only then adds what the margin can carry.
lockAmount
lockAmount:
bigint
The collateral the pool would lock at maxQuantity.
topUpRequired
topUpRequired:
bigint
What auto-pull would take from the wallet at maxQuantity — 0n unless
autoPull was passed. Show it beside the size: at a wallet-limited max this
is essentially the whole approved balance, and a trader clicking Max deserves to
see the transfer before they sign it.
wallet
wallet: {
balance:bigint;allowance:bigint; } |null
The owner's collateral-token balance and MarginBank allowance, null unless
autoPull was passed. Read limitedBy to see which one bound.
placeable
placeable:
boolean
Whether maxQuantity clears the pool's minQuantity.
limitedBy
limitedBy:
PerpMaxOrderSizeLimit
Which gate stopped it going one lot higher.
lotSize
lotSize:
bigint
The pool's quantity grid — every order must be a multiple.
The value maxQuantity was actually aligned to, floored at 1n. A pool
reporting 0n has no grid to speak of, and handing that back would give a
caller a divisor that throws.
minQuantity
minQuantity:
bigint
The pool's minimum order quantity.
maxPositionSize
maxPositionSize:
bigint
The market's per-account position cap.
positionSize
positionSize:
bigint
SIGNED existing position size.
markPrice
markPrice:
bigint
The mark the adverse gap was measured against.
effectiveImfBps
effectiveImfBps:
bigint
The OI-scaled IMF used, bps.