Deposit

Deposit Mode-Specific Parameters

  1. FixedOneSide

    • fixed_amount: Fixed amount to deposit

    • fixed_coin_a: Boolean indicating whether to fix coin A (true) or coin B (false)

  2. FlexibleBoth

    • coin_amount_a: Amount of coin A to deposit

    • coin_amount_b: Amount of coin B to deposit

  3. OnlyCoinA/OnlyCoinB

    • coin_amount: Amount of single coin to deposit

Deposit Usage Example

// Initialize SDK and get pool information
const sdk = CetusZapSDK.createSDK({ env: 'mainnet' })

const pool_id = 'YOUR_POOL_ID'
const pool = await sdk.CetusClmmSDK.Pool.getPool(pool_id)

// Pre-calculate deposit amounts (example: FixedOneSide mode)
const result = await sdk.Zap.preCalculateDepositAmount(
  {
    pool_id,
    tick_lower,
    tick_upper,
    current_sqrt_price: pool.current_sqrt_price.toString(),
    slippage: 0.01,
  },
  {
    mode: 'FixedOneSide',
    fixed_amount: toDecimalsAmount(1, 6).toString(),
    fixed_coin_a: false,
  }
)

const pos_id = 'YOUR_POSITION_ID'
// Build and send transaction
const tx = await sdk.Zap.buildDepositPayload({
  deposit_obj: result,
  pool_id,
  coin_type_a: pool.coin_type_a,
  coin_type_b: pool.coin_type_b,
  tick_lower,
  tick_upper,
  slippage: 0.01,
  pos_obj: {
    // Optional: Add to existing position
    pos_id,
    collect_fee: false,
    collect_rewarder_types: [],
  },
})

// Simulate or send the transaction
const sim_result = await sdk.FullClient.sendSimulationTransaction(tx, wallet)

Last updated