Transfers
Transfers let you move balances and positions between subaccounts owned by the same authority.
Why Use Subaccount Transfers?
Subaccounts let you isolate risk and organize trading strategies. Common use cases for transfers include:
- Strategy isolation: Separate market making from directional trading to prevent one strategy’s losses from affecting another’s collateral
- Risk management: Move profits from an active trading account to a safer holding account
- Rebalancing: Redistribute collateral when one subaccount needs more margin
- Bot separation: Isolate automated trading bots on separate subaccounts while keeping manual trades separate
- Experimentation: Test new strategies on a subaccount with limited capital, then transfer funds if successful
All subaccounts under the same wallet share cross-margin, but transfers let you explicitly move balances and positions to reorganize your capital.
SDK Usage
Transfer a Spot Deposit Between Subaccounts
const marketIndex = 0; // e.g. USDC
const amount = driftClient.convertToSpotPrecision(marketIndex, 100);
// transferDeposit(amount, marketIndex, fromSubAccountId, toSubAccountId)
await driftClient.transferDeposit(amount, marketIndex, 0, 1);Method DriftClient.transferDepositReference ↗
Method DriftClient.transferDepositReference ↗| Parameter | Type | Required |
|---|---|---|
amount | any | Yes |
marketIndex | number | Yes |
fromSubAccountId | number | Yes |
toSubAccountId | number | Yes |
txParams | TxParams | No |
| Returns |
|---|
Promise<string> |
Transfer a Perp Position Between Subaccounts
import { BASE_PRECISION, BN } from "@drift-labs/sdk";
// transferPerpPosition(fromSubAccountId, toSubAccountId, marketIndex, amount)
const amount = new BN(1).mul(BASE_PRECISION); // 1 base unit
await driftClient.transferPerpPosition(0, 1, 0, amount);Method DriftClient.transferPerpPositionReference ↗
Method DriftClient.transferPerpPositionReference ↗| Parameter | Type | Required |
|---|---|---|
fromSubAccountId | number | Yes |
toSubAccountId | number | Yes |
marketIndex | number | Yes |
amount | any | Yes |
txParams | TxParams | No |
| Returns |
|---|
Promise<string> |
Transfer Between Insurance Fund Pools
// Transfer between insurance fund pools (admin only)
await driftClient.transferPools();Method DriftClient.transferPoolsReference ↗
Method DriftClient.transferPoolsReference ↗| Parameter | Type | Required |
|---|---|---|
depositFromMarketIndex | number | Yes |
depositToMarketIndex | number | Yes |
borrowFromMarketIndex | number | Yes |
borrowToMarketIndex | number | Yes |
depositAmount | any | Yes |
borrowAmount | any | Yes |
fromSubAccountId | number | Yes |
toSubAccountId | number | Yes |
txParams | TxParams | No |
| Returns |
|---|
Promise<string> |
Transfer Isolated Perp Position Deposit
// Move deposits associated with an isolated perp position between subaccounts
await driftClient.transferIsolatedPerpPositionDeposit(0, 1, 0);Method DriftClient.transferIsolatedPerpPositionDepositReference ↗
Method DriftClient.transferIsolatedPerpPositionDepositReference ↗| Parameter | Type | Required |
|---|---|---|
amount | any | Yes |
perpMarketIndex | number | Yes |
subAccountId | number | No |
txParams | TxParams | No |
trySettle | boolean | No |
noBuffer | boolean | No |
| Returns |
|---|
Promise<string> |
Last updated on