Skip to main content

Overview

Manage your funds with the LFG SDK through deposits, withdrawals, and transfers. This guide covers all fund movement operations.

Deposit

Move funds from wallet to trading subaccount

Withdraw

Move funds from subaccount back to wallet

Transfer

Transfer between subaccounts

Deposit to Subaccount

Basic Deposit

Deposit USDC from your wallet to a trading subaccount:
SubaccountInfo
required
The subaccount to deposit into
string
required
Amount in USDC to deposit (as string)
string
Optional memo for the transaction
You must have USDC in your source wallet before depositing to a subaccount. Check your source balance first.

Deposit with Memo

Check Source Balance Before Deposit

Deposits require gas fees. Ensure you have enough USDC for both the deposit amount and gas.

Withdraw from Subaccount

Basic Withdrawal

Withdraw USDC from a subaccount back to your wallet:
SubaccountInfo
required
The subaccount to withdraw from
string
required
Amount in USDC to withdraw (as string)
string
required
Address to receive the withdrawal
string
Optional memo for the transaction

Withdraw to Different Address

Safe Withdrawal with Balance Check

Withdrawing too much collateral while holding positions can lead to liquidation. Always maintain sufficient margin.

Transfer Between Subaccounts

Basic Transfer

Transfer USDC from one subaccount to another:
SubaccountInfo
required
The source subaccount (sending funds)
string
required
The recipient wallet address (can be same wallet)
number
required
The destination subaccount number
string
required
Amount in USDC to transfer (as string)
string
Optional memo for the transaction

Transfer Between Different Wallets

Transfer from your subaccount to another user’s subaccount:

Send Tokens from Source

Send tokens directly from your source wallet (outside subaccounts):
This sends tokens from your source wallet, not from subaccounts. Use transferToSubaccount for subaccount transfers.

Transaction Memos

Adding Memos to Transactions

Memos help you track and organize transactions:

Memo Best Practices

Handling Transaction Errors

Retry Logic

Error Handling

Fund Management Strategies

Automated Rebalancing

Emergency Withdrawal

Best Practices

Verify sufficient funds before initiating transfers:
Add descriptive memos to track transaction purposes:
Never withdraw all free collateral while holding positions:
Implement retry logic for network failures:

Next Steps

Market Data

Query markets and orderbooks

Balances Guide

Monitor balances and positions

CompositeClient Reference

Complete CompositeClient API

ValidatorClient Reference

Detailed ValidatorClient documentation