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

@odatano/defi

v0.5.0

Published

Cardano DeFi protocol constants and datum decoders: pure functions from on-chain CBOR to typed records

Readme

@odatano/defi

Cardano DeFi protocols as data: the deployed script hashes and policies, and pure functions that turn an output's datum and value into a typed record. No network, no database, no framework; @harmoniclabs/plutus-data reads the CBOR.

npm install @odatano/defi
import { minswapV2PoolState, sundaeV3PoolState, decodeFluidLoanDatum, decodeLiqwidMarketState, decodeIndigoCdp } from '@odatano/defi';

const pool = minswapV2PoolState({ datum, value: [{ unit: 'lovelace', quantity: '4999452955' }, ...] });
// { protocol: 'minswap-v2', poolId, assetA, assetB, reserveA, reserveB, lpSupply, feeBps }

Every decoder takes the datum as CBOR hex and returns null when the bytes are not that datum, so one address with several datum shapes can be filtered without exceptions. Amounts are bigint in the smallest unit of the asset; timestamps are milliseconds.

Protocols

| Protocol | Constants | Decoders | | --- | --- | --- | | Minswap V1 | MINSWAP_V1_CONFIG (pool and order script, pool NFT and LP policy, factory token) | decodeMinswapV1PoolDatum, minswapV1PoolState (reserves from the value; the pool NFT name is the pool id; fixed 0.3 % fee), decodeMinswapV1OrderDatum, minswapV1Order (names no pool: a swap offers what the value holds besides the wanted asset; the owner is the sender) | | Minswap V2 | MINSWAP_V2_CONFIG (pool, order, factory, LP policy, pool NFT per network) | decodeMinswapV2PoolDatum, minswapV2PoolState (needs the pool NFT and exactly one LP token in the value; the LP token name is the pool id), decodeMinswapV2OrderDatum, minswapV2Order (every order step; a swap's offered asset comes from the value by direction) | | SundaeSwap V3 | SUNDAE_V3_CONFIG (pool, order, settings, manager; the pool script mints the pool NFT and LP tokens) | decodeSundaeV3PoolDatum, sundaeV3PoolState (reserves from the value, protocol fees netted out of the ADA side; the pool identifier is the pool id), decodeSundaeV3OrderDatum, sundaeV3Order | | SundaeSwap V4 | SUNDAE_V4_CONFIG (pool, order and settings script, pool NFT and LP policy, the constant-sum and stableswap modules) | decodeSundaeV4PoolDatum, sundaeV4Curve (constant sum or stableswap, from the module that leads an enabled action), sundaeV4PoolState (reserves from the datum, pools of two assets), sundaeV4CurveConfig (fees, prices and rates: the datum keeps only their hash, the configuration with that hash is found in the redeemers of the transaction that created the state), sundaeV4Price (second asset per first at the margin, before the fee) | | WingRiders V2 | WINGRIDERS_V2_CONFIG (constant product and stableswap pools and requests, factory, LP policy) | decodeWingRidersV2PoolDatum, wingRidersV2PoolState (reserves from the value minus the treasuries and the 3 ADA minimum; LP supply is the maximum minus what the pool holds), decodeWingRidersV2RequestDatum, wingRidersV2Order (names the pool by its asset pair) | | FluidTokens Lending V3 | FLUIDTOKENS_V3_CONFIG (validators and policies of the mainnet deployment) | decodeFluidPoolDatum, decodeFluidLoanDatum, decodeFluidConfigDatum | | Liqwid v2 | LIQWID_MARKETS (market id, MarketState script, underlying asset and decimals per live market), liqwidMarketByCredential | decodeLiqwidMarketState, liqwidTotalSupplied, liqwidUtilization, liqwidQTokenRate | | Djed | DJED_CONFIG (DJED, SHEN and reserve NFT units, the pre-minted supply) | djedReserveState (reserve ADA and DJED and SHEN in circulation from the value of the reserve UTxO), djedReserveRatioPct | | RealFi | REALFI_CONFIG (USDrf and sUSDrf units, staking vault, treasury, order and yield oracle scripts with their NFTs) | decodeRealFiVaultDatum, realFiVaultState (USDrf held, sUSDrf supply and the running reward of the vault UTxO), realFiStakedUsdrf, realFiStakeRate (USDrf per sUSDrf at a point in time), realFiTreasuryState (USDrf supply) | | Indigo | INDIGO_CONFIG (current and former CDP validators, CDP token, stability pools) | decodeIndigoCdp (every CDP layout so far; the iAsset registry entry at the same script decodes to null) |

STABLECOINS lists the mainnet stablecoins with policy, asset name, decimals, peg and backing.

PoolState is the shape every DEX decoder maps to, so a consumer can aggregate pools of different DEXes together: protocol, poolId, assetA, assetB, reserveA, reserveB, lpSupply, feeBps. poolPrice gives A per B in smallest units, adaUsdOfPool the dollars per ADA an ADA / stablecoin pool implies, median folds several of those into one.

Helpers

decodeData, fields, int, num, bytes, list, option, bool, credential, address and asset read PlutusData the way Aiken encodes it (Option as Constr 0/1, Bool as Constr 0/1, Credential as Constr 0 key / Constr 1 script, assets as Constr 0 [policy, name]). They return null instead of throwing, so a decoder is a chain of reads with one check at the end.

Tests

npm test runs the decoders against outputs read from mainnet (test/fixtures.ts, test/fixtures-dex.ts, test/fixtures-orders.ts, test/fixtures-hash.ts, test/fixtures-realfi.ts, test/fixtures-sundae-v4.ts), field by field against the published layouts and against on-chain invariants (LP supply plus the pool's LP holding is the maximum; Liqwid's rate times its qToken supply is the total supplied).

License

Apache License 2.0, see LICENSE.