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

krystal-zapp

v0.0.17

Published

A powerful React component for zapping into liquidity pools on Uniswap V3 and compatible platforms. KrystalZap enables users to swap tokens and add liquidity in a single transaction.

Readme

KrystalZap Component

A powerful React component for zapping into liquidity pools on Uniswap V3 and compatible platforms. KrystalZap enables users to swap tokens and add liquidity in a single transaction.

KrystalZap Component

Installation

# Using npm
npm install @krystaldefi/zap

# Using yarn
yarn add @krystaldefi/zap

# Using pnpm
pnpm add @krystaldefi/zap

# Using bun
bun add @krystaldefi/zap

Features

  • Single-Transaction Zapping: Swap tokens and add liquidity to Uniswap V3 pools in one transaction
  • Multi-Chain Support: Works across multiple EVM-compatible blockchains
  • Protocol Support: Compatible with Uniswap V3 and similar DEXs
  • Customizable Price Range: Set custom price ranges for concentrated liquidity positions
  • Slippage Controls: Configure separate slippage tolerances for swaps and liquidity provision
  • Theming: Light and dark mode support
  • Token Selection: Seamless token selection from user wallet balances

Basic Usage

import { KrystalZap } from "@krystaldefi/zap";

// In your component
const MyComponent = () => {
  const handleTxDataReady = (txData) => {
    console.log("Transaction data ready:", txData);
    // Use this data to execute the transaction with your web3 provider
  };

  return (
    <KrystalZap
      platform="uniswapv3"
      chainId={1}
      poolAddress="0x99ac8ca7087fa4a2a1fb6357269965a2014abc35"
      userAddress="0x..."
      onTxDataReady={handleTxDataReady}
      onError={(error) => console.error(error)}
      onLoading={(loading) => console.log("Loading:", loading)}
    />
  );
};

Props

| Prop | Type | Required | Default | Description | | ------------------- | ---------------------------- | -------- | --------- | --------------------------------------------------- | | platform | string | Yes | - | DEX platform ID (e.g., 'uniswapv3') | | chainId | number | Yes | - | Blockchain network ID | | poolAddress | string | Yes | - | Address of the liquidity pool | | userAddress | string | Yes | - | User wallet address | | swapSlippage | number | No | 0.01 | Slippage tolerance for token swap (1% = 0.01) | | liquiditySlippage | number | No | 0.02 | Slippage tolerance for adding liquidity (2% = 0.02) | | onTxDataReady | (txObj: TxData) => void | Yes | - | Callback when transaction data is ready | | onError | (error: string) => void | Yes | - | Callback when an error occurs | | onLoading | (loading: boolean) => void | Yes | - | Callback for loading state changes | | poolDetail | PoolDetailType | No | - | Pre-fetched pool details | | borderRadius | string | No | '12px' | Border radius for the component container | | theme | 'light' \| 'dark' | No | 'light' | Component theme |

Advanced Configuration

Supported Chains and Platforms

To get the list of supported chains and protocols:

// Fetch supported chains and protocols
const fetchChainConfig = async () => {
  const response = await fetch(
    "https://api.krystal.app/all/v1/lp_explorer/configs"
  );
  const data = await response.json();
  return data.data;
};

Complete Example with Transaction Execution

import React, { useState } from "react";
import { KrystalZap } from "@krystaldefi/zap";
import { useSendTransaction, useWaitForTransactionReceipt } from "wagmi";

const ZapComponent = () => {
  const [txData, setTxData] = useState(null);
  const { sendTransactionAsync } = useSendTransaction();
  const [hash, setHash] = useState();
  const { isSuccess: isConfirmed } = useWaitForTransactionReceipt({ hash });
  const [isExecuting, setIsExecuting] = useState(false);

  const handleTxDataReady = (txObj) => {
    console.log("Transaction object:", txObj);
    setTxData(txObj);
  };

  const executeZap = async () => {
    if (!txData) return;

    setIsExecuting(true);
    try {
      const result = await sendTransactionAsync({
        to: txData.to,
        data: txData.data,
        value: BigInt(txData.value || 0),
        chainId: txData.chainId,
      });

      setHash(result);

      // Handle confirmation in a useEffect
      if (isConfirmed) {
        console.log("Transaction confirmed!");
        setIsExecuting(false);
      }
    } catch (error) {
      console.error("Transaction error:", error);
      setIsExecuting(false);
    }
  };

  return (
    <div>
      <KrystalZap
        platform="uniswapv3"
        chainId={1}
        poolAddress="0x99ac8ca7087fa4a2a1fb6357269965a2014abc35"
        userAddress="0x..."
        onTxDataReady={handleTxDataReady}
        onError={(error) => console.error("Zap error:", error)}
        onLoading={(loading) => console.log("Loading:", loading)}
        theme="dark"
      />

      <button onClick={executeZap} disabled={!txData || isExecuting}>
        {isExecuting ? "Processing..." : "Execute Zap"}
      </button>
    </div>
  );
};

Pool Detail Type

interface PoolDetailType {
  chain: {
    name: string;
    id: number;
    logo: string;
    explorer: string;
  };
  poolAddress: string;
  poolPrice: number;
  protocol: {
    key: string;
    name: string;
    factoryAddress: string;
    logo: string;
  };
  feeTier: number;
  token0: {
    address: string;
    symbol: string;
    name: string;
    decimals: number;
    logo: string;
    balance?: string;
    usdPrice?: string;
  };
  token1: {
    address: string;
    symbol: string;
    name: string;
    decimals: number;
    logo: string;
    balance?: string;
    usdPrice?: string;
  };
  tvl: number;
  stats1h: {
    volume: number;
    fee: number;
    apr: number;
  };
  stats24h: {
    volume: number;
    fee: number;
    apr: number;
  };
  stats7d: {
    volume: number;
    fee: number;
    apr: number;
  };
  stats30d: {
    volume: number;
    fee: number;
    apr: number;
  };
}

Transaction Data Type

interface TxData {
  to: string;
  data: string;
  value?: string;
  chainId: number;
}

Dependencies

KrystalZap requires the following peer dependencies:

  • React (^18.3.1 or ^19.0.0)
  • React DOM (^18.3.1 or ^19.0.0)

License

MIT

Support

For any issues or questions, please reach out to the Krystal team or open an issue on our GitHub repository.