SDK guide
One package covers reads, previews, transaction building and the indexer for both Dusk programs.
Updated Nov 9, 2026
@omnipair/dusk-sdk is the TypeScript client for Omnipair V2. It ships both program IDLs, typed account readers and previews, transaction builders for every instruction, operator and referral helpers, and an indexer client. It is strict ESM, targets Dusk market layout v14, and is MIT licensed.
Install and pin
npm install --save-exact @omnipair/dusk-sdk@2.21.0-next.20261109The SDK is published to npm, and a version publishes only once every IDL it ships matches the program deployed on its cluster.
Devnet builds publish under the next tag, which always points at the newest deployed devnet build. Mainnet builds publish under latest, the tag a plain install reads. Until the first mainnet release, latest holds 2.0.2, a deprecated build for a program that no longer exists.
Pin an exact version in anything you ship; npm saves a caret range unless told otherwise. The IDL the package carries is the contract your transactions are encoded against: when the program is redeployed with a new IDL, a new SDK follows, and a mismatch shows up as account or discriminator errors.
The app pins the version, the npm tarball's hash and both IDL hashes in one frozen revision object, and builds no transaction until the deployment the API reports matches them. Do the same, and compare against Addresses.
Module map
| Import | What it gives you |
|---|---|
Dusk | The client: new Dusk({ provider, indexerBaseUrl }) with write, get, fetch, operator, orders and the raw program |
IDL, leverageDelegateIdl() | The two Anchor IDLs, for error tables, event decoding and custom builders |
PROGRAM_ID, DUSK_PROGRAM_ID | The Dusk program id |
createDuskProgram, createLeverageDelegateProgram | Raw Anchor Program instances |
SEEDS, derive…Address | Every PDA seed and a derivation helper for each account |
deriveMarketParamsHash, defaultMarketLaunchConfig, lpMintLen, lpMintRent | Market creation |
decodePreview…ReturnData | Decoders for every preview_* instruction's return data |
feeParameterUpdate … trancheParameterUpdate, assertParameterUpdate, uploadProposalMetadata, tryFetchProposalDescription | Operator parameter and metadata helpers |
referralBindingInterestShareBps, quoteReferralInterestShare | Referral math |
ORDER_PROTOCOL_FEE_BPS, calculateOrderProtocolFee, orderProtocolFeeAccounts | Order fees |
tokenProgramForMint, resolveTransferHookAccountMetas, buildLpTransferHook… | Token-2022 plumbing |
previewVirtualBook, decodeDuskVirtualBookBatch | The depth view |
Subpaths ./idl, ./preview, ./indexer | The same pieces without the client |
The client in three parts
import { Dusk } from "@omnipair/dusk-sdk"
const dusk = new Dusk({ provider, indexerBaseUrl })
dusk.write // typed builders per flow, plus any instruction by name
dusk.get // PDA helpers, account fetches, typed simulation previews
dusk.fetch // the indexer's REST routes
dusk.orders // typed builders for the leverage-delegate program
dusk.program // the raw Anchor Program<DuskIdl>Most instructions have a typed builder, such as buildSwapTransaction, addLiquidityTransaction, buildBorrowTransaction or buildOpenLeverageTransaction: TypeScript checks every field, and the builder derives the accounts and adds the hLP account prefix wherever the program needs it. Composite helpers return an instruction with the setup it needs: yield accounts from depositSingleSided and withdrawSingleSided, the referral accrual from referredBorrow and referredOpenLeverage, and operator proposal PDAs from dusk.operator.
write.builder, write.instruction, write.transaction and write.rpc take any IDL instruction by name, with instruction arguments and account names checked against the IDL at compile time and before encoding. The writing transactions page walks through each; reading state and quotes covers get and fetch.
Accounts and seeds
Every account is a PDA. The seeds, from SEEDS:
| Account | Seeds |
|---|---|
| Market | market_v2, base mint, quote mint, params hash |
| Reserve, collateral, interest vault | market_reserve / market_collateral / market_interest, market, mint |
| Leverage collateral vault | leverage_collateral, market, mint |
| Borrow position | borrow_position_v2, market, owner, position id |
| Leverage position | leverage_position_v2, market, position owner, namespace authority, position id |
| Leverage delegation | leverage_delegation_v2, position |
| Yield account | yield, market, owner, LP mint, asset mint, kind |
| hLP srLP custody | hlp_ylp_vault, market, hLP mint |
| Futarchy authority | futarchy_authority |
| Referral partner, accrual | referral_partner, authority; referral_accrual, partner, market, mint |
| Operator proposal, revenue archive | operator_change, market, nonce (u64 LE); operator_revenue, market, revenue epoch (u64 LE) |
| Event authority | __event_authority |
The params hash for a market is sha256("dusk-<network>:<BASE-QUOTE label>:<base mint>:<quote mint>"), computed by deriveMarketParamsHash; the mints are never sorted.
Amounts and prices
All amounts are raw integer atoms as BN or bigint. Prices and price limits are quote per base in fixed nine-decimal NAD units.
Mints with the Token-2022 interest-bearing or scaled-UI-amount extensions display differently from atoms / 10^decimals; convert with the token program's AmountToUiAmount for display and keep raw integers everywhere else. A display multiplier never creates collateral or yield.
Testing
The SDK's scripts folder has operator, preview and virtual-book checks, all read-only. Preview a transaction with dusk.get before you send it.
Compatibility
-
Node 20 or later; strict ESM with
.jsspecifiers. -
Peer
@coral-xyz/anchor0.30 or later and@solana/web3.js1.95 or later. -
The legacy
@omnipair/program-interfacepackage targets the V1 program and shares nothing with this SDK.