npm package: @rakeshsteer/internal-sdk
Description: A TypeScript SDK for interacting with Algebra Integral protocol - a next-generation AMM protocol
Author: cryptoalgebra
Latest version: 0.12.9

# Algebra Integral SDK

A TypeScript SDK for interacting with Algebra Integral protocol - a next-generation AMM protocol.

## Installation

```bash
npm install @rakeshsteer/internal-sdk
```

or

```bash
yarn add @rakeshsteer/internal-sdk
```

## Features

- **Type Safety**: Full TypeScript support with comprehensive type definitions
- **Multi-chain Support**: Works across multiple blockchain networks
- **Comprehensive Utilities**: Pool calculations, price conversions, and more
- **Modern Architecture**: Built with modern JavaScript/TypeScript practices

## Quick Start

```typescript
import { ChainId, Token, CurrencyAmount } from '@rakeshsteer/internal-sdk';

// Create a token
const token = new Token(
  ChainId.Mantle,
  '0x...',
  18,
  'SYMBOL',
  'Token Name'
);

// Work with currency amounts
const amount = CurrencyAmount.fromRawAmount(token, '1000000000000000000');
```

## Supported Chains

The SDK supports the following blockchain networks:

- **Mainnets**: ZKSync, Mantle, Telos, Mode, Arthera, Linea
- **Testnets**: Goerli, ZKSync Testnet, BSC Testnet, Mantle Testnet, Telos Testnet, Mode Testnet, Blast Testnet, Arthera Testnet, Linea Sepolia, Mantle Sepolia, Base Sepolia, Holesky
- **Development Networks**: Berachain Testnet, Form Testnet, Katla, Sei Devnet, Neon Devnet

## Core Entities

### ChainId

```typescript
import { ChainId } from '@rakeshsteer/internal-sdk';

console.log(ChainId.Mantle); // 5000
console.log(ChainId.ZKSync); // 324
```

### Token

```typescript
import { Token, ChainId } from '@rakeshsteer/internal-sdk';

const USDC = new Token(
  ChainId.Mantle,
  '0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9',
  6,
  'USDC',
  'USD Coin'
);
```

### Currency Amount

```typescript
import { CurrencyAmount, Token } from '@rakeshsteer/internal-sdk';

const amount = CurrencyAmount.fromRawAmount(token, '1000000');
const humanReadable = amount.toExact(); // "1.0" for 6 decimal token
```

### Pool

```typescript
import { Pool, Token } from '@rakeshsteer/internal-sdk';

const pool = new Pool(
  tokenA,
  tokenB,
  fee,
  sqrtRatioX96,
  liquidity,
  tickCurrent
);
```

## Utilities

The SDK provides numerous utility functions for:

- **Price Calculations**: Converting between different price representations
- **Tick Math**: Working with concentrated liquidity positions
- **Pool Math**: Calculating swap amounts, liquidity, etc.
- **Encoding**: Creating calldata for contract interactions

## API Reference

### Constants

- `ChainId`: Enum of supported chain IDs
- `POOL_DEPLOYER_ADDRESSES`: Pool deployer contract addresses per chain
- `POOL_INIT_CODE_HASH`: Init code hashes for pool creation

### Entities

- `Token`: Represents an ERC-20 token
- `Currency`: Base currency interface
- `CurrencyAmount`: Token amount with decimal handling
- `Price`: Exchange rate between two currencies
- `Pool`: Concentrated liquidity pool
- `Position`: Liquidity position in a pool
- `Route`: Multi-hop swap route
- `Trade`: Swap trade with input/output amounts

### Enums

- `ChainId`: Supported blockchain networks
- `TradeType`: EXACT_INPUT or EXACT_OUTPUT
- `Rounding`: Rounding modes for calculations

## Development

### Building

```bash
npm run build
```

### Linting

```bash
npm run lint
```

### Publishing

Use the provided publish script:

```bash
./publish.sh --patch  # Bump patch version and publish
./publish.sh --dry-run  # Test publish without actually publishing
./publish.sh --help  # See all options
```

For automated publishing, set your npm token in the environment:

```bash
# Using environment variable
NPM_DEPLOYMENT_KEY=your_npm_token ./publish.sh --patch

# Or create .env file (not recommended for production)
echo "NPM_DEPLOYMENT_KEY=your_npm_token" > .env
./publish.sh --patch
```

### Getting NPM Automation Token

1. Go to [npm access tokens](https://www.npmjs.com/settings/tokens)
2. Generate a new token with "Automation" type
3. Set the token in your environment:
   - For CI/CD: Set as environment variable
   - For local development: Add to `.env` file (ensure it's in `.gitignore`)

## License

MIT

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## Support

For questions and support, please visit the [Algebra Protocol documentation](https://docs.algebra.finance/).