Two things before you start: a Node API token for authentication (without one, requests return
401 Unauthorized) and an API Wallet to sign transactions.Purpose
- Place/cancel orders (limit/market/stop, TP/SL, TWAP).
- Manage collateral, Trading Accounts, delegations, and builder fees.
- Create, fund, and manage vaults; place orders on behalf of a vault subaccount.
When to use
- Use when you need to submit transactions or manage trading state.
- Avoid embedding private keys in browsers. Prefer:
- Wallets/session keys and pass
accountOverridefor specific calls. - Server-side orchestration where secrets are controlled.
- Wallets/session keys and pass
Formatting price and size
See the formatting guide for converting UI values into chain units (e.g.,amountToChainUnits).
Initialization
Function reference
The tables below enumerate every callable helper exposed inDecibelWriteDex (plus the roundToTickSize utility) along with the argument types you should pass. All functions live on an instantiated write client unless otherwise noted.
Utilities
roundToTickSize
Returns: number
price:number(required) – price in chain unitstickSize:number(required) – tick size in chain units
sendSubaccountTx
Returns: Promise<CommittedTransactionResponse>
sendTx:(subaccountAddr: string) => Promise<CommittedTransactionResponse>(required)subaccountAddr:string(optional) – defaults to primary subaccount
withSubaccount
Returns: Promise<T>
fn:(subaccountAddr: string) => Promise<T>(required)subaccountAddr:string(optional) – defaults to primary subaccount
Trading Accounts and Collateral
renameSubaccount
Returns: Promise<void>
subaccountAddress:string(required)newName:string(required)
createSubaccount
Returns: Promise<CommittedTransactionResponse>
No arguments. Creates a new Trading Account for the owner.
deposit
Returns: Promise<CommittedTransactionResponse>
amount:number(required) – USDC amount in u64 base unitssubaccountAddr:string(optional) – defaults to primary subaccount
withdraw
Returns: Promise<CommittedTransactionResponse>
amount:number(required) – USDC amount in u64 base unitssubaccountAddr:string(optional) – defaults to primary subaccount
configureUserSettingsForMarket
Returns: Promise<CommittedTransactionResponse>
marketAddr:string(required)subaccountAddr:string(required)isCross:boolean(required)userLeverage:number(required)
buildDeactiveSubaccountTx
Returns: Promise<SimpleTransaction>
subaccountAddr:string(required)revokeAllDelegations:boolean(required, defaults totrue)signerAddress:AccountAddress(required)
Orders and matching
placeOrder
Returns: Promise<PlaceOrderResult>
marketName:string(required)price:number(required) – in chain unitssize:number(required) – in chain unitsisBuy:boolean(required)timeInForce:TimeInForce(required)isReduceOnly:boolean(required)clientOrderId:string(optional)stopPrice:number(optional)tpTriggerPrice:number(optional)tpLimitPrice:number(optional)slTriggerPrice:number(optional)slLimitPrice:number(optional)builderAddr:string(optional)builderFee:number(optional)subaccountAddr:string(optional)accountOverride:Account(optional)tickSize:number(optional) – auto-rounds prices to tick multiples
cancelOrder
Returns: Promise<CommittedTransactionResponse>
orderId:number | string(required)marketName:string(required ifmarketAddrnot provided)marketAddr:string(required ifmarketNamenot provided)subaccountAddr:string(optional)accountOverride:Account(optional)
cancelClientOrder
Returns: Promise<CommittedTransactionResponse>
clientOrderId:string(required)marketName:string(required)subaccountAddr:string(optional)accountOverride:Account(optional)
triggerMatching
Returns: Promise<{ success: boolean; transactionHash: string }>
marketAddr:string(required)maxWorkUnit:number(required)
placeTwapOrder
Returns: Promise<PlaceOrderResult>
marketName:string(required)size:number(required) – in chain unitsisBuy:boolean(required)isReduceOnly:boolean(required)clientOrderId:string(optional)twapFrequencySeconds:number(required)twapDurationSeconds:number(required)builderAddress:string(optional)builderFees:number(optional)subaccountAddr:string(optional)accountOverride:Account(optional)
cancelTwapOrder
Returns: Promise<CommittedTransactionResponse>
orderId:string(required)marketAddr:string(required)subaccountAddr:string(optional)accountOverride:Account(optional)
placeOrder argument shape
Position TP/SL helpers
placeTpSlOrderForPosition
Returns: Promise<CommittedTransactionResponse>
marketAddr:string(required)tpTriggerPrice:number(optional)tpLimitPrice:number(optional)tpSize:number(optional)slTriggerPrice:number(optional)slLimitPrice:number(optional)slSize:number(optional)subaccountAddr:string(optional)accountOverride:Account(optional)tickSize:number(optional) – auto-rounds prices to tick multiples
updateTpOrderForPosition
Returns: Promise<CommittedTransactionResponse>
marketAddr:string(required)prevOrderId:number | string(required)tpTriggerPrice:number(optional)tpLimitPrice:number(optional)tpSize:number(optional)subaccountAddr:string(optional)accountOverride:Account(optional)
updateSlOrderForPosition
Returns: Promise<CommittedTransactionResponse>
marketAddr:string(required)prevOrderId:number | string(required)slTriggerPrice:number(optional)slLimitPrice:number(optional)slSize:number(optional)subaccountAddr:string(optional)accountOverride:Account(optional)
cancelTpSlOrderForPosition
Returns: Promise<CommittedTransactionResponse>
marketAddr:string(required)orderId:number | string(required)subaccountAddr:string(optional)accountOverride:Account(optional)
Delegation and builder fees
delegateTradingToForSubaccount
Returns: Promise<CommittedTransactionResponse>
subaccountAddr:string(required)accountToDelegateTo:string(required)expirationTimestampSecs:number(optional)
revokeDelegation
Returns: Promise<CommittedTransactionResponse>
subaccountAddr:string(optional) – defaults to primary subaccountaccountToRevoke:string(required)
approveMaxBuilderFee
Returns: Promise<CommittedTransactionResponse>
builderAddr:string(required)maxFee:number(required) – in basis pointssubaccountAddr:string(optional) – defaults to primary subaccount
revokeMaxBuilderFee
Returns: Promise<CommittedTransactionResponse>
builderAddr:string(required)subaccountAddr:string(optional) – defaults to primary subaccount
Vault transactions
Vault lifecycle helpers call the same on-chain entry functions documented in the Vault Integration Guide. That guide uses only
DecibelWriteDex / DecibelReadDex for TypeScript.On Aptos testnet, a full smoke flow needs about 210 USDC in the contributor subaccount (100_000_000 creation fee + 100_000_000 minimum initialFunding + 10_000_000 minimum follow-on depositToVault). See the funding table in the guide.End-to-end reference: typescript/packages/e2e/src/vault-e2e.ts — run cd typescript/packages/e2e && pnpm start:vault-e2e (.env.example lists required keys).Gas Station (optional) — Omit
gasStationApiKey to have users pay gas with APT; createVault, depositToVault, withdrawFromVault, and placeOrder work as usual. If gasStationApiKey is set, custom Move calls (e.g. testnet restricted_mint) and manually signed build* transactions must use buildTx + submitTx instead of aptos.transaction.build.simple. See Gas Station and vault guide steps 5 and 9. The vault-e2e script enables Gas Station on testnet for convenience only.createVault, depositToVault, and withdrawFromVault build, sign, and submit in one call. The build* helpers below return a SimpleTransaction for custom signing (for example fee-payer flows).
createVault
Returns: Promise<CommittedTransactionResponse>
Same parameters as CreateVaultArgs (see type references), plus optional subaccountAddr and accountOverride. Submits vault_api::create_and_fund_vault. Parse the new vault address with extractVaultAddressFromCreateTx.
depositToVault
Returns: Promise<CommittedTransactionResponse>
vaultAddress:string(required)amount:number(required) — USDC in chain units (6 decimals)subaccountAddr:string(required) — contributor’s Trading Account
withdrawFromVault
Returns: Promise<CommittedTransactionResponse>
vaultAddress:string(required)shares:number(required) — share amount in chain units (minimum redemption is about5_000_000units, ~$5 at 6 decimals on testnet)subaccountAddr:string(optional) — defaults to primary subaccount
current_num_shares before redeeming: read.vaults.getUserPerformancesOnVaults({ ownerAddr: subaccountAddr }) — ownerAddr must be the contributor’s Trading Account (subaccount), not the wallet address.
All build* vault helpers accept WithSignerAddress<T> (payload plus signerAddress).
buildCreateVaultTx
Returns: Promise<SimpleTransaction>
contributionAssetType:string(optional)vaultName:string(required)vaultDescription:string(required)vaultSocialLinks:string[](required)vaultShareSymbol:string(required)vaultShareIconUri:string(optional)vaultShareProjectUri:string(optional)feeBps:number(required)feeIntervalS:number(optional)contributionLockupDurationS:number(optional)initialFunding:number(required)acceptsContributions:boolean(optional)delegateToCreator:boolean(optional)signerAddress:AccountAddress(required)
buildActivateVaultTx
Returns: Promise<SimpleTransaction>
vaultAddress:string(required)signerAddress:AccountAddress(required)
buildDepositToVaultTx
Returns: Promise<SimpleTransaction>
vaultAddress:string(required)amount:number(required)signerAddress:AccountAddress(required)
buildWithdrawFromVaultTx
Returns: Promise<SimpleTransaction>
vaultAddress:string(required)shares:number(required)signerAddress:AccountAddress(required)
buildDelegateDexActionsToTx
Returns: Promise<SimpleTransaction>
vaultAddress:string(required)accountToDelegateTo:string(required)signerAddress:AccountAddress(required)expirationTimestampSecs:number(optional)
Trading on behalf of a vault
Vault trading is not a separate API. After the vault creator (or a delegate) is authorized viadelegateToCreator or buildDelegateDexActionsToTx, call placeOrder, cancelOrder, TP/SL, or TWAP with subaccountAddr set to the vault portfolio subaccount — not your wallet’s primary subaccount.
Derive the vault subaccount from the vault object address:
typescript/packages/e2e/src/vault-e2e.ts in this repository. That script runs create → depositToVault → withdrawFromVault → delegate → placeOrder on testnet.
For the full vault launch walkthrough (mint, fund, create, delegate), see the Vault Integration Guide.
TWAP and notification helpers
placeTwapOrder, cancelTwapOrder, and the readers exposed under read.userActiveTwaps bridge the trading + monitoring workflow. For notification rendering, reference the Rust trading API docs.
Session keys and overrides
All transaction helpers accept anaccountOverride to sign with a different account (e.g., a session key) while the SDK was constructed with the primary account:

