Torch DEX
WebsiteSwap
  • Overview
  • Terms of Use
  • Getting Started
    • Introduction
    • Challenges on TON
    • Solution for TON
    • Architecture
      • Concept
      • Core Components
        • Factory
        • Vault
        • Pool
        • LP Account
        • Oracle
      • Comparison
      • Interoperability
      • Meesage Flows
        • Deposit
        • Swap
        • Withdraw
        • Cross-Pool Operations
  • Developer Guide
    • DEX SDK Guide
      • Setup
      • Perform Swap
      • Deposit Liquidity
      • Withdraw Liquidity
      • How to send transaction
        • Mnemonic (Node JS)
        • TonConnect (React)
      • Deployments
  • USER Guide
    • Getting Started
  • Protocol
    • Audits
    • Tokenomics
  • Other
    • Brand Kit
    • Contacts
    • Achievements
  • FAQ
    • How to get Transaction hash by Message hash
    • React (Vite) - Buffer Issues
Powered by GitBook
On this page
  • Deposit and Deposit
  • Deposit and Deposit Process
  • Detailed Flow
  • Alternative Deposit Scenarios
  • Deposit and Swap
  • Deposit and Swap Process
  • Detailed Flow
  • Swap and Withdraw
  • Swap and Withdraw Process
  • Detailed Flow
  • Withdraw and Withdraw
  • Withdraw and Withdraw Process
  • Detailed Flow
  • Withdrawal Modes
  1. Getting Started
  2. Architecture
  3. Meesage Flows

Cross-Pool Operations

PreviousWithdrawNextDEX SDK Guide

Last updated 4 months ago

Deposit and Deposit

TorchDepositDepositFlow

Let's assume there are two pools:

  1. Base Pool – triTON Pool (TON/tsTON/stTON)

  2. Meta Pool – quaTON Pool (triTON LP / hTON)

Deposit and Deposit Process

Suppose you currently hold stTON and hTON and want to maximize your rewards. You can achieve this through a deposit and deposit process.

Here’s how it works:

  1. First Deposit – Deposit stTON into the triTON Pool to receive triTON LP tokens.

  2. Second Deposit – Take the obtained triTON LP along with hTON and deposit them into the quaTON Pool to receive quaTON LP tokens.


Detailed Flow

  • The LP Account contract will wait until both stTON and hTON deposits are received.

  • Once both assets arrive, the LP Account sends an op::deposit_all message to the triTON Pool to process the stTON deposit.

  • The triTON Pool calculates the amount of triTON LP the user will receive.

  • After calculation, the triTON Pool packages the triTON LP and hTON deposit information and sends an op::deposit_between message to the quaTON Pool.

  • The quaTON Pool then calculates the final amount of quaTON LP the user will receive.


Alternative Deposit Scenarios

This process can also be performed using only the assets within the triTON Pool, without the need for hTON. In such cases, users can still achieve the deposit and deposit operation by utilizing assets directly from the Base Pool.


Deposit and Swap

In the following example, the scenario typically involves users swapping Token A for Token B, a process that may involve multiple pools.

Deposit and Swap Process

Continuing from the previous example, suppose you currently hold stTON and want to swap it for hTON. This can be achieved through a deposit and swap process.

Here’s how it works:

  1. First Step – Deposit stTON into the triTON Pool to receive triTON LP tokens.

  2. Second Step – Use the obtained triTON LP to perform a swap in the quaTON Pool, swapping the triTON LP for hTON.


Detailed Flow

  • However, after the triTON Pool completes the deposit, it does not send an op::payout to the LP Vault.

  • Instead, the triTON Pool sends an op::swap_between message to the quaTON Pool to initiate the swap.

  • Once the swap is completed, the quaTON Pool sends an op::payout message to the hTON vault, transferring hTON to the user’s designated address.


Swap and Withdraw

Swap and Withdraw Process

Suppose you currently hold hTON and want to swap it for stTON. This can be done through the following steps:

  1. Step 1 – Swap hTON for triTON LP

    • Swap hTON for triTON LP in the quaTON Pool.

  2. Step 2 – Withdraw triTON LP to receive stTON

    • Use the obtained triTON LP to perform a withdrawal (Withdraw One mode) in the triTON Pool to receive stTON.


Detailed Flow

  • However, after the quaTON Pool completes the swap, it does not send an op::payout to the stTON Vault directly.

  • Instead, the quaTON Pool sends an op::withdraw_between message to the triTON Pool to initiate the withdrawal process.

  • After the triTON Pool completes the withdrawal, it sends an op::payout message to the stTON Vault, transferring the assets to the user’s designated address.


Withdraw and Withdraw

Continuing from the previous Deposit and Deposit example, this time we perform the reverse operation through Withdraw and Withdraw to convert assets from quaTON LP to stTON in the triTON Pool.

Withdraw and Withdraw Process

Suppose you currently hold quaTON LP and want to convert it to stTON in the triTON Pool. This can be achieved through the following steps:

  1. Step 1 – Withdraw quaTON LP for triTON LP

    • Perform a withdrawal in the quaTON Pool to receive triTON LP.

  2. Step 2 – Withdraw triTON LP for stTON

    • Use the obtained triTON LP to perform a withdrawal in the triTON Pool to receive stTON.


Detailed Flow

  • However, after the quaTON Pool completes the withdrawal, it does not send an op::payout to the triTON LP Vault.

  • Instead, the quaTON Pool sends an op::withdraw_between message to the triTON Pool to initiate the next withdrawal process.

  • After the triTON Pool completes the withdrawal, it sends an op::payout message to the stTON Vault, transferring the assets to the user’s designated address.


Withdrawal Modes

Since Torch supports two withdrawal modes – Withdraw All and Withdraw One – there are four possible combinations during the Withdraw and Withdraw process:

  • Withdraw All and Withdraw All

  • Withdraw One and Withdraw One

  • Withdraw All and Withdraw One

  • Withdraw One and Withdraw All

Users can choose the appropriate combination based on their specific needs and desired outcomes.


For a complete view of the process, please refer to the .

TorchDepositSwapFlow

The deposit process for the first step is the same as the one described earlier (refer to for details).

TorchSwapWithdrawFlow

Continuing from the previous example, this time we perform the reverse operation through Swap and Withdraw to convert assets from hTON to stTON.

The swap process is the same as the one described earlier (refer to ).

TorchWithdrawWithdarwFlow

The withdrawal process for the first step is the same as the one described earlier (refer to ).

diagram
this link
Deposit and Swap
this link
this link