Squid 백서

Squid

원문

bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 27쪽 중 11쪽

s often returned for 5-10 seconds after the transaction was executed, while chain indexing occurs. This should not persist after maximum a few minutes (some chains such as Filecoin take a very long time to index, and for block inclusion). If it does, then get in touch with us on Discord. #### REFUND This status is specific to failed Squid Intents routes. When a Squid Intents transaction fails, the funds are automatically refunded on the source chain. This is the default behavior for Squid Intents routes when passing the user's address as the `fromAddress`. Refunds typically take \~10 minutes **How Squid Intents refunds work:** * Funds are always transferred from the `msg.sender` on the source chain (this could be the user for direct calls to Squid Intents, or a smart contract like Multicall) * When refunded, funds are sent to the `order.fromAddress` which is encoded to the user, not the caller * The `fromAddress` from the route request is used as the `order.fromAddress` for refunds * This ensures that even if the transaction was initiated through a smart contract, the refund goes to the actual user # Types We recommend using the types from our npm package. If you are using our API without our SDK, you can find the types inside `node_modules/@0xsquid/sdk/dist/types/index.d.ts` after installing the SDK (`npm install @0xsquid/sdk`). ```typescript import { Token, ChainData } from '@0xsquid/sdk/dist/types' ``` # Collect Fees ### Integrator Fee Structure Squid allows integrators to implement their own fee structure on top of Squid's platform fees. This document details the structure of Integrator fees implemented on through Squid. <mark style="color:yellow;">**To implement fees please contact the Squid team.**</mark>\ Note, Squid splits all fees collected by integrators 50/50. Please see the Platform Fee Structure section for more detail. #### Integrator Fee Configuration As an integrator, you can implement the following fee structures: 1. Flat fee: A fixed amount per transaction 2. Percentage fee: A percentage of the transaction amount 3. Secondary address fees (optional): Fees sent to a second address 4. Option to waive platform fee (if allowed by Squid) #### Fee Display Within the returned route request, all fees (including your integrator fees and Squid's platform fees) are aggregated into a single "Service fee" in the route response. This appears in the `feeCosts` array and `route.actions`: ```json { "feeCosts": [ { "amount": "31178739678247", "amountUsd": "0.12", "description": "Service fee", "name": "Service fee", "token": { "type": "evm", "chainId": "42161", "address": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", "name": "Ethereum", "symbol": "ETH", "decimals": 18, "logoURI": "https://raw.githubusercontent.com/0xsquid/assets/main/images/tokens/eth.svg", "coingeckoId": "ethereum", "usdPrice": 3798.076408348585 } } ], "actions": [ { // ... other action properties "provider": "Service fee", "description": "Service fee", "priceImpact": 0, "exchangeRate": "0.99" } ] } ``` ### Platform Fee Structure <mark style="color:yellow;">Squid splits all fees collected by integrators 50/50.</mark> In the future, Squid may charge additional platform fees on top of integrator fees. The total fee for a transaction is calculated as: ``` Total Fee = Platform Fees + Integrator Fees ``` Note: In some cases, Squid may allow integrators to waive certain platform fees. Please contact us for more information on fee customization options. # Collect Fees Integrators can reach out to Squid to implement fee capture on their cross-chain swaps. Squid takes 50% of any fees collected by an integratorAddress. Example route request with \`collectFees\` ```typescript const params = { fromChain: 5, // Goerli testnet fromToken: "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6", // WETH on Goerli fromAmount: "50000000000000000", // 0.05 WETH toChain: 43113, // Avalanche Fuji Testnet toToken: "0x57f1c63497aee0be305b8852b354cec793da43bb", // aUSDC on Avalanche Fuji Testnet fromAddress: "0xAD3A87a43489C44f0a8A33113B2745338ae71A9D", // ethers.signer.address; transaction sender address toAddress: "0xAD3A87a43489C44f0a8A33113B2745338ae71A9D", // the recipient of the trade slippage: 1.00, // 1.00 = 1% max slippage across the entire route enableForecall: true, // instant execution service, defaults to true quoteOnly: false // optional, defaults to false, collectFees: { integratorAddress: "0x", fee: 50 } }; ``` | Property | Description | | ----------------- | ------------------------------------------------------------------------------------------------------------------ | | integratorAddress | The EVM address of the integrator that will receive the fee | | fee | The amount in "basis points" for the fee. 50 = 0.50%. there is currently soft limit of 1% fee allowed for each tx. | **New objects in route response** ```json feeCosts": [ { "name": "Integrator Fee", "description": "Integrator Fee", "percentage": "0.9%", "token": { "chainId": 43113, "address": "0x57f1c63497aee0be305b8852b354cec793da43bb", "name": "Axelar USDC", "symbol": "aUSDC", "decimals": 6, "logoURI": "https://raw.githubusercontent.com/axelarnetwork/axelar-docs/main/public/images/assets/usdc.svg", "coingeckoId": "axlusdc", "commonKey": "uausdc" }, "amount": "14190", "amountUSD": "0.0142" }, ] ``` **Fee collection token**\ Fees are collected in the bridge token, most of the time this will be [axlUSDC](https://docs.axelar.dev/learn/axlusdc) as this is the primary bridging token, if the source or destination token is an [Axelar wrapped](https://docs.axelar.dev/resources/mainnet#assets) token the fee could be taken in that token, to unwrap Axelar token see [here](https://docs.axelar.dev/resources/wrapped-tokens) The API route response will tell whether it is the source or destination chain that has the fee taken \ You can see the "collectFees" object returned by the api in the "params" section of the response. This specific route will take fees on destination. ```json "params": { "collectFees": { "integratorAddress": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174", "fee": 90, "feeLocation": "DESTINATION" }, .... } ``` **Fee logic** Fees are are currently only supported on EVM chains, although fees will eventually be supported on Cosmos chains. The fee is generally taken on the chain where swaps happen. The following table outlines where the fee is taken based on the route. swaps = some swap to or from a token to the bridge token (eg axlUSDC) send only = no swaps Cosmos = not supported <table><thead><tr><th>Source</th><th>Destination</th><th>Fee taken</th><th data-hidden></th></tr></thead><tbody><tr><td>EVM (with swaps)</td><td>EVM (with swaps)</td><td>Source</td><td></td></tr><tr><td>EVM (no swaps)</td><td>EVM (with swaps)</td><td>Destination</td><td></td></tr><tr><td>EVM (no swaps)</td><td>EVM (no swaps)</td><td>Destination</td><td></td></tr><tr><td>EVM (with swaps)</td><td>EVM (no swaps)</td><td>Source</td><td></td></tr><tr><td>EVM (with swaps)</td><td>Cosmos</td><td>Source</td><td></td></tr><tr><td>EVM (no swaps)</td><td>Cosmos</td><td>None</td><td></td></tr></tbody></table> **How to check fee balances** You can check the Squid fee collector smart contracts for the balance of each token for the integrator address.\ The feeCollector contract addresses are documented in the next section.\ \ You can read balances by putting in the "token address" and "integratorAddress" into the getBalance function\ <https://testnet.snowtrace.io/address/0xf80De6D6CF6846Ae7c3243F4b6486EF662C59d29#readProxyContract> **Fee Collector contract address** | Network | Address | | ------- | ------------------------------------------ | | Testnet | 0xf80De6D6CF6846Ae7c3243F4b6486EF662C59d29 | | Mainnet | 0x19cd4F3820E7BBed45762a30BFA37dFC6c9C145b | | | | # Fee collector contract addresses Testnet: `0xf80De6D6CF6846Ae7c3243F4b6486EF662C59d29` Mainnet: `0x19cd4F3820E7BBed45762a30BFA37dFC6c9C145b` # Wallet History The Wallet History API allows you to retrieve all cross-chain transaction records associated with a specific wallet address. This provides a comprehensive view of a user's historical interactions with #### API Endpoint <table data-header-hidden><thead><tr><th width="111.24609375"></th><th></th></tr></thead><tbody><tr><td><strong>Method</strong></td><td><strong>Endpoint</strong></td></tr><tr><td><code>GET</code></td><td><code>https://v2.api.squidrouter.com/v2/history/wallet</code></td></tr></tbody></table> #### Parameters | **Parameter** | **Type** | **Required** | **Description** | | ----------------- | -------- | ------------ | ----------------------------------------------------------------------- | | `address` | `string` | Yes | The EVM or Cosmos wallet address to query. | | `x-integrator-id` | `header` | Yes | Your unique integrator ID. Requests count toward your Rate Limit (RPS). | #### Key Features * Global History: Returns all transactions associated with the wallet across all integrators. * Time Range: Returns history for the last 3 months. * No Pagination: This endpoint returns the full result set in a single response. #### Example Request ``` curl --location 'https://v2.api.squidrouter.com/v2/history/wallet?address=ADD_ADDRESS_HERE' \ --header 'x-integrator-id: your-integrator-id' ``` ``` const getWalletHistory = async (address, integratorId) => { try { const result = await axios.get("https://v2.api.squidrouter.com/v2/history/wallet", { params: { address }, headers: { "x-integrator-id": integratorId }, }); return result.data; } catch (error) { console.error("Error fetching history:", error.response?.data || error.message); throw error; } }; ``` #### Example Response ``` [ { "transactionId": "0x081e2b20246ce3a6798e617b12e9bbe45d4487441cfab6273422dbd69f56c501", "bridgeType": "rfq", "createdAt": "2026-01-13T22:41:03.988Z", "fromChainId": "999", "quote": { "route": { "estimate": { "fromAmount": "3916444925567914", "toAmount": "90851975792151072", "fromAmountUSD": "0.09", "toAmountUSD": "0.09", "fromToken": { "address": "0x5555555555555555555555555555555555555555", "chainId": "999", "decimals": 18, "logoURI": "https://raw.githubusercontent.com/0xsquid/assets/main/images/tokens/whype.svg", "name": "Wrapped HYPE", "symbol": "WHYPE", "coingeckoId": "wrapped-hype", "usdPrice": 25.169077678, "type": "evm" }, "toToken": { "address": "0x55d398326f99059ff775485246999027b3197955", "chainId": "56", "decimals": 18, "logoURI": "https://raw.githubusercontent.com/0xsquid/assets/main/images/tokens/usdt.svg", "name": "USDT", "symbol": "USDT", "coingeckoId": "tether", "usdPrice": 0.9998056774098082, "type": "evm" }, "estimatedRouteDuration": 10 } } }, "quoteId": "bb398cb754d3015474ad673658845af1", "statusResponse": { "id": "0x081e2b20246ce3a6798e617b12e9bbe45d4487441cfab6273422dbd69f56c501", "status": "success", "squidTransactionStatus": "success", "transactionUrl": "https://hyperevmscan.io/tx/0x081e2b20246ce3a6798e617b12e9bbe45d4487441cfab6273422dbd69f56c501" }, "toChainId": "56", "updatedAt": "2026-01-13T22:41:03.988Z", "totalFeesUSD": 0.008399678805983213 } ] ``` # getAllBalances Squid's SDK provides a function to get the balance of every token we support by providing an address for each environment. ```typescript const squid = new Squid({ baseUrl: "https://v2.api.squidrouter.com", integratorId: "squid-test" }); await squid.init(); const allBalances = await squid.getAllBalances({ chainIds: ["osmosis-1", 43114, 8453], evmAddress: "0x344b63c2BcB4B61765083735e8F49Bb203415a33", cosmosAddresses: [ { address: "cosmos1awrua7e2kj69d7vn5qt5tccrhavmj9xajl58pw", chainId: "cosmoshub-4", coinType: 118 } ] }) // result: // { // cosmos: [ // { // balance: "676727870", // denom: // "ibc/E6931F78057F7CC5DA0FD6CEF82FF39373A6E0452BF1FD76910B93292CF356C1", // chainId: "osmosis-1", // decimals: 6 // }, // { // balance: "5987424", // denom: "uosmo", // chainId: "osmosis-1", // decimals: 6 // } // ], // evm: [ // { // balance: "2981435909446986", // symbol: "ETH", // address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // decimals: 18, // chainId: "8453" // }, // { // balance: "788395441854562446", // symbol: "AVAX", // address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // decimals: 18, // chainId: "43114" // } // ] // } const evmBalances = await squid.getEvmBalances({ userAddress: "0x344b63c2BcB4B61765083735e8F49Bb203415a33", chains: [1, 43114, 8453] }) // result: // [ // { // balance: "41345097216001030", // symbol: "ETH", // address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // decimals: 18, // chainId: "1" // }, { // balance: "9424225", // symbol: "USDC", // address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // decimals: 6, // chainId: "1" // }, { // balance: "81435909446986", // symbol: "ETH", // address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // decimals: 18, // chainId: "8453" // }, { // balance: "788395441854562446", // symbol: "AVAX", // address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // decimals: 18, // chainId: "43114" // } // ] const cosmos = await squid.getCosmosBalances({ addresses: [ { chainId: "cosmoshub", address: "cosmos1awrua7e2kj69d7vn5qt5tccrhavmj9xajl58pw", coinType: 118 } ] }) // result: // [ // { // balance: "1804685", // denom: "uatom", // chainId: "cosmoshub-4", // decimals: 6 // } // ] ``` # Squid Intents <figure><img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2FLXBTQ8dgckaNzHmOGlht%2F1500x500.jpg?alt=media&amp;token=79be6d5e-2e11-4efc-86e7-9ec776dbd87d" alt=""><figcaption></figcaption></figure> ## Squid's Intent Swaps Protocol Squid Intents is Squid's intent-based settlement protocol transforming how regular crosschain swaps are executed. It turns user intent into simple onchain transfers and handling complex execution offchain using Trusted Execution Environment (TEE)-verified settlement. Squid Intents offers unparalleled reliability, better pricing, and a smoother user experience across EVM and non-EVM chains alike. As crosschain logic is handled by TEEs, it delivers efficiency while maintaining the decentralized and non-custodial nature of the protocol while ensuring that Squid can expand to any chain and any token, including chains that don’t have smart contracts. Squid’s TEEs are powered by [Cubist](https://cubist.dev/blog/squid-launches-sub-second-cross-chain-swaps-enabled-by-cubists-new-private-smart-contract-tech), who we chose for their formidable security background, having secured over $10B USD already, and their commitment to crypto's original values: decentralization and privacy. Their approach ensures high availability, censorship resistance, and decentralized upgrade and deployment pathways for protocols developing on their platform. ### Why Squid Intents? * Sub-5 second execution for most transactions * Zero slippage guaranteed through direct market maker integration * 90% reduction in gas costs compared to traditional AMM-based routing * MEV protection built into the protocol architecture * No route expiry: routes don't expire, submit your transaction at any time after receiving a quote * 15-minute refunds: if a transaction fails, funds are automatically returned on the source chain * Integrator fee support built in <figure><img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2FFwHS9jfjnoiFZEVbtpnl%2F1920x1080.jpg?alt=media&amp;token=17de455a-d2dd-4685-b8d0-56c89231d51b" alt=""><figcaption></figcaption></figure> ### Squid Intents Competitive landscape <table data-header-hidden><thead><tr><th width="134.73046875">Feature</th><th>Squid Intents</th><th>Across Protocol</th><th>deBridge (DLN)</th><th>UniswapX</th><th>NEAR Confidential</th><th>Circle CCTP</th></tr></thead><tbody><tr><td><strong>TEE-Verified Settlement</strong></td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>✅</td><td>❌</td></tr><tr><td><strong>Post-Deposit RFQ Auctions</strong></td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td></tr><tr><td><strong>Native Bitcoin Support</strong></td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td></tr><tr><td><strong>Native Solana Support</strong></td><td>✅</td><td>✅</td><td>✅</td><td>❌</td><td>❌</td><td>✅</td></tr><tr><td><strong>Native XRPL Support</strong></td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td></tr><tr><td><strong>Guaranteed 15-Min Refunds</strong></td><td>✅</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td><td>❌</td></tr><tr><td><strong>No Route Expiry</strong></td><td>✅</td><td>✅</td><td>✅</td><td>✅</td><td>✅</td><td>✅</td></tr><tr><td><strong>Multisig Compatibility</strong></td><td>✅</td><td>✅</td><td>✅</td><td>✅</td><td>✅</td><td>✅</td></tr><tr><td><strong>Zero-TVL Architecture</strong></td><td>❌</td><td>❌</td><td>✅</td><td>❌</td><td>❌</td><td>❌</td></tr><tr><td><strong>MEV-Resistant Privacy</strong></td><td>❌</td><td>❌</td><td>❌</td><td>❌</td><td>✅</td><td>❌</td></tr></tbody></table> ### How It Works Squid Intents uses the `/v2/route` endpoint as all Squid transactions. For **EVM-to-EVM** swaps, the flow is identical to a standard Squid integration — request a route, execute it, and poll for status. The route response's `transactionRequest` object will include a `transaction_request_type` field that indicates how to execute: * `"ON_CHAIN_EXECUTION"` — standard on-chain transaction (EVM) * `"DEPOSIT_ADDRESS_CALLDATA"` — submit a deposit to the provided address with the specified calldata (non-EVM) * `"DEPOSIT_ADDRESS_WITH_SIGNATURE"` — submit a signed deposit to the provided address (non-EVM) ### Getting Squid Intents Enabled Squid Intents is not enabled by default. To get started: 1. If you don't already have a Squid integration, submit a [partnership request](https://squidrouter.typeform.com/partnerships) to apply for an Integrator ID (issued on a limited basis upon review) 2. Contact the Squid team to enable Squid Intents on your integrator ID 3. Follow the [Integrating Squid Intents](/api-and-sdk-integration/coral-intent-swaps/integrating-squid-intents) guide {% hint style="warning" %} **Widget Users**: Squid Intents requires `@0xsquid/widget` version **6.5.0 or newer**. Please ensure your widget is updated before enabling Squid Intents. {% endhint %} ### Supported Chains Squid Intents currently supports the following chains: **EVM Chains**: Celo, BNB Chain, Citrea, Peaq, HyperEVM, Avalanche, Optimism, Arbitrum, Linea, Berachain, Polygon, Gnosis, Base, Sonic, Hedera, XRPL EVM, Soneium, Blast **Coming Soon**: Bitcoin, Solana # Integrating Squid Intents Integrating Squid Intents follows the same flow as a standard Squid integration. If you already have Squid integrated, the only steps are to have Squid Intents enabled on your integrator ID, poll for status with a `quoteId`, and handle the transaction request type. Squid Intents must be enabled on your integrator ID. Reach out to the Squid team to get started. ### Route Request <a href="#route-request" id="route-request"></a> Squid Intents uses the `/v2/route` endpoint. When Squid Intents is enabled and a route is available, it will be automatically selected. **There are no expiry constraints** — You do not need to submit the transaction within a time window. #### EVM Route Request Example <a href="#evm-route-request-example" id="evm-route-request-example"></a> <a class="button secondary">Copy</a> ``` const params = { fromAddress: signer.address, fromChain: "42161", // Arbitrum fromToken: usdcAddress, fromAmount: amount, toChain: "1", // Ethereum toToken: nativeToken, toAddress: signer.address, quoteOnly: false, }; // Get the route const routeResult = await axios.post( "https://v2.api.squidrouter.com/v2/route", params, { headers: { "x-integrator-id": integratorId, "Content-Typ
프로젝트로 돌아가기