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

@cooperalma/hydrex-sdk

v1.2.5

Published

A TypeScript SDK for interacting with the Hydrex concentrated-liquidity AMM on Base.

Downloads

65

Readme

Hydrex SDK

A TypeScript SDK for interacting with the Hydrex concentrated-liquidity AMM on Base.

Overview

The Hydrex SDK provides tools to:

  • Compute pool addresses
  • Model pools, positions, routes, and trades
  • Build calldata for swaps via the swap router
  • Build calldata for liquidity management via the position manager
  • Work with ERC4626 "boosted" token vaults

Installation

npm install @hydrex/sdk
# or
yarn add @hydrex/sdk

Supported Networks

| Network | Chain ID | Status | Pool Deployer | |--------------|----------|------------|----------------------------------------------| | Base | 8453 | Mainnet | 0x1595A5D101d69D2a2bAB2976839cC8eeEb13Ab94 |

Quick Start

import {
  Token,
  Pool,
  Position,
  Route,
  Trade,
  TradeType,
  SwapRouter,
  NonfungiblePositionManager,
  ChainId,
  WNATIVE,
  Percent,
  CurrencyAmount,
} from '@hydrex/sdk';

Core Concepts

Tokens

import { Token, ChainId } from '@hydrex/sdk';

const USDC = new Token(
  ChainId.Base,
  '0xYourUSDCAddress',
  6,
  'USDC',
  'USD Coin'
);

const WETH = WNATIVE[ChainId.Base];

Computing Pool Addresses

import { computePoolAddress, ChainId } from '@hydrex/sdk';

const poolAddress = computePoolAddress({
  tokenA: USDC,
  tokenB: WETH,
});

For pools deployed by a custom deployer:

import { computeCustomPoolAddress } from '@hydrex/sdk';

const customPoolAddress = computeCustomPoolAddress({
  tokenA: USDC,
  tokenB: WETH,
  customPoolDeployer: '0xYourCustomDeployer',
});

Creating a Pool Instance

import { Pool, INITIAL_POOL_FEE, DEFAULT_TICK_SPACING } from '@hydrex/sdk';

const pool = new Pool(
  USDC,
  WETH,
  INITIAL_POOL_FEE, // pool fee tier
  sqrtRatioX96,     // current sqrt price
  liquidity,        // current in-range liquidity
  tickCurrent,      // current tick
  ticks             // tick data provider or array
);

Swapping

Build calldata for an exact-input swap:

import { Trade, Route, SwapRouter, TradeType, Percent, CurrencyAmount } from '@hydrex/sdk';

const route = new Route([pool], USDC, WETH);

const trade = Trade.createUncheckedTrade({
  route,
  inputAmount: CurrencyAmount.fromRawAmount(USDC, '1000000'), // 1 USDC
  outputAmount: CurrencyAmount.fromRawAmount(WETH, estimatedOutput),
  tradeType: TradeType.EXACT_INPUT,
});

const { calldata, value } = SwapRouter.swapCallParameters(trade, {
  slippageTolerance: new Percent(50, 10_000), // 0.5%
  recipient: '0xYourWallet',
  deadline: Math.floor(Date.now() / 1000) + 60 * 20,
  feeOnTransfer: false,
});

// Send transaction to the swap router contract

Managing Liquidity

Minting a new position

import { Position, NonfungiblePositionManager, Percent, DEFAULT_TICK_SPACING } from '@hydrex/sdk';

const position = Position.fromAmounts({
  pool,
  tickLower: nearestUsableTick(tickCurrent - DEFAULT_TICK_SPACING * 10, DEFAULT_TICK_SPACING),
  tickUpper: nearestUsableTick(tickCurrent + DEFAULT_TICK_SPACING * 10, DEFAULT_TICK_SPACING),
  amount0: '1000000',
  amount1: '500000000000000000',
  useFullPrecision: true,
});

const { calldata, value } = NonfungiblePositionManager.addCallParameters(position, {
  slippageTolerance: new Percent(50, 10_000),
  recipient: '0xYourWallet',
  deadline: Math.floor(Date.now() / 1000) + 60 * 20,
});

Collecting fees

const { calldata, value } = NonfungiblePositionManager.collectCallParameters({
  tokenId: '42',
  recipient: '0xYourWallet',
  expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(USDC, '0'),
  expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(WETH, '0'),
});

Removing liquidity

const { calldata, value } = NonfungiblePositionManager.removeCallParameters(position, {
  tokenId: '42',
  liquidityPercentage: new Percent(100, 100), // 100% removal
  slippageTolerance: new Percent(50, 10_000),
  deadline: Math.floor(Date.now() / 1000) + 60 * 20,
  collectOptions: {
    expectedCurrencyOwed0: CurrencyAmount.fromRawAmount(USDC, '0'),
    expectedCurrencyOwed1: CurrencyAmount.fromRawAmount(WETH, '0'),
    recipient: '0xYourWallet',
  },
});

Boosted Tokens (ERC4626 Vaults)

Hydrex supports ERC4626 vault-wrapped tokens as first-class entities for routing:

import { BoostedToken, BoostedRoute } from '@hydrex/sdk';

const mwETH = new BoostedToken(
  ChainId.Base,
  '0xYourVaultAddress',
  18,
  'mwETH',
  'Morpho Wrapped ETH',
  WETH // underlying token
);

// A BoostedRoute automatically handles the wrap/unwrap steps
const boostedRoute = new BoostedRoute([pool], USDC, mwETH);

ABIs

The package exports the contract ABIs for direct use with ethers.js or viem:

import { hydrexSwapRouterABI, hydrexPositionManagerABI, selfPermitABI } from '@hydrex/sdk';

Constants

import {
  ChainId,
  POOL_DEPLOYER_ADDRESSES,
  POOL_INIT_CODE_HASH,
  WNATIVE,
  ADDRESS_ZERO,
  INITIAL_POOL_FEE,
  DEFAULT_TICK_SPACING,
} from '@hydrex/sdk';

// Base mainnet WETH (0x4200000000000000000000000000000000000006)
const weth = WNATIVE[ChainId.Base];

// Hydrex Base mainnet deployment
const deployer = POOL_DEPLOYER_ADDRESSES[ChainId.Base];
// => 0x1595A5D101d69D2a2bAB2976839cC8eeEb13Ab94

const initCodeHash = POOL_INIT_CODE_HASH[ChainId.Base];
// => 0xa18736c3ee97fe3c96c9428c0cc2a9116facec18e84f95f9da30543f8238a782

Development

# Install dependencies
npm install      # or: yarn

# Build
npm run build    # or: yarn build

# Watch mode
npm start        # or: yarn start

# Lint
npm run lint     # or: yarn lint

License

MIT © Hydrex