# Router Client

A TypeScript client for the Morpho Router API.

## Installation

```bash
pnpm add @morpho-dev/router
```

## Usage

### Basic Setup

```typescript
import { Router } from "@morpho-dev/router";

// Create a router client
const router = Router.connect();

// With custom URL
const router = Router.connect({
  url: "https://router.morpho.dev"
});
```

### Get Offers

```typescript
// Get all offers
const result = await router.get({});

// Get buy offers on Ethereum mainnet
const result = await router.get({
  side: "buy",
  chains: [1],
  limit: 10
});

// Get offers with specific filters
const result = await router.get({
  side: "sell",
  chains: [1, 137],
  loanTokens: ["0x1234567890123456789012345678901234567890"],
  minAmount: 1000n,
  maxAmount: 10000n,
  minRate: 500000000000000000n,
  maxRate: 1500000000000000000n,
  sortBy: "rate",
  sortOrder: "asc"
});
```

### Match Offers

```typescript
// Match offers for buy on Ethereum mainnet
const result = await router.match({
  side: "buy",
  chainId: 1
});

// Match with specific requirements
const result = await router.match({
  side: "sell",
  chainId: 1,
  rate: 1000000000000000000n,
  loanToken: "0x1234567890123456789012345678901234567890",
  collaterals: [
    {
      asset: "0x1234567890123456789012345678901234567890",
      oracle: "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
      lltv: 800000000000000000n
    }
  ],
  minMaturity: 1700000000,
  maxMaturity: 1800000000
});
```