概览

许多团队会通过在交换中收取费用,将 Skip Go 作为项目收入来源之一来使用。(未来也将支持在转账中收取费用!)在整个产品和文档中,我们将这类费用称为“联盟费用”。 Skip Go 的联盟费用功能简单但灵活,支持多种定制化费用收取场景:
  • 为每一笔交换设置你期望的费用水平(这样你可以为最忠诚的用户提供更低费用)
  • 为每一笔交换设置接收费用的账户(这样你可以更方便地核算资金,并将收入拆分到不同类别中)
  • 按可自定义比例将费用分配给不同账户(这样你可以与合作伙伴和 KOL 建立推荐人或联盟分成计划)

联盟费用如何运作

  1. 目前,联盟费用只能在交换中收取。我们暂不支持在仅由转账组成的路径上收取联盟费用(例如 CCTP 转账、IBC 转账等),即使其中包含多跳转账也是如此。如果你很看重在转账中收取费用,请联系我们。
  2. 联盟费用会在最后一次交换发生的链上收取:Skip Go 会聚合多条链上的交换场所(DEX、订单簿、流动性质押协议等)。有些路径甚至包含多次交换。对于你收取费用的每一笔跨链或单链交换,费用都会应用在最后一次交换上,并发送到你指定的、位于最后一次交换所在链上的地址。
  3. 联盟费用会以每笔交换的输出代币进行收取和计价:例如,如果用户将 OSMO 交换为 ATOM,那么你的费用收款地址将收到 ATOM 形式的费用。
  4. 联盟费用基于最小输出数量计算,该数量会在考虑用户滑点容忍度后,根据我们预估的执行价格来设定:例如,假设一笔 ATOM 到 OSMO 的交换中,最小输出数量为 10 uosmo,累计费用为 1000 bps,即 10%。如果交换成功执行,联盟费用将为 1 uosmo。无论用户最终实际收到 10、11 还是 12 uosmo,联盟费用都会是 1 uosmo。

如何使用联盟费用

使用联盟费用包含两个简单步骤:
  1. 在报价中纳入费用:你需要在请求路径和报价时传入将要收取的总费用金额(以基点为单位),这样 Skip Go 才能自动从返回给用户的预估 amount_out 中扣除该费用。这可以确保你展示给用户的报价已经包含费用,避免用户最终收到低于预期的数量。
  2. 设置接收费用的地址:你还需要告诉 Skip Go 应将费用收入发送到哪些具体地址。你需要传入一个地址列表,并为每个地址指定要收取的费用金额(以基点为单位)。

通过 /route 和 /msgs 接入费用

当你使用 /route 和 /msgs 端点执行交换时,可以在 /route 请求中指定总费用,并在 /msgs 请求中详细说明费用接收方,从而接入联盟费用。下面是正确实现方式的完整说明。
  1. 在 /route 请求中设置总费用
在你的 /route 请求中,加入 cumulative_affiliate_fee_bps 参数,以指定你希望收取的总费用,单位为基点(bps)。
  • 定义:1% 费用 = 100 个基点。
  • 示例:如果要收取 0.75% 的费用,请将 cumulative_affiliate_fee_bps 设置为 "75"。
{
  "cumulative_affiliate_fee_bps": "75",
  // ...other parameters
}
如果你使用的是 @skip-go/client,请使用驼峰命名:cumulativeAffiliateFeeBps。
  1. 识别交换链
在 /route 请求完成后,使用响应中的 swap_venue.chain_id 字段来确定交换将发生在哪条链上。下一步中你需要这项信息,以便提供有效的接收地址。
  1. 在 /msgs 请求中指定费用接收方
在你的 /msgs 请求中,定义 chainIdsToAffiliates 对象,将费用分配给相关链上的指定地址。
结构:
{
  "chainIdsToAffiliates": {
    "<chain_id>": {
      "affiliates": [
        {
          "basisPointsFee": "<fee_in_bps>",
          "address": "<recipient_address>"
        },
        // ...additional affiliates
      ]
    },
    // ...additional chains
  }
}
示例:
{
  "chainIdsToAffiliates": {
    "noble-1": {
      "affiliates": [
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble1..."
        },
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble2..."
        }
      ]
    },
    "osmosis-1": {
      "affiliates": [
        {
          "basisPointsFee": "200", // 2% fee
          "address": "osmo1..."
        }
      ]
    }
  }
}
注意:
  • 交换链上所有联盟接收方的 basisPointsFee 数值总和必须等于你在 /route 请求中设置的 cumulative_affiliate_fee_bps。
  • 所有地址都必须在交换实际发生的链上有效。无效地址会导致返回 400 错误。
  • 如果使用 @skip-go/client,请记得在配置中使用驼峰命名(例如 basisPointsFee)。

通过 /msgs_direct 接入费用

我们建议优先使用 /route 和 /msgs,而不是 /msgs_direct,因为在 /msgs_direct 中处理费用会增加复杂度。
使用 /msgs_direct 端点时,你需要为交换可能发生的每一条链指定联盟费用,因为交换链是在请求过程中确定的。

步骤:

  1. 为所有可能的交换链定义 chainIdsToAffiliates
    • 使用 chainIdsToAffiliates 对象,将每个可能的 chain_id 映射到对应的联盟接收方。
    • 对于每个 chain_id,提供一个 affiliates 列表,其中每一项都包含:
      • basisPointsFee:费用金额,单位为基点(bps)。
      • address:该链上的接收方地址。
  2. 为每一条可能的链都包含条目
    • 通过查询 /v2/fungible/swap_venues 端点,获取所有可能的交换链。
    • 在 chainIdsToAffiliates 中,为列表中的每个 chain_id 都加入对应条目。
  3. 确保各链上的费用保持一致
    • 每条链上联盟接收方的 basisPointsFee 数值总和必须在所有链之间保持相等。
    • 这样做是必要的,因为无论交换最终发生在哪条链上,交换中使用的费用金额都必须相同。
    • 如果不同链之间的费用总和不一致,请求将返回错误。

示例请求:

{
  "chainIdsToAffiliates": {
    "noble-1": {
      "affiliates": [
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble1..."
        },
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble2..."
        }
      ]
    },
    "osmosis-1": {
      "affiliates": [
        {
          "basisPointsFee": "200", // 2% fee
          "address": "osmo1..."
        }
      ]
    },
    // Include entries for all other potential chains
  },
  // ...other parameters
}
注意:
  • 在上面的示例中,每条链的总费用都是 200 bps(2%)。
  • 请确保所有地址在各自对应的链上都有效。
有问题或反馈?欢迎帮助我们持续改进!加入我们的 Discord,并选择 Skip Go Developer 角色来分享你的问题和反馈。

Overview

Many teams use Skip Go as a source of a revenue for their project by charging fees on swaps. (Charging fees on transfers will be possible in the future!). We refer to these fees throughout the product and documentation as “affiliate fees” Skip Go’s affiliate fee functionality is simple but flexible — supporting a large variety of bespoke fee collection scenarios:
  • Set your desired fee level on each swap (so you can offer lower fees to your most loyal users)
  • Set the account that receives the fee on each swap (so you can account for funds easily & separate revenue into different tranches)
  • Divide the fee up in customizable proportions among different accounts (so you can create referral/affiliate revenue sharing programs with partners and KOLs)

Affiliate Fees Work

  1. At this time, affiliate fees can only be collected on swaps. We do not support collecting affiliate fees on routes that only consist of transfers (e.g. CCTP transfers, IBC transfers, etc…) even when there are multi-hop transfers. Please contact us if charging fees on transfers is important to you
  2. Affiliate fees are collected on the chain where the last swap takes place: Skip Go aggregates over swap venues (DEXes, orderbooks, liquid staking protocols, etc…) on many different chains. Some routes even contain multiple swaps. For each individual cross-chain or single chain swap where you collect a fee, the fee is applied on the last swap and sent to an address you specify on the chain where the last swap takes place
  3. Affiliate fees are collected/denominated in the output token of each swap: For example, if a user swaps OSMO to ATOM, your fee collection address will earn a fee in ATOM
  4. Affiliate fees are calculated using the minimum output amount, which is set based on our estimated execution price after accounting for the user’s slippage tolerance : For example, consider an ATOM to OSMO swap where min amount out is 10 uosmo and the cumulative fees are 1000 bps or 10%. If the swap successfully executes, the affiliate fee will be 1 uosmo. It will be 1 uosmo regardless of whether the user actually gets 10, 11, or 12 uosmo out of the swap

How to Use Affiliate Fees

There are two simple steps involved in using affiliate fees:
  1. Incorporate the fee into the quote : You need to request the route & quote with the total fee amount (in basis points) you will collect, so Skip Go can deduct this automatically from the estimated amount_out it returns to the user. This ensures the quote you show the user already accounts for the fee, and they won’t receive any unexpectedly low amount.
  2. Set the address(es) to receive the fee: You also need to tell Skip Go the exact address(es) to send the fee revenue to. You need to pass a list of addresses and specify a fee amount (in basis points) for each to collect.

Incorporating Fees with /route and /msgs

When executing swaps using the /route and /msgs endpoints, you can incorporate affiliate fees by specifying the total fee during the /route request and detailing the fee recipients during the /msgs request. Below is a comprehensive guide on how to correctly implement this.
  1. Set Total Fee in /route Request
In your /route request, include the cumulative_affiliate_fee_bps parameter to specify the total fee you wish to collect, expressed in basis points (bps).
  • Definition: 1% fee = 100 basis points.
  • Example: To collect a 0.75% fee, set cumulative_affiliate_fee_bps to "75".
{
  "cumulative_affiliate_fee_bps": "75",
  // ...other parameters
}
If you’re using @skip-go/client, use camelCase: cumulativeAffiliateFeeBps.
  1. Identify Swap Chain
After the /route request, use the swap_venue.chain_id field in the response to determine which chain the swap will occur on. You’ll need this information to provide valid recipient addresses in the next step.
  1. Specify Fee Recipients in /msgs Request
In your /msgs request, define the chainIdsToAffiliates object to allocate fees to specific addresses on the relevant chains.
Structure:
{
  "chainIdsToAffiliates": {
    "<chain_id>": {
      "affiliates": [
        {
          "basisPointsFee": "<fee_in_bps>",
          "address": "<recipient_address>"
        },
        // ...additional affiliates
      ]
    },
    // ...additional chains
  }
}
Example:
{
  "chainIdsToAffiliates": {
    "noble-1": {
      "affiliates": [
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble1..."
        },
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble2..."
        }
      ]
    },
    "osmosis-1": {
      "affiliates": [
        {
          "basisPointsFee": "200", // 2% fee
          "address": "osmo1..."
        }
      ]
    }
  }
}
Notes:
  • The sum of basisPointsFee values across all affiliates on the swap chain must equal the cumulative_affiliate_fee_bps set in the /route request.
  • All addresses must be valid on the chain where the swap will take place. Invalid addresses will result in a 400 error.
  • If using @skip-go/client, remember to use camelCase (e.g., basisPointsFee) in the config.

Incorporating Fees with /msgs_direct

We recommend using /route and /msgs over /msgs_direct due to the added complexity when handling fees with /msgs_direct.
When using the /msgs_direct endpoint, you need to specify affiliate fees for every possible chain the swap might occur on since the swap chain is determined during the request.

Steps:

  1. Define chainIdsToAffiliates for All Potential Swap Chains
    • Use the chainIdsToAffiliates object to map each potential chain_id to its corresponding affiliates.
    • For each chain_id, provide a list of affiliates, each with:
      • basisPointsFee: The fee amount in basis points (bps).
      • address: The recipient’s address on that chain.
  2. Include Entries for Every Possible Chain
    • Retrieve all potential swap chains by querying the /v2/fungible/swap_venues endpoint.
    • Include an entry in chainIdsToAffiliates for each chain_id from the list.
  3. Ensure Fee Consistency Across Chains
    • The sum of basisPointsFee values for affiliates on each chain must be equal across all chains.
    • This consistency is necessary because the fee amount used in the swap must be the same, regardless of which chain the swap occurs on.
    • If the fee sums differ between chains, the request will return an error.

Example Request:

{
  "chainIdsToAffiliates": {
    "noble-1": {
      "affiliates": [
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble1..."
        },
        {
          "basisPointsFee": "100", // 1% fee
          "address": "noble2..."
        }
      ]
    },
    "osmosis-1": {
      "affiliates": [
        {
          "basisPointsFee": "200", // 2% fee
          "address": "osmo1..."
        }
      ]
    },
    // Include entries for all other potential chains
  },
  // ...other parameters
}
Notes:
  • In the example above, the total fee for each chain is 200 bps (2%).
  • Ensure that all addresses are valid on their respective chains.
Have questions or feedback? Help us get better!Join our Discord and select the “Skip Go Developer” role to share your questions and feedback.