DeDust Hub
Quickstart

Rewards

In addition to trading fees, liquidity providers can earn extra incentives known as Rewards. Rewards can be any supported asset (TON or Jetton) and are distributed proportionally to LPs based on their share of the pool's total liquidity.

The protocol supports multiple simultaneous reward programs for a single pool.

Funding Rewards

Anyone can fund a reward program for a pool, provided the asset is in the pool's allowedRewards list (configured during pool creation).

Funding is performed via a Payment carrying the reward asset and a FundReward payload.

FundReward Payload

The payload specifies the duration of the distribution by setting an end timestamp (till).

struct (0x2eb87df9) FundReward {
    till: uint40
}
ParameterDescription
tillUnix timestamp indicating when the distribution should end.

Distribution Logic

  1. New Distribution: If the reward program is currently inactive, the sent amount is distributed evenly from the current time until till.
  2. Top-up: If the program is already active, the new amount is added to the remaining budget. The duration may be extended by updating till, but the new distribution rate (rewards per second) cannot be lower than the current one (to prevent dilution attacks).

Example Flow (Funding with Jettons)

Transfer (Reward Amount + PayJetton) Internal Transfer Transfer Notification (FundReward) Excesses (Remaining Gas) 1. Validate Asset 2. Update Reward Rates Funder Pool Pool's Reward Wallet FunderWallet

Claiming Rewards

Rewards accumulate in the user's Position contract. They are not sent automatically to the user's wallet to save gas. Users must explicitly claim them.

Claim Flow

To claim rewards, a user sends a ClaimReward message to the Pool.

  1. User sends ClaimReward to Pool.
  2. Pool forwards the request to the user's Position via ClaimPositionReward.
  3. Position calculates the accrued rewards based on the latest rates and sends a PayoutReward request back to the Pool.
  4. Pool transfers the reward assets to the User.
ClaimReward (index) ClaimPositionReward PayoutReward Transfer Reward Asset Update Checkpoints & Calc Delta User Pool Position

ClaimReward Message

struct (0x909fdb65) ClaimReward {
    queryId: uint64
    rewardIndex: uint2
    excessesTo: address
}
ParameterDescription
rewardIndexThe index of the reward program in the pool's allowedRewards list.
excessesToAddress to receive remaining gas.

Reward Calculation

Rewards are distributed using a Reward per Token algorithm, similar to the MasterChef contract in DeFi.

  1. Global Index (rewardsPerToken): The Pool tracks the cumulative rewards emitted per 1 unit of liquidity since the beginning. This value increases every time the pool is touched (swaps, deposits, etc.) based on the time elapsed.
  2. User Checkpoint: The Position contract stores a snapshot of the global index (rewardsPerTokenCheckpoint) from the last time the user interacted with the pool.
  3. Pending Reward:
Pending=Liquidity×(GlobalIndexUserCheckpoint)+UnclaimedPending = Liquidity \times (GlobalIndex - UserCheckpoint) + Unclaimed

This ensures that users only earn rewards for the time intervals during which they held liquidity.

On this page