npm package: @ponderfinance/sdk
Description: SDK for interacting with Ponder DEX and 55555 Launcher
Author: @taayyohh
Latest version: 1.0.38

# Ponder SDK

TypeScript SDK for interacting with the Ponder DEX protocol on Bitkub Chain.

## Installation

```bash
npm install @ponderfinance/sdk
# or
yarn add @ponderfinance/sdk
```

## Quick Start

```typescript
import { PonderSDK } from '@ponderfinance/sdk'
import { createPublicClient, createWalletClient, http, custom } from 'viem'

// Initialize SDK
const sdk = new PonderSDK({
  chainId: 96, // Bitkub Chain
  // Optional: provide your own clients
  publicClient,
  walletClient
})
```

## Core Features

### Factory Operations

```typescript
// Get pair address
const pairAddress = await sdk.factory.getPair(tokenA, tokenB)

// Create new pair
const result = await sdk.factory.createPair({
  tokenA: '0x...',
  tokenB: '0x...'
})
const { pairAddress, token0, token1 } = await result.wait()
```

### Router Operations

```typescript
// Add liquidity
await sdk.router.addLiquidity({
  tokenA: '0x...',
  tokenB: '0x...',
  amountADesired: parseEther('1'),
  amountBDesired: parseEther('1'),
  amountAMin: parseEther('0.95'),
  amountBMin: parseEther('0.95'),
  to: userAddress,
  deadline: BigInt(Math.floor(Date.now() / 1000) + 1200) // 20 minutes
})

// Get swap amounts
const amountsOut = await sdk.router.getAmountsOut(
  parseEther('1'),
  [tokenA, tokenB]
)

// Swap tokens
await sdk.router.swapExactTokensForTokens({
  amountIn: parseEther('1'),
  amountOutMin: parseEther('0.95'),
  path: [tokenA, tokenB],
  to: userAddress,
  deadline: BigInt(Math.floor(Date.now() / 1000) + 1200)
})
```

### Pair Operations

```typescript
const pair = sdk.getPair(pairAddress)

// Get reserves
const { reserve0, reserve1, blockTimestampLast } = await pair.getReserves()

// Add liquidity
await pair.mint(userAddress)

// Remove liquidity
await pair.burn(userAddress)
```

### MasterChef Operations

```typescript
// Get pool info
const poolInfo = await sdk.masterChef.poolInfo(0n)
const userInfo = await sdk.masterChef.userInfo(0n, userAddress)

// Get pending rewards
const pending = await sdk.masterChef.pendingPonder(0n, userAddress)

// Stake LP tokens
await sdk.masterChef.deposit(0n, parseEther('1'))

// Unstake LP tokens
await sdk.masterChef.withdraw(0n, parseEther('1'))

// Boost rewards with PONDER tokens
await sdk.masterChef.boostStake(0n, parseEther('100'))
```

## React/Next.js Integration

```typescript
import { usePublicClient, useWalletClient } from 'wagmi'
import { PonderSDK } from '@ponderfinance/sdk'
import { useMemo } from 'react'

function usePonderSDK() {
  const publicClient = usePublicClient()
  const { data: walletClient } = useWalletClient()

  const sdk = useMemo(() => {
    if (!publicClient) return null

    return new PonderSDK({
      chainId: 96,
      publicClient,
      walletClient: walletClient ?? undefined
    })
  }, [publicClient, walletClient])

  return sdk
}

// Usage in component
function SwapComponent() {
  const sdk = usePonderSDK()

  const handleSwap = async () => {
    if (!sdk) return
    
    const amountsOut = await sdk.router.getAmountsOut(
      parseEther('1'),
      [tokenA, tokenB]
    )
    
    // Execute swap...
  }

  return <button onClick={handleSwap}>Swap</button>
}
```

## Error Handling

```typescript
try {
  await sdk.router.swapExactTokensForTokens({
    // ... params
  })
} catch (error) {
  if (error.message.includes('Wallet client required')) {
    console.error('Please connect your wallet')
  } else if (error.message.includes('INSUFFICIENT_OUTPUT_AMOUNT')) {
    console.error('Slippage too high')
  } else {
    console.error('Swap failed:', error)
  }
}
```

## Supported Chains

- Bitkub Chain (ChainID: 96)
- Bitkub Testnet (ChainID: 25925)

## API Reference

See [API Documentation](./docs/API.md) for detailed information about all available methods and types.

## TypeScript Support

The SDK is written in TypeScript and provides full type definitions for all exports.

## Contributing

Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.

## License

MIT Licensed. See [LICENSE](./LICENSE) for more details.