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

@lista-dao/moolah-sdk-core

v1.0.3

Published

Core types, pure calculation functions, and utilities for the Moolah lending protocol.

Readme

@lista-dao/moolah-sdk-core

Core types, pure calculation functions, and utilities for the Moolah lending protocol.

Installation

pnpm add @lista-dao/moolah-sdk-core

Overview

This package provides the foundation for all Moolah SDK packages:

  • Types - Protocol types for markets, vaults, loans, and operations
  • Calculations - Pure functions for LTV, rates, positions (no chain interaction)
  • Contracts - ABIs and contract addresses
  • Utilities - Decimal/Fraction for safe fixed-point math

Exports

Decimal & Fraction

BigInt-backed fixed-point arithmetic to avoid floating-point precision issues.

import { Decimal, Fraction, RoundingMode } from "@lista-dao/moolah-sdk-core";

// Parse values
const amount = Decimal.parse("123.456", 18);

// Arithmetic
amount.add(10).mul(2).div(3);

// Rounding
amount.dp(2, RoundingMode.ROUND); // 123.46

// Format
amount.toString(2); // "123.46" (trims zeros)
amount.toFixed(4); // "123.4560"
amount.toFormat(2); // "123.46" (with commas for large numbers)

// Comparison
amount.gt(100); // true
amount.eq(123.456); // true

Position Calculations

import {
  computeLTV,
  computeLoanable,
  computeWithdrawable,
  getExtraRepayAmount,
  computeLiquidationPrice,
  simulateBorrow,
  simulateRepay,
} from "@lista-dao/moolah-sdk-core";

// Calculate current LTV
const ltv = computeLTV({
  collateral: 1000000000000000000n, // 1 ETH collateral
  borrowed: 500000000n, // 500 USDC borrowed
  priceRate: 2000000000000000000000n, // ETH = 2000 USDC
});

// Simulate a borrow operation
const result = simulateBorrow({
  collateral: 1000000000000000000n,
  borrowed: 0n,
  priceRate: 2000000000000000000000n,
  lltv: 800000000000000000n, // 80% LLTV
  supplyAmount: 500000000000000000n, // Adding 0.5 ETH
  borrowAmount: 500000000n, // Borrowing 500 USDC
});
// result: { newLTV, newLiqPrice, newLoanable, newWithdrawable, ... }

Interest Rate Calculations

import {
  computeBorrowRate,
  getBorrowRateInfo,
  getAnnualBorrowRate,
  getApy,
  getInterestRates,
} from "@lista-dao/moolah-sdk-core";

// Get annual borrow rate from per-second rate
const annualRate = getAnnualBorrowRate(ratePerSecond);

// Get comprehensive rate info
const rateInfo = getBorrowRateInfo({
  totalBorrowAssets,
  totalSupplyAssets,
  irm: { curve1, curve2 },
});

// Generate rate curve for charts
const curve = getInterestRates({
  totalBorrowAssets,
  totalSupplyAssets,
  irm: { curve1, curve2 },
  steps: 100,
});

Vault Simulation

import {
  simulateVaultDeposit,
  simulateVaultWithdraw,
  Decimal,
} from "@lista-dao/moolah-sdk-core";

// Simulate vault deposit (user balance → locked in vault)
const depositResult = simulateVaultDeposit({
  depositAmount: Decimal.parse("100", 18),
  userLocked: Decimal.parse("500", 18),
  userBalance: Decimal.parse("1000", 18),
  apy: Decimal.parse("0.05", 18), // optional, for earnings projection
  assetPrice: Decimal.parse("1", 18), // optional
});
// depositResult: { locked, balance, yearlyEarnings?, monthlyEarnings? }

// Simulate vault withdraw
const withdrawResult = simulateVaultWithdraw({
  withdrawAmount: Decimal.parse("100", 18),
  userLocked: Decimal.parse("500", 18),
  userBalance: Decimal.parse("200", 18),
});
// withdrawResult: { locked, balance, yearlyEarnings?, monthlyEarnings? }

Loan Calculations

import {
  calculateDynamicLoanRepayment,
  calculateFixedLoanRepayment,
  normalizeAprRate,
} from "@lista-dao/moolah-sdk-core";

// Calculate fixed-term loan repayment
const repayment = calculateFixedLoanRepayment({
  principal,
  apr,
  durationDays,
});

Types

import type {
  // Network
  NetworkName, // 'bsc' | 'ethereum'

  // Tokens
  TokenInfo,

  // Markets
  MarketInfo,
  MarketExtraInfo,
  WriteMarketConfig,

  // Vaults
  VaultInfo,
  VaultMetadata,

  // Smart Markets
  SmartMarketExtraInfo,
  WriteSmartMarketConfig,

  // Broker
  BrokerUserPositionsData,
  FixedTermAndRate,
  BrokerInfo,

  // Operations
  BuiltSupplyOperation,
  BuiltBorrowOperation,
  BuiltRepayOperation,
  // ... more
} from "@lista-dao/moolah-sdk-core";

Contract ABIs & Addresses

import {
  MOOLAH_ABI,
  MOOLAH_VAULT_ABI,
  INTEREST_RATE_MODEL_ABI,
  ERC20_ABI,
  getContractAddress,
  getContractAddressOptional,
} from "@lista-dao/moolah-sdk-core";

// Get contract address
const moolahAddress = getContractAddress("bsc", "moolah");

Network Utilities

import {
  getApiChain,
  getListaApiUrl,
  getNativeCurrencySymbol,
  isUsdtLikeToken,
} from "@lista-dao/moolah-sdk-core";

// Get API chain identifier (for list APIs)
const apiChain = getApiChain("bsc"); // "bsc"

// Get API URL
const url = getListaApiUrl("prod"); // "https://api.lista.org"

Package Architecture

This is a zero-dependency core package (except for Morpho SDK for interest calculations). It's designed to be:

  • Pure - No side effects, all functions are deterministic
  • Portable - Works in Node.js, browsers, and serverless
  • Type-safe - Full TypeScript support
moolah-sdk-core/
├── calculations/
│   ├── position.ts     # LTV, loanable, withdrawable (bigint)
│   ├── interestRate.ts # Borrow rates, APY
│   ├── stablepool.ts   # Stable swap / LP math
│   └── loan.ts         # Loan repayment calculations
├── simulate/
│   ├── market.ts       # simulateMarketBorrow, simulateMarketRepay
│   ├── vault.ts        # simulateVaultDeposit, simulateVaultWithdraw
│   └── smart.ts        # Smart market simulate + LP breakdown
├── contracts/
│   ├── abis/           # Contract ABIs
│   └── config.ts       # Contract addresses
├── types/
│   ├── market.ts       # Market types
│   ├── vault.ts        # Vault types
│   ├── smart.ts        # Smart market types
│   ├── broker.ts       # Broker types
│   └── operations.ts   # Operation result types
└── utils/
    ├── decimal.ts      # Decimal class
    ├── fraction.ts    # Fraction class
    ├── apiChain.ts     # getApiChain, getListaApiUrl
    └── network.ts      # getNativeCurrencySymbol

License

MIT