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

@reflectmoney/tranches

v1.0.0

Published

SDK for orchestrating Reflect Tranches (senior/junior) using Proxy Program and RLP

Readme

@reflectmoney/tranches

TypeScript SDK for orchestrating Reflect Tranches on Solana. Wraps the on-chain Proxy Program (senior tranche) and RLP (junior tranche) into a single high-level surface: deposit, withdraw, simulate, build address lookup tables, and discover existing tranches.

For pure exchange-rate math (designed to be called from another Solana program), see the Rust companion crate tranche-rate-sdk.

Install

npm install @reflectmoney/tranches

Peer requirements:

  • @solana/kit ^6.8
  • @reflectmoney/whitelabel ^1.0
  • @reflectmoney/insurance (published as a sibling)

Quick start

Construct a Tranches orchestrator

import { createSolanaRpc, address } from "@solana/kit";
import { Tranches } from "@reflectmoney/tranches";

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");

const tranches = new Tranches(rpc, {
  stablecoinMint: address("..."),  // underlying base asset (e.g. USDC+)
  seniorMint:     address("..."),  // senior tranche token mint
  juniorMint:     address("..."),  // junior tranche LP mint
});

await tranches.load();

Deposit and withdraw

// Senior tranche: stablecoin in → senior tokens out
const seniorDepositIxs = await tranches.depositSenior(
  user,                // TransactionSigner
  1_000_000,           // raw amount of stablecoin
  0,                   // minimum senior tokens (slippage protection)
);

// Junior tranche: stablecoin in → LP tokens out
const juniorDepositIxs = await tranches.depositJunior(user, 1_000_000);

// Senior tranche: senior tokens in → stablecoin out (immediate)
const seniorWithdrawIxs = await tranches.withdrawSenior(user, 500_000, 0);

// Junior tranche: two-step (cooldown)
const requestIx = await tranches.requestWithdrawJunior(user, 500_000);
// ...wait for cooldown to elapse on chain...
const withdrawIxs = await tranches.withdrawJunior(user, cooldownId);

Each call returns one or more Instructions — assemble them into a v0 transaction yourself.

Simulate before sending

// Senior:
const wrap = await tranches.simulateSeniorDeposit(1_000_000);
// → { outputAmount, newPrincipal, newIntegratorsCommission }

const unwrap = await tranches.simulateSeniorWithdraw(500_000);

// Junior:
const lpMinted = await tranches.simulateJuniorDeposit(1_000_000);

const breakdown = await tranches.simulateJuniorWithdraw(500_000);
// → [{ mint, amount }, ...]

The simulation math mirrors the on-chain logic exactly (dynamic virtual offset, oracle dispatch, settlement/crank).

Discovery

import { Tranches } from "@reflectmoney/tranches";

// List every senior + junior tranche on chain:
const all = await Tranches.getAllTranches(rpc);

// Filter to tranches that hold a specific asset:
const usdcPlus = await Tranches.getTranchesByAsset(rpc, address("..."));

// Detailed stats for one tranche pair:
const seniorStats = await tranches.getSeniorTrancheStats();
const juniorStats = await tranches.getJuniorTrancheStats();

Address lookup tables

The full deposit/withdraw paths touch ~12–16 accounts (more for multi-asset junior pools). To fit into a v0 transaction, build a LUT once:

const {
  lookupTableAddress,
  createInstruction,
  extendInstructions,
} = await tranches.createLookupTable(payer);

// Send `createInstruction` first, then each `extendInstructions[i]` —
// each extend is sized to fit in one tx.

Crank operations

For protocol-side rebalancing:

// Route senior commission to junior pool:
const ixs = await tranches.routeYield(crankAuthority, amount);

// Slash junior pool to top up senior vault:
const ixs = await tranches.slashAndRestore(crankAuthority, amount);

// Burn LP held by authority to boost junior rate:
const ix = await tranches.burnAuthorityLpTokens(authority, amount);

Setup operations

initializeSeniorTranche and initializeJuniorTranche create new tranches end-to-end (transfer mint authority, register the pool, build the vault ATAs). See JSDoc on those methods.

License

MIT.