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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@skate-org/skate_amm_sui_sdk

v1.1.15

Published

SKATE AMM's Sui SDK

Downloads

62

Readme

Skate AMM Sui SDK

This SDK provides a convenient way to interact with the Skate AMM protocol on the Sui blockchain. It supports both staging and production environments, which can be selected upon initialization.

Table of Contents

Installation

To get started, install the SDK from npm:

npm install @skate-org/skate_amm_sui_sdk

Initialization

First, import the SDK and the Environment enum. Then, create an instance of the SDK by passing the desired environment (Environment.Staging or Environment.Production) to the constructor.

import SkateAmmSdk, { Environment, PoolType } from '@skate-org/skate_amm_sui_sdk';

// Initialize the SDK for the staging environment
const sdk = new SkateAmmSdk(Environment.Staging); 

This instance will be pre-configured with the correct contract addresses and pool configurations for the selected environment.

Configuration

Keypairs

The example.ts script automatically generates and loads keypairs for manager, gateway, and user roles. These keypairs are stored in the keypairs/ directory relative to your project root. If the keypair files do not exist, new ones will be generated.

Pool Configuration

The src/utils/poolconfig.ts file contains the configuration for different liquidity pools, separated by environment (staging and production). You should update this file with the poolId and managerCapId after successfully initializing a pool (see initializePool command below).

Additionally, config.ts holds various parameters for transactions like minting, swapping, and burning. Review and adjust these values as needed for your operations.

Usage Example

The example.ts script demonstrates how to use various functions of the SDK. You can run individual commands using ts-node.

ts-node example.ts [command]

Available Commands

Here are the commands available through example.ts:

  • initializePool: Initializes a new liquidity pool on the Sui blockchain. This command will output the new poolId and managerCapId which you should then update in src/utils/poolconfig.ts.
  • mint: Mints new liquidity tokens by providing TOKEN0 and TOKEN1 to a specified pool.
  • swap: Initiates a token swap within a pool (e.g., TOKEN0 for TOKEN0 to TOKEN1 or vice-versa).
  • settleSwap: Settles a previously initiated swap operation.
  • settleMint: Settles a previously initiated mint operation.
  • removeStagedAssets: Removes all staged assets from the pool for a user.
  • removeSpecificStaged: Removes only a specified amount of staged TOKEN0/TOKEN1 assets for a user.
  • burn: Burns liquidity tokens to redeem TOKEN0 and TOKEN1 from a specified pool.
  • settleBurn: Settles a previously initiated burn operation.
  • increaseLiquidity: Increases the liquidity in an existing position.
  • decreaseLiquidity: Decreases the liquidity from an existing position.
  • updatePoolConfig: Updates the configuration of an existing pool. Requires poolId and managerCapId.
  • addGateway: Adds a new gateway address to the pool's configuration. Requires poolId and managerCapId.
  • removeGateway: Removes an existing gateway address from the pool's configuration. Requires poolId and managerCapId.
  • createPoolConfigJson: Creates a poolconfig.json file in the project root with the current environment's pool configurations.
  • getPoolBalances: Fetches the current token balances for a specified liquidity pool.
  • getUserData: Retrieves user positions and staged asset information (read-only).
  • all: Executes all of the above commands sequentially (for demonstration purposes).

Detailed Command Usage with Examples

Below are detailed examples for each command, showcasing how to call the SDK functions with sample values. These values are based on config.ts.

First, initialize the SDK:

import SkateAmmSdk, { Environment, PoolType } from 'skate-amm-sui-sdk';

const sdk = new SkateAmmSdk(Environment.Staging);

initializePool

Initializes a new liquidity pool. After successful initialization, update src/utils/poolconfig.ts with the new poolId and managerCapId from the output.

const tx = sdk.pool.initializePool({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC, // Example: Using SUI_USDC pool type
  gateways: ["0xYOUR_MANAGER_ADDRESS", "0xYOUR_GATEWAY_ADDRESS"], // Example addresses
});
// Execute the transaction with managerKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: managerKeypair });

mint

Mints new liquidity tokens for a specified pool. Ensure you have sufficient TOKEN0 and TOKEN1 in the userOwner's wallet.

const tx = await sdk.liquidity.mint({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  coins0: [/* array of coin objects for token 0 */],
  coins1: [/* array of coin objects for token 1 */],
  amountToken0: "100", // Example from config.mint.amountToken0
  amountToken1: "100", // Example from config.mint.amountToken1
  tickLower: "-887272", // Example from config.mint.tickLower
  tickUpper: "887272", // Example from config.mint.tickUpper
  amountToken0Min: "0", // Example from config.mint.amountToken0Min
  amountToken1Min: "0", // Example from config.mint.amountToken1Min
  actionBoxSeed: new Date().getTime().toString(), // Example from config.mint.actionBoxSeed
});
// Execute the transaction with userKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: userKeypair });

swap

Initiates a token swap. zeroForOne determines the swap direction (true for TOKEN0 to TOKEN1, false for TOKEN1 to TOKEN0).

const tx = await sdk.swap.swap({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  coinsIn: [/* array of coin objects for the input token */],
  recipientStr: "0x6eff7d0d0a5e759566867e8bbc10a21bfc35fcf5c5cbd301a0c7712f693106b7", // Example from config.swap.recipientStr
  zeroForOne: true, // Example from config.swap.zeroForOne
  amountSpecified: "11", // Example from config.swap.amountIn
  amountIsPositive: true, // Based on amountIn > 0
  sqrtPriceLimitX96Str: "4295128736", // Example from config.swap.sqrtPriceLimitX96Str
  destChainId: "1001", // Example from config.swap.destChainId
  destVmType: 4, // Example from config.swap.destVmType
  extraData: "", // Example from config.swap.extraData
  actionBoxSeed: new Date().getTime().toString(), // Example from config.swap.actionBoxSeed
  amountIn: "11", // Example from config.swap.amountIn
});
// Execute the transaction with userKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: userKeypair });

settleSwap

Settles a previously initiated swap operation. This is typically called by a gateway service after cross-chain messages have been confirmed.

const tx = sdk.swap.settleSwap({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  userAddr: "0x96472f7a858e7d8de2e969cd56d2a32f9ed4cd2911b928f792708ea275a13cd3", // Example from config.settleSwap.userAddr
  amount0ToTransferRaw: "10", // Example from config.settleSwap.amount0ToTransferRaw
  amount1ToTransferRaw: "10", // Example from config.settleSwap.amount1ToTransferRaw
  amount0ToSettleRaw: "10", // Example from config.settleSwap.amount0ToSettleRaw
  amount1ToSettleRaw: "10", // Example from config.settleSwap.amount1ToSettleRaw
  taskId: "1", // Example from config.settleSwap.taskId
});
// Execute the transaction with gatewayKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: gatewayKeypair });

settleMint

Settles a previously initiated mint operation.

const tx = sdk.liquidity.settleMint({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  userAddr: "0xYOUR_USER_ADDRESS", // Replace with actual user address
  amount0ToSettleRaw: "01", // Example from config.settleMint.amount0ToSettleRaw
  amount1ToSettleRaw: "01", // Example from config.settleMint.amount1ToSettleRaw
  amount0ToTransferToUserRaw: "10", // Example from config.settleMint.amount0ToTransferToUserRaw
  amount1ToTransferToUserRaw: "10", // Example from config.settleMint.amount1ToTransferToUserRaw
  taskId: "1", // Example from config.settleMint.taskId
});
// Execute the transaction with gatewayKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: gatewayKeypair });

removeStagedAssets

Removes all staged assets from the pool for a user. This can be used to clear pending assets after a settlement.

const tx = sdk.liquidity.removeStagedAssets({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  userAddr: "0xYOUR_USER_ADDRESS", // Example from config.removeStagedAssets.userAddr, replace with actual user address
});
// Execute the transaction with gatewayKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: gatewayKeypair });

removeSpecificStaged

Removes specified amounts of staged TOKEN0 and TOKEN1 from the pool for a given user.

const tx = sdk.liquidity.removeSpecificStaged({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  userAddr: "0xYOUR_USER_ADDRESS",   // Replace with actual user address
  amount0ToReturnRaw: "10",          // Amount of TOKEN0 to return
  amount1ToReturnRaw: "10",          // Amount of TOKEN1 to return
});
// Execute the transaction with gatewayKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: gatewayKeypair });

burn

Burns liquidity tokens to redeem underlying TOKEN0 and TOKEN1 from a position.

const tx = sdk.liquidity.burn({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  tickLower: "-887272", // Example from config.burn.tickLower
  tickUpper: "887272", // Example from config.burn.tickUpper
  liquidityAmount: "10000000", // Example from config.burn.liquidityAmount
  amount0Min: "0", // Example from config.burn.amount0min
  amount1Min: "0", // Example from config.burn.amount1min
  tokenId: "1", // Example from config.burn.tokenId
  actionBoxSeed: new Date().getTime().toString(), // Example from config.burn.actionBoxSeed
});
// Execute the transaction with userKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: userKeypair });

settleBurn

Settles a previously initiated burn operation.

const tx = sdk.liquidity.settleBurn({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  userAddr: "0xYOUR_USER_ADDRESS", // Replace with actual user address
  amount0ToTransferRaw: "10", // Example from config.settleBurn.amount0ToTransferRaw
  amount1ToTransferRaw: "10", // Example from config.settleBurn.amount1ToTransferRaw
  taskId: "1", // Example from config.settleBurn.taskId
});
// Execute the transaction with gatewayKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: gatewayKeypair });

increaseLiquidity

Adds more liquidity to an existing position (NFT).

const tx = await sdk.liquidity.increaseLiquidity({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  coins0: [/* array of coin objects for token 0 */],
  coins1: [/* array of coin objects for token 1 */],
  tokenId: "1", // Example from config.increaseLiquidity.tokenId
  amountToken0: "1000", // Example from config.increaseLiquidity.amountToken0
  amountToken1: "1000", // Example from config.increaseLiquidity.amountToken1
  amountToken0Min: "0", // Example from config.increaseLiquidity.amountToken0Min
  amountToken1Min: "0", // Example from config.increaseLiquidity.amount1Min
  actionBoxSeed: "123456789", // Example from config.increaseLiquidity.actionBoxSeed
});
// Execute the transaction with userKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: userKeypair });

decreaseLiquidity

Removes a portion of liquidity from an existing position (NFT).

const tx = sdk.liquidity.decreaseLiquidity({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  tokenId: "1", // Example from config.decreaseLiquidity.tokenId
  liquidityAmount: "10000", // Example from config.decreaseLiquidity.liquidityAmount
  amount0Min: "0", // Example from config.decreaseLiquidity.amount0min
  amount1Min: "0", // Example from config.decreaseLiquidity.amount1min
  actionBoxSeed: "123456789", // Example from config.decreaseLiquidity.actionBoxSeed
});
// Execute the transaction with userKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: userKeypair });

updatePoolConfig

Updates configuration parameters of an existing pool. This is a manager-only function.

const tx = sdk.pool.updatePoolConfig({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolId: "0xYOUR_POOL_ID", // Replace with actual Pool ID
  managerCapId: "0xYOUR_MANAGER_CAP_ID", // Replace with actual Manager Cap ID
  newChainId: "1001", // Example: config.updatePoolConfig.newChainId
  newSrcVmType: 4, // Example: config.updatePoolConfig.newSrcVmType
  newDescription: "Updated pool description", // Example: config.updatePoolConfig.newDescription
  newGateways: ["0xNEW_GATEWAY_ADDRESS"], // Example: config.updatePoolConfig.newGateways
  newKernelFactory: "0xB32841DD65316F672eb07c63508f4b6841b6Aee4", // Example: config.updatePoolConfig.newKernelFactory
  newKernelPool: "0x21527481C7683d6d1d3604bB99cb06e56ae81b40", // Example: config.updatePoolConfig.newKernelPool
});
// Execute the transaction with managerKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: managerKeypair });

addGateway

Adds a new gateway address to the pool's configuration. This is a manager-only function.

const tx = sdk.pool.addGateway({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  poolId: "0xYOUR_POOL_ID", // Replace with actual Pool ID
  managerCapId: "0xYOUR_MANAGER_CAP_ID", // Replace with actual Manager Cap ID
  gatewayAddress: "0xADD_THIS_GATEWAY_ADDRESS", // Replace with the gateway address to add
});
// Execute the transaction with managerKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: managerKeypair });

removeGateway

Removes an existing gateway address from the pool's configuration. This is a manager-only function.

const tx = sdk.pool.removeGateway({
  peripheryModule: sdk.constants.PERIPHERY_MODULE,
  poolType: PoolType.SUI_USDC,
  poolId: "0xYOUR_POOL_ID", // Replace with actual Pool ID
  managerCapId: "0xYOUR_MANAGER_CAP_ID", // Replace with actual Manager Cap ID
  gatewayAddress: "0xREMOVE_THIS_GATEWAY_ADDRESS", // Replace with the gateway address to remove
});
// Execute the transaction with managerKeypair
// const result = await client.signAndExecuteTransaction({ transaction: tx, signer: managerKeypair });

createPoolConfigJson

Creates a poolconfig.json file in the project root with the current environment's pool configurations. This is useful for persisting pool configurations.

ts-node example.ts createPoolConfigJson

getPoolBalances

Fetches the current token balances for a specified liquidity pool. This is a read-only operation and does not require signing a transaction.

import SkateAmmSdk, { Environment, PoolType } from 'skate-amm-sui-sdk';
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';

// This is an example of how to use it.
async function checkBalances() {
  const rpcUrl = getFullnodeUrl('mainnet');
  const client = new SuiClient({ url: rpcUrl });
  const sdk = new SkateAmmSdk(Environment.Staging);
  const poolType = PoolType.SUI_USDC;

  const { balance0, balance1 } = await sdk.liquidity.getPoolBalances(client, poolType);
  console.log(`Pool ${poolType} balances:`);
  console.log(`  Token0 Balance: ${balance0}`);
  console.log(`  Token1 Balance: ${balance1}`);
}

checkBalances();

getUserData

Fetches on-chain information (positions, staged assets, etc.) for a specific user address. This is a read-only helper and does not require signing a transaction.

import SkateAmmSdk, { Environment, PoolType } from 'skate-amm-sui-sdk';
import { getFullnodeUrl, SuiClient } from '@mysten/sui/client';

async function fetchUserData() {
  const rpcUrl = getFullnodeUrl('mainnet');
  const client = new SuiClient({ url: rpcUrl });
  const sdk = new SkateAmmSdk(Environment.Staging);
  const poolType = PoolType.SUI_USDC;
  const userAddr = "0xYOUR_USER_ADDRESS"; // Replace with actual user address

  const userData = await sdk.view.getUserData(
    client,
    poolType,
    userAddr
  );

  console.log(`User data for ${userAddr}:`, userData);
}

fetchUserData();

Remember to review and adjust the parameters in config.ts and src/utils/poolconfig.ts according to your specific needs before running the commands.