# Developer Guide

The Gator SDK provides easy programmatic access to decentralized exchanges on NEAR.

### 1. Compute Swap Routes

A typical usage is to find the best swap route. This is what you can access on the gator.fi web page:

```typescript
import { Gator } from '@gator/sdk';
const gator = new Gator();

const routes gator.computeRoutes({
    input: 'wrap.near',
    output: 'aurora.near',
    amount: '3'
});
const txs = gator.generateTransactions(routes[0]);

// Transactions are ready to be signed and sent to blockchain
await wallet.signAndSendTransactions({ transactions: txs });
```

### 2. Find Best Bid/Offer - simple arbitrage bot

The Gator SDK also allows you to find the best bid/offer across decentralized exchanges on NEAR. The functions `computeBestBid` and `computeBestOffer` does the necessarily conversion so the numbers fit into a traditional base/quote pair paradigm. For example, we can use the Gator SDK to implement a simple arbitrage strategy:

```typescript
while (true) {
    const base = 'aurora.near';
    const quote = 'wrap.near';
    
    // Aggregate bid / ask levels within 10 bips
    const bestBid = gator.computeBestBid({ base, quote }, 0.001);
    const bestOffer = gator.computeBestOffer({ base, quote }, 0.001);

    if (bestBid['price'] < bestOffer['price']) {
        const amount = Math.min(bestBid['amount'], bestOffer['amount'])
        await wallet.signAndSendTransactions({
            transactions: [
                ...gator.generateTransactions({ ...bestBid, amount }),
                ...gator.generateTransactions({ ...bestOffer, amount }),
            ]
        })
    }

    await new Promise((r) => setTimeout(r, 5000));
}
```


---

# Agent Instructions: 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:

```
GET https://gator.gitbook.io/docs/developers/developer-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
