Skip to main content

UserAction

Type Alias UserAction 

Source
pub type UserAction = UserAction<Address>;
Expand description

User-facing trading action (placing orders, withdrawals, etc.).

Aliased Type§

#[repr(u8)]
pub enum UserAction {
Show 42 variants Deposit { asset_id: AssetId, amount: PositiveDecimal, }, Withdraw { asset_id: AssetId, amount: PositiveDecimal, }, DepositSpotCollateral { asset_id: AssetId, amount: PositiveDecimal, }, WithdrawSpotCollateral { asset_id: AssetId, amount: PositiveDecimal, }, TransferSpotCollateral { asset_id: AssetId, amount: PositiveDecimal, direction: SpotCollateralTransferDirection, sub_account_index: Option<u8>, }, BorrowSpot { asset_id: AssetId, amount: PositiveDecimal, sub_account_index: Option<u8>, }, CreateSubAccount { index: u8, }, TransferToSubAccount { asset_id: AssetId, amount: PositiveDecimal, sub_account_index: u8, to_sub_account: bool, }, DelegateUser { delegate: Address, name: CustomString, }, RevokeDelegation { delegate: Address, }, UpdateMaxLeverage { market_id: MarketId, max_leverage: u16, sub_account_index: Option<u8>, }, ClaimReferralRewards { asset_id: AssetId, }, DepositIso { market_id: MarketId, amount: PositiveDecimal, }, WithdrawIso { market_id: MarketId, amount: PositiveDecimal, }, SetPerpLedgerTradingMode { market_id: MarketId, trading_mode: TradingMode, sub_account_index: Option<u8>, }, DelegateUserV1 { delegate: Address, name: CustomString, sub_account_index: Option<u8>, }, RevokeDelegationV1 { delegate: Address, sub_account_index: Option<u8>, }, DelegateUserV2 { delegate: Address, name: CustomString, sub_account_index: Option<u8>, expires_at: Option<UnixTimestampMicros>, flags: u32, }, PlaceOrders { market_id: MarketId, orders: Vec<NewOrderArgs>, replace: bool, sub_account_index: Option<u8>, }, AmendOrders { market_id: MarketId, orders: Vec<AmendOrderArgs>, sub_account_index: Option<u8>, }, CancelOrders { market_id: MarketId, orders: Vec<CancelOrderArgs>, sub_account_index: Option<u8>, }, CancelMarketOrders { market_id: MarketId, sub_account_index: Option<u8>, }, CreateTriggerOrders { market_id: MarketId, trigger_orders: Vec<NewTriggerOrderArgs>, sub_account_index: Option<u8>, }, CreatePositionTpsl { market_id: MarketId, tpsl_pair: TpslPair, size: Option<PositiveDecimal>, sub_account_index: Option<u8>, }, CancelTriggerOrders { market_id: MarketId, trigger_order_ids: Vec<TriggerOrderId>, sub_account_index: Option<u8>, }, CreateTwapOrder { market_id: MarketId, twap_order_args: NewTwapOrderArgs, sub_account_index: Option<u8>, }, CancelTwapOrder { market_id: MarketId, twap_id: TwapId, sub_account_index: Option<u8>, }, CancelAllOrders { sub_account_index: Option<u8>, }, DepositToPnlPool { usdc_amount: PositiveDecimal, }, SettleFromPnlPool { sub_account_index: Option<u8>, }, DepositToInsuranceFund { usdc_amount: PositiveDecimal, }, DepositToTreasury { asset_id: AssetId, amount: PositiveDecimal, }, ClaimBorrowLendFees {}, DepositToIsoInsuranceFund { market_id: MarketId, amount: PositiveDecimal, }, CreateVault { args: CreateVaultArgs<Address>, }, DepositToVault { vault_address: Address, asset_id: AssetId, amount: PositiveDecimal, }, QueueWithdrawal { vault_address: Address, shares: PositiveDecimal, }, CancelQueuedWithdrawal { vault_address: Address, }, ForceWithdrawVault { vault_address: Address, shares: PositiveDecimal, }, BackstopLiquidatePerpPositions { address: Address, positions: Option<Vec<BackstopLiquidatePerpPositionArgs>>, sub_account_index: Option<u8>, }, LiquidateBorrowLendLiability { liquidatee_address: Address, liability_asset_id: AssetId, collateral_asset_id: AssetId, liability_amount: PositiveDecimal, sub_account_index: Option<u8>, }, BackstopLiquidateIsoPerpPosition { address: Address, position: BackstopLiquidatePerpPositionArgs, sub_account_index: Option<u8>, },
}

Variants§

§

Deposit

Deposit assets to perp margin account.

Fields

§asset_id: AssetId
§

Withdraw

Withdraw assets from perp margin account.

Fields

§asset_id: AssetId
§

DepositSpotCollateral

Deposit assets to spot collateral.

Fields

§asset_id: AssetId
§

WithdrawSpotCollateral

Withdraw assets from spot collateral.

Fields

§asset_id: AssetId
§

TransferSpotCollateral

Transfer assets between perp margin and spot collateral.

Fields

§asset_id: AssetId
§sub_account_index: Option<u8>
§

BorrowSpot

Borrow assets from spot pool.

Fields

§asset_id: AssetId
§sub_account_index: Option<u8>
§

CreateSubAccount

Create a new sub-account.

Fields

§index: u8
§

TransferToSubAccount

Transfer assets between main account and sub-account.

Fields

§asset_id: AssetId
§sub_account_index: u8
§to_sub_account: bool
§

DelegateUser

Delegate trading permissions to another address.

Fields

§delegate: Address
§

RevokeDelegation

Revoke delegation from an address.

Fields

§delegate: Address
§

UpdateMaxLeverage

Update maximum leverage for a market.

Fields

§market_id: MarketId
§max_leverage: u16
§sub_account_index: Option<u8>
§

ClaimReferralRewards

Claim your own referral rewards.

Fields

§asset_id: AssetId
§

DepositIso

Deposit USDC into an isolated market / isolated margin position.

Fields

§market_id: MarketId
§

WithdrawIso

Withdraw USDC from an isolated market / isolated margin position.

Fields

§market_id: MarketId
§

SetPerpLedgerTradingMode

Set the trading mode of a perp ledger to cross or iso.

Fields

§market_id: MarketId
§trading_mode: TradingMode
§sub_account_index: Option<u8>
§

DelegateUserV1

Delegate trading permissions to another address allowing for sub accounts to be delegated.

Fields

§delegate: Address
§sub_account_index: Option<u8>
§

RevokeDelegationV1

Revoke delegation from an address allowing for sub accounts to revoke delegation.

Fields

§delegate: Address
§sub_account_index: Option<u8>
§

DelegateUserV2

Delegate trading permissions with optional expiry and flags

Fields

§delegate: Address
§sub_account_index: Option<u8>
§flags: u32
§

PlaceOrders

Place new orders on a market.

Fields

§market_id: MarketId
§replace: bool
§sub_account_index: Option<u8>
§

AmendOrders

Amend existing orders (cancel + place).

Fields

§market_id: MarketId
§sub_account_index: Option<u8>
§

CancelOrders

Cancel specific orders.

Fields

§market_id: MarketId
§sub_account_index: Option<u8>
§

CancelMarketOrders

Cancel all orders on a market.

Fields

§market_id: MarketId
§sub_account_index: Option<u8>
§

CreateTriggerOrders

Create trigger orders for spot markets.

Fields

§market_id: MarketId
§trigger_orders: Vec<NewTriggerOrderArgs>
§sub_account_index: Option<u8>
§

CreatePositionTpsl

Create take-profit/stop-loss for a perp position.

Fields

§market_id: MarketId
§tpsl_pair: TpslPair
§sub_account_index: Option<u8>
§

CancelTriggerOrders

Cancel trigger orders.

Fields

§market_id: MarketId
§trigger_order_ids: Vec<TriggerOrderId>
§sub_account_index: Option<u8>
§

CreateTwapOrder

Create TWAP orders

Fields

§market_id: MarketId
§twap_order_args: NewTwapOrderArgs
§sub_account_index: Option<u8>
§

CancelTwapOrder

Cancel a TWAP order

Fields

§market_id: MarketId
§twap_id: TwapId
§sub_account_index: Option<u8>
§

CancelAllOrders

Cancel all orders for perp or spot

Fields

§sub_account_index: Option<u8>
§

DepositToPnlPool

Deposit USDC to the PnL pool.

Fields

§usdc_amount: PositiveDecimal
§

SettleFromPnlPool

Settle user’s PnL from the pool.

Fields

§sub_account_index: Option<u8>
§

DepositToInsuranceFund

Deposit to the insurance fund.

Fields

§usdc_amount: PositiveDecimal
§

DepositToTreasury

Deposit to protocol treasury.

Fields

§asset_id: AssetId
§

ClaimBorrowLendFees

Claim accumulated borrow/lend protocol fees.

§

DepositToIsoInsuranceFund

Deposit to the iso insurance fund.

Fields

§market_id: MarketId
§

CreateVault

Create a new vault (caller becomes the vault leader).

§

DepositToVault

Deposit assets to a vault.

Fields

§vault_address: Address
§asset_id: AssetId
§

QueueWithdrawal

Queue a withdrawal from a vault.

Fields

§vault_address: Address
§

CancelQueuedWithdrawal

Cancel a queued withdrawal.

Fields

§vault_address: Address
§

ForceWithdrawVault

Force withdraw from a vault (bypasses queue).

Fields

§vault_address: Address
§

BackstopLiquidatePerpPositions

Backstop liquidation for perp positions (user provides capital).

Fields

§address: Address
§sub_account_index: Option<u8>
§

LiquidateBorrowLendLiability

Liquidate borrow/lend liability (user provides capital).

Fields

§liquidatee_address: Address
§liability_asset_id: AssetId
§collateral_asset_id: AssetId
§liability_amount: PositiveDecimal
§sub_account_index: Option<u8>
§

BackstopLiquidateIsoPerpPosition

Fields

§address: Address
§sub_account_index: Option<u8>