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

@dipcoinlab/dex-sui-sdk

v0.0.10

Published

SDK for dipcoin DEX

Readme

DipCoin-Sui-SDK

TypeScript SDK for DipCoin DEX on Sui blockchain.

Quick Start

Initialize SDK

import { initDipCoinSDK } from "@dipcoinlab/dex-sui-sdk";

// Initialize for mainnet
const sdk = initDipCoinSDK({
  network: "mainnet",
  customRpc: "https://fullnode.mainnet.sui.io", // Optional custom RPC
});

// Initialize for testnet
const sdk = initDipCoinSDK({
  network: "testnet",
});

Core Features

Liquidity Operations

Add Liquidity

Add liquidity to an existing pool with slippage protection:

const txResponse = await sdk.addLiquidity(keypair, {
  pooId: "YOUR_POOL_ID",
  typeX: "0x...::usdc::USDC", // First token type
  typeY: "0x...::wsol::WSOL", // Second token type
  amountX: new BigNumber(2000000000), // 2000 USDC (with 6 decimals)
  amountY: new BigNumber(10000000), // 10 WSOL (with 6 decimals)
  slippage: 0.03, // 3% slippage tolerance,if not specified,default is 0.05
});

if (txResponse.status) {
  console.log(`Add liquidity success, txId: ${txResponse.txId}`);
} else {
  console.log("Add liquidity failed:", txResponse.error);
}

Remove Liquidity

Remove liquidity from a pool:

const txResponse = await sdk.removeLiquidity(keypair, {
  pooId: "YOUR_POOL_ID",
  typeX: "0x...::usdc::USDC",
  typeY: "0x...::wsol::WSOL",
  removeLpAmount: new BigNumber(300000000), // Amount of LP tokens to remove
  slippage: 0.03, // 3% slippage tolerance,if not specified,default is 0.05
});

if (txResponse.status) {
  console.log(`Remove liquidity success, txId: ${txResponse.txId}`);
} else {
  console.log("Remove liquidity failed:", txResponse.error);
}

Swap Operations

Swap Exact Input

Swap an exact amount of input tokens for output tokens:

const txResponse = await sdk.swapExactXToY(keypair, {
  pooId: "YOUR_POOL_ID",
  typeX: "0x...::wsol::WSOL", // Input token
  typeY: "0x...::usdc::USDC", // Output token
  amountIn: new BigNumber(1000000000), // 1000 WSOL
  slippage: 0.03, // 3% slippage tolerance
});

if (txResponse.status) {
  console.log(`Swap exact X to Y success, txId: ${txResponse.txId}`);
} else {
  console.log("Swap failed:", txResponse.error);
}

Swap Exact Output

Swap tokens for an exact amount of output tokens:

const txResponse = await sdk.swapXToExactY(keypair, {
  pooId: "YOUR_POOL_ID",
  typeX: "0x...::usdc::USDC", // Input token
  typeY: "0x...::wsol::WSOL", // Output token
  amountOut: new BigNumber(1000000000), // Desired output amount
  slippage: 0.03, // 3% slippage tolerance
});

if (txResponse.status) {
  console.log(`Swap X to exact Y success, txId: ${txResponse.txId}`);
} else {
  console.log("Swap failed:", txResponse.error);
}

Query Functions

Get Pool Information

const poolResponse = await sdk.getPool("YOUR_POOL_ID");
if (poolResponse.status && poolResponse.data) {
  console.log("Pool info:", poolResponse.data);
}

Get Pool ID

Get pool ID for a token pair:

const poolId = await sdk.getPoolId("0x...::usdc::USDC", "0x...::wsol::WSOL");
console.log("Pool ID:", poolId);

Get Global Configuration

const globalResponse = await sdk.getGlobal();
if (globalResponse.status && globalResponse.data) {
  console.log("Global config:", globalResponse.data);
}

Split Coins

Split a specified amount from available coins. This is typically used internally by the SDK but can also be used directly if needed:

import { Transaction } from "@mysten/sui/transactions";

// Create a new transaction
const tx = new Transaction();

// Split coins
const splitCoinResult = await sdk.splitCoin(
  ownerAddress, // The address of the coin owner
  coinType, // The coin type (e.g. "0x...::usdc::USDC")
  amount, // Amount to split (BigNumber)
  tx // Transaction object
);

The method will:

  1. Query available coins of the specified type
  2. Merge multiple coins if necessary
  3. Split the requested amount
  4. Return the split coin reference

Example usage within a custom transaction:

const tx = new Transaction();

try {
  // Split 1000 USDC
  const splitUSDC = await sdk.splitCoin(
    signer.getPublicKey().toSuiAddress(),
    "0x...::usdc::USDC",
    new BigNumber(1000000000), // 1000 USDC with 6 decimals
    tx
  );

  // Use the split coin in your transaction
  tx.moveCall({
    target: "your_package::module::function",
    arguments: [
      splitUSDC,
      // other arguments...
    ],
    typeArguments: [
      /* type arguments */
    ],
  });

  // Sign and execute the transaction
  const result = await sdk.client.signAndExecuteTransaction({
    signer: signer,
    transaction: tx,
  });
} catch (error) {
  console.error("Split coin failed:", error);
}

Error handling:

  • Throws if no coins are available
  • Throws if total balance is insufficient
  • Throws if coin operations fail

Types

Pool Interface

interface Pool {
  id: string; // Pool ID
  bal_x: bigint; // Token X balance
  bal_y: bigint; // Token Y balance
  fee_bal_x: bigint; // Accumulated fee balance for token X
  fee_bal_y: bigint; // Accumulated fee balance for token Y
  lp_supply: bigint; // Total LP token supply
  fee_rate: bigint; // Pool fee rate
}

Transaction Response

interface TxResponse {
  txId: string; // Transaction hash
  status: boolean; // Transaction success status
  error?: string; // Error message if failed
}

Error Handling

All SDK methods return a response object with status and error information:

interface SDKResponse<T = any> {
  status: boolean; // Operation success status
  data?: T; // Response data if successful
  error?: string; // Error message if failed
}

Constants

Default Values

  • Default slippage tolerance: 5% (0.05)
  • Maximum fee rate: 1% (0.01)

License

Apache License 2.0