Skip to main content

UserAction

Enum UserAction 

Source
#[repr(u8)]
pub enum UserAction<Address> {
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>, },
}
Expand description

User operations requiring account ownership or delegation.

These operations are authorized via context.sender() with optional delegate resolution. Operations include account management, trading, vault deposits, and user-initiated liquidations.

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).

Fields

§args: CreateVaultArgs<Address>
§

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>

Trait Implementations§

Source§

impl<Address> AsRef<str> for UserAction<Address>

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Address> BorshDeserialize for UserAction<Address>
where Address: BorshDeserialize,

Source§

fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl<Address> BorshSerialize for UserAction<Address>
where Address: BorshSerialize,

Source§

fn serialize<__W: Write>(&self, writer: &mut __W) -> Result<(), Error>

Source§

impl<Address: Clone> Clone for UserAction<Address>

Source§

fn clone(&self) -> UserAction<Address>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Address: Debug> Debug for UserAction<Address>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de, Address> Deserialize<'de> for UserAction<Address>
where Address: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Address> EnumExt for UserAction<Address>
where Address: BorshDeserialize,

Source§

fn deserialize_variant<__R: Read>( reader: &mut __R, variant_tag: u8, ) -> Result<Self, Error>

Deserialises given variant of an enum from the reader. Read more
Source§

impl<'_enum, Address> From<&'_enum UserAction<Address>> for UserActionDiscriminants

Source§

fn from(val: &'_enum UserAction<Address>) -> UserActionDiscriminants

Converts to this type from the input type.
Source§

impl<Address> From<UserAction<Address>> for CallMessage<Address>

Source§

fn from(v: UserAction<Address>) -> Self

Converts to this type from the input type.
Source§

impl<Address> From<UserAction<Address>> for UserActionDiscriminants

Source§

fn from(val: UserAction<Address>) -> UserActionDiscriminants

Converts to this type from the input type.
Source§

impl<Address: Hash> Hash for UserAction<Address>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Address: JsonSchema> JsonSchema for UserAction<Address>

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

impl<Address: Ord> Ord for UserAction<Address>

Source§

fn cmp(&self, other: &UserAction<Address>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<Address: PartialEq> PartialEq for UserAction<Address>

Source§

fn eq(&self, other: &UserAction<Address>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Address: PartialOrd> PartialOrd for UserAction<Address>

Source§

fn partial_cmp(&self, other: &UserAction<Address>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<Address> Serialize for UserAction<Address>
where Address: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<Address: Eq> Eq for UserAction<Address>

Source§

impl<Address> StructuralPartialEq for UserAction<Address>

Auto Trait Implementations§

§

impl<Address> Freeze for UserAction<Address>
where Address: Freeze,

§

impl<Address> RefUnwindSafe for UserAction<Address>
where Address: RefUnwindSafe,

§

impl<Address> Send for UserAction<Address>
where Address: Send,

§

impl<Address> Sync for UserAction<Address>
where Address: Sync,

§

impl<Address> Unpin for UserAction<Address>
where Address: Unpin,

§

impl<Address> UnsafeUnpin for UserAction<Address>
where Address: UnsafeUnpin,

§

impl<Address> UnwindSafe for UserAction<Address>
where Address: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,