@somnia-chain/markets-sdk / index / PerpOrderMarginQuoteInputs
Interface: PerpOrderMarginQuoteInputs
Defined in: packages/sdk/src/perp/margin.ts:1765
Everything the placement gates need, and nothing that has to come from a particular
block — so perpOrderMarginQuote stays pure.
Properties
isBid
isBid:
boolean
Defined in: packages/sdk/src/perp/margin.ts:1767
True = a buy.
quantity
quantity:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1769
Order quantity, raw base units.
price
price:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1771
Limit price, raw quote units per whole base.
oneBase
oneBase:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1773
10^decimals of the synthetic base.
markPrice
markPrice:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1775
Current mark, raw quote units per whole base.
effectiveImfBps
effectiveImfBps:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1777
The OI-scaled IMF in force, bps.
positionSize
positionSize:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1779
SIGNED existing position size, raw base units.
effectiveReducingCapacity
effectiveReducingCapacity:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1781
Reducing capacity resting orders have not already spoken for, raw base units.
equity
equity:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1783
Account equity, signed.
imRequirement
imRequirement:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1785
Aggregate initial-margin requirement.
unlockedCollateral
unlockedCollateral:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1787
Unlocked collateral balance, signed.
accountMaxLeverageX
accountMaxLeverageX:
number
Defined in: packages/sdk/src/perp/margin.ts:1789
The account's own per-market cap, 0 when unset.
protocolMaxLeverageX
protocolMaxLeverageX:
number
Defined in: packages/sdk/src/perp/margin.ts:1791
Protocol-wide ceiling.
creditFloor
creditFloor:
bigint
Defined in: packages/sdk/src/perp/margin.ts:1793
The account's credit-voucher floor.
voucherLeverageCapX
voucherLeverageCapX:
number
Defined in: packages/sdk/src/perp/margin.ts:1795
The protocol's voucher leverage cap, 0 when unset.
voucherMarketAllowed
voucherMarketAllowed:
boolean
Defined in: packages/sdk/src/perp/margin.ts:1797
Whether this market is voucher-allowlisted.
wallet?
optionalwallet?:object
Defined in: packages/sdk/src/perp/margin.ts:1814
The owner's wallet, which turns auto-pull (T70) modelling ON.
Supply it only when the transaction sender will be the order owner, because
that is the pool's entire gate: PerpPool._autoPullMargin returns early unless
msg.sender == order.owner, deliberately narrower than spot's, which also admits
registry-approved operators. Routing through placeOrderFor, an operator grant,
a router, or the stop registry means no pull — omit this and the gates fall back
to the in-bank balance, which is what those paths actually face.
balance is the owner's collateral-token balance and allowance their approval
to the MarginBank (the same one deposit already needs — the pool reaches the
wallet through depositFor). Both bind: the pull is an ordinary transferFrom,
so whichever is smaller is the ceiling, and an insufficient one reverts from the
TOKEN rather than being swallowed.
balance
balance:
bigint
allowance
allowance:
bigint
mainWalletCapacity?
optionalmainWalletCapacity?:bigint
Defined in: packages/sdk/src/perp/margin.ts:1835
A linked MAIN's spendable capacity — MarginBank.quoteWalletCapacity(payer), which
is min(balance, allowance) in one number. Omit it when the account has no main.
This is the SECOND funding leg, and without it a linked child's placement reads as
underfunded when it is not. PerpPool._reserveAndPullMargin spends the owner's own
wallet first and takes the residual from the main, so the two legs add: the pull
succeeds when ownCapacity + mainWalletCapacity covers
PerpOrderMarginQuote.topUpRequired.
It only participates when wallet is also supplied, because the whole pull —
both legs — is gated on msg.sender == order.owner. A main never funds an
operator-routed or stop-triggered order.
One number rather than a balance/allowance pair on purpose: the bank exposes only the minimum for another wallet, and reading the pair separately would let the SDK's sizing disagree with the contract's. The cost is that a main-side shortfall does not say which of the two bound — a caller that needs to know reads the main's token balance and allowance directly.
mainFundingBlocked?
optionalmainFundingBlocked?:boolean
Defined in: packages/sdk/src/perp/margin.ts:1851
The main's leg cannot be spent because the account still owes a DIFFERENT payer.
Defaults to false.
MarginBank.depositForFromMain allows one payer at a time: while
mainFundedPrincipal is outstanding it reverts PriorFundingPayerOutstanding
unless the live payer IS the recorded one. A child funded by main A, unlinked, and
re-linked to main B is exactly that state, and quoteFundingPayer names B — so
counting B's capacity would quote an executable order that reverts.
While true the main's leg is treated as zero, whatever
mainWalletCapacity says. The account can still place whatever its own
wallet and bank balance fund. The fix is to clear the old claim with
trader.repayPerpMainFunding, not to fund either main.
takerFeeBpsTimes1k?
optionaltakerFeeBpsTimes1k?:bigint
Defined in: packages/sdk/src/perp/margin.ts:1856
The pool's taker fee, BPS_TIMES_1K. Feeds PerpOrderMarginQuote.feeHeadroom
only; the lock itself is fee-free. Defaults to 0n.
makerFeeBpsTimes1k?
optionalmakerFeeBpsTimes1k?:bigint
Defined in: packages/sdk/src/perp/margin.ts:1858
The pool's maker fee, BPS_TIMES_1K and SIGNED — negative is a rebate. Defaults to 0n.
builderFeeBpsTimes1k?
optionalbuilderFeeBpsTimes1k?:bigint
Defined in: packages/sdk/src/perp/margin.ts:1860
The builder fee attached to this order, BPS_TIMES_1K. Defaults to 0n.
restricted?
optionalrestricted?:boolean
Defined in: packages/sdk/src/perp/margin.ts:1867
The market is in close-only mode (PerpPool.isRestricted()). Defaults to false.
Rejects any order with an increasing leg outright — no arithmetic involved — so it behaves like the voucher block rather than like a margin gate.
isolationAllowsMarket?
optionalisolationAllowsMarket?:boolean
Defined in: packages/sdk/src/perp/margin.ts:1874
MarginBank.isolationAllowsMarket(account, pool). Defaults to true.
false rejects the WHOLE order, reducing legs included — the one placement gate
that does, because it is a market-selection rule rather than a margin one.