TokenClient
The TokenClient handles x0-USD mint initialization, fee configuration, and token operations using SPL Token-2022.
Mint Initialization
buildInitializeMintInstruction(params, payer)
Create a new x0-USD token mint with Token-2022 extensions:
This instruction initializes a mint with:
- TransferFee extension — 0.8% protocol fee
- TransferHook extension — x0-guard policy enforcement
- ConfidentialTransfer extension (optional) — ElGamal-encrypted balances
Enable confidential transfers on an existing mint:
Token Operations
buildMintTokensInstruction(params, authority)
Mint new tokens (authority only):
buildDepositConfidentialInstruction(params, owner)
Deposit public tokens into the confidential balance:
Fee Management
buildWithdrawFeesInstruction(mint, sourceAccounts, feeReceiver, authority)
Withdraw accumulated transfer fees from token accounts:
buildHarvestFeesInstruction(mint, authority, sourceAccounts)
Harvest fees from multiple accounts in a single transaction.
Fee Calculation
calculateTransferFee(amount)
calculateAmountAfterFee(amount)
Token Account Helpers
getAssociatedTokenAddress(mint, owner)
buildCreateATAInstruction(mint, owner, payer)
Mint Info
fetchMintInfo(mint)
Returns: X0TokenMintInfo
Factory
Derive the PDA for the TransferHook extra account metas:
Last modified on February 8, 2026