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/junior

v1.0.0

Published

TypeScript SDK for the Reflect Liquid Protection (RLP) program, powering junior tranche of Reflect's two-tranche protection system.

Readme

@reflectmoney/junior

TypeScript SDK for the Reflect Liquid Protection (RLP) Solana program — the junior tranche of Reflect's two-tranche stablecoin protection system.

Wraps Codama-generated instruction builders and provides higher-level helpers for pool lifecycle, deposits, cooldown-gated withdrawals, NAV-based slashing, and admin operations.


Install

npm install @reflectmoney/junior @solana/kit

Peer expectations: a @solana/kit Rpc<SolanaRpcApi> for read paths, and a TransactionSigner for writes.


Quick start

import { createSolanaRpc } from "@solana/kit";
import { JuniorTranche, PdaClient } from "@reflectmoney/junior";

const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const juniorTranche = new JuniorTranche(rpc);
await juniorTranche.load();

// Deposit into liquidity pool 0
const ix = await juniorTranche.deposit(
  signer,
  1_000_000_000n,  // amount in raw asset units
  USDC_MINT,
  0,               // liquidity pool id
  null,            // minLpTokens slippage guard (null = no minimum)
);

What this SDK covers

Pool lifecycle (admin)

| Method | Notes | | --- | --- | | initializeRlp(signer, swapFeeBps) | One-time program bootstrap. | | addAsset(signer, mint, oracle, accessLevel) | Whitelist a deposit/swap asset. | | updateOracle(signer, assetMint, newOracle) | Rotate an asset's Pyth feed. | | initializeLiquidityPool(signer, lpToken, cooldownDuration, assets, protectedVault?) | Create a pool. protectedVault opts the pool into NAV-based slashing (audit-M06). | | initializePoolReserve(signer, liquidityPoolId, assetMint) | Pre-create the pool's ATA for a whitelisted asset. Idempotent. | | forceRemoveAsset(signer, liquidityPoolId, assetMint) | Recovery path for a pool reserve that has been permanently frozen by the mint authority (audit-M02). | | updateDepositCap(signer, liquidityPoolId, newCap) | Set or clear per-pool deposit cap. |

User flow

| Method | Notes | | --- | --- | | deposit(signer, amount, mint, liquidityPoolId, minLpTokens?) | Mints LP tokens proportional to NAV. minLpTokens is a slippage guard. | | requestWithdrawal(signer, liquidityPoolId, amount) | Burns LP tokens and opens a per-pool cooldown account. | | withdraw(signer, liquidityPoolId, cooldownId) | Settles a matured cooldown. Excess LP tokens (if pool grew during cooldown) are refunded automatically (audit-1). | | swap(signer, liquidityPoolId, tokenFrom, tokenTo, amountIn, minOut?) | Oracle-priced rebalance between pool assets. |

Slashing (NAV-based — audit-M06)

| Method | Notes | | --- | --- | | slash(signer, liquidityPoolId, assetMint, proxyState, maxAmount) | RLP (junior) covers losses of the senior proxy tranche. Pool must have been initialized with a protectedVault. The instruction computes loss = max(0, principal + integratorsCommission − vaultValue) from the ProxyState account and transfers up to maxAmount of assetMint into the proxy vault. |

The legacy operator-discretion slash has been removed.

Permissions

| Method | Notes | | --- | --- | | createPermissionAccount(signer, target) | Create a user-permissions PDA. | | updateRoleHolder(signer, target, role, add) | Grant/revoke a role for a user. | | updateActionRole(signer, action, role, add) | Bind an action (Deposit/Withdraw/Swap/Slash/etc.) to a role. Slash cannot be assigned to Role.PUBLIC. |

PDAs

PdaClient exposes pure helpers:

const [settings]         = await PdaClient.deriveSettings();
const [permissions]      = await PdaClient.deriveUserPermissions(user);
const [pool]             = await PdaClient.deriveLiquidityPool(0);
const [asset]            = await PdaClient.deriveAsset(mint);
const [cooldown]         = await PdaClient.deriveCooldown(poolId, cooldownId);
const [eventAuthority]   = await PdaClient.deriveEventAuthority();
const [proxyState]       = await PdaClient.deriveProxyState(brandedMint);

Audit fixes in this release

The SDK is aligned with the integrated audit-fixes branch. Notable behavioral changes that callers may need to know about:

  • NAV-based slash replaces the operator-discretion slash. Call signature is different — see above.
  • initializeLiquidityPool accepts protectedVault. Pass null for a pool that is not protecting any proxy vault. Pass the proxy state PDA otherwise.
  • withdraw refunds excess LP tokens. No caller change, but the on-chain math now redeems against the current NAV at withdraw time, capped by what the cooldown originally locked.
  • Action.Slash is not publicly assignable. Attempting updateActionRole(Action.Slash, Role.PUBLIC, …) is rejected by the program.
  • forceRemoveAsset + initializePoolReserve are new admin wrappers for the frozen-pool-reserve recovery path.
  • Cooldowns are now per-pool (a separate counter on each LiquidityPool rather than the program-wide settings counter).

Development

npm install
npm run build          # tsc → dist/
npm test               # mocha + litesvm + the in-tree rlp.so

The test suite uses LiteSVM and loads ../target/deploy/rlp.so, so make sure the program is built (anchor build or cargo-build-sbf) before running.

npm publish runs prepublishOnly which cleans dist, rebuilds, and runs the test suite — publish will fail if any of those steps fail.