Aftermath TypeScript SDK
This skill documents aftermath-ts-sdk v3.1.0 against the Aftermath API as of
2026-08-19. Read the focused reference files only for the package or
compatibility surface being changed.
Start with the supported entry point
Install and import the package by its actual name:
npm i aftermath-ts-sdk@3.1.0
import { Aftermath } from "aftermath-ts-sdk";
const sdk = await Aftermath.create({ network: "MAINNET" });
const pools = sdk.Pools();
const perps = sdk.Perpetuals();
Do not use the old new Aftermath(...); await init() pattern or the old
@aftermath-finance/sdk package name. Direct construction is private; the
async factory bootstraps addresses and a SuiGrpcClient.
Choose the surface
| Need |
Use |
| Initialization, network overrides, BigInt, abort signals, gRPC, JSON-RPC, or transport errors |
transport-and-lifecycle.md |
| Pool/farm/staking/router/coin/wallet/general package methods |
packages.md |
| Perpetual markets, accounts, vaults, order builders, TWAP, or WebSockets |
perpetuals.md |
| Determine whether an SDK method matches the current API service |
backend-alignment.md |
| Raw endpoint payloads and operational safety |
../api/SKILL.md and its focused references |
The root package re-exports the configured provider, selected package classes,
types, casting helpers, and transport error utilities. Prefer
sdk.<Accessor>() for configured clients; the accessors are functions, not
singleton properties. The current configured accessors are Pools, Staking,
SuiFrens, Faucet, Router, NftAmm, ReferralVault (deprecated),
Referrals, GasPools, Perpetuals, Rewards, Farms, Dca, Multisig,
LimitOrders, UserData, Sui, Prices, Wallet(address),
Coin(coinType?), DynamicGas, and Auth. At v3.1.0, not every accessor
class is re-exported from the package barrel (Dca, LimitOrders,
Multisig, Referrals, Rewards, UserData, and DynamicGas are the
important exceptions); use the configured accessors instead of assuming a
direct named import exists.
Rules that prevent common breakage
- Serialize SDK
bigint request values as the SDK expects; its JSON replacer
emits strings such as "123n", and normal response parsing revives those
strings to bigint. Do not globally patch BigInt.prototype.
- Transaction methods return
@mysten/sui Transaction objects. The SDK
chooses Transaction.fromKind for ordinary txKind responses and
Transaction.from when a response includes sponsorSignature; set the
sender when the request has walletAddress.
- Pass an
AbortSignal as the final positional argument where supported.
Aftermath.create(options, signal) supports bootstrap cancellation, and
selected pool/farm/price/coin metadata/decimal reads and summary methods
accept final positional abort signals.
Perpetuals().getVaultsConfig(signal?) reads the live vault protocol limits
from POST /api/perpetuals/vaults/config. Integer fields are returned as
bigint values; do not use removed hardcoded PerpetualsVault.constants.
Perpetuals().getGrantVaultAgentWalletTx(...) and
getRevokeVaultAgentWalletTx(...) build vault-owner transactions for
assistant capabilities. A PerpetualsVault wrapper exposes the corresponding
getGrantAgentWalletTx(...) and getRevokeAgentWalletTx(...) methods.
- Catch
AftermathTransportError and branch on kind (http, network,
abort, timeout, or decode) instead of matching only error text. HTTP
messages retain the legacy HTTP <status> <statusText>: <body> format.
- Check backend-alignment.md before using
signed DCA, limit-order, referral, gas-sponsor, or deprecated integrator
vault helpers. The service has moved to reusable terms authentication while
deprecated v3.1.0 action-message builders remain in some package surfaces.
- Use
AftermathApi only when direct protocol API helpers are needed. It is
gRPC-first; the optional JSON-RPC client is required by the three legacy
helpers named by requireJsonRpcClient. Prefer high-level Aftermath API
providers for events, transaction history, and system state.
1---2name: aftermath-ts-sdk3description: Integrate and troubleshoot the current Aftermath TypeScript SDK for Sui, including Aftermath.create initialization, protocol accessors, transaction builders, perpetuals, pools, farms, transport errors, gRPC setup, and SDK/API compatibility. Use when working with the aftermath-ts-sdk package, its TypeScript source/types, or code that must reconcile the SDK with the Aftermath API.4---56# Aftermath TypeScript SDK78This skill documents `aftermath-ts-sdk` v3.1.0 against the Aftermath API as of92026-08-19. Read the focused reference files only for the package or10compatibility surface being changed.1112## Start with the supported entry point1314Install and import the package by its actual name:1516```bash17npm i aftermath-ts-sdk@3.1.018```1920```typescript21import { Aftermath } from "aftermath-ts-sdk";2223const sdk = await Aftermath.create({ network: "MAINNET" });24const pools = sdk.Pools();25const perps = sdk.Perpetuals();26```2728Do not use the old `new Aftermath(...); await init()` pattern or the old29`@aftermath-finance/sdk` package name. Direct construction is private; the30async factory bootstraps addresses and a `SuiGrpcClient`.3132## Choose the surface3334| Need | Use |35|---|---|36| Initialization, network overrides, BigInt, abort signals, gRPC, JSON-RPC, or transport errors | [transport-and-lifecycle.md](references/transport-and-lifecycle.md) |37| Pool/farm/staking/router/coin/wallet/general package methods | [packages.md](references/packages.md) |38| Perpetual markets, accounts, vaults, order builders, TWAP, or WebSockets | [perpetuals.md](references/perpetuals.md) |39| Determine whether an SDK method matches the current API service | [backend-alignment.md](references/backend-alignment.md) |40| Raw endpoint payloads and operational safety | [../api/SKILL.md](../api/SKILL.md) and its focused references |4142The root package re-exports the configured provider, selected package classes,43types, casting helpers, and transport error utilities. Prefer44`sdk.<Accessor>()` for configured clients; the accessors are functions, not45singleton properties. The current configured accessors are `Pools`, `Staking`,46`SuiFrens`, `Faucet`, `Router`, `NftAmm`, `ReferralVault` (deprecated),47`Referrals`, `GasPools`, `Perpetuals`, `Rewards`, `Farms`, `Dca`, `Multisig`,48`LimitOrders`, `UserData`, `Sui`, `Prices`, `Wallet(address)`,49`Coin(coinType?)`, `DynamicGas`, and `Auth`. At v3.1.0, not every accessor50class is re-exported from the package barrel (`Dca`, `LimitOrders`,51`Multisig`, `Referrals`, `Rewards`, `UserData`, and `DynamicGas` are the52important exceptions); use the configured accessors instead of assuming a53direct named import exists.5455## Rules that prevent common breakage5657- Serialize SDK `bigint` request values as the SDK expects; its JSON replacer58 emits strings such as `"123n"`, and normal response parsing revives those59 strings to `bigint`. Do not globally patch `BigInt.prototype`.60- Transaction methods return `@mysten/sui` `Transaction` objects. The SDK61 chooses `Transaction.fromKind` for ordinary `txKind` responses and62 `Transaction.from` when a response includes `sponsorSignature`; set the63 sender when the request has `walletAddress`.64- Pass an `AbortSignal` as the final positional argument where supported.65 `Aftermath.create(options, signal)` supports bootstrap cancellation, and66 selected pool/farm/price/coin metadata/decimal reads and summary methods67 accept final positional abort signals.68- `Perpetuals().getVaultsConfig(signal?)` reads the live vault protocol limits69 from `POST /api/perpetuals/vaults/config`. Integer fields are returned as70 `bigint` values; do not use removed hardcoded `PerpetualsVault.constants`.71- `Perpetuals().getGrantVaultAgentWalletTx(...)` and72 `getRevokeVaultAgentWalletTx(...)` build vault-owner transactions for73 assistant capabilities. A `PerpetualsVault` wrapper exposes the corresponding74 `getGrantAgentWalletTx(...)` and `getRevokeAgentWalletTx(...)` methods.75- Catch `AftermathTransportError` and branch on `kind` (`http`, `network`,76 `abort`, `timeout`, or `decode`) instead of matching only error text. HTTP77 messages retain the legacy `HTTP <status> <statusText>: <body>` format.78- Check [backend-alignment.md](references/backend-alignment.md) before using79 signed DCA, limit-order, referral, gas-sponsor, or deprecated integrator80 vault helpers. The service has moved to reusable terms authentication while81 deprecated v3.1.0 action-message builders remain in some package surfaces.82- Use `AftermathApi` only when direct protocol API helpers are needed. It is83 gRPC-first; the optional JSON-RPC client is required by the three legacy84 helpers named by `requireJsonRpcClient`. Prefer high-level Aftermath API85 providers for events, transaction history, and system state.