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
UsecreatePhoenixClient(...) 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:
- Create the Phoenix token ATA if needed.
- Convert wallet USDC to Phoenix canonical tokens through Ember.
- Deposit the Phoenix tokens into the Phoenix trader account.
buildWithdrawIxs(...) returns five instructions:
- Create the Phoenix token ATA if needed.
- Approve Ember to spend Phoenix canonical tokens.
- Create the USDC ATA if needed.
- Withdraw Phoenix tokens from the Phoenix trader account.
- Convert Phoenix tokens back to wallet USDC through Ember.
TypeScript
buildEmberDeposit, buildDepositFunds, buildWithdrawFunds, and buildEmberWithdraw, but most integrations should prefer the full flow helpers above.
Rust
UsePhoenixHttpClient 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
rust/sdk/examples/deposit_funds.rs.