bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 27쪽 중 27쪽
.**
#### 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 backend for integrators:
```javascript
const params = {
// ... other route parameters
collectFees: {
integratorAddress: "0x123...abc", // Your address to receive fees
fee: 50, // Fee in basis points (e.g., 50 = 0.5%)
integratorAddress2: "0x456...def", // Optional secondary address
fee2: 25, // Optional fee for secondary address (in basis points)
}
};
const { route } = await squid.getRoute(params);
```
#### 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
Squid splits all fees collected by integrators 50/50.
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.
# Collect Fees
Integrators can pass in a collectFees object to the SDK or API to collect a fee on each transaction. 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`
# Get supported tokens and chains
{% hint style="info" %}
See all our supported chains and tokens at <https://v2.app.squidrouter.com>
{% endhint %}
{% tabs %}
{% tab title="SDK" %}
```typescript
// access using squid.tokens
const fromToken = squid.tokens.find(
(t) =>
t.symbol.toLocaleLowerCase() === "USDC" && t.chainId === "1"
);
// access using squid.chains
const fromChain = squid.chains.find(
(c) =>
c.chainId === "1"
);
```
{% endtab %}
{% tab title="API" %}
```typescript
const getChains = async () => {
const result = await axios.get('https://v2.api.squidrouter.com/v2/chains', {
headers: {
'x-integrator-id': integratorId,
},
});
return result.data;
};
const getTokens = async () => {
const result = await axios.get('https://v2.api.squidrouter.com/v2/tokens', {
headers: {
'x-integrator-id': integratorId,
},
});
return result.data;
};
```
{% endtab %}
{% tab title="Widgets" %}
Every widget will automatically pull down all Squid's supported tokens and chains.
You can limit the available tokens and chains using this guide:[Default Chains and Tokens](/old-v2-documentation-deprecated/add-a-widget/widget/customization-guide/default-chains-and-tokens)
{% endtab %}
{% endtabs %}프로젝트로 돌아가기