Skip to content

Perps Calls

Calls on the perps module, submitted Borsh-encoded to the single Submit Transaction endpoint. Fields are listed in Borsh serialization order; see Encoding and Data Structures & Constants.

Create Perp Orderbook

perps.create_perp_orderbook

Create a new perpetual orderbook

Protocol / admin operation.

FieldTypeRequiredDescription
base_token_nameTokenNameyesthe base token name/symbol
base_decimalsuint8yes
tick_sizeuint64yestick size in quote smallest units
default_maker_fee_100th_bpsSignedBPS100thFeeyesdefault maker fee in 100th bps (negative = rebate)
default_taker_fee_100th_bpsSignedBPS100thFeeyesdefault taker fee in 100th bps (negative = rebate)
margin_tiersVec<(uint64, uint8)>yesposition size-based margin requirements
max_market_order_valueuint64yesmaximum single market order notional value
max_limit_order_valueuint64yesmaximum single limit order notional value
impact_quantityuint64yesquantity to use for impact price calculation
oracle_idOracleIdyesOracle identifier for market
max_mark_deviation_bpsuint16yesMaximum mark price deviation from oracle in basis points (e.g., 500 = 5%). 0 = disabled.
price_band_bpsuint16yesExecution price-band half-width in bps: a fill must be within oracle ± this percentage (e.g. 500 = ±5%). 0 = disabled. (Distinct from the placement band.)

Deposit Margin

perps.deposit_margin

Deposit margin into a subaccount

FieldTypeRequiredDescription
subaccount_idSubAccountIdyessubaccount to deposit into
amountuint64yesamount in quote atoms
addressOption<EthereumAddress>noOptional address to credit. Defaults to the transaction sender.

Withdraw Margin

perps.withdraw_margin

Withdraw margin from a subaccount

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
subaccount_idSubAccountIdyessubaccount to withdraw from
amountuint64yesamount in quote atoms

Subaccount Transfer

perps.subaccount_transfer

Transfer margin between subaccounts of the same user

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
from_subaccount_idSubAccountIdyessource subaccount id
to_subaccount_idSubAccountIdyesdestination subaccount id
amountuint64yesamount to transfer in quote atoms

Place Order

perps.place_order

Place an order on a perp market

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner and the order routes to the vault's account
subaccount_idOption<SubAccountId>noThe subaccount to place order from (defaults to 0)
market_idMarketIdyesmarket to place order on
sideSideyesorder side (Bid = Long, Ask = Short)
order_typeOrderTypeyesorder type (Market, Limit, etc.)
order_fill_methodTimeInForceyesfill method
quantityuint64yesorder quantity
priceOption<uint64>noorder price (ignored for market orders and pegged orders) For stop orders, this is the limit price at which the order will execute.
client_order_idClientOrderIdyesclient order id for tracking
offsetOption<uint8>noThe optional price offset of the order for oracle peg orders
max_priceOption<uint64>noMaximum price for pegged orders (price cap for buy, floor for sell)
trigger_priceOption<uint64>noThe optional trigger price of the order for stop orders
parentOption<ClientOrderId>noThe optional parent order id of the order for OCO orders
reduce_onlyOption<bool>noIf true, this order can only reduce an existing position, not increase it. Reduce-only orders placed by accounts in Warning/Restrict tier are allowed. During matching, reduce-only maker orders that would increase position are cancelled.

Cancel Order

perps.cancel_order

Cancel an order by client order ID

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
client_order_idClientOrderIdyesThe client order ID of the order to cancel
subaccount_idOption<SubAccountId>noThe subaccount the order belongs to (defaults to 0)

Cancel All Orders

perps.cancel_all_orders

Cancel all orders for a subaccount

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idOption<SubAccountId>noThe subaccount to cancel all orders for (defaults to 0)

Place Oco Order

perps.place_oco_order

Place an OCO (one-cancels-other) order pair (e.g. TP + SL bracket)

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idOption<SubAccountId>noThe subaccount to place orders from (defaults to 0)
order_1PlaceOrderParamsyesThe first order (e.g. take-profit)
order_2PlaceOrderParamsyesThe second order (e.g. stop-loss)
reduce_onlyOption<bool>noIf true, both legs can only reduce an existing position

Modify Order

perps.modify_order

Modify an order. Cancels and replaces with a new order keeping the same client order id.

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idOption<SubAccountId>noThe subaccount the order belongs to (defaults to 0)
market_idMarketIdyesThe new market id
sideSideyesThe new side
order_typeOrderTypeyesThe new order type
order_fill_methodTimeInForceyesThe new fill method
priceOption<uint64>noThe new price (None for market/pegged orders)
quantityuint64yesThe new quantity
client_order_idClientOrderIdyesThe client order id (must match existing order)
offsetOption<uint8>noThe optional price offset for oracle peg orders
max_priceOption<uint64>noMaximum price for pegged orders
trigger_priceOption<uint64>noThe optional trigger price for stop orders
parentOption<ClientOrderId>noThe optional parent order id for OCO orders
reduce_onlyOption<bool>noIf true, this order can only reduce an existing position

Place Multiple Orders

perps.place_multiple_orders

Place multiple orders in a single transaction

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idOption<SubAccountId>noThe subaccount to place orders from (defaults to 0)
ordersSafeVec_512_of_PlaceOrderParamsyesThe orders to place

Cancel Pegged Order If Beyond Max Price

perps.cancel_pegged_order_if_beyond_max_price

Cancel a pegged order if its effective price exceeds its max price

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idOption<SubAccountId>noThe subaccount the order belongs to (defaults to 0)
client_order_idClientOrderIdyesThe client order id of the pegged order

Cancel Restricted Orders

perps.cancel_restricted_orders

Cancel all orders for an account in Restrict health tier (permissionless keeper)

Anyone can call this for any account that is at or below Restrict tier. BLP accounts are exempt.

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyesThe user address whose orders should be cancelled
subaccount_idSubAccountIdyesThe subaccount to cancel orders for

Change Leverage

perps.change_leverage

Change leverage for a market

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
market_idMarketIdyesmarket to change leverage for
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idSubAccountIdyessubaccount to change leverage for
new_leverageuint8yesnew leverage value

Change Margin Mode

perps.change_margin_mode

Change margin mode for a market (cross <-> isolated)

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
market_idMarketIdyesmarket to change margin mode for
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idSubAccountIdyessubaccount to change margin mode for
new_modeMarginModeyesnew margin mode

Adjust Isolated Margin

perps.adjust_isolated_margin

Adjust allocated margin for an isolated position

FieldTypeRequiredDescription
ownerOption<EthereumAddress>noOptional owner when signed by a delegate
market_idMarketIdyesmarket of the isolated position
vault_idOption<uint64>noOptional vault ID — when set, sender must be vault manager/owner
subaccount_idSubAccountIdyessubaccount of the isolated position
margin_adjustmentint128yesmargin adjustment (positive = add margin, negative = remove margin)

Crank Mark Price

perps.crank_mark_price

Crank the mark price for a market Updates EMA state and emits MarkPriceUpdated event Can be called a maximum of once every 500ms

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyes

Crank Stop Orders

perps.crank_stop_orders

Crank stop orders for a market

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyes

Sample Premium

perps.sample_premium

Sample premium rate for funding Should be called once every minute

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyes

Apply Funding

perps.apply_funding

Apply funding to market Should be called at the top of every hour

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyes

Crank All Mark Prices

perps.crank_all_mark_prices

Crank mark price for all markets Should be called every 500ms

Protocol / admin operation.

No parameters.

Sample All Premiums

perps.sample_all_premiums

Sample premium rate for all markets Should be called once every minute

Protocol / admin operation.

No parameters.

Apply All Funding

perps.apply_all_funding

Apply funding to all markets Should be called at the top of every hour

Protocol / admin operation.

No parameters.

Liquidate Account

perps.liquidate_account

Liquidate an account

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyesThe user address to liquidate
subaccount_idSubAccountIdyesThe subaccount to liquidate

Liquidate Position

perps.liquidate_position

Liquidate a single isolated position

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyesThe user address to liquidate
subaccount_idSubAccountIdyesThe subaccount to liquidate
market_idMarketIdyesThe market to liquidate

Adl Position

perps.adl_position

Auto-Deleverage a position against specified counterparties

Called by an offchain process when: 1. A liquidation failed and escalated to "ADL required" error 2. A flash crash makes an account directly have negative equity

The counterparties list should be sorted by the offchain process using: (mark_price / entry_price) * (notional_position / account_value)

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyesThe user address whose position needs to be ADL'd
subaccount_idSubAccountIdyesThe subaccount to ADL
market_idMarketIdyesThe market in which to ADL
counterpartiesVec<(EthereumAddress, SubAccountId)>yesList of (address, subaccount) pairs to ADL against, in priority order These should be opposite-side positions with positive PnL

Adl Cross Account

perps.adl_cross_account

Auto-deleverage all cross-margin positions with proportional deficit distribution

This is called by an offchain process when a cross-margin account has negative equity and cannot be handled by backstop liquidation. The deficit is distributed proportionally across all positions with negative uPnL.

Counterparties must have zero prices that "align" with the bankruptcy prices, meaning ADL won't reduce their health.

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyesThe user address whose account needs to be ADL'd
subaccount_idSubAccountIdyesThe subaccount to ADL
counterparties_by_marketVec<(MarketId, Vec<(EthereumAddress, SubAccountId)>)>yesMap of market_id to list of (address, subaccount) counterparty pairs Counterparties should be sorted by: (mark_price / entry_price) * (notional / account_value)

Deposit To BLP

perps.deposit_to_b_l_p

Deposit margin into the BLP and receive shares

FieldTypeRequiredDescription
quote_lotsuint64yesAmount of margin to deposit (quote lots)
sourceVaultDepositSourceyesSource of funds (spot or margin)
subaccount_idOption<SubAccountId>noThe subaccount to deposit from (defaults to 0)

Withdraw From BLP

perps.withdraw_from_b_l_p

Withdraw from the BLP by burning shares

FieldTypeRequiredDescription
sharesuint128yesAmount of shares to withdraw
destinationVaultWithdrawDestinationyesDestination of funds (spot or margin)
subaccount_idOption<SubAccountId>noThe subaccount to withdraw to (defaults to 0)

Add BLP Manager

perps.add_b_l_p_manager

Add an BLP manager (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
managerEthereumAddressyesThe address to add as an BLP manager

Remove BLP Manager

perps.remove_b_l_p_manager

Remove an BLP manager (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
managerEthereumAddressyesThe address to remove as an BLP manager

Create Vault

perps.create_vault

Create a new vault with a required initial deposit

FieldTypeRequiredDescription
initial_deposituint64yesInitial deposit amount (quote atoms)

Deposit To Vault

perps.deposit_to_vault

Deposit margin into a vault and receive shares

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID to deposit into
amountuint64yesAmount of margin to deposit (quote atoms)
sourceOption<VaultDepositSource>noSource of funds (spot or margin). Defaults to Spot if not specified.
subaccount_idOption<SubAccountId>noThe subaccount to deposit from (defaults to 0)

Withdraw From Vault

perps.withdraw_from_vault

Withdraw from a vault by burning shares

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID to withdraw from
sharesuint128yesAmount of shares to burn
destinationOption<VaultWithdrawDestination>noDestination for withdrawn funds (spot or margin). Defaults to Spot if not specified.
subaccount_idOption<SubAccountId>noThe subaccount to withdraw to (defaults to 0)

Add Vault Manager

perps.add_vault_manager

Add a vault manager (vault owner only)

Protocol / admin operation.

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID
managerEthereumAddressyesThe address to add as a manager

Remove Vault Manager

perps.remove_vault_manager

Remove a vault manager (vault owner only)

Protocol / admin operation.

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID
managerEthereumAddressyesThe address to remove as a manager

Propose Vault Ownership Transfer

perps.propose_vault_ownership_transfer

Propose ownership transfer for a vault (current owner only). The new owner must call AcceptVaultOwnershipTransfer to complete.

Protocol / admin operation.

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID
new_ownerEthereumAddressyesThe proposed new owner

Accept Vault Ownership Transfer

perps.accept_vault_ownership_transfer

Accept a pending vault ownership transfer (proposed new owner only).

Protocol / admin operation.

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID

Freeze Vault

perps.freeze_vault

Freeze a vault (admin only). Blocks deposits, withdrawals, and trading.

Protocol / admin operation.

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID to freeze

Unfreeze Vault

perps.unfreeze_vault

Unfreeze a vault (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
vault_iduint64yesThe vault ID to unfreeze

Set BLP Status

perps.set_b_l_p_status

Set BLP operational status (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
statusBLPStatusyesThe new BLP status

Update Fee Recipient

perps.update_fee_recipient

Update the protocol fee recipient address (admin only) The fee recipient receives protocol fee shares from BLP profits

Protocol / admin operation.

FieldTypeRequiredDescription
fee_recipientEthereumAddressyesNew fee recipient address

Update BLP Protocol Fee

perps.update_b_l_p_protocol_fee

Update the BLP protocol fee rate (admin only) Fee is in 100ths of basis points (10000 = 1%)

Protocol / admin operation.

FieldTypeRequiredDescription
protocol_fee_100th_bpsuint16yesNew protocol fee rate (max 50000 = 5%)

Set Fee Override

perps.set_fee_override

Set fee override for an address (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyes
maker_fee_100th_bpsSignedBPS100thFeeyes
taker_fee_100th_bpsSignedBPS100thFeeyes

Update Backstop Risk Config

perps.update_backstop_risk_config

Update backstop risk configuration (admin only) Controls when the BLP can absorb liquidated positions

Protocol / admin operation.

FieldTypeRequiredDescription
configBackstopRiskConfigyes

Remove Fee Override

perps.remove_fee_override

Remove fee override for an address (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
userEthereumAddressyes

Withdraw Accumulated Fees

perps.withdraw_accumulated_fees

Withdraw accumulated trading fees to the fee_recipient (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
amountuint64yesAmount to withdraw in quote atoms

Update Vault Withdrawal Timelock

perps.update_vault_withdrawal_timelock

Update the vault withdrawal timelock duration (admin only) Controls how long users must wait after their last deposit before withdrawing

Protocol / admin operation.

FieldTypeRequiredDescription
timelock_msuint64yesNew timelock duration in milliseconds (max 10 days = 864000000)

Update Blp Withdrawal Timelock

perps.update_blp_withdrawal_timelock

Update the BLP withdrawal timelock duration (admin only) Controls how long users must wait after their last deposit before withdrawing

FieldTypeRequiredDescription
timelock_msuint64yesNew timelock duration in milliseconds (max 10 days = 864000000)

Pause Market

perps.pause_market

Pause a perp market (admin only). Blocks new orders, cranks (mark price, stop triggers), and funding. Users can still cancel their own orders. On unpause, the first crank updates mark price from oracle and liquidations fire naturally.

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyesThe market to pause

Unpause Market

perps.unpause_market

Unpause a paused perp market (admin only).

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyesThe market to unpause

Delist Market

perps.delist_market

Delist a perp market and initiate final settlement (admin only). Blocks all new orders. Existing positions must be settled via SettleDelistedPositions.

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyesThe market to delist
settlement_priceOption<uint64>noSettlement price. If None, uses current oracle price.

Settle Delisted Position

perps.settle_delisted_position

Settle a position in a delisted market at the settlement price.

Expected keeper flow: 1. Identify all accounts whose margin would go negative at settlement price (margin_balance + PnL < 0 for cross, allocated + PnL < 0 for isolated) 2. ADL those accounts first via AdlPosition (socializes loss to counterparties) 3. Settle everyone else in batches with this call — includes profitable positions, losing positions with sufficient margin, and any remaining positions

This call rejects accounts that would go negative (must ADL first). Accounts with large losses but sufficient margin are settled normally.

Protocol / admin operation.

FieldTypeRequiredDescription
market_idMarketIdyesThe delisted market
userEthereumAddressyesThe user whose position to settle
subaccount_idSubAccountIdyesThe subaccount

Add Adl Keeper

perps.add_adl_keeper

Add an authorized ADL keeper (admin only)

ADL keepers are authorized to call AdlPosition and AdlCrossAccount. This gates ADL operations to trusted off-chain processes.

Protocol / admin operation.

FieldTypeRequiredDescription
keeperEthereumAddressyesThe address to authorize as an ADL keeper

Remove Adl Keeper

perps.remove_adl_keeper

Remove an ADL keeper (admin only)

Protocol / admin operation.

FieldTypeRequiredDescription
keeperEthereumAddressyesThe address to remove from ADL keepers