@wagrlabs/sdk
v0.1.1
Published
WAGR TypeScript SDK -- Solana prediction market client + LMSR helpers + UMA-style optimistic oracle hooks.
Maintainers
Readme
@wagrlabs/sdk
TypeScript SDK for the WAGR prediction market standard on Solana.
npm i @wagrlabs/sdkWhat is in here
import { WagrClient, WAGR_PROGRAM_ID, lmsr, oracle } from "@wagrlabs/sdk";WagrClient-- read / write client for the Anchor program. Wallet adapter agnostic.lmsr-- Hanson (2003) LMSR pricing helpers (lmsrCost,lmsrPrice,lmsrBuyQuote,lmsrSellQuote,lmsrMaxLoss,lmsrPriceVector). Numerically stablelogSumExp.oracle-- UMA-style optimistic resolution state machine + multi-source consensus aggregator.WAGR_PROGRAM_ID-- the Anchor program id (devnet today, mainnet pending).
Example
import { lmsr } from "@wagrlabs/sdk";
// A binary YES/NO market with liquidity b = 1000 and no shares sold yet.
const qs = [0, 0];
const b = 1000;
console.log(lmsr.lmsrPriceVector(qs, b)); // [0.5, 0.5]
console.log(lmsr.lmsrBuyQuote(qs, b, 0, 100)); // cost to buy 100 YES shares
console.log(lmsr.lmsrMaxLoss(b, 2)); // worst-case AMM lossStatus
- Anchor program: live on Solana devnet at
GreSDUbtzBpDRgCYo9sXGZbFDM3HXFQWTdeAacF8HDEc. Mainnet pending. - This SDK: live on npm. The LMSR + oracle helpers are pure logic and work without a wallet.
- Repo: https://github.com/wagr-labs/wagr
- Site: https://wagr.fi
License
Apache 2.0.
