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

meng-lending-sdk

v0.1.5

Published

TypeScript SDK for MetEngine Lending

Readme

meng-lending-sdk

TypeScript SDK for the MetEngine Lending Protocol on Solana. Built on @solana/kit.

Installation

npm install meng-lending-sdk @solana/kit

Fetch & Decode Accounts

The SDK provides codegen fetch helpers and hand-written parsers that decode Pod types into native JS values.

import { fetchLendingReserve, parseLendingReserve } from "meng-lending-sdk"

const reserve = await fetchLendingReserve(rpc, reserveAddress)

const parsed = parseLendingReserve(accountData)
parsed.supplyExchangePrice
parsed.collateralFactorBps
parsed.totalSupplyRaw

Available parsers: parseProtocolState, parseLendingMarket, parseLendingReserve, parseUserAccount, parseRegisteredPool, parseEmissionConfig, parseUserEmission

PDA Derivation

import { getMarketPda, getReservePda, getUserAccountPda, encodeMarketName } from "meng-lending-sdk"

const [marketAddress] = await getMarketPda(encodeMarketName("main"))
const [reserveAddress] = await getReservePda(marketAddress, usdcMint)
const [userAccountAddress] = await getUserAccountPda(marketAddress, walletAddress)

Available: getProtocolPda, getMarketPda, getReservePda, getUserAccountPda, getRegisteredPoolPda, getEmissionConfigPda, getUserEmissionPda

Build Instructions

All instructions are generated from the IDL. Each has a sync and async variant (async resolves PDAs automatically).

Deposit Liquidity

import { getDepositReserveLiquidityInstruction } from "meng-lending-sdk"

const ix = getDepositReserveLiquidityInstruction({
  market: marketAddress,
  reserve: reserveAddress,
  liquidityVault,
  receiptMint,
  depositMint,
  userLiquidity: userTokenAccount,
  userReceipt: userReceiptAccount,
  depositor: signer,
  amount: 1_000_000n,
})

Redeem Liquidity

import { getRedeemReserveLiquidityInstruction } from "meng-lending-sdk"

const ix = getRedeemReserveLiquidityInstruction({
  market: marketAddress,
  reserve: reserveAddress,
  liquidityVault,
  receiptMint,
  depositMint,
  userLiquidity: userTokenAccount,
  userReceipt: userReceiptAccount,
  depositor: signer,
  receiptAmount: 500_000n,
})

Deposit Collateral & Borrow

import {
  getInitUserAccountInstructionAsync,
  getDepositCollateralInstruction,
  getBorrowLiquidityInstruction,
} from "meng-lending-sdk"

const initIx = await getInitUserAccountInstructionAsync({
  market: marketAddress,
  owner: signer,
})

const depositIx = getDepositCollateralInstruction({
  market: marketAddress,
  collateralReserve: reserveAddress,
  userAccount: userAccountAddress,
  liquidityVault,
  userCollateral: userTokenAccount,
  depositMint,
  owner: signer,
  amount: 1_000_000n,
})

const borrowIx = getBorrowLiquidityInstruction({
  market: marketAddress,
  borrowReserve: reserveAddress,
  userAccount: userAccountAddress,
  liquidityVault,
  userLiquidity: userTokenAccount,
  depositMint,
  owner: signer,
  amount: 500_000n,
})

Repay & Withdraw

import {
  getRepayLiquidityInstruction,
  getWithdrawCollateralInstruction,
} from "meng-lending-sdk"

const repayIx = getRepayLiquidityInstruction({
  market: marketAddress,
  repayReserve: reserveAddress,
  userAccount: userAccountAddress,
  liquidityVault,
  payerLiquidity: payerTokenAccount,
  depositMint,
  accountOwner: ownerAddress,
  payer: signer,
  amount: 500_000n,
})

const withdrawIx = getWithdrawCollateralInstruction({
  market: marketAddress,
  collateralReserve: reserveAddress,
  userAccount: userAccountAddress,
  liquidityVault,
  userCollateral: userTokenAccount,
  depositMint,
  owner: signer,
  amount: 1_000_000n,
})

Flash Loans

import {
  getFlashBorrowReserveLiquidityInstruction,
  getFlashRepayReserveLiquidityInstruction,
} from "meng-lending-sdk"

const borrowIx = getFlashBorrowReserveLiquidityInstruction({
  market: marketAddress,
  reserve: reserveAddress,
  liquidityVault,
  depositMint,
  userLiquidity: userTokenAccount,
  borrower: signer,
  amount: 10_000_000n,
})


const repayIx = getFlashRepayReserveLiquidityInstruction({
  market: marketAddress,
  reserve: reserveAddress,
  liquidityVault,
  feeVault,
  depositMint,
  userLiquidity: userTokenAccount,
  borrower: signer,
  amount: 10_000_000n,
})

Liquidation

import {
  getLiquidateUserAccountInstruction,
  calculateLiquidationBonusBps,
  maxRepayValueForTargetHf,
} from "meng-lending-sdk"

const bonus = calculateLiquidationBonusBps(healthFactorBps, minBonus, maxBonus, hfForMaxBonus)
const maxRepay = maxRepayValueForTargetHf(collateralValue, debtValue, bonus, cfBps, targetHf, dust)

const ix = getLiquidateUserAccountInstruction({
  market: marketAddress,
  repayReserve,
  collateralReserve,
  userAccount: unhealthyAccount,
  repayVault,
  collateralVault,
  liquidatorRepay: liquidatorRepayAccount,
  liquidatorCollateral: liquidatorCollateralAccount,
  repayMint,
  collateralMint,
  insuranceVault,
  accountOwner: accountOwnerAddress,
  liquidator: signer,
  repayAmount: BigInt(maxRepay),
})

Emission Rewards

import { getClaimEmissionRewardsInstruction } from "meng-lending-sdk"

const ix = getClaimEmissionRewardsInstruction({
  market: marketAddress,
  reserve: reserveAddress,
  emissionConfig,
  userEmission,
  emissionVault,
  userReceipt: userReceiptAccount,
  userRewardAccount,
  emissionMint,
  user: signer,
})

Math Utilities

Client-side math that mirrors on-chain calculations.

import {
  calculateHealthFactor,
  utilizationBps,
  calculateAdaptiveBorrowRate,
  accrueInterest,
  tokenValueUsd,
} from "meng-lending-sdk"

const hf = calculateHealthFactor(userAccount.totalCollateralValue, userAccount.totalDebtValue)

const util = utilizationBps(
  reserve.totalSupplyRaw, reserve.totalBorrowRaw,
  reserve.supplyExchangePrice, reserve.borrowExchangePrice,
)

const { borrowRateBps } = calculateAdaptiveBorrowRate(util, reserve.rateModel, reserve.rateAtTargetBps, 60)

const result = accrueInterest(
  reserve.supplyExchangePrice, reserve.borrowExchangePrice,
  reserve.totalSupplyRaw, reserve.totalBorrowRaw,
  BigInt(borrowRateBps), 3600n, waterfallConfig,
)

Constants

import {
  MENG_LEND_PROGRAM_ADDRESS,
  EXCHANGE_PRICE_PRECISION,
  BPS,
  ReserveStatus,
  MAX_USER_COLLATERAL,
  MAX_USER_DEBT,
} from "meng-lending-sdk"

License

MIT