bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 27쪽 중 2쪽
and customizing the Squid Widget iframe.
### Why Use the iFrame?
* **Framework Compatibility**: If you're not using React, NextJS, or Vite the iframe method allows you to integrate the Squid Widget into any web application.
* **Simplicity**: Embedding an iframe is straightforward and doesn't require additional dependencies.
* **Isolation**: The widget runs in its own context, minimizing potential conflicts with your existing code.
### iFrame Source URL
The base URL for the Squid Widget iframe is:
```
https://studio.squidrouter.com/iframe?config=...
```
The `config` parameter at the end of the URL will contain your custom configuration settings.
### Customization
To customize your widget:
1. Visit the [Squid Widget Studio](https://www.squidstudio.app).
2. Adjust the widget settings to your preferences.
3. Click the "Get iframe" button when you're satisfied with the customization.
4. You'll be redirected to a standalone widget page with a URL that includes your custom configuration.
### Embedding the Widget
Once you have your customized iframe URL, you can embed it in your HTML like this:
```html
<iframe
title="squid_widget"
width="430"
height="684"
src="https://studio.squidrouter.com/iframe?config=....."
></iframe>
```
Important notes:
* Adjust the `width` and `height` attributes as needed to fit your layout.
* Replace the `src` URL with your customized URL from the [**Squid Widget Studio**](https://studio.squidrouter.com/) which you can find when you click the export button.
# Customization Guide
## Squid Widget Customization Guide
The Squid Widget offers extensive customization options to tailor its appearance and behavior to your needs. This guide covers how to configure the widget using both the[ **Squid Widget Studio** ](https://studio.squidrouter.com/)and manual configuration.
### Using the Squid Widget Studio
For interactive customization:
1. Visit the [Squid Widget Studio](https://studio.squidrouter.com/).
2. Adjust settings to your preferences.
3. Click the "Copy Config" button to get the configuration code.
4. Paste the copied configuration into your React component.
<figure><img src="https://4247625265-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtXbXyuWIO2PwzNc5Dets%2Fuploads%2F864xhwGHuMIpzVbZ4o30%2FScreenshot%202024-10-08%20at%201.42.51%20PM.png?alt=media&token=0e74e927-10bf-43fd-8f26-dae876bf0a2a" alt=""><figcaption></figcaption></figure>
### Configuration Options
The widget can be configured in several areas:
1. **General Settings**: Set the widget name and API URL.
2. **User Defaults**: Configure default settings like slippage.
3. **Visual Theme**: Customize the widget's appearance.
4. **Content**: Modify titles and animations.
5. **Token Selection**: Set default and initial tokens and chains.
### Basic Configuration Example
For a basic setup with default values:
```jsx
import { SquidWidget } from '@0xsquid/widget';
function App() {
return <SquidWidget />;
}
```
### Full Configuration Example
For a comprehensive setup with custom options:
```jsx
import { SquidWidget } from "@0xsquid/widget"
function App() {
return (
<SquidWidget
config={{
integratorId: "<your-integrator-id>",
theme: {
borderRadius: {
"button-lg-primary": "3.75rem",
container: "1.875rem",
input: "9999px"
// ... other border radius settings
},
fontSize: {
caption: "0.875rem",
"body-medium": "1.40625rem"
// ... other font size settings
},
fontWeight: {
"body-medium": "400",
"heading-large": "400"
// ... other font weight settings
},
fontFamily: {
"squid-main": "Geist, sans-serif"
},
boxShadow: {
container:
"0px 2px 4px 0px rgba(0, 0, 0, 0.20), 0px 5px 50px -1px rgba(0, 0, 0, 0.33)"
},
color: {
"grey-100": "#FBFBFD",
"royal-500": "#9E79D2",
"status-positive": "#7AE870"
// ... other color settings
}
},
themeType: "dark",
apiUrl: "https://v2.api.squidrouter.com",
priceImpactWarnings: {
warning: 3,
critical: 5
},
initialAssets: {
from: {
address: "0xd4d42f0b6def4ce0383636770ef773390d85c61a", // SUSHI
chainId: "42161" // Arbitrum
},
to: {
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // GLMR
chainId: "1284" // Moonbeam
}
}
// ... other configuration options
}}
/>
)
}
```
### Additional Configuration Options
* `disabledChains`: Disable specific chains.
* `slippage`: Set the default slippage tolerance.
* `hideAnimations`: Toggle widget animations.
* `mainLogoUrl`: Set a custom logo URL.
* `priceImpactWarnings`: Customize price impact limits.
###
# Default User Settings
### **Default slippage:** *slippage*
The default slippage must be selected from the slippage options, which can be a number between 0 and 1. Setting `slippage` to `undefined` will make Squid to define the best slippage for each route:
```jsx
slippage: 1 // number between 0-1, or undefined for "Auto" mode
```
### **Disable chains settings:** *disabledChains*
You can disable chains for a specific direction by specifying them in the `disabledChains` setting.
Disabled chains will not be displayed in the chains list on the widget:
```jsx
disabledChains: {
source: [
"1", // Ethereum
"137" // Polygon
],
destination: [
"osmosis-1" // Osmosis
];
};
```
### **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&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&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&token=7f2c7485-8247-48e1-a64c-614056b463f7" alt=""><figcaption></figcaption></figure>
# Configuring Content
## Squid Widget: Configuring Content Guide
This guide explains how to customize various content elements of the Squid Widget, including the logo, title headings, and animations.
### Changing the Logo
You can set a custom logo for your widget using the `mainLogoUrl` property:
```jsx
<SquidWidget
config={{
mainLogoUrl: "https://your-domain.com/path-to-your-logo.png"
}}
/>
```
**Notes:**
* 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.
* Ensure the image URL is accessible and loads quickly for the best user experience.
### Customizing Title Headings
You can customize the text for various sections of the widget using the `titles` property:
```jsx
<SquidWidget
config={{
titles: {
swap: "Convert",
settings: "Settings",
wallets: "Wallets",
tokens: "Tokens",
chains: "Networks",
history: "Transaction History",
transaction: "Transaction Details",
destination: "Destination Address",
}
}}
/>
```
**Available title customizations:**
* `swap`: Main action button (default: "Swap")
* `settings`: Settings page title
* `wallets`: Wallets selection page title
* `tokens`: Token selection page title
* `chains`: Chain (network) selection page title
* `history`: Transaction history page title
* `transaction`: Transaction details page title
* `destination`: Label for destination address input
**Note:** If you set any of these strings to an empty value (`""`), the corresponding title will be invisible.
### Managing Animations
The Squid Widget includes custom Lottie animations by default. You can choose to hide these animations:
```jsx
<SquidWidget
config={{
hideAnimations: true
}}
/>
```
* Set `hideAnimations` to `true` to disable all custom animations.
* Set `hideAnimations` to `false` (default) to keep the animations enabled.
### Best Practices
1. **Consistency:** Ensure that your custom content aligns with your brand and the overall user experience of your application.
2. **Localization:** Consider providing localized versions of titles if your application supports multiple languages.
3. **Performance:** If using a custom logo, optimize the image for web to ensure fast loading times.
4. **Accessibility:** When customizing text, maintain clear and descriptive labels to support all users, including those using screen readers.
### Full Example
Here's an example that combines all of these content configurations:
```jsx
import { SquidWidget } from '@0xsquid/widget';
function App() {
return (
<SquidWidget
config={{
mainLogoUrl: "https://your-domain.com/your-logo.png",
titles: {
swap: "Transfer",
settings: "Preferences",
wallets: "Connect Wallet",
tokens: "Select Token",
chains: "Choose Network",
history: "Past Transfers",
transaction: "Transfer Details",
destination: "Recipient Address",
},
hideAnimations: false,
// ... other configuration options
}}
/>
);
}
export default App;
```
# Default Chains and Tokens
## Squid Widget v2.0: Default Chains and Tokens Configuration Guide
This guide explains how to configure default chains and tokens for the Squid Widget v2.0. Note that there have been significant changes from previous versions.
### Finding Chain IDs and Token Addresses
Before configuring, you'll need to know the correct chain IDs and token addresses:
* **Chain IDs**:
* Use Squid's [API playground](https://api.squidrouter.com/docs)
* Or access the [chains endpoint](https://api.squidrouter.com/v1/chains) directly
* **Token Addresses**:
* Use the [tokens endpoint](https://api.squidrouter.com/v1/tokens)
* Or filter by chain in the [API playground](https://api.squidrouter.com/docs#/tokens/get_v1_tokens) (input the chain ID in the `/tokens` reference)
### Configuring Initial Assets (Chains and Tokens)
In Squid v2.0, `initialFromChainId` and `initialToChainId` have been replaced by the `initialAssets` object:
```jsx
<SquidWidget
config={{
initialAssets: {
from: {
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // Token address
chainId: "1", // Ethereum
},
to: {
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // Token address
chainId: "42161", // Arbitrum
},
},
// ... other configuration options
}}
/>
```
### Configuring Default Tokens Per Chain
The `defaultTokens` property has been renamed to `defaultTokensPerChain`:
```jsx
<SquidWidget
config={{
defaultTokensPerChain: [
{
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH on Ethereum
chainId: "1",
},
{
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", // ETH on Arbitrum
chainId: "42161",
},
],
// ... other configuration options
}}
/>
```
### Visible Tokens And Chains
Limit the tokens and chains visible on your widget by applying `availableChains` and `availableTokens` on the `source` or `destination`.
```jsx
<SquidWidget
config={{
"availableChains": {
"destination": [
"56",
"8453",
"42161"
]
},
"availableTokens": {
"destination": {
"56": [
"0xf3527ef8de265eaa3716fb312c12847bfba66cef",
"0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92"
],
"8453": [
"0xf3527ef8de265eaa3716fb312c12847bfba66cef",
"0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92"
],
"42161": [
"0xf3527ef8de265eaa3716fb312c12847bfba66cef",
"0x7788a3538c5fc7f9c7c8a74eac4c898fc8d87d92"
]
}
}
// ... other configuration options
}}
/>
```
### Removed Features
Please note that the following features have been removed in Squid v2.0:
* `favTokens`: Favorite tokens are no longer supported.
* Several other properties including `companyName`, `titles`, `enableExpress`, `mainLogoUrl`, and others. Refer to the migration guide for a full list.
### Full Example
Here's a complete example combining these configurations:
```jsx
import { SquidWidget } from '@0xsquid/widget';
function App() {
return (
<SquidWidget
config={{
integratorId: "<your-integrator-id>",
apiUrl: "https://v2.api.squidrouter.com",
initialAssets: {
from: {
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
chainId: "1",
},
to: {
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
chainId: "42161",
},
},
defaultTokensPerChain: [
{
address: "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
chainId: "1",
},
{
address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
chainId: "42161",
},
],
// ... other configuration options
}}
/>
);
}
export default App;
```
# Configuration Types
This document outlines the configuration types available for the Squid Widget v2.0. For an implementation example, refer to the Full Configuration Example.
### Core Configuration Types
```typescript
export interface SquidConfig {
integratorId: string;
apiUrl?: string;
theme?: Theme;
themeType?: 'dark' | 'light';
initialAssets?: {
from: TokenData;
to: TokenData;
};
defaultTokensPerChain?: TokenData[];
priceImpactWarnings?: {
warning: number;
critical: number;
};
availableChains?: {
source?: ChainId[];
destination?: ChainId[];
};
loadPreviousStateFromLocalStorage?: boolean;
slippage?: SlippageOption;
hideAnimations?: boolean;
preferDex?: DexName[] | string[];
collectFees?: {
integratorAddress: string;
fee: number; // Basis points (e.g., 50 = 0.05%)
};
degenMode?: boolean;
}
export type ChainId = number | string;
export type SlippageOption = 0.5 | 1 | 1.5 | 3;
export type TokenData = {
address: string;
chainId: ChainId;
};
export type DexName = string; // Specific DEX names to be listed here
```
### Theme Configuration
```typescript
export interface Theme {
borderRadius?: {
"button-lg-primary"?: string;
"button-lg-secondary"?: string;
"button-lg-tertiary"?: string;
"button-md-primary"?: string;
"button-md-secondary"?: string;
"button-md-tertiary"?: string;
"container"?: string;
"input"?: string;
"menu-sm"?: string;
"menu-lg"?: string;
"modal"?: string;
};
fontSize?: {
"caption"?: string;
"body-small"?: string;
"body-medium"?: string;
"body-large"?: string;
"heading-small"?: string;
"heading-medium"?: string;
"heading-large"?: string;
};
fontWeight?: {
"caption"?: string;
"body-small"?: string;
"body-medium"?: string;
"body-large"?: string;
"heading-small"?: string;
"heading-medium"?: string;
"heading-large"?: string;
};
fontFamily?: {
"squid-main"?: string;
};
boxShadow?: {
"container"?: string;
};
color?: {
"grey-100"?: ColorType;
"grey-200"?: ColorType;
"grey-300"?: ColorType;
"grey-400"?: ColorType;
"grey-500"?: ColorType;
"grey-600"?: ColorType;
"grey-700"?: ColorType;
"grey-800"?: ColorType;
"grey-900"?: ColorType;
"royal-300"?: ColorType;
"royal-400"?: ColorType;
"royal-500"?: ColorType;
"royal-700"?: ColorType;
"status-positive"?: ColorType;
"status-negative"?: ColorType;
"status-partial"?: ColorType;
"highlight-700"?: ColorType;
"animation-bg"?: ColorType;
"animation-text"?: ColorType;
"button-lg-primary-bg"?: ColorType;
"button-lg-primary-text"?: ColorType;
"button-lg-secondary-bg"?: ColorType;
"button-lg-secondary-text"?: ColorType;
"button-lg-tertiary-bg"?: ColorType;
"button-lg-tertiary-text"?: ColorType;
"button-md-primary-bg"?: ColorType;
"button-md-primary-text"?: ColorType;
"button-md-secondary-bg"?: ColorType;
"button-md-secondary-text"?: ColorType;
"button-md-tertiary-bg"?: ColorType;
"button-md-tertiary-text"?: ColorType;
"input-bg"?: ColorType;
"input-placeholder"?: ColorType;
"input-text"?: ColorType;
"input-selection"?: ColorType;
"menu-bg"?: ColorType;
"menu-text"?: ColorType;
"menu-backdrop"?: ColorType;
"modal-backdrop"?: ColorType;
};
}
export type ColorType = string; // The color format must be of type #FFFFFF
```
### Important Notes
1. The `apiUrl` is now [`https://v2.api.squidrouter.com`](https://v2.api.squidrouter.com) by default.
2. `initialFromChainId` and `initialToChainId` have been replaced by `initialAssets`.
3. `defaultTokens` has been renamed to `defaultTokensPerChain`.
4. `favTokens` has been removed and is no longer supported.
5. Several properties have been removed in v2.0, including `companyName`, `titles`, `enableExpress`, `mainLogoUrl`, and others. Refer to the migration guide for a full list of removed properties.
6. A new `degenMode` property has been added.
### Deprecated or Removed Types
The following types and properties are no longer used in Squid Widget v2.0:
* `ConfigTheme` (replaced by `Theme`)
* `enableExpress`
* `enableGetGasOnDestination`
* `mainLogoUrl`
* `titles`
* `internalSameChainSwapAllowed`
* `advanced.shareOnTwitter`
* `advanced.disableTradeLimit`
* `favTokens`
* `comingSoonChainIds`
# Collect Fees
### Integrator Fee Structure
Squid v2 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)
#### Implementing Integrator Fees
In order to prevent abuse an abuse of the fee collection system, we implement the `collectFees` parameter on the backen프로젝트로 돌아가기