Skip to main content
Phoenix perps are margined in USDC. The SDK deposit and withdrawal helpers build Solana instructions; your app still signs and sends the transaction with the trader authority wallet. Deposit and withdrawal amounts are expressed in native USDC units when using the TypeScript SDK: 1 USDC = 1_000_000n. The Rust PhoenixTxBuilder convenience methods accept decimal USDC amounts as f64.
Deposit and withdrawal flows target a Phoenix trader account. Register the trader account first if it does not already exist. Withdrawals are subject to Phoenix account health checks and the protocol withdraw queue; see Collateral for more detail.

TypeScript

Use createPhoenixClient(...) and the client.ixs helpers when you want the SDK to resolve exchange accounts, Ember accounts, trader PDAs, and token accounts for you. buildDepositIxs(...) returns three instructions:
  1. Create the Phoenix token ATA if needed.
  2. Convert wallet USDC to Phoenix canonical tokens through Ember.
  3. Deposit the Phoenix tokens into the Phoenix trader account.
buildWithdrawIxs(...) returns five instructions:
  1. Create the Phoenix token ATA if needed.
  2. Approve Ember to spend Phoenix canonical tokens.
  3. Create the USDC ATA if needed.
  4. Withdraw Phoenix tokens from the Phoenix trader account.
  5. Convert Phoenix tokens back to wallet USDC through Ember.
TypeScript
You can also build the protocol instructions individually with buildEmberDeposit, buildDepositFunds, buildWithdrawFunds, and buildEmberWithdraw, but most integrations should prefer the full flow helpers above.

Rust

Use PhoenixHttpClient to fetch exchange metadata, then pass that metadata into PhoenixTxBuilder. The builder returns instruction arrays that should be sent in a single transaction signed by the trader authority.
Rust
For a complete runnable Rust example, see rust/sdk/examples/deposit_funds.rs.

Monitoring

After a transaction confirms, fetch trader state or collateral history to verify the account: