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

@ekubo/yul-router-sdk

v0.8.0

Published

Constructs swap transaction calldata and price quotation calldata for the Ekubo Yul Router on EVM chains

Downloads

1,934

Readme

@ekubo/yul-router-sdk

Builds the packed swap calldata for the Ekubo Yul Router on EVM chains, and the calldata for reading a price quotation for that same route.

The router takes custom packed calldata rather than a conventional ABI-encoded function call. This SDK is what produces those bytes: you describe a route as a list of hops, and it returns the 0x… calldata to send to the router address.

Installation

npm install @ekubo/yul-router-sdk
# or
bun add @ekubo/yul-router-sdk

viem is a peer dependency.

Constructing a swap transaction

encodeRoutes(...) / generateCalldata(...) take a set of multi-hops and return the calldata for the swap. Every multi-hop starts from the same specifiedToken and ends at the same calculatedToken; the router executes them all under one Core lock, aggregates the amounts, applies a single slippage check, and settles once.

import { generateCalldata, YUL_ROUTER_ADDRESS } from "@ekubo/yul-router-sdk";

const data = generateCalldata({
  multiHops: [
    {
      specifiedAmount: 10n ** 18n,
      hops: [{ poolKey, sqrtRatioLimit: MIN_SQRT_RATIO }],
    },
  ],
  specifiedToken: tokenIn,
  calculatedToken: tokenOut,
  calculatedAmountThreshold: minimumOut, // required; guards slippage
  recipient,
});

// Send with any EVM client:
await walletClient.sendTransaction({ to: YUL_ROUTER_ADDRESS, data, value });

calculatedAmountThreshold is mandatory — a positive minimum output for exact-input routes, a negative maximum input for exact-output. Omitting it throws rather than silently encoding an unbounded slippage threshold.

Exact-input amounts are positive; exact-output amounts are negative.

Obtaining a price quotation

generateQuoteCalldata(...) / encodeQuoteCalldata(...) produce the calldata for the router's quote(bytes) entrypoint, which runs the identical route inside a Core lock and returns the resulting amounts without settling. No token balance and no approval are required, and all pool and extension state changes are rolled back.

import { generateQuoteCalldata } from "@ekubo/yul-router-sdk";

const data = generateQuoteCalldata({ multiHops, specifiedToken, calculatedToken });
const { data: result } = await publicClient.call({ to: YUL_ROUTER_ADDRESS, data });
// decodes to (specifiedToken, calculatedToken, specifiedAmount, calculatedAmount)

Direct execution, forwarding, and quoting all return the same four-word tuple for the same route and starting state, so a quotation and the swap built from it stay byte-for-byte comparable.

Hop types

| Hop | Use | |---|---| | CoreHop | A swap against an Ekubo Core pool | | ForwardedHop | A swap routed through an extension's forward callback | | SignedExclusiveSwapHop | A swap filled against a signed exclusive quote | | WrapperHop | A token wrap or unwrap step |

Also exported

  • encodeRoute(...) — encode a single route body
  • encodeSignedSwapMeta(...) — encode the metadata for a signed exclusive swap
  • encodePoolBalanceUpdate(...) — encode a pool balance delta
  • calldataSize(...) — byte length of encoded calldata
  • YUL_ROUTER_ADDRESS, YUL_ROUTER_ABI, and the sqrt-ratio and threshold bounds

License

See the repository.