TL-B schemes

Factory

Message "create_vault"

create_vault#21cfe02b query_id:uint64 asset:Asset = InMsgBody;
NameTypeRequiredDescription
query_iduint64noQuery ID
assetAssetyesThe asset for which a Vault will be created.

Message "create_volatile_pool"

create_volatile_pool#97d51f2f query_id:uint64 asset0:Asset asset1:Asset = InMsgBody;
NameTypeRequiredDescription
query_iduint64noQuery ID
asset0AssetyesThe asset for which a Pool will be created.
asset1AssetyesThe asset for which a Poo will be created.

📘

Assets can be reordered.

Assets can be switched (asset0 becomes asset1 and vice versa).

This ensures a consistent address for a Pool regardless of asset order (e.g. A / B or B / A).

Common Types

Asset

native$0000 = Asset;
jetton$0001 workchain_id:int8 address:uint256 = Asset;
extra_currency$0010 currency_id:int32 = Asset;

Timestamp

timestamp#_ _:uint32 = Timestamp;

SwapKind

given_in$0 = SwapKind;
given_out$1 = SwapKind; // Not implemented.

SwapParams

Set of parameters relevant for the entire swap.

swap_params#_ deadline:Timestamp recipient_addr:MsgAddressInt referral_addr:MsgAddress
              fulfill_payload:(Maybe ^Cell) reject_payload:(Maybe ^Cell) = SwapParams;
NameTypeRequiredDescription
deadlineTimestampnoSpecifies a deadline for the swap. If the swap reaches the Pool after this time, it will be rejected. Default: 0 (disabled).
recipient_addrMsgAddressnoSpecifies an address where funds will be sent after the swap. Default: sender's address.
referral_addrMsgAddressnoReferral address. Required for the Referral Program.
fulfill_payloadMaybe ^CellnoCustom payload that will be attached to the fund transfer upon a successful swap.
reject_payloadMaybe ^CellnoCustom payload that will be attached to the fund transfer upon a rejected swap.

SwapStep

Set of parameters relevant for the specific step.

step#_ pool_addr:MsgAddressInt params:SwapStepParams = SwapStep;
NameTypeRequiredDescription
pool_addrMsgAddressIntyesThe pool is responsible for swapping assets at this step.
paramsSwapStepParamsyesSet of extra parameters relevant for a specific step.

SwapStepParams

Set of extra parameters relevant for a specific step.

step_params#_ kind:SwapKind limit:Coins next:(Maybe ^SwapStep) = SwapStepParams;
NameTypeRequiredDescription
kindSwapKindnoNote: Only given_in option is implemented.
limitCoinsnoMinimum output of the swap. If the actual value is less than specified, the swap will be rejected.
nextMaybe ^SwapStepnoReference to the next step. Can be used for multi-hop swaps.

PoolType

volatile$0 = PoolType;
stable$1 = PoolType;

PoolParams

pool_params#_ pool_type:PoolType asset0:Asset asset1:Asset = PoolParams;
NameTypeRequiredDescription
pool_typePoolTypeyes
asset0Assetyes
asset1Assetyes

Native Vault

Message "swap"

swap#ea06185d query_id:uint64 amount:Coins _:SwapStep swap_params:^SwapParams = InMsgBody;
NameTypeRequiredDescription
query_iduint64noQuery ID
amountCoinsyesTON amount for the swap
swap_params^SwapParamsyesSet of parameters relevant for the entire swap

Message "deposit_liquidity"

deposit_liquidity#d55e4686 query_id:uint64 amount:Coins pool_params:PoolParams
                           min_lp_amount:Coins
                           asset0_target_balance:Coins asset1_target_balance:Coins
                           fulfill_payload:(Maybe ^Cell)
                           reject_payload:(Maybe ^Cell) = InMsgBody;
NameTypeRequiredDescription
query_iduint64noQuery ID
amountCoinsyes
pool_paramsPoolParamsyes
min_lp_amountCoinsno
asset0_target_balanceCoinsyes
asset1_target_balanceCoinsyes
fulfill_payloadMaybe ^Cellno
reject_payloadMaybe ^Cellno

Message "payout"

payout#474f86cf query_id:uint64 payload:(Maybe ^Cell) = InMsgBody;
NameTypeRequiredDescription
query_iduint64noQuery ID
payloadMaybe ^Cellno

Jetton Vault

Message "swap"

swap#e3a0d482 _:SwapStep swap_params:^SwapParams = ForwardPayload;
NameTypeRequiredDescription
swap_params^SwapParamsyes

Message "deposit_liquidity"

deposit_liquidity#40e108d6 pool_params:PoolParams min_lp_amount:Coins
                           asset0_target_balance:Coins asset1_target_balance:Coins
                           fulfill_payload:(Maybe ^Cell)
                           reject_payload:(Maybe ^Cell) = ForwardPayload;
NameTypeRequiredDescription
pool_paramsPoolParamsyes
min_lp_amountCoinsno
asset0_target_balanceCoinsyes
asset1_target_balanceCoinsyes
fulfill_payloadMaybe ^Cellno
reject_payloadMaybe ^Cellno

Pool Events

To simplify the process of indexing, DeDust Procotol uses mechanism of events.
For that purpose we use "external messages" proposed by TON Blockchain.

Event "swap"

swap#9c610de3 asset_in:Asset asset_out:Asset amount_in:Coins amount_out:Coins
              ^[ sender_addr:MsgAddressInt referral_addr:MsgAddress
              reserve0:Coins reserve1:Coins ] = ExtOutMsgBody;
NameTypeRequiredDescription
asset_inAssetyesThe asset provided by the user.
asset_outAssetyesThe asset received by the user.
amount_outCoinsyesAmount of asset_out received by the user.
amount_inCoinsyesAmount of asset_in supplied by the user.
sender_addrMsgAddressIntyesAddress of the contract that initiated the swap.
referral_addrMsgAddressnoReferral address. Required for the Referral Program.
reserve0CoinsyesAmount of asset0 remaining in reserve after the swap.
reserve1CoinsyesAmount of asset1 remaining in reserve after the swap.

Event "deposit"

deposit#b544f4a4 sender_addr:MsgAddressInt amount0:Coins amount1:Coins
                 reserve0:Coins reserve1:Coins liquidity:Coins = ExtOutMsgBody;
NameTypeRequiredDescription
sender_addrMsgAddressIntyesAddress of the contract that initiated the deposit.
amount0CoinsyesAmount of asset0 provided by the sender.
amount1CoinsyesAmount of asset1 provided by the sender.
reserve0CoinsyesAmount of asset0 remaining in reserve after the withdrawal.
reserve1CoinsyesAmount of asset1 remaining in reserve after the withdrawal.
liquidityCoinsyesAmount of LP tokens issued for the sender.

Event "withdrawal"

withdrawal#3aa870a6 sender_addr:MsgAddressInt liquidity:Coins
                    amount0:Coins amount1:Coins
                    reserve0:Coins reserve1:Coins = ExtOutMsgBody;
NameTypeRequiredDescription
sender_addrMsgAddressIntyesAddress of the contract that initiated the withdrawal.
liquidityCoinsyesAmount of LP tokens burned by the sender.
amount0CoinsyesAmount of asset0 sent to the sender.
amount1CoinsyesAmount of asset1 sent to the sender.
reserve0CoinsyesAmount of asset0 remaining in reserve after the withdrawal.
reserve1CoinsyesAmount of asset1 remaining in reserve after the withdrawal.

Liquidity Deposit

Message "cancel_deposit"

cancel_deposit#166cedee query_id:uint64 payload:(Maybe ^Cell) = InMsgBody;
NameTypeRequiredDescription
query_iduint64noQuery ID
payloadMaybe ^CellnoCustom payload that will be attached to the funds transfer to the user.