> For the complete documentation index, see [llms.txt](https://docs.squidrouter.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.squidrouter.exchange/additional-resources/additional-dev-resources/sdk-easter-eggs/setting-toamount.md).

# Setting toAmount

If you want to buy something worth a certain amount, the best method is to overestimate by more than the expected slippage. We have a method on the SDK to estimate the required `fromAmount` you need to get a `toAmount` on the destination chain. It uses coingecko prices to approximate a number.

Get a `fromAmount` based on `fromToken`, `toToken` and `toAmount`.

Example usage:

```typescript
const ETH = squid.getTokenData(
  "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  "1"
);

const USDC = squid.getTokenData(
  "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
  "1"
);

const usdcToEth = await squid.getFromAmount({
  fromToken: USDC,
  toAmount: "1",
  toToken: ETH
}); // expected: ~1600

const ethToUsdc = await squid.getFromAmount({
  fromToken: ETH,
  toAmount: "200",
  toToken: USDC
}); // expected: ~0.12...

// you can also specify slippage percentage (default is 1.5%)
const usdcToEth3 = await squid.getFromAmount({
  fromToken: USDC,
  toAmount: "1",
  toToken: ETH,
  slippagePercentage: 3
}); // expected: ~1648
```


---

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

```
GET https://docs.squidrouter.exchange/additional-resources/additional-dev-resources/sdk-easter-eggs/setting-toamount.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.
