Pool
The Pool contract is the central component of the CPMM V2 protocol.
It implements the Constant Product Market Maker () 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
| # | Name | Type | Description |
|---|---|---|---|
| 0 | status | int (PoolStatus) | Current lifecycle state of the pool: uninitialized (0), initializing (1), or initialized (2). |
| 1 | depositActive | int (bool) | Indicates whether deposit operations are currently enabled. |
| 2 | swapActive | int (bool) | Indicates whether swap operations are currently enabled. |
| 3 | assetX | slice (Asset) | Address identifying asset X of the pool (native TON or jetton minter address). |
| 4 | assetY | slice (Asset) | Address identifying asset Y of the pool (native TON or jetton minter address). |
| 5 | walletsByAssets | cell (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. |
| 6 | assetsByWallets | cell (map<uint256, Asset>) | Reverse mapping from wallet account hashes to their associated assets. |
| 7 | walletsResolutions | cell (map<uint256, address>) | Cache of resolved wallet addresses used during asset resolution to avoid repeated lookups. |
| 8 | baseFeeBPS | int (uint16) | Base swap fee, expressed in basis points (BPS), applied to all swaps in the pool. |
| 9 | reserveX | int (coins) | Current reserve of asset X held by the pool. |
| 10 | reserveY | int (coins) | Current reserve of asset Y held by the pool. |
| 11 | liquidity | int (coins) | Total amount of liquidity tokens currently issued by the pool. |
| 12 | protocolFeeX | int (coins) | Accumulated protocol fees in asset X that have not yet been withdrawn. |
| 13 | protocolFeeY | int (coins) | Accumulated protocol fees in asset Y that have not yet been withdrawn. |
| 14 | creatorFeeX | int (coins) | Accumulated creator fees in asset X that have not yet been withdrawn. |
| 15 | creatorFeeY | int (coins) | Accumulated creator fees in asset Y that have not yet been withdrawn. |
| 16 | xLPFeePerToken | int (Q120X120) | Amount of fees in asset X accrued per one unit of liquidity, used for proportional fee distribution. |
| 17 | yLPFeePerToken | int (Q120X120) | Amount of fees in asset Y accrued per one unit of liquidity, used for proportional fee distribution. |
| 18 | rewards | cell (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
| # | Name | Type | Description |
|---|---|---|---|
| 0 | owner_address | slice (address) | Address of the position owner. |
Returns
| # | Name | Type | Description |
|---|---|---|---|
| 0 | position_account | slice (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
nextStatesnapshot 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>
}| Parameter | Type | Description |
|---|---|---|
amountXIn | coins | Amount of asset X deposited into the pool. |
amountYIn | coins | Amount of asset Y deposited into the pool. |
liquidity | coins | Amount of pool liquidity minted as a result of the deposit. |
initiatorAddress | address | Address that initiated the deposit transaction. |
recipientAddress | address | Address that received the minted liquidity. |
nextState | Cell<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>
}| Parameter | Type | Description |
|---|---|---|
liquidity | coins | Amount of pool liquidity burned as part of the withdrawal. |
amountXOut | coins | Amount of asset X withdrawn from the pool. |
amountYOut | coins | Amount of asset Y withdrawn from the pool. |
initiatorAddress | address | Address that initiated the withdrawal transaction. |
recipientAddress | address | Address that received the withdrawn assets. |
nextState | Cell<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>
}| Parameter | Type | Description |
|---|---|---|
xToY | bool | Swap direction. true indicates X → Y, false indicates Y → X. |
amountIn | coins | Amount of the input asset provided for the swap. |
amountOut | coins | Amount of the output asset received from the swap. |
initiatorAddress | address | Address that initiated the swap transaction. |
recipientAddress | address | Address that received the output asset. |
nextState | Cell<PoolUpdatedState> | Cell containing PoolUpdatedState, representing the pool state after the swap. |
fees | Cell<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?
}| Parameter | Type | Description |
|---|---|---|
minimalAmountOut | coins | Minimum acceptable amount of the output asset. The swap must revert if the actual output is lower. |
deadline | uint40 | Unix timestamp after which the swap must not be executed. |
next | Cell<SwapStep>? | Optional next swap step (SwapStep), enabling multi-step swaps. Can be recursive itself. |
partnerConfig | PartnerConfig? | Optional partner configuration (PartnerConfig)applied to this swap. |
referrerConfig | ReferrerConfig? | 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
nextis 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:
amountXspecifies the expected amount of asset XamountYspecifies 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
}| Parameter | Type | Description |
|---|---|---|
amountX | coins | Amount of asset X expected to be paid by the first payment. |
amountY | coins | Amount of asset Y expected to be paid by the second payment. |
minimalLiquidity | coins | Minimum acceptable amount of liquidity to be minted. The deposit must revert if the resulting liquidity is lower. |
lockedLiquidityShare | uint16 | Share of the minted liquidity that is locked, expressed in basis points or protocol-defined units. |
Semantics
- A
Depositpayment 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). lockedLiquiditySharedetermines 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
}| Parameter | Type | Description |
|---|---|---|
till | uint40 | Unix 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 themaxDurationspecified 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?
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique identifier for the request, used to match the response. |
customPayload | cell? | 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>
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique identifier for the transaction. |
amount | coins | The amount of native TON being paid to the pool. |
paymentPayload | cell | Operation-specific data (e.g., SwapPayload or DepositPayload). |
payoutConfig | Cell<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
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique identifier for the transaction, typically provided by the jetton sender. |
amount | coins | The amount of jettons received by the pool. |
sender | address | The address of the user who initiated the jetton transfer. |
forwardPayload | RemainingBitsAndRefs | cell | Operation-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
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
config | Cell<DepositConfig> | The original deposit configuration (DepositConfig). |
amountX | coins | Amount of asset X to be refunded. |
amountY | coins | Amount of asset Y to be refunded. |
initiatorAddress | address | The 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
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
config | Cell<DepositConfig> | Configuration of the deposit process (DepositConfig). |
amountX | coins | Amount of asset X to be refunded. |
amountY | coins | Amount of asset Y to be refunded. |
initiatorAddress | address | The 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
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
excessesTo | address | Address 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
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
to | address | The recipient address where the accumulated protocol fees will be sent. |
excessesTo | address | Address 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
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
to | address | The recipient address where the accumulated creator fees will be sent. |
excessesTo | address | Address 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>
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
liquidity | coins | Amount of liquidity tokens to be burned for assets. |
minimalXOut | coins | Minimum amount of asset X expected to be received (slippage protection). |
minimalYOut | coins | Minimum amount of asset Y expected to be received (slippage protection). |
autoClaimFees | bool | If true, any accrued fees for this position will be claimed automatically during the exit. |
payoutConfig | Cell<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
| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
includeConfig | bool | If true, the response will include the pool configuration (PoolConfig). |
includeFees | bool | If true, the response will include the accumulated fees (PoolFees). |
includeCodeHash | bool | If true, the response will include the hash of the contract code. |
includeRewards | bool | If 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
| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
rewardIndex | uint2 | Index of the reward program to claim from. |
excessesTo | address | Address 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
| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique request identifier. |
amount | coins | Amount of the reward asset to be paid out. |
rewardIndex | uint2 | Index of the reward program in the pool's registry. |
ownerAddress | address | The recipient of the reward assets. |
excessesTo | address | Address 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?
}| Parameter | Type | Description |
|---|---|---|
queryId | uint64 | Unique identifier of the request, used to match the response with the original InitPool call. |
exitCode | int32 | Result of the operation. 0 indicates success; any other value represents an error code. |
customPayload | cell? | 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?
}| Field | Type | Description |
|---|---|---|
queryId | uint64 | Identifier copied from the corresponding ProvidePoolState request. |
status | PoolStatus | Current lifecycle state of the pool. |
depositActive | bool | Whether liquidity deposits are currently allowed. |
swapActive | bool | Whether swaps are currently allowed. |
liquidity | coins | Total liquidity issued by the pool. |
reserveX | coins | Current reserve of token X held by the pool. |
reserveY | coins | Current reserve of token Y held by the pool. |
config | Cell<PoolConfig>? | Present only if includeConfig = true in ProvidePoolState. Contains pool configuration parameters. |
fees | Cell<PoolFees>? | Present only if includeFees = true in ProvidePoolState. Contains fee configuration. |
rewards | PoolRewards? | Present only if includeRewards = true in ProvidePoolState. Contains reward / incentive parameters. |
codeHash | uint256? | 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>
}| Parameter | Type | Description |
|---|---|---|
paymentPayload | cell | Operation-specific data (e.g., SwapPayload or DepositPayload). |
payoutConfig | Cell<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| Status | Tag | Description |
|---|---|---|
uninitialized | 0b00 | The pool has been deployed but not yet configured. |
initializing | 0b01 | The pool is in the process of resolving asset wallet addresses. Contains the initiatorAddress. |
initialized | 0b10 | The pool is fully functional and ready for swaps and deposits. |
Initializing Parameters
| Parameter | Type | Description |
|---|---|---|
initiatorAddress | address | The 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>
}| Parameter | Type | Description |
|---|---|---|
assetX | Asset | Identifier for the first asset in the pair. |
assetY | Asset | Identifier for the second asset in the pair. |
creatorAddress | address | Address of the pool creator, authorized to claim creator fees. |
baseFeeBPS | uint16 | Standard swap fee in basis points (1 unit = 0.01%). |
creatorFeeBPS | uint16 | Additional fee in basis points directed to the pool creator. |
depositActivation | Cell<Activation>? | Optional activation rules for liquidity deposits (e.g., time-lock or specific initiator). |
swapActivation | Cell<Activation>? | Optional activation rules for asset swaps. |
feeIn | FeeIn | Strategy for fee collection (FeeIn). |
customResolvers | map<uint256, address> | Mapping of jetton assets (account part of address) to custom resolver contracts for non-standard jetton wallets. |
allowedRewards | map<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| Parameter | Type | Description |
|---|---|---|
| value | address_any | Address 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
}| Strategy | Tag | Description |
|---|---|---|
both | 0b00 | Fees are collected in the input asset of the swap. |
assetX | 0b01 | Fees are always collected in Asset X, regardless of the swap direction. |
assetY | 0b10 | Fees 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
| ActivationInitiatorTime-based activation
| Parameter | Type | Description |
|---|---|---|
activeSince | uint40 | Unix timestamp from which the entity is considered active. |
Initiator-based activation
| Parameter | Type | Description |
|---|---|---|
initiatorAddress | address | Address whose interaction triggers activation. |
Type RewardConfig
Defines configuration parameters for a reward program.
struct RewardConfig {
asset: Asset;
maxDuration: uint40;
}| Parameter | Type | Description |
|---|---|---|
asset | Asset | Asset distributed as a reward. |
maxDuration | uint40 | Maximum 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>| Key | Value type | Description |
|---|---|---|
uint2 | PoolReward | Mapping 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
}| Parameter | Type | Description |
|---|---|---|
remainingTime | uint40 | Remaining reward distribution time, in seconds. |
remainingBudget | coins | Amount of reward asset still available for distribution. |
rewardsPerToken | Q120X120 | Accumulated reward per unit of liquidity. |
lastUpdate | uint40 | Unix 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;
}| Parameter | Type | Description |
|---|---|---|
isX | bool | Indicates which asset the fees are denominated in. true for X, false for Y. |
lpFee | coins | Portion of the swap fee allocated to liquidity providers. |
creatorFee | coins | Portion of the swap fee allocated to the pool creator. |
protocolFee | coins | Portion of the swap fee allocated to the protocol. |
partnerFee | coins | Portion of the swap fee allocated to the partner, if applicable. |
referrerFee | coins | Portion 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 = varuint32Type PoolFees
Represents accumulated fees and fee distribution state of the pool.
protocolFee*— fees owed to the protocolcreatorFee*— 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
}| Parameter | Type | Description |
|---|---|---|
protocolFeeX | coins | Accumulated protocol fees in asset X. |
protocolFeeY | coins | Accumulated protocol fees in asset Y. |
creatorFeeX | coins | Accumulated fees owed to the pool creator in asset X. |
creatorFeeY | coins | Accumulated fees owed to the pool creator in asset Y. |
xFeePerToken | Q120X120 | Accumulated fee in asset X per unit of liquidity. |
yFeePerToken | Q120X120 | Accumulated 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>
}| Parameter | Type | Description |
|---|---|---|
reserveX | coins | Updated reserve of asset X in the pool. |
reserveY | coins | Updated reserve of asset Y in the pool. |
liquidity | coins | Updated total liquidity supply of the pool. |
fees | Cell<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>?
}| Parameter | Type | Description |
|---|---|---|
pool | address | Address of the pool where this swap step is executed. |
minimalAmountOut | coins | Minimum acceptable output amount for this step. The step must fail if the actual output is lower. |
deadline | uint40 | Unix timestamp after which this swap step must not be executed. |
next | Cell<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
}| Parameter | Type | Description |
|---|---|---|
partnerId | uint256 | Unique identifier of the partner. |
partnerFeeBPS | uint16 | Partner 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
}| Parameter | Type | Description |
|---|---|---|
referrerId | uint256 | Unique identifier of the referrer. |
referrerFeeBPS | uint16 | Referrer 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
}| Parameter | Type | Description |
|---|---|---|
fulfill | PayoutOptions | Instructions for handling a successful operation (e.g., where to send swapped assets). |
reject | PayoutOptions | Instructions for handling a failed or rejected operation (e.g., where to return funds). |
excessesTo | address | Address 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
}| Parameter | Type | Description |
|---|---|---|
options | PayoutOptions | Payout parameters including destination and gas settings. |
excessesTo | address | Address 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
}| Parameter | Type | Description |
|---|---|---|
destination | address | The recipient address for the assets or refunds. |
extraGas | coins | Optional TON amount to be forwarded along with the asset transfer to cover downstream gas costs (e.g., for a TransferNotification at the recipient). |
payload | cell? | Optional arbitrary data to be included in the outgoing message. |
wrapPayload | bool | If 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?
}| Parameter | Type | Description |
|---|---|---|
exitCode | int32 | The status code of the completed operation. 0 typically indicates success. |
payload | cell? | The original payload from PayoutOptions, now associated with an explicit exit code. |