Squid 백서

Squid

원문

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

amp;token=67ee2612-9ec6-4fc3-9984-3dc891b5a769" alt="" data-size="line"> The URL of this standalone page embeds the config you selected on the customization step, and is ready to embed. ### Embedding Now that you have the iframe link, you can copy and paste it into your frontend code to embed it into your website, at the location of your choice. Keep in mind the width and height parameters are important so that the widget displays properly. ```html <iframe title="squid_widget" width="430" height="684" src=" https://v2.api.squidrouter.com/iframe?config=....." /> ``` # Customization Guide To customize the widget's theme interactively, visit the [Squid Widget Studio](https://widget.squidrouter.com/). Copy paste the config code snippet into your code via this button: <img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2FMR1O7818yTo2B9H79wKZ%2Fcopy%20snippet.png?alt=media&amp;token=c0f8d498-2f81-4307-a78d-1bc260776e21" alt="" data-size="line"> There are a number of ways to configure the widget’s behaviour, UX and design: * [Broken mention](broken://pages/iz4XwzgEdJG6PulCFIv2): Giving the widget a name and setting the correct API. * [Default User Settings](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/default-user-settings): Configure the default user settings such as slippage. * [Theme Customization](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/theme-customization): Configure the widget's visual theme. * [Configuring Content](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/configuring-content): Customize the widget's content, like titles and animations. * [Default Chains and Tokens](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/default-chains-and-tokens): Select which tokens appear on load and pin favourites to the top of token lists. ### Default configuration example You can use the widget with default values like this: ```jsx import { SquidWidget } from '@0xsquid/widget'; // ... <SquidWidget /> ``` ### Full configuration example ```jsx <SquidWidget config={ { companyName: "Squid", slippage: 1, // default slippage style: { neutralContent: "#9DA7B1", baseContent: "#FFFDFD", base100: "#434565", base200: "#202230", base300: "#161522", error: "#ED6A5E", warning: "#FFB155", success: "#62C555", primary: "#AB67CB", secondary: "#37394C", secondaryContent: "#B2BCD3", neutral: "#383A4C", roundedBtn: "24px", roundedBox: "20px", roundedDropDown: "0px", displayDivider: false, advanced: { transparentWidget: false, }, }, hideAnimations: true, instantExec: true, infiniteApproval: true, apiUrl: " https://v2.api.squidrouter.com", mainLogoUrl: "", titles: { swap: "Convert", settings: "Settings", wallets: "Wallets", tokens: "Tokens", chains: "Chains", history: "History", transaction: "Transaction", destination: "Destination address", }, priceImpactWarnings: { warning: 3, critical: 5, }, initialFromChainId: 42161, // Arbitrum initialToChainId: 1284, // Moonbeam favTokens: [ { address: "0x539bdE0d7Dbd336b79148AA742883198BBF60342", // Token address for MAGIC chainId: 42161, // Chain ID for Arbitrum }, { address: "0x0E358838ce72d5e61E0018a2ffaC4bEC5F4c88d2", // Token address for STELLA chainId: 1284, // Chain ID for Moonbeam }, ], defaultTokens: [ { address: "0xd4d42F0b6DEF4CE0383636770eF773390d85c61A", // Token address for SUSHI chainId: 42161, // Chain ID for Arbitrum }, { address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // Token address for GLMR chainId: 1284, // Chain ID for Moonbeam }, ], } }/> ``` All configuration types can be found at [Configuration Types](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/configuration-types) # Default User Settings ### **Default slippage:** *slippage* The default slippage must be selected from the slippage options, which are `0.5%`, `1%`, `1.5%` or `3%`. ```jsx slippage: 1 // Slippage, see SlippageOption type ``` ### **Infinite Approval setting:** *infiniteApproval* When the user swaps tokens with the widget for the first time, they have to grant Squid permission to route the tokens on their behalf. By enabling the Infinite Approval setting by default, you authorize Squid to route an unlimited amount of them. In some instances, unchecking the Infinite Approval option can improve the user’s security since it limits the amount that is approved by Squid's Router contract. ```jsx infiniteApproval: true ``` ### **Instant execution setting:** *instantExec* Instant execution is a feature coming in early 2023 that makes any transaction up to only 10 seconds long. A small fee is associated with this setting. ```jsx instantExec: true ``` ### **Price impact warning trigger points:** *priceImpactWarnings* The user will receive a warning in the UI if the price impact percentage is over the `warning` value, and will be unable to swap if the price impact is over the `critical` value. We recommend keeping these as default. ```jsx priceImpactWarnings: { warning: 3, critical: 5, } ``` # Theme Customization The `style` attribute enables customisation of the widget theme's colors, opacity and the inclusion of a divider between the "from" and "to" sections. ### Full theme customization example ```jsx <SquidWidget config={ { style: { neutralContent: "#9DA7B1", baseContent: "#FFFDFD", base100: "#434565", base200: "#202230", base300: "#161522", error: "#ED6A5E", warning: "#FFB155", success: "#62C555", primary: "#AB67CB", secondary: "#37394C", secondaryContent: "#B2BCD3", neutral: "#383A4C", roundedBtn: "24px", roundedBox: "20px", roundedDropDown: "0px", displayDivider: false, advanced: { transparentWidget: false, }, } } } /> ``` ### Styling via CSS To style each component of the Widget via CSS, you can use the following IDs selectors: * Widget container: `squid-widget` * Widget header: `squid-widget-header` * Widget header logo: `squid-header-logo` * Widget header title: `squid-header-title` * Swap direction text ("from" or "to"): `squid-swap-direction-txt` * Primary Hover button: `squid-primary-hover-button` * Secondary hover button: `squid-secondary-hover-button` * Dropdown button: `squid-dropdown-btn` * Dropdown icon: `squid-dropdown-icon` * Dropdown label: `squid-dropdown-label` * Icon button: `squid-icon-button` * Submit swap button: `squid-submit-swap-btn` * Swap source container: `squid-swap-source` * Swap destination container: `squid-swap-destination` Then, in your CSS, add your custom styles: ```css #squid-swap-source { background-color: #091428; color: #fff; } #squid-swap-destination { background-color: #000309; color: #fff; } ``` ### Display divider If you would like to include a divider between the "From" and "To" sections, set this to true. When set to true, both "From" and "To" sections are set to `base200`, and the divider color is set to `base300`. ```jsx displayDivider: true ``` ### Transparent widget If you would like the widget to be slightly transparent, there is an advanced attribute for this: ```jsx advanced:{ transparentWidget: true, } ``` ### Theme configuration visual guide <figure><img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2FfHEYmggdxH4kIsTFge6j%2Fcustomize-a.png?alt=media&amp;token=ae4bde26-0526-4756-924b-065b669329cd" alt=""><figcaption></figcaption></figure> <figure><img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2FyMZLLSE9QICXRHUcuvyT%2Fcustomize-b.png?alt=media&amp;token=3ae98c10-84ca-4dcd-b0ae-24bfa2213688" alt=""><figcaption></figcaption></figure> <figure><img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2FgRA1Aut4a3sG48ilBIT2%2Fcustomize-c.png?alt=media&amp;token=7f2c7485-8247-48e1-a64c-614056b463f7" alt=""><figcaption></figcaption></figure> # Configuring Content ### **Changing the logo:** *mainLogoUrl* Recommended logo dimensions are 36px x 36px. If this field is empty, the logo in the top left corner of the widget will be invisible. ```jsx mainLogoUrl: "" ``` ### **Changing the widget title headings:** *titles* If you would like to change the default titles displayed in the widget. If the string is empty, the title will be invisible. ```jsx titles: { swap: "Convert", settings: "Settings", wallets: "Wallets", tokens: "Tokens", chains: "Chains", history: "History", transaction: "Transaction", destination: "Destination address", } ``` ### **Hiding animations:** *hideAnimations* To hide Squid's bespoke Lottie animations, set this attribute to "false". ```jsx hideAnimations: false ``` # Default Chains and Tokens To customize which chains and tokens are displayed on loading the widget, you will need the chain ID and token address. A full list of chains and their IDs can be found via Squid's API playground [here](https://squidrouter.readme.io/reference/get_chains), or at our API's [chains endpoint](https://api.0xsquid.com/v1/chains). All tokens and their IDs can be found at our API's [tokens endpoint](https://api.0xsquid.com/v1/tokens), or you can filter them by chain at our API playground by visiting the /tokens reference [here](https://squidrouter.readme.io/reference/get_tokens) and inputting the chain's ID. ### **Default chains:** *initialFromChainID* and *initialToChainID* ```jsx initialFromChainId: 42161, // eg. Arbitrum initialToChainId: 1284 // eg. Moonbeam ``` ### **Default tokens:** *defaultTokens* ```jsx defaultTokens: [ { address: "0xd4d42F0b6DEF4CE0383636770eF773390d85c61A", // Token address for SUSHI chainId: 42161, // Chain ID for Arbitrum }, { address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", // Token address for GLMR chainId: 1284, // Chain ID for Moonbeam }, ] ``` ### **Favourite tokens:** *favTokens* ```jsx favTokens: [ { address: "0x539bdE0d7Dbd336b79148AA742883198BBF60342", // Token address for MAGIC chainId: 42161, // Chain ID for Arbitrum }, { address: "0x0E358838ce72d5e61E0018a2ffaC4bEC5F4c88d2", // Token address for STELLA chainId: 1284, // Chain ID for Moonbeam }, ] ``` # Configuration Types For an example of how to implement the following configuration types in your application, check out the [Customization Guide](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide#full-configuration-example). ### All configuration types ```jsx export type ColorType // The color format must be of type #FFFFFF export type SlippageOption = 0.5 | 1 | 1.5 | 3; export type TokenConfig = { address: string; chainId: number | string; }; export interface AppConfig { companyName?: string; slippage?: SlippageOption; style?: ConfigTheme; enableExpress?: boolean; enableGetGasOnDestination?: boolean; // If set to true, will enable getting gas on destination on widget loads. infiniteApproval?: boolean; loadPreviousStateFromLocalStorage?: boolean; apiUrl?: string; mainLogoUrl?: string; // Logo displayed in the header, if put to "", will hide the logo titles?: Record<Routes, string>; // Header titles internalSameChainSwapAllowed?: boolean; // Will display a message indicating that the swap is possible on the website hideAnimations?: boolean; preferDex?: DexName[] | string[]; // Can select a preferred dex to route transactions, will be sent to the sdk when executing route advanced?: { shareOnTwitter?: boolean; disableTradeLimit?: boolean; // Will probably disappear in the future, when we remove the trade limit by default }; priceImpactWarnings?: { warning: number; critical: number; }; favTokens?: TokenConfig[]; comingSoonChainIds?: any[]; // number | string chain ids. If set to [], will show all chains initialFromChainId?: number | string; // When widget loads initialToChainId?: number | string; // When widget loads defaultTokens?: TokenConfig[]; // When chain is changed, this allow to chose the first token that will be selected availableChains?: { source?: (number | string)[]; destination?: (number | string)[]; }; // If set to [] or undefined, will show all chains collectFees?: { integratorAddress: string; // The EVM address of the integrator that will receive the fee fee: 50; // The amount in "basis points" for the fee. 50 = 0.05%. there is currently soft limit of 1% fee allowed for each tx. }; } // More detail about what is inside style export interface ConfigTheme { neutralContent?: ColorType; // Neutral text color baseContent?: ColorType; // Main text color base100?: ColorType; // Background for chain and token dropdowns and secondary buttons base200?: ColorType; // "From" section background and "Settings" section background base300?: ColorType; // "To" section background and main widget background on all other views error?: ColorType; // Errors (usually red) warning?: ColorType; // Warning (usually orange) primary?: ColorType; // Background color for primary buttons secondary?: ColorType; // Hover background for secondary buttons secondaryContent?: ColorType; // Hover content for secondary buttons secondaryFocus?: ColorType; // Button background color for chains and tokens dropdowns neutral?: ColorType; // Text with less visibility (price balance) success?: ColorType; // Usually green roundedBtn?: string; // rem or px roundedBox?: string; // rem or px roundedDropDown?: string; // rem or px displayDivider?: boolean; // displays a divider between the "from and "to" section advanced?: { transparentWidget?: boolean; // When "true", the widget becomes slightly transparent }; } ``` # Collect fees It's also possible for integrators to collect fees on each transaction made through the widget. You'll need to update the configuration to do so. ```typescript collectFees?: { integratorAddress: string; // The EVM address of the integrator that will receive the fee fee: number; // The amount in "basis points" for the fee. 50 = 0.05%. there is currently soft limit of 1% fee allowed for each tx. }; ``` Note: Squid takes a 50% fee on all fees collected by an integratorAddress. You can find the full configuration types here: [Configuration Types](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/configuration-types) # 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 #### Gas fees Aside from standard gas fees paid via the user's wallet, token transfers across chains are charged a fixed network gas fee by Axelar. You will find all of Axelar’s fees [here](https://docs.axelar.dev/resources/mainnet#cross-chain-relayer-gas-fee). If gas prices change and the users overpay, they will be refunded the difference. Cross-chain gas fees are subtracted from the swap amount, which means they are included in the quoted exchange rate and estimated receive amount. #### 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: unde
프로젝트로 돌아가기