> For the complete documentation index, see [llms.txt](https://docs.crosscurve.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.crosscurve.fi/developer-documentation/integration-guide-old/simplified-integration-with-sdk.md).

# Simplified Integration with SDK

TypeScript SDK for cross-chain token swaps via CrossCurve protocol

### Installation

```bash
npm install crosscurve-sdk

# Plus one signer library:
npm install viem        # recommended
```

### Quick Start

```typescript
import { CrossCurveSDK, ViemAdapter } from 'crosscurve-sdk';
import { createWalletClient, createPublicClient, http } from 'viem';
import { arbitrum } from 'viem/chains';
import { mnemonicToAccount } from 'viem/accounts';

const account = mnemonicToAccount('your mnemonic');
const walletClient = createWalletClient({ account, chain: arbitrum, transport: http() });
const publicClient = createPublicClient({ chain: arbitrum, transport: http() });
const signer = new ViemAdapter(walletClient, publicClient, account);

const sdk = new CrossCurveSDK();
await sdk.init();

// Get quote
const quote = await sdk.getQuote({
  fromChain: 42161,                                      // Arbitrum
  toChain: 10,                                           // Optimism
  fromToken: '0x0000000000000000000000000000000000000000', // Native ETH
  toToken: '0x0000000000000000000000000000000000000000',   // Native ETH
  amount: '1000000000000000',                             // 0.001 ETH (in wei)
  slippage: 0.5,
  sender: account.address,
  providers: ['cross-curve', 'rubic', 'bungee'],  // optional: filter by provider
});

// Execute with auto-recovery
const result = await sdk.executeQuote(quote, {
  signer,
  autoRecover: true,
  onStatusChange: (status) => console.log('Status:', status.status),
});

console.log('TX:', result.transactionHash);
console.log('Request ID:', result.requestId);
```

### Adapters

```typescript
import { ViemAdapter, EthersV6Adapter, EthersV5Adapter, Web3Adapter } from 'crosscurve-sdk';

// Viem (recommended)
new ViemAdapter(walletClient, publicClient, account)

// Ethers v6
new EthersV6Adapter(signer)

// Ethers v5
new EthersV5Adapter(signer)

// Web3.js v4
new Web3Adapter(web3, address)
```

All adapters implement `ChainSigner` interface with optional `getChainId()` method.

### Configuration

```typescript
const sdk = new CrossCurveSDK({
  // API
  apiKey: 'your-key',           // For fee sharing / integrator revenue
  baseUrl: 'https://...',       // Custom API URL

  // Validation
  maxSlippage: 5,               // Max slippage threshold (%)
  approvalMode: 'exact',        // 'exact' (recommended) or 'unlimited'

  // Polling timing
  polling: {
    initialInterval: 10000,     // 10s initial poll interval
    backoffMultiplier: 1.5,     // Exponential backoff
    maxInterval: 60000,         // 60s max interval
    timeout: 900000,            // 15min timeout
  },

  // External bridge polling (Rubic, Bungee)
  bridgePolling: {
    initialInterval: 15000,
    timeout: 1800000,           // 30min timeout
  },

  // HTTP client
  http: {
    timeout: 90000,             // Request timeout
    retryMaxTime: 90000,        // Total retry window
    retryInitialDelay: 1000,    // Initial retry delay
    retryBackoffMultiplier: 2,
  },

  // Cache
  cache: {
    ttlMs: 600000,              // 10min cache TTL
  },

  // Security
  security: {
    allowedHosts: ['custom-api.example.com'],  // Additional allowed hosts
    enforceHttps: true,         // Require HTTPS for non-localhost
  },

  // Permit
  permitDeadlineSeconds: 3600,  // 1 hour permit signature validity
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.crosscurve.fi/developer-documentation/integration-guide-old/simplified-integration-with-sdk.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
