@meridianprotocol/sdk
v0.3.0
Published
TypeScript SDK for Meridian Protocol: AI Analyst pre-deal structuring + prospectus validation, plus onchain settlement rails on Avalanche
Downloads
232
Maintainers
Readme
@meridianprotocol/sdk
TypeScript SDK for Meridian Protocol. Two surfaces in one package:
- Analyst (the licensable rails): a dependency-free HTTP client for the AI Analyst API. Structure and stress-test an ABS pool, and validate a prospectus against the engine, before any deal is issued.
- Onchain: typed contract addresses, ABIs, and shared constants for the protocol on Avalanche. Where a structured deal settles.
Install
npm install @meridianprotocol/sdk viemviem ^2.0.0 is a peer dependency, used only by the onchain surface. The Analyst client has no runtime dependencies. Works in plain Node ESM (>= 18), Next.js, Vite, Deno, and any modern bundler.
Analyst
The Analyst surface is a thin client over the hosted analyst API. It runs the same deterministic structuring + stress engine and the same prospectus validator the Meridian Workbench uses. No viem needed, no onchain calls: this is the pre-deal layer.
import { AnalystClient, type PoolInput } from "@meridianprotocol/sdk";
const analyst = new AnalystClient(); // defaults to https://app.meridianprotocol.xyz
const pool: PoolInput = {
assetClass: "solar-loans",
poolSize: 5_000_000,
numLoans: 420,
grossCouponPct: 11.5, // percents are whole numbers (11.5 = 11.5%)
termYears: 7,
annualDefaultRatePct: 3.5,
recoveryRatePct: 45,
servicingFeePct: 1.25,
ltvPct: 70,
};
// 1. Structure + stress the pool.
const analysis = await analyst.analyzePool(pool);
for (const t of analysis.tranches) {
// engine ratios come back as decimals (0.06 = 6%)
console.log(t.name, "size", t.size, "apr", t.apr, "breakeven", t.returnBreakevenPoolRate);
}
// 2. Validate a deal document against the engine.
const { claim, diff } = await analyst.validateProspectus(
"Class A Notes 78% ... Class B 14% ... Class C (residual) 8% ... AAA / BBB ..."
);
console.log("aligned:", diff.overallAligned);
for (const d of diff.diffs) {
console.log(d.field, "claimed", d.claimed, "engine", d.engine, d.aligned ? "ok" : d.note);
}Functional helpers (no instance needed) and a configurable base URL are also available:
import { analyzePool, validateProspectus } from "@meridianprotocol/sdk";
const a = await analyzePool(pool, { baseUrl: "https://staging.meridianprotocol.xyz", apiKey: "..." });
const v = await validateProspectus(text);Full request/response shapes: see ANALYST_API.md.
From source (contributors)
The protocol repo is private during the pre-mainnet phase. Contributors with repo access:
cd meridianprotocol/sdk
npm install
npm run buildWhat's exported
| Export | Purpose |
|---|---|
| AnalystClient, analyzePool, validateProspectus | Analyst API client + functional helpers |
| PoolInput, AnalysisResult, TrancheResult, ProspectusClaim, ProspectusDiff, ProspectusValidation | Analyst type shapes |
| DEFAULT_ANALYST_BASE_URL, AnalystApiError | Analyst defaults + typed error |
| ADDRESSES[chainId] | Per-chain map of every deployed contract (Fuji = 43113) |
| ChainId, ContractName | Type helpers derived from ADDRESSES |
| MAX_PROTOCOL_FEE_BPS, BPS_DENOMINATOR | Protocol-wide constants |
| *Abi (e.g. ForgeFactoryAbi, CDSPoolAbi) | viem-compatible ABIs for all 19 user-facing contracts |
Full export list: see src/index.ts.
Onchain quick start
import { createPublicClient, http } from "viem";
import { avalancheFuji } from "viem/chains";
import { ADDRESSES, ForgeFactoryAbi } from "@meridianprotocol/sdk";
const client = createPublicClient({ chain: avalancheFuji, transport: http() });
const vaultCount = await client.readContract({
address: ADDRESSES[43113].forgeFactory,
abi: ForgeFactoryAbi,
functionName: "vaultCount",
});Coverage
The SDK ships ABIs for every contract in the public surface area:
- Forge (tranched credit):
ForgeFactory,ForgeVault - Shield (CDS):
ShieldFactory,CDSContract,CDSPool,CDSPoolFactory - Nexus (cross-chain margin):
NexusHub,NexusVault,HedgeRouter - Yield:
YieldVault,YieldVaultFactory,StrategyRouter - AI layer:
AIAnalyst - Secondary market:
SecondaryMarketRouter - Tokens / utilities:
MockUSDC,ERC20
For full deployed addresses, see docs/deployed-addresses.md in the main repo.
Versioning
Pre-1.0. Breaking changes are possible until the protocol is mainnet-deployed and the SDK surface is locked. Pinning to a specific version is recommended.
License
MIT
