@somnia-chain/markets-sdk


@somnia-chain/markets-sdk / index / PerpOrderMarginQuoteInputs

Interface: PerpOrderMarginQuoteInputs

Defined in: packages/sdk/src/perp/margin.ts:1731

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:1733

True = a buy.


quantity

quantity: bigint

Defined in: packages/sdk/src/perp/margin.ts:1735

Order quantity, raw base units.


price

price: bigint

Defined in: packages/sdk/src/perp/margin.ts:1737

Limit price, raw quote units per whole base.


oneBase

oneBase: bigint

Defined in: packages/sdk/src/perp/margin.ts:1739

10^decimals of the synthetic base.


markPrice

markPrice: bigint

Defined in: packages/sdk/src/perp/margin.ts:1741

Current mark, raw quote units per whole base.


effectiveImfBps

effectiveImfBps: bigint

Defined in: packages/sdk/src/perp/margin.ts:1743

The OI-scaled IMF in force, bps.


positionSize

positionSize: bigint

Defined in: packages/sdk/src/perp/margin.ts:1745

SIGNED existing position size, raw base units.


effectiveReducingCapacity

effectiveReducingCapacity: bigint

Defined in: packages/sdk/src/perp/margin.ts:1747

Reducing capacity resting orders have not already spoken for, raw base units.


equity

equity: bigint

Defined in: packages/sdk/src/perp/margin.ts:1749

Account equity, signed.


imRequirement

imRequirement: bigint

Defined in: packages/sdk/src/perp/margin.ts:1751

Aggregate initial-margin requirement.


unlockedCollateral

unlockedCollateral: bigint

Defined in: packages/sdk/src/perp/margin.ts:1753

Unlocked collateral balance, signed.


accountMaxLeverageX

accountMaxLeverageX: number

Defined in: packages/sdk/src/perp/margin.ts:1755

The account's own per-market cap, 0 when unset.


protocolMaxLeverageX

protocolMaxLeverageX: number

Defined in: packages/sdk/src/perp/margin.ts:1757

Protocol-wide ceiling.


creditFloor

creditFloor: bigint

Defined in: packages/sdk/src/perp/margin.ts:1759

The account's credit-voucher floor.


voucherLeverageCapX

voucherLeverageCapX: number

Defined in: packages/sdk/src/perp/margin.ts:1761

The protocol's voucher leverage cap, 0 when unset.


voucherMarketAllowed

voucherMarketAllowed: boolean

Defined in: packages/sdk/src/perp/margin.ts:1763

Whether this market is voucher-allowlisted.


wallet?

optional wallet?: object

Defined in: packages/sdk/src/perp/margin.ts:1780

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?

optional mainWalletCapacity?: bigint

Defined in: packages/sdk/src/perp/margin.ts:1801

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?

optional mainFundingBlocked?: boolean

Defined in: packages/sdk/src/perp/margin.ts:1817

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?

optional takerFeeBpsTimes1k?: bigint

Defined in: packages/sdk/src/perp/margin.ts:1822

The pool's taker fee, BPS_TIMES_1K. Feeds PerpOrderMarginQuote.feeHeadroom only; the lock itself is fee-free. Defaults to 0n.


makerFeeBpsTimes1k?

optional makerFeeBpsTimes1k?: bigint

Defined in: packages/sdk/src/perp/margin.ts:1824

The pool's maker fee, BPS_TIMES_1K and SIGNED — negative is a rebate. Defaults to 0n.


builderFeeBpsTimes1k?

optional builderFeeBpsTimes1k?: bigint

Defined in: packages/sdk/src/perp/margin.ts:1826

The builder fee attached to this order, BPS_TIMES_1K. Defaults to 0n.


restricted?

optional restricted?: boolean

Defined in: packages/sdk/src/perp/margin.ts:1833

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?

optional isolationAllowsMarket?: boolean

Defined in: packages/sdk/src/perp/margin.ts:1840

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.