> For the complete documentation index, see [llms.txt](https://docs.clipper.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clipper.exchange/disclaimers-and-technical/integrating-with-clipper-rfq/guides/integration-examples/swap-shorttail-shorttail.md).

# Swap Shorttail → Shorttail

E.g: 2 DAI -> USDC on Polygon (Chain 137)

{% file src="/files/aQLi0qsgSmlfob5AeYIa" %}
ABI used in the example
{% endfile %}

```javascript
const fetch = require('node-fetch');
import ethers from "ethers";
import exchangeAbi from "./exchangeAbi.json";

async function getQuote() {
  const quotePayload = {
    "pool_address": "0x6Bfce69d1Df30FD2B2C8e478EDEC9dAa643Ae3B8",
    "output_asset_symbol": "USDC",
    "input_asset_symbol": "DAI",
    "time_in_seconds": 60,
    "input_amount": "2000000000000000000"
  };
  const queryString = new URLSearchParams(quotePayload).toString();

  const requestOptions = {
    method: 'GET',
    headers: {
      'x-api-key': 'YXBpLXVzZXI6dXNlci1wYXNz',  // This is a placeholder 
      'Content-Type': 'application/json'
    }
  };

  const response = await fetch(`https://blade-api.sushi.com/rfq/v2/quote/137?${queryString}`);
  const quote = await response.json();
  
  return quote;
}

async function signQuote(quote) {
  const signPayload = {
    "quote_id": quote.id,
    "destination_address": "0xab83Af831dfb4028EBFd3fFA74A828a4d5DCaAC5"
  };

  const requestOptions = {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(signPayload)
  };

  const response = await fetch('https://blade-api.sushi.com/rfq/sign', requestOptions);
  const signResponse = await response.json();
  
  return signResponse;
}

async function executeSwap(signResponse) {
  const provider = new ethers.providers.JsonRpcProvider(process.env.RPC_URL);
  const exchangeContract = new ethers.Contract(
    signResponse.clipper_exchange_address,
    exchangeAbi,
    provider
  );

  const auxData = "0x00000000000000000000000000000000000000000000000000";

  const result = await exchangeContract.transmitAndSwap(
    signResponse.input_asset_address,
    signResponse.output_asset_address,
    signResponse.input_amount,
    signResponse.output_amount,
    signResponse.good_until,
    signResponse.destination_address,
    [signResponse.signature.v, signResponse.signature.r, signResponse.signature.s],
    auxData
  );
}

async function main() {
  // 1. Get quote
  const quote = await getQuote();
  console.log("Quote:", quote);
  
  // 2. Sign the quote
  const signResponse = await signQuote(quote);
  console.log("Sign Response:", signResponse);
  
  // 3. Execute transaction
  await executeSwap(signResponse);
  console.log("Swap executed successfully.");
}

```


---

# 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.clipper.exchange/disclaimers-and-technical/integrating-with-clipper-rfq/guides/integration-examples/swap-shorttail-shorttail.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.
