kX

Kodiak's Swap Aggregator

What is kX?

kX is Kodiak's advanced swap aggregator and API. It automatically finds the best route to swap, whether or not it's in a Kodiak Liquidity Pool.

When trading on a dex, users swaps are routed through liquidity pools. Until now, swapping on Kodiak would route through liquidity that's only on Kodiak. With kX, users swapping on the Kodiak App's Front End are able to access liquidity outside of Kodiak and facilitate the best swaps, including:

  • Liquidity on other DEX (e.g. BEX), even ones competitive to Kodiak

  • Non-dex mint / redeem routes (e.g. minting HONEY with USDC)

  • Unique "zap" routes (e.g. zapping into Islands or Baults)

  • Tokens and chains with no native Kodiak Liquidity

  • External market maker quotes via RFQ / Hooks

How does kX work?

The kX router automatically finds the best route by quoting an upgraded version of the Kodiak Router and aggregating it with various external providers. The current list of supported external providers is in the API docs: Swap API (kX)

Modular Infrastructure - single approval to immutable contract

The kX router (KXRouter.sol) requires a single token approval to route through the best route everywhere. Similar to the legacy Kodiak Router, the kX router is fully immutable and non-upgradeable. It was specifically designed with a modular architecture of separating the main router and executor (KodiakExecutor.sol) contracts. This ensures that there is no possibility of malicious upgrades that could pose a security concern with token approvals.

This means users only have to approve once and always have access to the "best-execution" routing.

"Best execution"

The kX API returns the best, most reliable quotes. In general, there is no preference for "Kodiak routes" over routes via "external providers" using default settings. The Kodiak Frontend also quotes all possible routes and returns the quotes that result in the best output for users.

That said, there are few caveats to how the "best" quote is calculated:

  1. Most external providers charge small, additional fees - if "Kodiak quote" is the very close to the next best quote, "Kodiak" will be selected as the best provider. Currently, the threshold for this is around 1-2 basis points , based on an analysis of the average cost of aggregation.

  2. Optimize for speed with a timeout of 1-2 seconds. If a particular quote provider has slow response speed, it will be dropped (but only if other, good quotes are available).

  3. Small penalty for quote providers that have relatively high latency. A penalty of 0-5 basis points is charged when evaluating the best quote, based on the experienced volatility of the actual output vs the quote

  4. Routes that consistently display expiring quotes and / or have low liquidity are excluded because of lack of reliability. Certain routes (e.g. RFQ quotes) have quotes that expire in 10-15 seconds, these are typically excluded from the route search because it's not reliable for our broad user base, which includes users that need quotes to be live for several minutes (e.g. for multisig transactions).

Modern Design

Fees

In general, with default settings, fees are zero.

That said, there are 2 forms of fees technically supported:

  1. Surplus Fees: similar to most other aggregators, kX Router has the ability to charge when the actual output exceeds the quoted amount. Unlike other aggregators, kX has special features:

    1. The overall surplus is capped at 1%. This cannot be changed. That is, no matter what, the evaluated surplus can never exceed 1% of the output amount, and this ensures users are never over-charged even user inputs high slippage.

    2. The share of surplus that is charged as fee is configurable between 0-100%. Most other aggregators are hardcoded to take 100% of surplus as fees. In kX, a fraction of the surplus can be charged.

    3. Surplus can be charge relative to a custom benchmark called feeQuote, rather than the actual final quote. Even using a custom benchmark, the overall surplus is still capped at 1%.

  2. Frontend Fees: the kX API supports referral codes to charge an optional frontend fee to facilitate integrators. This requires registration of a referral code, each referral code comes with a maximum frontend fee that can be charged and a share to the referrer. For example, a refCode could be configured with a maximum 1% fee, of which 90% is retained by the referrer. Each referrer can specify a frontend fee with each API request (and it can be customized for each quote).

The default kX API sets surplus fee and frontend fee to 0%. All kX API users on Berachain can swap using the API to achieve the best routing for free.

Kodiak Frontend also does not charge any frontend fees and generally does not charge surplus fees. In certain routes where Kodiak is competitive (and would have otherwise gotten the flow via the frontend), a small fraction of the surplus can be charged, only on the degree a quote beats Kodiak, subject to the surplus caps described above.

Audits?

See Audits.

API user?

See Swap API (kX), and reach out to register a refCode.

Last updated