bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 27쪽 중 9쪽
posthook). |
| `bypassGuardrails` | `boolean` | No | Ignores slippage warnings on the returned route response. **If set to true, the integrator is liable for any loss of funds during the route.** |
# Route Response Schema
When you call `POST https://v2.api.squidrouter.com/v2/route`, the API returns a route response containing the optimal path, estimated output, and (if `quoteOnly` is `false`) the transaction data needed for execution.
## Top-Level Structure
```json
{
"route": {
"estimate": { ... }, // Route pricing, actions, fees, and gas costs
"transactionRequest": { ... }, // Transaction data for on-chain execution (empty when quoteOnly: true)
"params": { ... }, // Echo of your original request parameters
"quoteId": "string" // Unique quote identifier — required for Squid Intents status tracking
}
}
```
{% hint style="danger" %}
**Important:** The `quoteId` field is required for all Squid Intents status tracking. If `quoteId` is not included in status calls, the transaction will be **refunded** to the source chain.
{% endhint %}
***
## `route.estimate`
The estimate object contains all pricing information, the ordered list of actions, and cost breakdowns.
| Field | Type | Description |
| ------------------------ | ----------- | ------------------------------------------------------------------ |
| `actions` | `Action[]` | Ordered array of steps the route will take (swaps, bridges, wraps) |
| `fromAmount` | `string` | Input amount in the token's smallest unit |
| `toAmount` | `string` | Estimated output amount in the token's smallest unit |
| `toAmountMin` | `string` | Minimum output after accounting for slippage |
| `exchangeRate` | `string` | Overall exchange rate between source and destination tokens |
| `aggregatePriceImpact` | `string` | Total price impact across all steps (e.g. `"0.0"`, `"-0.02"`) |
| `fromAmountUSD` | `string` | USD value of the input amount |
| `toAmountUSD` | `string` | USD value of the estimated output |
| `toAmountMinUSD` | `string` | USD value of the minimum output |
| `aggregateSlippage` | `number` | Total slippage percentage across the route |
| `fromToken` | `Token` | Full source token object |
| `toToken` | `Token` | Full destination token object |
| `feeCosts` | `FeeCost[]` | Breakdown of fees (bridging fees, boost fees) |
| `gasCosts` | `GasCost[]` | Breakdown of gas costs |
| `estimatedRouteDuration` | `number` | Estimated total time in seconds |
***
## `Action` Object
Each action represents one step in the route. Actions are executed in order, with `stage: 0` for source chain actions and `stage: 1` for destination chain actions.
| Field | Type | Description |
| ------------------- | -------- | ------------------------------------------------------------------- |
| `type` | `string` | Type of action: `"bridge"`, `"swap"`, or `"wrap"` |
| `chainType` | `string` | Chain ecosystem (e.g. `"evm"`, `"cosmos"`) |
| `data` | `object` | Provider-specific data (varies by action type — see below) |
| `fromChain` | `string` | Chain ID where this action starts |
| `toChain` | `string` | Chain ID where this action ends |
| `fromToken` | `Token` | Input token for this step |
| `toToken` | `Token` | Output token for this step |
| `fromAmount` | `string` | Input amount for this step |
| `toAmount` | `string` | Estimated output for this step |
| `toAmountMin` | `string` | Minimum output after slippage for this step |
| `exchangeRate` | `string` | Exchange rate for this step |
| `priceImpact` | `string` | Price impact for this step |
| `stage` | `number` | `0` = source chain, `1` = destination chain |
| `provider` | `string` | Provider name (e.g. `"Axelar"`, `"Uniswap V3"`, `"Pancakeswap V3"`) |
| `logoURI` | `string` | Provider logo URL |
| `description` | `string` | Human-readable description (e.g. `"Swap USDC to WETH"`) |
| `estimatedDuration` | `number` | (Bridges only) Estimated duration in seconds |
### Action Type: `bridge`
Cross-chain bridge step. The `data` object contains:
```json
{
"name": "Axelar",
"provider": "Axelar",
"type": "axelar-gmp",
"logoURI": "https://..."
}
```
### Action Type: `swap`
DEX swap step. The `data` object contains:
```json
{
"address": "0x...", // Pool or pair address
"chainId": "42161",
"coinAddresses": ["0x...", "0x..."],
"dex": "Uniswap V3", // DEX name
"path": ["0x...", "0x..."], // Token swap path
"slippage": 0.0105,
"aggregateSlippage": 0.0105,
"target": "0x..." // Router contract address
}
```
### Action Type: `wrap`
Native token wrap or unwrap step. The `data` object contains:
```json
{
"address": "0x...", // Wrapped token contract
"type": "WrappedNative",
"path": ["0x...", "0x..."],
"direction": "wrap", // "wrap" or "unwrap"
"target": "0x..."
}
```
***
## `route.transactionRequest`
When `quoteOnly: false`, this object contains the transaction data needed for on-chain execution. The structure depends on the [Transaction Type](/api-and-sdk-integration/key-concepts/transaction-types).
For EVM `ON_CHAIN_EXECUTION` transactions:
| Field | Type | Description |
| ---------------------- | -------- | ---------------------------------------------------- |
| `routeType` | `string` | Route type (e.g. `"CALL_BRIDGE_CALL"`, `"EVM_ONLY"`) |
| `target` | `string` | Contract address to call |
| `data` | `string` | Encoded calldata |
| `value` | `string` | Native token value to send (wei) |
| `gasLimit` | `string` | Recommended gas limit |
| `gasPrice` | `string` | Current gas price |
| `maxFeePerGas` | `string` | EIP-1559 max fee |
| `maxPriorityFeePerGas` | `string` | EIP-1559 priority fee |
For `DEPOSIT_ADDRESS_WITH_SIGNATURE` transactions (Hedera):
| Field | Type | Description |
| ------------------- | -------- | ---------------------------------------- |
| `routeType` | `string` | `"DEPOSIT_ADDRESS_WITH_SIGNATURE"` |
| `depositAddress` | `string` | Address to send funds to |
| `signatureRequired` | `object` | Contains `orderHash` that must be signed |
{% hint style="info" %}
When `quoteOnly: true`, `transactionRequest` is an empty object `{}`. This is useful for showing users estimated outputs before they commit to executing the swap.
{% endhint %}
***
## `route.params`
An echo of your original request parameters, returned for reference:
```json
{
"fromChain": "1",
"toChain": "42161",
"fromToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
"toToken": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"fromAmount": "1000000",
"fromAddress": "0x...",
"toAddress": "0x...",
"slippage": 1,
"quoteOnly": true
}
```
***
## `FeeCost` Object
| Field | Type | Description |
| --------------- | -------- | --------------------------------------------------- |
| `name` | `string` | Fee name (e.g. `"Gas receiver fee"`, `"Boost fee"`) |
| `description` | `string` | Human-readable description |
| `amount` | `string` | Fee amount in token's smallest unit |
| `amountUsd` | `string` | Fee amount in USD |
| `token` | `Token` | Token used for the fee |
| `gasLimit` | `string` | Gas limit (if applicable) |
| `gasMultiplier` | `number` | Gas multiplier (if applicable) |
***
## `GasCost` Object
| Field | Type | Description |
| ----------- | -------- | ------------------------------------ |
| `type` | `string` | Gas cost type (e.g. `"executeCall"`) |
| `token` | `Token` | Token used for gas |
| `amount` | `string` | Gas cost in token's smallest unit |
| `gasLimit` | `string` | Gas limit |
| `amountUsd` | `string` | Gas cost in USD |
***
## `Token` Object
Token objects appear throughout the response (in `estimate`, `actions`, `feeCosts`, etc.):
| Field | Type | Description |
| ------------- | -------- | ---------------------------- |
| `address` | `string` | Token contract address |
| `chainId` | `string` | Chain ID |
| `symbol` | `string` | Token symbol (e.g. `"USDC"`) |
| `name` | `string` | Full token name |
| `decimals` | `number` | Token decimal places |
| `logoURI` | `string` | Token logo URL |
| `usdPrice` | `number` | Current USD price |
| `coingeckoId` | `string` | CoinGecko identifier |
| `type` | `string` | Chain type (e.g. `"evm"`) |
***
## Example: Native Token Swap
An ETH swap from Arbitrum → Base produces a multi-step route:
1. **Wrap** (stage 0): Wrap ETH → WETH on Arbitrum
2. **Swap** (stage 0): Swap WETH → USDC via Uniswap V3
3. **Swap** (stage 0): Swap USDC → USDC.axl via Pancakeswap V3
4. **Bridge** (stage 0→1): Bridge USDC.axl via Axelar to Base
5. **Swap** (stage 1): Swap USDC.axl → USDC on Base
6. **Swap** (stage 1): Swap USDC → WETH via Uniswap V3
7. **Unwrap** (stage 1): Unwrap WETH → ETH on Base
# Get a route
{% hint style="info" %}
We recommend getting a new route or quote every 20 seconds to refresh prices.
{% endhint %}
{% tabs %}
{% tab title="SDK" %}
```typescript
// Set up parameters for swapping tokens and depositing into Radiant lending pool
const params = {
fromAddress: signer.address,
fromChain: arbitrumId,
fromToken: usdcArbitrumAddress,
fromAmount: amount,
toChain: polygonId,
toToken: nativeToken,
toAddress: signer.address,
slippage: 1,
quoteOnly: false,
};
// Get the swap route using Squid SDK
const { route, requestId } = await squid!.getRoute(params);
```
You can then explore the route response. This includes all the information on your quote `route.estimate` and all the data needed to generate a transaction `route.transactionRequest`.
{% endtab %}
{% tab title="API" %}
```typescript
// Function to get the optimal route for the swap using Squid API
const getRoute = async (params: any) => {
try {
const result = await axios.post(
"https://v2.api.squidrouter.com/v2/route",
params,
{
headers: {
"x-integrator-id": integratorId,
"Content-Type": "application/json",
},
}
);
const requestId = result.headers["x-request-id"]; // Retrieve request ID from response headers
return { data: result.data, requestId: requestId };
} catch (error) {
if (error.response) {
console.error("API error:", error.response.data);
}
console.error("Error with parameters:", params);
throw error;
}
};
// Get the swap route using Squid API
const routeResult = await getRoute(params);
const route = routeResult.data.route;
const requestId = routeResult.requestId;
console.log("Calculated route:", route);
console.log("requestId:", requestId);
```
{% endtab %}
{% tab title="Widgets" %}
All Squid widgets will get a route when the user can entered all the necessary parameters.
Widgets refresh quotes every 20 seconds.
{% endtab %}
{% endtabs %}
# Execute the route
{% tabs %}
{% tab title="SDK" %}
```typescript
// Execute the swap and deposit transaction
const tx = (await squid.executeRoute({
signer,
route,
})) as unknown as ethers.providers.TransactionResponse;
const txReceipt = await tx.wait();
```
If you want to execute yourself, manually. You can get all the data needed for execution from `route.transactionRequest` . Including calldata, target address, value to send and gas recommendations.
{% endtab %}
{% tab title="API" %}
```typescript
const transactionRequest = route.transactionRequest;
// Execute the swap transaction
const contract = new ethers.Contract(
transactionRequest.targetAddress,
[],
signer
);
const tx = await contract.send(transactionRequest.data, {
value: transactionRequest.value,
gasPrice: await provider.getGasPrice(),
gasLimit: transactionRequest.gasLimit,
});
const txReceipt = await tx.wait();
```
{% endtab %}
{% endtabs %}
# Transaction Types
When requesting a route, the API returns a `transactionType` field that determines how the transaction should be constructed and submitted on-chain. The type depends on the source chain and whether the route involves DEX swaps.
***
## `DEPOSIT_ADDRESS_CALLDATA`
* **Source chains:** All EVMs (except Hedera), XRPL, Solana
* **Conditions:** Direct route (no DEX swaps)
* **Example routes:** Ethereum:USDC → Base:ETH, Solana:SOL → Arbitrum:USDC, XRPL:RLUSD → XRPL:XRP
**Code examples:**
| Route | API | SDK |
| ------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| EVM → EVM | [evmToEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/api/evmToEVMSwap) | [evmToEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/evmToEVMSwap) |
| Solana → EVM | [solanaToEVM\_Swap](https://github.com/0xsquid/examples/tree/main/V2/api/solanaToEVM_Swap) | — |
| XRPL → EVM | [xrplToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/api/xrplToArbitrumSwap) | [xrplToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/xrplToArbitrumSwap) |
| EVM → XRPL | [baseToXrplSwap](https://github.com/0xsquid/examples/tree/main/V2/api/baseToXrplSwap) | [baseToXrplSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/baseToXrplSwap) |
| Stellar → EVM | [stellarToEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/api/stellarToEVMSwap) | [stellarToEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/stellarToEVMSwap) |
***
## `DEPOSIT_ADDRESS_WITH_SIGNATURE`
* **Source chains:** Hedera
* **Conditions:** Direct route (no DEX swaps)
* **Example routes:** Hedera:HBAR → Arbitrum:USDC, Hedera:USDC → Arbitrum:USDC
This transaction type is unique to Hedera and requires an additional signing step. Instead of calling a contract directly, the user sends funds to a deposit address and provides a signed verification.
### How it works
1. **Request a route** — The route response includes a `transactionRequest` with a `depositAddress` and `signatureRequired.orderHash`.
2. **Sign the order hash** — Before sending funds, sign the `orderHash` using `signer.signMessage()`. This produces a `depositTxVerificationSignature` that proves the user authorized the deposit.
3. **Poll for token association (Hedera-specific)** — Before executing the transaction, poll using `estimateGas` to ensure the destination token is associated with the deposit address. Retry up to 15 times with 1-second delays.
4. **Send the transaction** — Transfer funds to the deposit address.
5. **Track status** — When polling status, include both `quoteId` **and** `depositTxVerificationSignature` as parameters.
```typescript
// Step 1: Sign the order hash
const orderHash = routeResponse.route.transactionRequest.signatureRequired.orderHash;
const depositTxVerificationSignature = await signer.signMessage(
ethers.getBytes(orderHash)
);
// Step 2: Include signature in status calls
const status = await axios.get("https://v2.api.squidrouter.com/v2/status", {
params: {
transactionId,
fromChainId,
toChainId,
quoteId,
depositTxVerificationSignature, // Required for DEPOSIT_ADDRESS_WITH_SIGNATURE
},
});
```
See the [Hedera Integration Guide](/api-and-sdk-integration/chain-integration-guides/hedera-integration) for complete working examples.
**Code examples:**
| Route | API | SDK |
| ------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Hedera → EVM | [hederaToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/api/hederaToArbitrumSwap) | [hederaToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/hederaToArbitrumSwap) |
***
## `ON_CHAIN_EXECUTION_WITH_SIGNATURE`
* **Source chains:** Hedera
* **Conditions:** Pre-hook (DEX swap) + Squid Intents step
* **Example route:** Hedera:SAUCE → Arbitrum:USDC
**Code examples:**
| Route | API | SDK |
| ------------ | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| Hedera → EVM | [hederaToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/api/hederaToArbitrumSwap) | [hederaToArbitrumSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/hederaToArbitrumSwap) |
***
## `ON_CHAIN_EXECUTION`
* **Source chains:** All EVMs (except Hedera), Cosmos
* **Conditions:** DEX swap as first action (Single-chain DEX swap, Pre-hook (DEX swap) + Squid Intents step, DEX swap + Axelar bridge step)
* **Example routes:** Arbitrum:USDC → Arbitrum:ETH, Arbitrum:USDT → Base:ETH, Osmosis:USDC → Base:USDC
**Code examples:**
| Route | API | SDK |
| ------------------------ | ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| EVM pre-hook → EVM | [evmPrehooktoEVM](https://github.com/0xsquid/examples/tree/main/V2/api/evmPrehooktoEVM) | [evmPrehooktoEVM](https://github.com/0xsquid/examples/tree/main/V2/sdk/evmPrehooktoEVM) |
| Cosmos → EVM | [cosmostoEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/api/cosmostoEVMSwap) | — |
| Cosmos → EVM (post-hook) | [CosmostoEVMPostHook](https://github.com/0xsquid/examples/tree/main/V2/api/CosmostoEVMPostHook) | — |
***
## `CHAINFLIP_DEPOSIT_ADDRESS`
* **Source chains:** Solana, Bitcoin
* **Conditions:** Chainflip as first step
* **Example routes:** Bitcoin:BTC → Arbitrum:ETH, Solana:SOL → Arbitrum:ETH
**Code examples:**
| Route | API | SDK |
| ------------- | -------------------------------------------------------------------------------------------- | --- |
| Bitcoin → EVM | [bitcoinToEVM\_Swap](https://github.com/0xsquid/examples/tree/main/V2/api/bitcoinToEVM_Swap) | — |
***
## `DEPOSIT_ADDRESS_DIRECT_TRANSFER`
* **Source chains:** Canton
* **Conditions:** Direct route from Canton (no on-chain DEX swap)
* **Example routes:** Canton:CC → Base:USDC, Canton:CC → Arbitrum:USDC
This transaction type is unique to Canton. Unlike EVM chains where a contract call executes the swap, Canton routes return a **deposit address** and an **order hash** that must be included as the transfer memo.
> Canton wallets use the CIP-103 protocol — a browser-based wallet discovery and signing standard. There is no exportable private key or Node.js signing SDK. The API and SDK examples handle routing and status tracking programmatically, but the deposit must be sent manually from a Canton wallet (Send, C8, or Nightly). For fully automated browser-based execution, use the Squid Widget.
### How it works
1. **Request a route** — The route response includes a `transactionRequest` with `target` (deposit address) and `data` (order hash).
2. **Send Canton Coin** — Transfer the specified amount to the `target` deposit address using your Canton wallet.
3. **Include the order hash as the memo** — The `data` field contains the order hash, which must be included as the transfer memo in the Canton wallet's reason field (`splice.lfdecentralizedtrust.org/reason`).
4. **Track status** — Poll using both `transactionId` and `quoteId`.
```typescript
// Extract deposit details from the route response
const depositAddress = transactionRequest.target;
const orderHash = transactionRequest.data; // Include as transfer memo
// Track status
const status = await axios.get("https://v2.api.squidrouter.com/v2/status", {
params: {
fromChainId: "canton",
toChainId: "8453",
transactionId: transactionId,
quoteId: quoteId, // Required for Squid Intents
},
});
```
See the [Canton Integration Guide](/api-and-sdk-integration/chain-integration-guides/canton-integration) for complete working examples.
**Code examples:**
| Route | API | SDK |
| ------------ | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| Canton → EVM | [cantonToEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/api/cantonToEVMSwap) | [cantonToEVMSwap](https://github.com/0xsquid/examples/tree/main/V2/sdk/cantonToEVMSwap) |
# Hooks
Squid is a transaction bundler at heart. Squid's hooks enable users to sign one transaction and that transaction handles a프로젝트로 돌아가기