> For the complete documentation index, see [llms.txt](https://docs.aftermath.finance/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aftermath.finance/for-developers/typescript-sdk.md).

# TypeScript SDK

The Aftermath SDK provides easy access to Aftermath Finance's protocols on the Sui blockchain.

### Installation

```bash
npm i aftermath-ts-sdk
```

### Quick Start (Aftermath SDK)

For most integrations, use the Aftermath SDK for simplified access:

```typescript
import { Aftermath } from "aftermath-ts-sdk";

const afSdk = await Aftermath.create({ network: "MAINNET" });

// Access protocols
const router = afSdk.Router();
const pools = afSdk.Pools();
const staking = afSdk.Staking();
const farms = afSdk.Farms();
const dca = afSdk.Dca();
const gasPools = afSdk.GasPools();
const dynamicGas = afSdk.DynamicGas();
```

### Advanced Usage (AftermathApi)

For complex transaction construction, use AftermathApi for direct control:

```typescript
const afApi = new AftermathApi(grpcClient, addresses, jsonRpcClient);
const afSdk = await Aftermath.create({ api: afApi });

// Access protocol APIs
const poolsApi = afSdk.Pools();
const stakingApi = afSdk.Staking();
const farmsApi = afSdk.Farms();
```

The SDK is ESM and expects `@mysten/sui >=2.0.0 <3.0.0` as a peer dependency. BigInt request fields serialize as strings such as `"123n"`, and matching response values are revived to JavaScript `bigint` values.

Transaction methods return Sui `Transaction` objects. Catch `AftermathTransportError` to distinguish HTTP, network, abort, timeout, and decode failures. See [Lifecycle & Transport](/for-developers/typescript-sdk/lifecycle-and-transport.md) for initialization, custom endpoints, abort signals, transaction parsing, and gRPC configuration.

{% hint style="warning" %}
Some v3 SDK methods still point to API routes or signed-message formats that have been removed from the current service. Check [SDK/API Compatibility](/for-developers/typescript-sdk/api-compatibility.md), especially for builder-code vaults, DCA, limit orders, referrals, GasPool sponsorship, and legacy router helpers.
{% endhint %}

### Available Protocols

#### Pools (AMM)

* Automated Market Maker pools for trading
* Support for stable and uncorrelated assets
* Up to 8 assets per pool
* [View Pools Documentation](https://docs.aftermath.finance/developers/aftermath-ts-sdk/products/pools)

#### Router

* Smart order routing across multiple pools
* Optimal trade execution via split routes
* [View Router Documentation](https://docs.aftermath.finance/developers/aftermath-ts-sdk/products/router)

#### Staking

* Liquid staking for SUI tokens
* Earn yield with afSUI
* [View Staking Documentation](https://docs.aftermath.finance/developers/aftermath-ts-sdk/products/liquid-staking)

#### Farms

* Yield farming opportunities
* Stake LP tokens and earn rewards
* [View Farms Documentation](https://docs.aftermath.finance/developers/aftermath-ts-sdk/products/farms)

#### DCA (Dollar-Cost Averaging)

* Automated periodic investments
* Reduce impact of market volatility
* [View DCA Documentation](https://docs.aftermath.finance/developers/aftermath-ts-sdk/products/DCA)

#### Gas Pools

* Create and fund shared SUI gas pools
* Grant or revoke wallet access and sponsor transactions
* [View Gas Pools Documentation](/for-developers/typescript-sdk/products/gas-pools.md)

#### Dynamic Gas

* Allow users to pay transaction gas with supported non-SUI coins
* [View Dynamic Gas Documentation](/for-developers/typescript-sdk/products/dynamic-gas.md)

### Limit Orders

* Set precise buy or sell conditions
* Enable automated trades at desired price levels
* [View Limit Order Documentation](#limit-orders)

### Rate Limits

Default rate limit: 1000 requests per 10 seconds

For higher limits, contact us via:

* [Telegram](https://t.me/aftermath_fi)
* [Discord](https://discord.gg/VFqMUqKHF3)
* [X/Twitter](https://x.com/AftermathFi)
