npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

test-zs123

v0.0.30

Published

Zap SDK

Readme

Zap Operations

The SDK provides a Zap module for specialized liquidity operations with different modes to suit various trading strategies.

Common Parameters

  • pool_id: The ID of the liquidity pool
  • tick_lower & tick_upper: Price range boundaries for the position
  • current_sqrt_price: Current square root price of the pool
  • slippage: Maximum acceptable price slippage (e.g., 0.01 for 1%)
  • coin_type_a & coin_type_b: Coin type identifiers for the trading pair
  • coin_decimal_a & coin_decimal_b: Decimal places for each coin type

1. Deposit Operations

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

Usage Example

// Initialize SDK and get pool information
const sdk = buildSdk(SdkEnv.mainnet)
const pool = await sdk.CetusClmmSDK.Pool.getPool(poolId)

// Pre-calculate deposit amounts (example: FixedOneSide mode)
const result = await sdk.Zap.preCalculateDepositAmount(
    {
        pool_id: poolId,
        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,
    }
)

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

// Simulate or send the transaction
const simResult = await sdk.FullClient.sendSimulationTransaction(tx, address)
// const txResult = await sdk.FullClient.sendTransaction(sendKeyPair, tx)

2. Withdraw Operations

Withdrawals require an existing position in the pool.

Mode-Specific Parameters

  1. FixedOneSide

    • fixed_amount: Fixed amount to withdraw
    • fixed_coin_a: Boolean indicating whether to withdraw coin A (true) or coin B (false)
  2. OnlyCoinA/OnlyCoinB

    • burn_liquidity: Amount of liquidity to burn
    • available_liquidity: Total available liquidity in the position

Usage Example

// Get pool and position information
const pool = await sdk.CetusClmmSDK.Pool.getPool(poolId)
const position = await sdk.CetusClmmSDK.Position.getPositionById(positionId)

if (!pool || !position) {
    throw new Error('Pool or Position not found')
}

// Pre-calculate withdrawal (example: OnlyCoinA mode)
const result = await sdk.Zap.preCalculateWithdrawAmount({
    mode: 'OnlyCoinA',
    pool_id: poolId,
    tick_lower: position.tick_lower_index,
    tick_upper: position.tick_upper_index,
    current_sqrt_price: pool.current_sqrt_price.toString(),
    burn_liquidity: '200000',
    available_liquidity: position.liquidity.toString(),
    coin_type_a: pool.coinTypeA,
    coin_type_b: pool.coinTypeB,
    coin_decimal_a: 6,
    coin_decimal_b: 9,
})

// Build and send transaction
const tx = await sdk.Zap.buildWithdrawPayload({
    withdraw_obj: result,
    pool_id: poolId,
    pos_id: positionId,
    close_pos: false,             // Whether to close the position
    collect_fee: true,            // Whether to collect accumulated fees
    collect_rewarder_types: [],   // Types of rewards to collect
    coin_type_a: pool.coinTypeA,
    coin_type_b: pool.coinTypeB,
    tick_lower: position.tick_lower_index,
    tick_upper: position.tick_upper_index,
    slippage: 0.01,
})

// Simulate or send the transaction
const simResult = await sdk.FullClient.sendSimulationTransaction(tx, address)
// const txResult = await sdk.FullClient.sendTransaction(sendKeyPair, tx)