mcxross

turbos

This skill should be used when the user asks about Turbos Finance, Turbos CLMM, Turbos DEX, Turbos concentrated liquidity, or wants to integrate with Turbos on Sui. Covers swaps, multi-hop routing, position management, liquidity provision, and pool queries.

mcxross 3 Actualitzat fa 8 mesos

Recursos

1
GitHub

Instal·la

npx skillscat add mcxross/skills/turbos

Instal·la des del registre de SkillsCat.

SKILL.md

Turbos Finance on Sui

Turbos is a concentrated liquidity market maker (CLMM) DEX on Sui. Like Cetus, it uses a Uniswap V3-style tick-based AMM, but pools are parameterized with a third type parameter T2 representing the fee tier.

Package IDs

Package Original ID Description
CLMM Core 0x91bfbc386a41afcfd9b2533058d7e915a1d3829089cc268ff4333d54d6339ca1 Pool, position, swap, fee logic

Source Files

Decompiled Move source:
packages/mainnet_most_used/0x54/61b2aa79e5da5057da1d51c6e988354bcd974328128edbf5c3d38a4c4ab75e/decompiled_modules/

Architecture

  • Pool<T0, T1, T2>: CLMM pool where T2 is a fee tier witness type (e.g., fee::FeeType500, fee::FeeType3000, fee::FeeType10000)
  • TurbosPositionNFT: Owned NFT referencing a position in the Positions table
  • Positions: Shared object storing all position data (keyed by NFT address)
  • Fee: Fee tier configuration (fee amount + tick spacing)
  • Versioned: Version gate for upgradeable contracts
  • PoolConfig: Pool registry tracking deployed pools

Key Modules

Module Purpose
pool Pool struct, flash swap, state queries, tick/position lookups
swap_router Entry points for single-hop and multi-hop swaps
position_manager Mint, burn, increase/decrease liquidity, collect fees/rewards
pool_factory Pool deployment, protocol fee collection, admin operations
pool_fetcher Read-only swap simulation, tick fetching
fee Fee tier types and configuration
position_nft TurbosPositionNFT struct and accessors
math_swap Core swap computation math
math_liquidity Liquidity <-> amount conversions

Common Integration Patterns

Swap A to B

// Single-hop swap (entry function)
swap_router::swap_a_b<CoinA, CoinB, FeeType>(
    pool, coins_in, amount, amount_threshold,
    sqrt_price_limit, amount_specified_is_input,
    recipient, deadline, clock, versioned, ctx
);

// With return value (programmable)
let (coin_out, coin_remaining) = swap_router::swap_a_b_with_return_<CoinA, CoinB, FeeType>(
    pool, coins_in, amount, amount_threshold,
    sqrt_price_limit, amount_specified_is_input,
    recipient, deadline, clock, versioned, ctx
);

Swap B to A

swap_router::swap_b_a<CoinA, CoinB, FeeType>(
    pool, coins_in, amount, amount_threshold,
    sqrt_price_limit, amount_specified_is_input,
    recipient, deadline, clock, versioned, ctx
);

Multi-Hop Swap (A->B->C)

swap_router::swap_a_b_b_c<A, B, FeeAB, B, C, FeeBC>(
    pool_ab, pool_bc, coins_in, amount, amount_threshold,
    sqrt_price_limit_ab, sqrt_price_limit_bc,
    amount_specified_is_input, recipient, deadline,
    clock, versioned, ctx
);

Mint Position (Add Liquidity)

position_manager::mint<CoinA, CoinB, FeeType>(
    pool, positions, coins_a, coins_b,
    tick_lower_index, tick_lower_is_neg,
    tick_upper_index, tick_upper_is_neg,
    amount_a_desired, amount_b_desired,
    amount_a_min, amount_b_min,
    recipient, deadline, clock, versioned, ctx
);

Decrease Liquidity + Collect

position_manager::decrease_liquidity<CoinA, CoinB, FeeType>(
    pool, positions, nft, liquidity_delta,
    min_amount_a, min_amount_b, deadline,
    clock, versioned, ctx
);
position_manager::collect<CoinA, CoinB, FeeType>(
    pool, positions, nft, amount_a_max, amount_b_max,
    recipient, deadline, clock, versioned, ctx
);

Pool Queries

let (balance_a, balance_b) = pool::get_pool_balance<T0, T1, T2>(pool);
let sqrt_price = pool::get_pool_sqrt_price<T0, T1, T2>(pool);
let tick = pool::get_pool_current_index<T0, T1, T2>(pool);
let liquidity = pool::get_pool_liquidity<T0, T1, T2>(pool);
let fee = pool::get_pool_fee<T0, T1, T2>(pool);

Compute Swap Result (read-only quote)

let result = pool_fetcher::compute_swap_result<T0, T1, T2>(
    pool, a_to_b, amount, by_amount_in,
    sqrt_price_limit, clock, versioned, ctx
);

Related Skills

  • cetus -- Primary CLMM DEX on Sui (similar architecture, no fee type param)
  • deepbook -- CLOB DEX
  • kriya -- AMM/PMM DEX
  • sui-framework -- Core Coin, Balance types