Squid 백서

Squid

원문

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

d for integrators. #### Fee Precision You can set fees with precision up to thousandths of a percent (0.001% - 100% or 0.00001 - 1 in decimal form). #### 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. These may include: * Platform Base Fee * Chain-specific Fees * Token-specific Fees * Volatility Tier 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. # Information for Integrators Here you will find a brief onboarding guide to ensure the integration is as smooth as possible for your team and users We're thrilled that you have chosen to integrate our widget and appreciate your trust in Squid 🦑 If you have any questions or concerns during the integration process, please don't hesitate to reach out to us on [Discord](https://discord.gg/squidrouter). ### Staying updated If you have integrated the widget, please let us know so we can share the news with our community! To stay updated with any changes or new features, please follow us on [Twitter](https://twitter.com/squidrouter) or join our [Discord](https://discord.gg/squidrouter). ### User support {% hint style="info" %} A full user guide can be found [here](https://docs.widget.squidrouter.com/) which contains a step-by-step guide on how to do a swap and how to troubleshoot any errors or issues. {% endhint %} Once you have integrated the widget, we recommend you create a support channel in your own community for users to troubleshoot issues that users may encounter while using the widget. If you our your users discover any persistent issues or errors while using the widget, please contact us on [Discord](https://discord.gg/squidrouter). Should you need to provide guidance on how to use the widget or troubleshoot technical issues, here are the most common user issues and how to resolve them: <details> <summary>The user is unable to initiate a swap</summary> The most likely reason for is is that their balance is insufficient to complete the trade and cover any bridge or swap fees. The user should try a lower swap amount, or top up their account with more of the native gas token. </details> <details> <summary>The swap is marked as complete, but the user does not see their tokens</summary> If this happens, it's likely that the user has received axlUSDC on the destination chain unexpectedly. This can happen as a result of price volatility and low slippage, which causes the transaction to revert. The user can complete their swap by swapping from axlUSDC to their desired token. Squid will support swaps on the same chain soon, but until then they can use a DEX on their destination chain to finish the transaction. </details> <details> <summary>Transaction failed or could not initiate</summary> If the initial swap on the source chain swap did not initiate, the user's tokens will still be in their wallet on the source chain, aside from a small amount that may have been spent on gas. They should return to the swap page and try again. </details> <details> <summary>Transaction is paused</summary> If gas prices rise and the transaction pauses as a result, the user can manually add gas to re-start the transaction by visiting the transaction's page in Axelarscan's UI. </details> ### Safety and security The safety and security of users and their assets is of the utmost importance to us. If a chain or token has downtime or is compromised, Squid will remove it from the chain and token lists as soon as we are notified, and the widget will update automatically to reflect this change. **If you ever encounter a security incident relating to the widget or one of Squid's supported chains, tokens or routes, please inform Squid immediately on** [**Discord**](https://discord.gg/squidrouter) **or** [**Twitter**](https://twitter.com/squidrouter)**.** ### Fees #### DEX fees Squid does not charge any DEX fees, but swaps are routed through other DEXs, such as Uniswap, Curve and Osmosis, who do charge fees. These fees are included in the total amount out provided by the widget's quote. For certain routes we charge a convenience fee on our frontend. # Set default chains and tokens via URL {% hint style="info" %} Squid website only! This is possible for widget integrators by setting [default chains and tokens](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/default-chains-and-tokens) via iframe URL or widget config {% endhint %} You can customize the chains and tokens that are selected by default when visiting [https://app.squidrouter.com](https://app.squidrouter.com/) via the `chains` and `tokens` query parameters. The first value (`x`) represents the source, and separated by a comma, the second one (`y`) represents the destination: ``` chains=x,y // chain id tokens=x,y // token address ``` For example, the following URL will open the Squid app using Arbitrum and MAGIC for source and Ethereum and DAI for destination: ``` https://v2.api.squidrouter.com/? chains=42161,1 &tokens=0x539bde0d7dbd336b79148aa742883198bbf60342, 0x6b175474e89094c44da98b954eedeac495271d0f ``` # Errors Here is a list of errors that some users were facing that have a known fix ### Wagmi Import error ```bash SyntaxError: The requested module '@wagmi/core' does not provide an export named 'getClient' at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21) at async ModuleJob.run (node:internal/modules/esm/module_job:190:5) { digest: undefined ``` This error can be fixed by installing explicitly the @wagmi/connectors package # Deposit widget ### Introduction Squid's Deposit Widget is a drop-in React component that lets your users deposit any token, from any supported chain, into a destination address you control — receiving the exact token you specify on the destination chain. The widget wraps Squid's cross-chain routing API and SDK, so integrators get a fully-featured deposit / payment flow (route quoting, wallet connection, transaction execution and progress tracking) with minimal dev effort. It's the fastest way to accept cross-chain deposits or one-shot payments into your app. ### Widget features * Two modes: `deposit` (user-entered amount) and `payment` (fixed amount, ideal for checkouts) * Cross-chain routing across all chains supported by Squid (EVM, Cosmos, XRPL, and more) * Fully themeable via the shared Squid theming system (light / dark + custom palette overrides) * Integrator branding (name + logo) rendered inside the widget * Built-in route preview, progress and success / error screens * Transaction history view, scoped to your destination address {% hint style="info" %} 💡 Need a cross-chain swap UI instead of a deposit / payment flow? Check out the [Swap Widget](/widget-integration/add-a-widget/widget). {% endhint %} # Getting Started Supported environments, chains, tokens and wallets ### Environments The Deposit Widget is a [React](https://reactjs.org/) component, so it works in any React-based app — [Next.js](https://nextjs.org/), Vite, Create React App, and similar. **Currently supported environments:** * React (18 or 19) * Next.js * Vite ### Supported chains and tokens The Deposit Widget supports every chain and token available on Squid's routing API, including EVM chains, Cosmos chains, XRPL, Bitcoin and Solana. The destination chain and token are fixed by you (the integrator) via configuration; users pick any supported source chain and token from inside the widget. ### Supported wallets The widget reuses Squid's wallet stack, so it supports the same wallets as the Swap Widget: **EVM:** MetaMask, Trust Wallet, Rabby, Zerion, Coinbase Wallet, WalletConnect, Rainbow, BitGet Wallet, OKX Wallet, and more. **Cosmos:** Keplr, Leap, Cosmostation. **Other:** Wallets for any non-EVM chain Squid supports on the source side (e.g. XRPL, Solana, Bitcoin) are surfaced when those chains are selected. # Installing the Widget Preparing to integrate the Deposit Widget into your app ## Installing the Squid Deposit Widget ### Prerequisites Before installing the Deposit Widget, ensure you have: 1. Registered for an Integrator ID with the Squid Team. 2. Node.js and a package manager (npm, yarn or pnpm) installed. 3. A React 18 or React 19 app to host the widget. ### Requesting an Integrator ID Squid issues Integrator IDs on a limited basis and upon review. To request an Integrator ID for your deposit widget integration: 1. Submit a [partnership request](https://squidrouter.typeform.com/partnerships) outlining your use case and integration plans. 2. A Squid team member will review your request and follow up regarding approval and credential issuance. ### Installation #### Step 1: Install the package Using npm: ```bash npm install @0xsquid/deposit-widget ``` Using yarn: ```bash yarn add @0xsquid/deposit-widget ``` #### Step 2: Provide React 18+ in your app The widget declares `react` and `react-dom` (`^18 || ^19`) as peer dependencies — make sure your app satisfies one of these versions. ### Next Steps After installation, follow the framework-specific guide: * [React Integration Guide](/widget-integration/add-a-widget/deposit-widget/react-installation) * [Next.js Integration Guide](/widget-integration/add-a-widget/deposit-widget/nextjs-installation) * [Vite Integration Guide](/widget-integration/add-a-widget/deposit-widget/vite-installation) Once the widget is rendered, head to [Configuration](/widget-integration/add-a-widget/deposit-widget/configuration) to customize destination, branding and theme. ### Support When you receive your Integrator ID, we'll follow up by email to set up a dedicated Telegram group with your team. That group is your direct line to the Squid team for any questions or assistance during integration. # React Installation Installing the React component ## React Installation Guide for the Deposit Widget This guide will help you integrate the Squid Deposit Widget into your React application. ### Prerequisites Ensure you have completed the steps in the [Installing the Widget](/widget-integration/add-a-widget/deposit-widget/installing-the-widget) guide before proceeding. ### Basic Integration After installing the npm package, follow these steps to add the widget to your React app: 1. Import the `DepositWidget` component and the `DepositConfig` type: ```tsx import { DepositWidget, type DepositConfig } from "@0xsquid/deposit-widget"; ``` 2. Define a config and render the widget: ```tsx import { DepositWidget, type DepositConfig } from "@0xsquid/deposit-widget"; const config: DepositConfig = { mode: "deposit", destinationAddress: "0xYourReceivingAddress", destinationToken: { address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum chainId: "42161", }, integrator: { id: "<your-integrator-id>", name: "Your App", logoUrl: "https://your.app/logo.png", }, }; function App() { return ( <div className="App"> <DepositWidget config={config} /> </div> ); } ``` Replace `<your-integrator-id>` with the Integrator ID you received from Squid, and `destinationAddress` / `destinationToken` with the address and token you want to receive. ### Customization Pass `theme` and `themeType` to the config to brand the widget: ```tsx <DepositWidget config={{ ...config, themeType: "dark", // or "light" theme: { // your theme overrides — see Configuration page }, }} /> ``` See the [Configuration](/widget-integration/add-a-widget/deposit-widget/configuration) page for the full list of options. # Next.js Installation Integrating the Deposit Widget into a Next.js app This guide will help you integrate the Squid Deposit Widget into your Next.js application. ### Prerequisites Ensure you have completed the steps in the [Installing the Widget](/widget-integration/add-a-widget/deposit-widget/installing-the-widget) guide before proceeding. ### Installation Steps #### Step 1: Install the package ```bash yarn add @0xsquid/deposit-widget ``` #### Step 2: Render the widget The widget uses browser-only APIs (wallets, `window`), so it must render on the client. The simplest way is to mark the page or component as a Client Component: ```tsx "use client"; import { DepositWidget, type DepositConfig } from "@0xsquid/deposit-widget"; const config: DepositConfig = { mode: "deposit", destinationAddress: "0xYourReceivingAddress", destinationToken: { address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum chainId: "42161", }, integrator: { id: "<your-integrator-id>", name: "Your App", logoUrl: "https://your.app/logo.png", }, }; export default function Page() { return <DepositWidget config={config} />; } ``` If you need to keep the parent as a Server Component, wrap the widget in a client-only child or load it dynamically with `next/dynamic` and `ssr: false`. Replace `<your-integrator-id>` with the Integrator ID you received from Squid. ### Customization Pass `theme` and `themeType` to brand the widget — see the [Configuration](/widget-integration/add-a-widget/deposit-widget/configuration) page for all available options. ### Running Your Next.js App ```bash yarn dev ``` # Vite Installation Integrating the Deposit Widget into a Vite app ## Vite Installation Guide for the Deposit Widget This guide will help you integrate the Squid Deposit Widget into your Vite + TypeScript project. ### Prerequisites Ensure you have completed the steps in the [Installing the Widget](/widget-integration/add-a-widget/deposit-widget/installing-the-widget) guide before proceeding. ### Installation Steps #### Step 1: Install the package ```bash yarn add @0xsquid/deposit-widget ``` #### Step 2: Add Polyfills The widget's underlying wallet stack relies on some Node built-ins, so Vite needs browser polyfills: 1. Install the `vite-plugin-node-polyfills` plugin: ```bash yarn add vite-plugin-node-polyfills -D ``` 2. Update your `vite.config.ts` file: ```typescript import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import { nodePolyfills } from "vite-plugin-node-polyfills"; export default defineConfig({ plugins: [react(), nodePolyfills()], }); ``` #### Step 3: Render the widget Add the Deposit Widget to your desired component. For example, in `src/App.tsx`: ```tsx import { DepositWidget, type DepositConfig } from "@0xsquid/deposit-widget"; const config: DepositConfig = { mode: "deposit", destinationAddress: "0xYourReceivingAddress", destinationToken: { address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum chainId: "42161", }, integrator: { id: "<your-integrator-id>", name: "Your App", logoUrl: "https://your.app/logo.png", }, }; function App() { return <DepositWidget config={config} />; } export default App; ``` Replace `<your-integrator-id>` with the Integrator ID you received from Squid. ### Customization Pass `theme` and `themeType` to brand the widget — see the [Configuration](/widget-integration/add-a-widget/deposit-widget/configuration) page for all available options. ### Running Your Vite App ```bash yarn dev ``` # Configuration Full reference for the Deposit Widget's config prop The Deposit Widget takes a single `config` prop, typed as `DepositConfig`. Like the Swap Widget, it accepts your **Integrator ID** and a **theme** for customization. On top of that, it adds the settings specific to deposits and payments: the destination address and token, and the `mode`. ```tsx import { DepositWidget, type DepositConfig } from "@0xsquid/deposit-widget"; <DepositWidget config={config} />; ``` ### Modes `DepositConfig` is a discriminated union over `mode`: * **`"deposit"`** — the user enters the amount to send. Use this for top-ups, account funding, and any flow where the amount is open-ended. * **`"payment"`** — the integrator fixes the amount via an extra `amount: string` field. Use this for checkout / pay-this-invoice flows. ### Config fields | Field | Type | Required | Description | | -------------------------- | ------------------------ | --------------------- | ------------------------------------------------------------------------------------------------------ | | `mode` | `"deposit" \| "payment"` | ✅ | Selects the widget flow. In `"payment"` mode, `amount` is required. | | `amount` | `string` | ✅ (payment mode only) | Fixed amount the user will pay, in destination-token units (human-readable string, e.g. `"25.5"`). | | `destinationAddress` | `string` | ✅ | Address that receives the deposit on the destination chain. | | `destinationToken.address` | `string` | ✅ | Token contract address on the destination chain. | | `destinationToken.chainId` | `string` | ✅ | Squid chain ID of the destination chain (e.g. `"42161"` for Arbitrum, `"xrpl-mainnet"` for XRPL). | | `integrator.id` | `string` | ✅ | Your Integrator ID. Required for Squid to route and account for your traffic. | | `integrator.name` | `string` | ✅ | Displayed in the widget header so users know which app they're paying / depositing to. | | `integrator.logoUrl` | `string` | ✅ | URL of your logo, displayed alongside the name. | | `apiUrl` | `string` | ❌ | Override the Squid API endpoint. Defaults to Squid's production API. | | `theme` | `Theme` | ❌ | Theme object (colors, border radii, shadows, font sizes / weights). See **Theme customization** below. | | `themeType` | `"light" \| "dark"` | ❌ | Selects the base palette before `theme` overrides apply. Defaults to `"light"`. | ### Deposit-mode example ```tsx const config: DepositConfig = { mode: "deposit", destinationAddress: "0xYourReceivingAddress", destinationToken: { address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum chainId: "42161", }, integrator: { id: "<your-integrator-id>", name: "Your App", logoUrl: "https://your.app/logo.png", }, }; ``` ### Payment-mode example ```tsx const config: DepositConfig = { mode: "payment", amount: "25.00", destinationAddress: "0xYourReceivingAddress", destinationToken: { address: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum chainId: "42161", }, integrator: { id: "<your-integrator-id>", name: "Your App", logoUrl: "https://your.app/logo.png", }, }; ``` ### Theme customization To customize the widget's appearance: 1. Use the [Widget Studio](https://studio.squidrouter.com/) to generate a custom theme. 2. Copy the generated `theme` (and `themeType`) and paste them into your `config`. # Stake widget Squid provides a react component or iframe widget for quickly building a "Stake or deposit from any chain" flow. This uses Squid's [Hooks](https://github.com/0xsquid/squid-documentation/tree/main/widget-integration/api-and-sdk-integration/key-concepts/hooks/README.md) feature, where the Squid contract can make arbitrary calls to any contract after a bridge
프로젝트로 돌아가기