Dedust

Dedust uses pools and vaults for swaps and liquidity provision on TON

Last updated ยท

Dedust is a decentralized exchange on TON that handles swaps through liquidity pools and contracts called vaults. Its protocol v2 separates the pool's pricing role from each vault's asset transfers. You can exchange the native TON coin or jettons, the tokens that run on TON. Direct swaps use a pool for the selected pair; multi-hop swaps connect pools through an intermediate asset. Liquidity provision serves a different purpose: supplying both pool assets produces liquidity provider (LP) tokens after the pool accepts the deposit. Understanding these outputs helps distinguish a completed swap from an LP position or a pending deposit.

Swaps and liquidity provision produce different outputs

Use a swap when the intended output is another asset. Supplying liquidity contributes both assets to a pool and produces LP tokens upon acceptance. Those tokens provide the means to remove liquidity later.

Liquidity pools connect these activities: traders exchange against the supplied assets, while liquidity providers receive LP tokens. The same pool can support trading and liquidity provision through different contract messages.

Pools calculate outputs while vaults move assets

Protocol v2 separates the contract that calculates an exchange from the contracts that transfer its assets. Each vault handles its associated asset, while the pool connects the pair and determines the output. This division explains why integration code needs the relevant vault as well as the pool address. The asset type determines how the input reaches that vault.

For a hypothetical successful direct swap, suppose native TON is the input and a selected jetton is the output. Assume the matching pool and required vaults are deployed and ready, with usable liquidity for the trade. A swap message sends TON to the native vault, which tells the pool about the deposit. The pool computes the output and instructs the jetton vault to pay it to the user. The jettons arrive from a vault because the pool delegates asset delivery. This example assumes an available direct pool; another pair may require a connected route.

Visual summary: Pools calculate outputs while vaults move assets (Dedust)

Open full-size image

Native TON and jettons use distinct transfer messages

Check that the relevant pool and vault are deployed before constructing a swap. The SDK v2 swap procedure checks both contracts for readiness. Sending funds to an inactive contract can result in irretrievable loss.

Native TON enters through a swap message

Native TON uses a swap message addressed to the native vault, with the required TON attached. The SDK exposes this through sendSwap . The message identifies the selected pool so the vault can pass the request into the correct exchange operation.

Jettons enter through token-wallet transfers

Jettons use their own transfer mechanism. The integration locates the user's wallet for the selected jetton, then sends a transfer to that jetton's vault. The transfer carries a swap payload that identifies the pool and tells the vault which operation to perform.

An integration resolves the wallet for that specific jetton using the owner's address. This keeps the token-sending wallet distinct from the account that owns it.

Multi-hop routes connect pools through an intermediate asset

Multi-hop swaps connect existing pools when a direct pair is unavailable or lacks usable liquidity. A route through an intermediate asset links one pair to the next, and the SDK v2 payload can express consecutive swaps together. Each route still needs the relevant pools and liquidity for its path. The final leg determines the destination asset.

Liquidity reaches the pool after both target deposits

Liquidity provisioning requires both assets of the selected pool, supplied through their respective vaults. The protocol tracks the contribution before the pool accepts it. For SDK v2 deposits, the assets and targetBalances inputs must match across the deposit messages.

In the SDK v2 deposit flow, the assets arrive through separate transfers. A temporary Liquidity Deposit contract records the deposited balances during this interval. Assets can therefore have entered the deposit process without yet becoming pool liquidity.

Reaching the target balances allows the pending contribution to proceed to the pool. The pool mints LP tokens to the depositor's address when it accepts the liquidity. Sending the first asset alone leaves the contribution pending while the contract waits for the other required asset.

The temporary contract terminates after the pool accepts the liquidity or after the pending deposit is withdrawn. LP tokens remain associated with an accepted pool position, so the deposit contract's closure does not itself remove that liquidity.

Cancellation and withdrawal apply to different liquidity states

A pending deposit can be cancelled

If one required asset has not arrived, the deposit remains pending and has not minted the intended LP tokens. Recovering those pending funds uses a cancellation message to the Liquidity Deposit contract. The SDK exposes this as sendCancelDeposit . This acts on the staged contribution rather than removing an accepted pool position.

An accepted position exits through an LP burn

Withdrawing accepted pool liquidity requires burning LP tokens. The SDK v2 withdrawal procedure locates the user's LP wallet for the pool and calls sendBurn . The amount that the method burns is an LP-token amount, distinct from an amount of either underlying asset.

The withdrawal example reads the LP wallet balance and uses it as the burn amount. That makes the example a full-balance burn for that LP wallet. Check which LP balance the request reads before approving that amount.

Execution budgets sit alongside the exchanged assets

Transaction messages need TON for execution in addition to the asset amount that the operation exchanges or deposits. In the native-swap SDK example, amount names the TON input and gasAmount names the execution allocation. Treating those fields as interchangeable would change what the request asks the vault to exchange.

Jetton transfers also attach TON. The v2 example specifies attached TON separately from the jetton amount and provides a forwardAmount for the forwarded message. These example allocations do not establish a universal trading fee or a fixed cost for every route. Choose the input amount only after allowing for the TON that the selected message needs.

What readers ask about Dedust

Can the Factory find contracts that already exist?

The Factory can locate existing contracts as well as create contracts within protocol v2. The SDK swap procedure uses it to find the native vault and the pool for a selected asset pair. Readiness still needs a separate check after the address lookup.

How can an integration estimate its LP output?

A getter on the selected pool can estimate the liquidity output for a planned deposit. LP issuance remains a separate outcome that follows the pool's acceptance of the contribution, so an estimate alone does not establish an accepted liquidity position.

When can a liquidity deposit mint LP tokens and return excess assets?

In the SDK v2 TON/DUST deposit flow, reaching the target balances can produce LP tokens alongside returned excess DUST. Returned DUST consists of unused tokens from the contribution. That excess return belongs to the deposit operation, separate from a later withdrawal of the resulting LP position.

Where does returned gas go in a jetton swap?

In the SDK v2 jetton-swap example, setting responseAddress to sender.address directs returned gas to the sender. The transfer separately names the jetton vault as its token destination. These fields describe different destinations, so keep the address for returned gas distinct from the vault receiving the tokens.

What identifies a pending deposit contract for cancellation?

The Factory lookup uses the owner's address, the pool type and the asset pair to identify the pending deposit contract. The SDK v2 cancellation example passes those values to getLiquidityDeposit, then sends the cancellation to that contract. A token ticker alone does not supply the owner and pool configuration that this lookup requires.