Cross-Pool Operations
Last updated
Last updated
Let's assume there are two pools:
Base Pool – triTON Pool (TON/tsTON/stTON)
Meta Pool – quaTON Pool (triTON LP / hTON)
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:
First Deposit – Deposit stTON into the triTON Pool to receive triTON LP tokens.
Second Deposit – Take the obtained triTON LP along with hTON and deposit them into the quaTON Pool to receive quaTON LP tokens.
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.
For a complete view of the process, please refer to the diagram.
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.
In the following example, the scenario typically involves users swapping Token A for Token B, a process that may involve multiple pools.
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:
First Step – Deposit stTON into the triTON Pool to receive triTON LP tokens.
Second Step – Use the obtained triTON LP to perform a swap in the quaTON Pool, swapping the triTON LP for hTON.
The deposit process for the first step is the same as the one described earlier (refer to this link for details).
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.
Continuing from the previous Deposit and Swap example, this time we perform the reverse operation through Swap and Withdraw to convert assets from hTON to stTON.
Suppose you currently hold hTON and want to swap it for stTON. This can be done through the following steps:
Step 1 – Swap hTON for triTON LP
Swap hTON for triTON LP in the quaTON Pool.
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.
The swap process is the same as the one described earlier (refer to this link).
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.
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.
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:
Step 1 – Withdraw quaTON LP for triTON LP
Perform a withdrawal in the quaTON Pool to receive triTON LP.
Step 2 – Withdraw triTON LP for stTON
Use the obtained triTON LP to perform a withdrawal in the triTON Pool to receive stTON.
The withdrawal process for the first step is the same as the one described earlier (refer to this link).
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.
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.