npm package: @suilab/factory-sdk
Description: TypeScript SDK for integrating SUI Lab Factory liquidity pools into your dApp
Author: SUI Lab Team
Latest version: 1.1.3

# @suilab/factory-sdk

TypeScript SDK for integrating SUI Lab Factory liquidity pools into your DeFi protocol, launchpad, or dApp.

## Installation

```bash
npm install @suilab/factory-sdk
# or
yarn add @suilab/factory-sdk
```

## Quick Start

```typescript
import { SuiLabFactorySDK, parseSUI } from '@suilab/factory-sdk';
import { SuiClient } from '@mysten/sui/client';

// Initialize SDK
const client = new SuiClient({ url: 'https://fullnode.mainnet.sui.io:443' });
const sdk = new SuiLabFactorySDK(client, 'MAINNET');

// Create pool transaction
const txb = sdk.createPoolTransaction({
  tokenAType: '0x2::sui::SUI',
  tokenBType: '0xYOUR_TOKEN::token::TOKEN',
  tokenAAmount: parseSUI(100),
  tokenBAmount: BigInt(1_000_000_000_000),
  senderAddress: 'YOUR_ADDRESS',
});

// Get pool info
const poolInfo = await sdk.getPoolInfo(poolId);

// Calculate swap output
const output = sdk.calculateSwapOutput(amountIn, reserveIn, reserveOut);
```

## Features

- ✅ Create liquidity pools programmatically
- ✅ Query pool information
- ✅ Calculate swap outputs
- ✅ Utility functions for coin management
- ✅ Full TypeScript support

## Documentation

Full documentation available at: https://docs.suilab.fun/integration

## API Reference

### SuiLabFactorySDK

Main SDK class for interacting with SUI Lab Factory.

#### Constructor

```typescript
constructor(client: SuiClient, network: 'MAINNET' | 'TESTNET' = 'MAINNET')
```

#### Methods

- `createPoolTransaction(params: PoolCreationParams): Transaction`
- `async getPoolInfo(poolId: string): Promise<PoolInfo | null>`
- `async getPoolsCreatedBy(address: string): Promise<string[]>`
- `getPoolCreationCost(): bigint`
- `calculateSwapOutput(amountIn, reserveIn, reserveOut): bigint`

### Utility Functions

- `mergeCoins(txb, coinType, coinIds)` - Merge multiple coin objects
- `splitCoin(txb, coinId, amount)` - Split exact amount from coin
- `sortTokenTypes(tokenA, tokenB)` - Sort token types alphabetically
- `formatSUI(mist)` - Format SUI amount (MIST to SUI)
- `parseSUI(sui)` - Parse SUI amount (SUI to MIST)

## Configuration

### Mainnet

```typescript
Factory ID: 0x7fde6f522facdf8708aca3152edc5725f5c00ee5e3341b8baac28cb17962cb3e
Package ID: 0x9a67f826e3d9ad2cdc7d735466435a9d6da0428705a3eb0840be271f2e62dcb6
Pool Creation Fee: 3 SUI
```

### Testnet

```typescript
Factory ID: 0xda14593db0d4258202871d40ffb73c0e0bee1d9064d1b076a666946e3eb0a020
Package ID: 0x47be8b5d9f9fbac048c54ca8ce2766bb1fa8f8d459a0ff1f19af615efe9f5415
Pool Creation Fee: 3 SUI
```

**Example: Using Testnet**

```typescript
import { SuiClient } from '@mysten/sui/client';
import { SuiLabFactorySDK } from '@suilab/factory-sdk';

const client = new SuiClient({ url: 'https://fullnode.testnet.sui.io:443' });
const sdk = new SuiLabFactorySDK(client, 'TESTNET');
```


## License

MIT

## Support

- Documentation: https://docs.suilab.fun/integration
- Email: support@suilab.fun
- GitHub Issues: https://github.com/suilab/factory-sdk/issues

**For bug reports or feature requests, email us at support@suilab.fun**