DeDust Hub
Technical Reference

Pool

The Pool contract is the central component of the CPMM V2 protocol.

It implements the Constant Product Market Maker (x×y=kx \times y = k) logic for a specific pair of assets.

The contract is responsible for:

  • Executing Swaps: Facilitating automated asset exchange with slippage protection and multi-hop routing support.
  • Liquidity Management: Orchestrating the minting and burning of liquidity shares through interaction with Deposit and Position contracts.
  • Fee Collection & Distribution: Accumulating trading fees and distributing them proportionally among liquidity providers, the pool creator, and the protocol.
  • Incentive Programs: Managing active reward distributions to encourage liquidity provisioning.

Each pool is uniquely identified by its configuration parameters (PoolConfig).

Getters

Method get_pool_data

Returns the current state of the pool, including configuration, reserves, fees, resolved wallets, and reward settings.

Arguments

This getter does not accept any arguments.

Returns

#NameTypeDescription
0statusint (PoolStatus)Current lifecycle state of the pool: uninitialized (0), initializing (1), or initialized (2).
1depositActiveint (bool)Indicates whether deposit operations are currently enabled.
2swapActiveint (bool)Indicates whether swap operations are currently enabled.
3assetXslice (Asset)Address identifying asset X of the pool (native TON or jetton minter address).
4assetYslice (Asset)Address identifying asset Y of the pool (native TON or jetton minter address).
5walletsByAssetscell (map<uint256, address>)Mapping from asset identifiers to resolved wallet addresses. The key is the account hash of a jetton minter address, and the value is the corresponding jetton wallet address owned by the pool.
6assetsByWalletscell (map<uint256, Asset>)Reverse mapping from wallet account hashes to their associated assets.
7walletsResolutionscell (map<uint256, address>)Cache of resolved wallet addresses used during asset resolution to avoid repeated lookups.
8baseFeeBPSint (uint16)Base swap fee, expressed in basis points (BPS), applied to all swaps in the pool.
9reserveXint (coins)Current reserve of asset X held by the pool.
10reserveYint (coins)Current reserve of asset Y held by the pool.
11liquidityint (coins)Total amount of liquidity tokens currently issued by the pool.
12protocolFeeXint (coins)Accumulated protocol fees in asset X that have not yet been withdrawn.
13protocolFeeYint (coins)Accumulated protocol fees in asset Y that have not yet been withdrawn.
14creatorFeeXint (coins)Accumulated creator fees in asset X that have not yet been withdrawn.
15creatorFeeYint (coins)Accumulated creator fees in asset Y that have not yet been withdrawn.
16xLPFeePerTokenint (Q120X120)Amount of fees in asset X accrued per one unit of liquidity, used for proportional fee distribution.
17yLPFeePerTokenint (Q120X120)Amount of fees in asset Y accrued per one unit of liquidity, used for proportional fee distribution.
18rewardscell (map<uint2, PoolReward>)Active reward configurations indexed by reward type, defining incentive distribution parameters for liquidity providers.

Method get_position_address

Calculates the account address of a Position contract for a given owner.

Arguments

#NameTypeDescription
0owner_addressslice (address)Address of the position owner.

Returns

#NameTypeDescription
0position_accountslice (address)Deterministically computed account address of the Position contract associated with the specified owner. The returned account may or may not be deployed at the time of the call.

Events

Events are emitted after successful state-changing operations and describe both the operation parameters and the resulting next pool state.

Each event includes:

  • operation-specific fields,
  • the initiator and recipient addresses,
  • a nextState snapshot representing the pool state after the operation.

Event Deposit

Emitted after a liquidity deposit into the pool.

The event records the deposited amounts of both assets, the amount of liquidity minted, and the resulting pool state.

struct (0x35df2e12) Deposit {
    amountXIn: coins
    amountYIn: coins
    liquidity: coins
    initiatorAddress: address
    recipientAddress: address
    nextState: Cell<PoolUpdatedState>
}
ParameterTypeDescription
amountXIncoinsAmount of asset X deposited into the pool.
amountYIncoinsAmount of asset Y deposited into the pool.
liquiditycoinsAmount of pool liquidity minted as a result of the deposit.
initiatorAddressaddressAddress that initiated the deposit transaction.
recipientAddressaddressAddress that received the minted liquidity.
nextStateCell<PoolUpdatedState>Cell containing PoolUpdatedState, representing the pool state after the deposit.

Event Withdrawal

Emitted after a liquidity withdrawal from the pool.

The event records the amount of liquidity burned, the withdrawn asset amounts, and the resulting pool state.

struct (0xc0d77b54) Withdrawal {
    liquidity: coins
    amountXOut: coins
    amountYOut: coins
    initiatorAddress: address
    recipientAddress: address
    nextState: Cell<PoolUpdatedState>
}
ParameterTypeDescription
liquiditycoinsAmount of pool liquidity burned as part of the withdrawal.
amountXOutcoinsAmount of asset X withdrawn from the pool.
amountYOutcoinsAmount of asset Y withdrawn from the pool.
initiatorAddressaddressAddress that initiated the withdrawal transaction.
recipientAddressaddressAddress that received the withdrawn assets.
nextStateCell<PoolUpdatedState>Cell containing PoolUpdatedState, representing the pool state after the withdrawal.

Event Swap

Emitted after a successful asset swap.

The event records the swap direction, input and output amounts, fees applied, and the resulting pool state.

struct (0x78e79ba4) Swap {
    xToY: bool
    amountIn: coins
    amountOut: coins
    initiatorAddress: address
    recipientAddress: address
    nextState: Cell<PoolUpdatedState>
    fees: Cell<SwapFees>
}
ParameterTypeDescription
xToYboolSwap direction. true indicates X → Y, false indicates Y → X.
amountIncoinsAmount of the input asset provided for the swap.
amountOutcoinsAmount of the output asset received from the swap.
initiatorAddressaddressAddress that initiated the swap transaction.
recipientAddressaddressAddress that received the output asset.
nextStateCell<PoolUpdatedState>Cell containing PoolUpdatedState, representing the pool state after the swap.
feesCell<SwapFees>Cell containing SwapFees, representing fees applied to this swap.

Payments

Payments are value-carrying messages that instruct the pool to perform a specific operation. Each payment includes a payment payload describing the operation parameters and MUST be accompanied by the appropriate asset transfer (native TON or jetton).

Payment Swap

Requests execution of an asset swap subject to slippage and time constraints.

For a step-by-step walkthrough of this process, see Swap.

struct (0xc442500f) Swap {
    minimalAmountOut: coins
    deadline: uint40
    next: Cell<SwapStep>?
    partnerConfig: PartnerConfig?
    referrerConfig: ReferrerConfig?
}
ParameterTypeDescription
minimalAmountOutcoinsMinimum acceptable amount of the output asset. The swap must revert if the actual output is lower.
deadlineuint40Unix timestamp after which the swap must not be executed.
nextCell<SwapStep>?Optional next swap step (SwapStep), enabling multi-step swaps. Can be recursive itself.
partnerConfigPartnerConfig?Optional partner configuration (PartnerConfig)applied to this swap.
referrerConfigReferrerConfig?Optional referrer configuration (ReferrerConfig) applied to this swap.

Semantics

  • The swap MUST fail if amountOut < minimalAmountOut.
  • The swap MUST fail if the current time is greater than deadline.
  • If next is present, the swap is treated as part of a multi-hop route.

Payment Deposit

Requests a liquidity deposit into the pool.

The deposit is fulfilled via two separate asset payments:

  • amountX specifies the expected amount of asset X
  • amountY specifies the expected amount of asset Y

Liquidity is added to the pool only after both payments are received. If either payment is missing or does not match the declared amounts, the deposit must not be finalized.

For a step-by-step walkthrough of this process, see Liquidity Provisioning.

struct (0xc9a015da) Deposit {
    amountX: coins
    amountY: coins
    minimalLiquidity: coins
    lockedLiquidityShare: uint16
}
ParameterTypeDescription
amountXcoinsAmount of asset X expected to be paid by the first payment.
amountYcoinsAmount of asset Y expected to be paid by the second payment.
minimalLiquiditycoinsMinimum acceptable amount of liquidity to be minted. The deposit must revert if the resulting liquidity is lower.
lockedLiquidityShareuint16Share of the minted liquidity that is locked, expressed in basis points or protocol-defined units.

Semantics

  • A Deposit payment initiates a multi-step process. The Pool deploys a temporary Deposit contract to accumulate the required assets.
  • The operation MUST fail if the actual minted liquidity is less than minimalLiquidity (slippage protection).
  • lockedLiquidityShare determines the portion of the minted liquidity that will be marked as "permanently locked" in the user's Position, preventing withdrawal.
  • The Pool calculates the required amount of the second asset based on the first payment's amount and the current reserves to maintain the constant product invariant.

Payment FundReward

Funds an active reward program of the pool. This payment increases the remaining budget of the specified reward program and potentially extends its duration.

struct (0x2eb87df9) FundReward {
    till: uint40
}
ParameterTypeDescription
tilluint40Unix timestamp indicating the new end time for the reward distribution. Must be greater than the current time.

Semantics

  • The payment MUST be accompanied by the asset defined in the pool's RewardConfig.
  • The new duration (till - now) MUST NOT exceed the maxDuration specified in the reward configuration.
  • If the reward is already active, the funding MUST NOT dilute the current reward rate.

Incoming Messages

Message InitPool

Starts the pool initialization process. This call triggers the resolution of jetton wallet addresses for the pool's assets and any allowed reward jettons. Once all addresses are resolved, the pool state transitions to initialized.

struct (0xde8402ce) InitPool {
    queryId: uint64
    customPayload: cell?
}
ParameterTypeDescription
queryIduint64Unique identifier for the request, used to match the response.
customPayloadcell?Optional payload that will be included in the InitPoolResult message upon completion or failure.

Message PayNative

Used for payments in native TON.

struct (0xa5a7cbf8) PayNative {
    queryId: uint64
    amount: coins
    paymentPayload: cell
    payoutConfig: Cell<ExtendedPayoutConfig>
}
ParameterTypeDescription
queryIduint64Unique identifier for the transaction.
amountcoinsThe amount of native TON being paid to the pool.
paymentPayloadcellOperation-specific data (e.g., SwapPayload or DepositPayload).
payoutConfigCell<ExtendedPayoutConfig>Configuration defining how to handle results (e.g., ExtendedPayoutConfig).

Message TransferNotification

A standard TEP-74 notification message received by the pool when jettons are transferred to it. The pool parses the forwardPayload to determine which operation (swap, deposit, or reward funding) to perform.

struct (0x7362d09c) TransferNotificationMessage {
    queryId: uint64
    amount: coins
    sender: address
    forwardPayload: RemainingBitsAndRefs | cell
}
ParameterTypeDescription
queryIduint64Unique identifier for the transaction, typically provided by the jetton sender.
amountcoinsThe amount of jettons received by the pool.
senderaddressThe address of the user who initiated the jetton transfer.
forwardPayloadRemainingBitsAndRefs | cellOperation-specific data. Expected to contain PayJetton.

Message JoinLiquidity

Sent by a Deposit contract to the Pool to finalize a liquidity provision. This message is sent only after the Deposit contract has successfully collected both required assets. The pool then mints liquidity tokens and updates its reserves.

struct (0x25251ee0) JoinLiquidity {
    queryId: uint64
    config: Cell<DepositConfig>
    amountX: coins
    amountY: coins
    initiatorAddress: address
}
ParameterTypeDescription
queryIduint64Unique request identifier.
configCell<DepositConfig>The original deposit configuration (DepositConfig).
amountXcoinsAmount of asset X to be refunded.
amountYcoinsAmount of asset Y to be refunded.
initiatorAddressaddressThe address of the user who originally initiated the deposit.

Message RefundDeposit

Sent by a Deposit contract to the Pool to finalize a liquidity provision. This message is sent only after the Deposit contract has successfully collected both required assets. The pool then mints liquidity tokens and updates its reserves.

struct (0x0d299e12) RefundDeposit {
    queryId: uint64
    config: Cell<DepositConfig>
    amountX: coins
    amountY: coins
    initiatorAddress: address
}
ParameterTypeDescription
queryIduint64Unique request identifier.
configCell<DepositConfig>Configuration of the deposit process (DepositConfig).
amountXcoinsAmount of asset X to be refunded.
amountYcoinsAmount of asset Y to be refunded.
initiatorAddressaddressThe address of the user who originally initiated the deposit.

Message TakeWalletAddress

A callback message used during pool initialization. It is sent by a Jetton Minter (or a custom resolver) to provide the address of the Jetton Wallet that the pool should use.

struct (0xd1735400) TakeWalletAddress {
    queryId: uint64
    walletAddress: address
    ownerAddress: Cell<address>?
}

Message ClaimPositionFees

Initiates the collection of accrued trading fees for a specific liquidity position. The pool synchronizes the fee states and forwards a request to the user's Position contract to calculate and claim the available fees.

struct (0x5652f1df) ClaimPositionFees {
    queryId: uint64
    excessesTo: address
}
ParameterTypeDescription
queryIduint64Unique request identifier.
excessesToaddressAddress to receive any remaining TON after gas fees and synchronization processes.

Message PayoutPositionFees

Sent by a Position contract to the Pool to trigger the actual transfer of collected fees to the position owner.

struct (0x29ff1bcf) PayoutPositionFees {
    queryId: uint64
    xFees: coins
    yFees: coins
    ownerAddress: address
    excessesTo: address
}

Message ClaimProtocolFees

Allows the protocol controller to withdraw accumulated protocol fees from the pool. The message triggers the transfer of the specified assets to the destination address, provided the sender is authorized.

struct (0x419a17b3) ClaimProtocolFees {
    queryId: uint64
    to: address
    excessesTo: address
}
ParameterTypeDescription
queryIduint64Unique request identifier.
toaddressThe recipient address where the accumulated protocol fees will be sent.
excessesToaddressAddress to receive any remaining TON after gas fees and transfer costs.

Message ClaimCreatorFees

Allows the pool creator to withdraw their share of accumulated trading fees. The pool verifies that the sender matches the creatorAddress defined in the pool's configuration and transfers the available fees.

struct (0xbe3e3179) ClaimCreatorFees {
    queryId: uint64
    to: address
    excessesTo: address
}
ParameterTypeDescription
queryIduint64Unique request identifier.
toaddressThe recipient address where the accumulated creator fees will be sent.
excessesToaddressAddress to receive any remaining TON after gas fees and transfer costs.

Message Withdraw

Initiates the withdrawal of liquidity from the pool. This message is sent to the pool, which then forwards the request to the user's Position contract to burn the liquidity tokens and calculate the proportional share of reserves to be returned.

struct (0x20b5ef89) Withdraw {
    queryId: uint64
    liquidity: coins
    minimalXOut: coins
    minimalYOut: coins
    autoClaimFees: bool
    payoutConfig: Cell<BasicPayoutConfig>
}
ParameterTypeDescription
queryIduint64Unique request identifier.
liquiditycoinsAmount of liquidity tokens to be burned for assets.
minimalXOutcoinsMinimum amount of asset X expected to be received (slippage protection).
minimalYOutcoinsMinimum amount of asset Y expected to be received (slippage protection).
autoClaimFeesboolIf true, any accrued fees for this position will be claimed automatically during the exit.
payoutConfigCell<BasicPayoutConfig>Configuration defining the recipient and fee handling for the withdrawn assets.

Message ExitLiquidity

Sent by a Position contract to the Pool to finalize the withdrawal process. The pool burns the liquidity tokens, updates its reserves, and sends the corresponding assets to the user.

struct (0xf6f6a3aa) ExitLiquidity {
    queryId: uint64
    liquidity: coins
    xFees: coins
    yFees: coins
    ownerAddress: address
    minimalAmountX: coins
    minimalAmountY: coins
    payoutConfig: Cell<BasicPayoutConfig>
}

Message ProvidePoolState

Requests a snapshot of the current pool state. The pool responds with a TakePoolState message. Detailed information such as configuration, fees, or reward settings can be requested via optional flags.

TODO: state that the response (TakePoolState) will contain null or Maybe values for the requested fields if the flags are false.

struct (0x00d8d379) ProvidePoolState {
    queryId: uint64
    includeConfig: bool
    includeFees: bool
    includeCodeHash: bool
    includeRewards: bool
}

Parameters

ParameterTypeDescription
queryIduint64Unique request identifier.
includeConfigboolIf true, the response will include the pool configuration (PoolConfig).
includeFeesboolIf true, the response will include the accumulated fees (PoolFees).
includeCodeHashboolIf true, the response will include the hash of the contract code.
includeRewardsboolIf true, the response will include reward program data (PoolRewards).

Caller: Any address.

Message ClaimReward

Initiates the process of claiming earned rewards for a specific reward program. The pool synchronizes reward states and forwards the claim request to the user's Position contract.

struct (0x909fdb65) ClaimReward {
    queryId: uint64
    rewardIndex: uint2
    excessesTo: address
}

Parameters

ParameterTypeDescription
queryIduint64Unique request identifier.
rewardIndexuint2Index of the reward program to claim from.
excessesToaddressAddress to receive any remaining TON after gas fees and synchronization costs.

Message PayoutReward

Sent by a Position contract to the Pool to request the actual distribution of earned rewards to the position owner.

struct (0x9e17fbbe) PayoutReward {
    queryId: uint64
    amount: coins
    rewardIndex: uint2
    ownerAddress: address
    excessesTo: address
}

Parameters

ParameterTypeDescription
queryIduint64Unique request identifier.
amountcoinsAmount of the reward asset to be paid out.
rewardIndexuint2Index of the reward program in the pool's registry.
ownerAddressaddressThe recipient of the reward assets.
excessesToaddressAddress to receive any remaining TON after gas fees and transfer costs.

Outgoing Messages

Message InitPoolResult

Sent to the initiator after an attempt to initialize the pool. It indicates whether the setup was successful or failed with a specific error.

struct (0xce185bd7) InitPoolResult {
  queryId: uint64
  exitCode: int32
  customPayload: cell?
}
ParameterTypeDescription
queryIduint64Unique identifier of the request, used to match the response with the original InitPool call.
exitCodeint32Result of the operation. 0 indicates success; any other value represents an error code.
customPayloadcell?Optional extra data returned by the contract, often used for extended status or debugging.

Message TakePoolState

TakePoolState is sent in response to a ProvidePoolState request. It returns a snapshot of the current pool state. Optional fields are included only if explicitly requested via the corresponding include* flags in ProvidePoolState.

struct (0x870a9579) TakePoolState {
    queryId: uint64
    status: PoolStatus
    depositActive: bool
    swapActive: bool
    liquidity: coins
    reserveX: coins
    reserveY: coins
    config: Cell<PoolConfig>?
    fees: Cell<PoolFees>?
    rewards: PoolRewards?
    codeHash: uint256?
}
FieldTypeDescription
queryIduint64Identifier copied from the corresponding ProvidePoolState request.
statusPoolStatusCurrent lifecycle state of the pool.
depositActiveboolWhether liquidity deposits are currently allowed.
swapActiveboolWhether swaps are currently allowed.
liquiditycoinsTotal liquidity issued by the pool.
reserveXcoinsCurrent reserve of token X held by the pool.
reserveYcoinsCurrent reserve of token Y held by the pool.
configCell<PoolConfig>?Present only if includeConfig = true in ProvidePoolState. Contains pool configuration parameters.
feesCell<PoolFees>?Present only if includeFees = true in ProvidePoolState. Contains fee configuration.
rewardsPoolRewards?Present only if includeRewards = true in ProvidePoolState. Contains reward / incentive parameters.
codeHashuint256?Present only if includeCodeHash = true in ProvidePoolState. Hash of the pool contract code.

Other Payloads

Payload PayJetton

Used for jetton payments. This payload is expected to be received as the forward_payload of a TransferNotification.

This structure contains the business logic payload (e.g., a swap or deposit request) and the configuration for handling the operation's result.

struct (0xcbc33949) PayJetton {
    paymentPayload: cell
    payoutConfig: Cell<ExtendedPayoutConfig>
}
ParameterTypeDescription
paymentPayloadcellOperation-specific data (e.g., SwapPayload or DepositPayload).
payoutConfigCell<ExtendedPayoutConfig>Configuration defining how to handle successful completions or rejections (e.g., where to send refunds).

Other Types

Type PoolStatus

Represents the current lifecycle stage of the pool.

struct (0b00) PoolStatusUninitialized {
}

struct (0b01) PoolStatusInitializing {
    initiatorAddress: address
}

struct (0b10) PoolStatusInitialized {
}

type PoolStatus =
    | PoolStatusUninitialized
    | PoolStatusInitializing
    | PoolStatusInitialized
StatusTagDescription
uninitialized0b00The pool has been deployed but not yet configured.
initializing0b01The pool is in the process of resolving asset wallet addresses. Contains the initiatorAddress.
initialized0b10The pool is fully functional and ready for swaps and deposits.

Initializing Parameters

ParameterTypeDescription
initiatorAddressaddressThe address that triggered the pool initialization process.

Type PoolConfig

Defines the immutable configuration parameters of the pool, established during its initialization.

struct PoolConfig {
    assetX: Asset
    assetY: Asset
    creatorAddress: address
    baseFeeBPS: uint16
    creatorFeeBPS: uint16
    depositActivation: Cell<Activation>?
    swapActivation: Cell<Activation>?
    feeIn: FeeIn
    customResolvers: map<uint256, address>
    allowedRewards: map<uint2, RewardConfig>
}
ParameterTypeDescription
assetXAssetIdentifier for the first asset in the pair.
assetYAssetIdentifier for the second asset in the pair.
creatorAddressaddressAddress of the pool creator, authorized to claim creator fees.
baseFeeBPSuint16Standard swap fee in basis points (1 unit = 0.01%).
creatorFeeBPSuint16Additional fee in basis points directed to the pool creator.
depositActivationCell<Activation>?Optional activation rules for liquidity deposits (e.g., time-lock or specific initiator).
swapActivationCell<Activation>?Optional activation rules for asset swaps.
feeInFeeInStrategy for fee collection (FeeIn).
customResolversmap<uint256, address>Mapping of jetton assets (account part of address) to custom resolver contracts for non-standard jetton wallets.
allowedRewardsmap<uint2, RewardConfig>Registry of allowed reward assets and their constraints for incentive programs.

Type Asset

Represents an asset identifier used by the pool (e.g. a jetton or native token).

type Asset = address_any
ParameterTypeDescription
valueaddress_anyAddress identifying the asset contract.

Type FeeIn

Defines the strategy for swap fee collection. The pool can collect fees in both assets of the pair or restrict it to one specific asset.

enum FeeIn : uint2 {
    Both = 0b00
    AssetX = 0b01
    AssetY = 0b10
}
StrategyTagDescription
both0b00Fees are collected in the input asset of the swap.
assetX0b01Fees are always collected in Asset X, regardless of the swap direction.
assetY0b10Fees are always collected in Asset Y, regardless of the swap direction.

Type Activation

Defines when swaps or deposits can be used, or who triggers their activation.

struct (0x01) ActivationTime {
    activeSince: uint40
}

struct (0x02) ActivationInitiator {
    initiatorAddress: address
}

type Activation =
    | ActivationTime
    | ActivationInitiator

Time-based activation

ParameterTypeDescription
activeSinceuint40Unix timestamp from which the entity is considered active.

Initiator-based activation

ParameterTypeDescription
initiatorAddressaddressAddress whose interaction triggers activation.

Type RewardConfig

Defines configuration parameters for a reward program.

struct RewardConfig {
    asset: Asset;
    maxDuration: uint40;
}
ParameterTypeDescription
assetAssetAsset distributed as a reward.
maxDurationuint40Maximum reward duration, in seconds.

Type PoolRewards

Represents all active reward programs of the pool.

It is encoded as a map indexed by a local index of reward.

type PoolRewards = map<uint2, PoolReward>
KeyValue typeDescription
uint2PoolRewardMapping from reward index to its current reward state.

Type PoolReward

Represents the current state of a single reward program.

struct PoolReward {
    remainingTime: uint40
    remainingBudget: coins
    rewardsPerToken: Q120X120
    lastUpdate: uint40
}
ParameterTypeDescription
remainingTimeuint40Remaining reward distribution time, in seconds.
remainingBudgetcoinsAmount of reward asset still available for distribution.
rewardsPerTokenQ120X120Accumulated reward per unit of liquidity.
lastUpdateuint40Unix timestamp of the last reward state update.

Type SwapFees

Represents the fee breakdown applied to a single swap.

struct SwapFees {
    isX: bool;
    lpFee: coins;
    creatorFee: coins;
    protocolFee: coins;
    partnerFee: coins;
    referrerFee: coins;
}
ParameterTypeDescription
isXboolIndicates which asset the fees are denominated in. true for X, false for Y.
lpFeecoinsPortion of the swap fee allocated to liquidity providers.
creatorFeecoinsPortion of the swap fee allocated to the pool creator.
protocolFeecoinsPortion of the swap fee allocated to the protocol.
partnerFeecoinsPortion of the swap fee allocated to the partner, if applicable.
referrerFeecoinsPortion of the swap fee allocated to the referrer, if applicable.

Type Q120X120

A Q120.120 fixed-point number representation.

This format uses:

  • 120 bits for the integer part
  • 120 bits for the fractional part

It is used for high-precision fractional values, such as accumulated fees per unit of liquidity.

See: https://en.wikipedia.org/wiki/Q_(number_format)

type Q120X120 = varuint32

Type PoolFees

Represents accumulated fees and fee distribution state of the pool.

  • protocolFee* — fees owed to the protocol
  • creatorFee* — fees owed to the pool creator
  • *FeePerToken — accumulated fee per unit of liquidity, used for proportional distribution
struct PoolFees {
    protocolFeeX: coins
    protocolFeeY: coins
    creatorFeeX: coins
    creatorFeeY: coins
    xFeePerToken: Q120X120
    yFeePerToken: Q120X120
}
ParameterTypeDescription
protocolFeeXcoinsAccumulated protocol fees in asset X.
protocolFeeYcoinsAccumulated protocol fees in asset Y.
creatorFeeXcoinsAccumulated fees owed to the pool creator in asset X.
creatorFeeYcoinsAccumulated fees owed to the pool creator in asset Y.
xFeePerTokenQ120X120Accumulated fee in asset X per unit of liquidity.
yFeePerTokenQ120X120Accumulated fee in asset Y per unit of liquidity.

Type PoolUpdatedState

A compact state snapshot emitted after pool-state-changing operations.

This structure contains only the minimal set of fields required to describe an updated pool state and is typically used in events, notifications, or intermediate computations.

struct PoolUpdatedState {
    reserveX: coins
    reserveY: coins
    liquidity: coins
    fees: Cell<PoolFees>
}
ParameterTypeDescription
reserveXcoinsUpdated reserve of asset X in the pool.
reserveYcoinsUpdated reserve of asset Y in the pool.
liquiditycoinsUpdated total liquidity supply of the pool.
feesCell<PoolFees>Cell containing the updated pool fee state (PoolFees).

Type SwapStep

Defines a single step in a multi-hop swap. Multiple SwapStep instances may be chained via next to describe routed swaps across several pools.

struct SwapStep {
    pool: address
    minimalAmountOut: coins
    deadline: uint40
    next: Cell<SwapStep>?
}
ParameterTypeDescription
pooladdressAddress of the pool where this swap step is executed.
minimalAmountOutcoinsMinimum acceptable output amount for this step. The step must fail if the actual output is lower.
deadlineuint40Unix timestamp after which this swap step must not be executed.
nextCell<SwapStep>?Optional next swap step, executed after this one completes successfully.

Type PartnerConfig

Specifies partner attribution and fee sharing for a swap operation.

struct PartnerConfig {
    partnerId: uint256
    partnerFeeBPS: uint16
}
ParameterTypeDescription
partnerIduint256Unique identifier of the partner.
partnerFeeBPSuint16Partner fee expressed in basis points, applied according to protocol rules.

Type ReferrerConfig

Specifies referrer attribution and fee sharing for a swap operation.

struct ReferrerConfig {
    referrerId: uint256
    referrerFeeBPS: uint16
}
ParameterTypeDescription
referrerIduint256Unique identifier of the referrer.
referrerFeeBPSuint16Referrer fee expressed in basis points, applied according to protocol rules.

Type ExtendedPayoutConfig

Configuration for handling both successful and rejected payment operations.

struct ExtendedPayoutConfig {
    fulfill: PayoutOptions
    reject: PayoutOptions
    excessesTo: address
}
ParameterTypeDescription
fulfillPayoutOptionsInstructions for handling a successful operation (e.g., where to send swapped assets).
rejectPayoutOptionsInstructions for handling a failed or rejected operation (e.g., where to return funds).
excessesToaddressAddress that will receive any remaining TON (excesses) after the operation is completed.

Type BasicPayoutConfig

Simplified configuration used for operations where only one outcome path is required, such as withdrawals.

struct BasicPayoutConfig {
    options: PayoutOptions
    excessesTo: address
}
ParameterTypeDescription
optionsPayoutOptionsPayout parameters including destination and gas settings.
excessesToaddressAddress that will receive any remaining TON (excesses) after the operation is completed.

Type PayoutOptions

Detailed parameters for asset delivery and notification.

struct PayoutOptions {
    destination: address
    extraGas: coins
    payload: cell?
    wrapPayload: bool
}
ParameterTypeDescription
destinationaddressThe recipient address for the assets or refunds.
extraGascoinsOptional TON amount to be forwarded along with the asset transfer to cover downstream gas costs (e.g., for a TransferNotification at the recipient).
payloadcell?Optional arbitrary data to be included in the outgoing message.
wrapPayloadboolIf true, the payload will be automatically wrapped into a PayoutPayload (containing an exitCode). If false, the payload is sent as-is. Useful for distinguishing success from error states.

Payload PayoutPayload

A wrapper used in outgoing messages to provide the result of an operation. It is automatically generated if wrapPayload is set to true in PayoutOptions.

struct (0xe8db4696) PayoutPayload {
    exitCode: int32
    payload: cell?
}
ParameterTypeDescription
exitCodeint32The status code of the completed operation. 0 typically indicates success.
payloadcell?The original payload from PayoutOptions, now associated with an explicit exit code.

On this page