Deposit Liquidity

This guide demonstrates how to perform a deposit into a liquidity pool using the Torch Finance SDK.

Example: Depositing Assets into a Pool

1. Initialize SDK

First, import the required modules and initialize the Torch Finance SDK:

import { TorchSDK, generateQueryId, DepositParams, toUnit } from '@torch-finance/sdk';
import { Asset } from '@torch-finance/core';

const sdk = new TorchSDK();

2. Define Deposit Parameters

Configure the parameters for depositing assets into a pool. For this example, we will

  1. Deposit 0.1 TON, 0.1 tsTON, and 0.1 stTON into a pool.

  2. Additionally, a subsequent 0.1 hTON deposit into a MetaPool will be prepared.

const queryId = await generateQueryId()

// Define assets
const TON_ASSET = Asset.ton();
const TSTON_ASSET = Asset.jetton("EQC98_qAmNEptUtPc7W6xdHh_ZHrBUFpw5Ft_IzNU20QAJav");
const STTON_ASSET = Asset.jetton("EQDNhy-nxYFgUqzfUzImBEP67JqsyMIcyk2S5_RwNNEYku0k");
const HTON_ASSET = Asset.jetton("EQDPdq8xjAhytYqfGSX8KcFWIReCufsB9Wdg0pLlYSO_h76w");

const LSDPoolAddress = "EQD_pool_address_example";
const MetaPoolAddress = "EQD_meta_pool_address_example";

// Define deposit parameters
const depositParams: DepositParams = {
    queryId,
    pool: BasePoolAddress,
    depositAmounts: [
      {
        asset: TSTON_ASSET,
        value: toUnit('0.0000001', 9), // 0.0000001 TSTON in TriTON pool
      },
      {
        asset: STTON_ASSET,
        value: toUnit('0.0000001', 9), // 0.0000001 STTON in TriTON pool
      },
      {
        asset: TON_ASSET,
        value: toUnit('0.0000001', 9), // 0.0000001 TON in TriTON pool
      },
    ],
    nextDeposit: {
      pool: MetaPoolAddress,
      depositAmounts: { asset: HTON_ASSET, value: toUnit('0.0000001', 9) }, // 0.0000001 HTON in Meta USD pool
    },
    slippageTolerance: 0.01, // 1%
  };

3. Preview the Deposit

Simulate the deposit to preview important details such as the LP token master address and the estimated LP token amount.

Example Output

4. Execute the Deposit

Send the deposit transaction and retrieve the msgHash to track its status.

4.1 Execute Swap with Simulation Result

4.2 Execute Swap Directly with Swap Params

Last updated