SDK/API reference
API reference
Index of every public symbol exported from @invia-app/sdk. For end-to-end usage
see Quickstart and the per-flow guides.
Top-level client
InviaClient
new InviaClient({ connection, rpcUrl, apiBaseUrl, programId, fetch, apiHeaders })
Bundles the program client and the API client. Either pass an existing
Connection or pass rpcUrl and let the SDK build one.
| Property | Type |
|---|
connection | Connection |
program | InviaProgramClient |
api | InviaApiClient |
Program client
InviaProgramClient
| Method | Description |
|---|
buildCreateOfferIx(args) | Returns { ix, pda, nonce } |
buildTakeOfferIx(args) | Returns { ix, pda } |
buildCancelOfferIx(args) | Returns { ix, pda } |
buildExpireOfferIx(args) | Returns { ix, pda } |
buildCloseOfferIx(args) | Returns { ix, pda } |
createOffer(wallet, args, options?) | Build + sign + send + confirm |
takeOffer(wallet, args, options?) | Build + sign + send + confirm |
cancelOffer(wallet, args, options?) | Build + sign + send + confirm |
expireOffer(wallet, args, options?) | Build + sign + send + confirm |
closeOffer(wallet, args, options?) | Build + sign + send + confirm |
fetchOffer(pda) | Read account, decode, return OfferAccount | null |
fetchAllOffers() | getProgramAccounts + decode each |
API client
InviaApiClient
| Method | Endpoint |
|---|
getOffers(filters?) | GET /v1/offers |
getOffer(pda) | GET /v1/offers/:pda |
getOfferFills(pda) | GET /v1/offers/:pda/fills |
getFills(filters?) | GET /v1/fills |
getStats() | GET /v1/stats |
getMakerStats(maker) | GET /v1/makers/:maker/stats |
getMakerOffers(maker, options?) | GET /v1/makers/:maker/offers |
getTokens(mints) | GET /v1/tokens |
getTrending() | GET /v1/trending |
Pricing helpers
| Function | Purpose |
|---|
pickPriceAndScale(sizeRaw, totalRaw) | Pick the smallest scale that lets size × price / 10^scale equal total |
totalFromPrice(sizeRaw, price, scale) | Inverse of the above |
feeFromTotal(totalRaw) | Compute the 20 bps taker fee |
netAfterFee(totalRaw) | totalRaw - feeFromTotal(totalRaw) |
Amount helpers
| Function | Purpose |
|---|
parseTokenAmount(input, decimals) | Human → raw bigint |
fmtTokenAmount(raw, decimals, maxFrac?) | Raw → human string |
shortAddress(addr, chars?) | Truncated middle ellipsis |
Derivation helpers
| Function | Purpose |
|---|
deriveOfferPda(maker, nonce, programId?) | Returns [pda, bump] |
deriveAssociatedTokenAddress(mint, owner, allowOffCurve?) | ATA helper |
deriveOfferAtas(offerPda, maker, tokenMint, paymentMint) | Returns vault + maker ATAs |
randomNonce() | Cryptographically random u64 for offer seeds |
Connection helpers
| Function | Purpose |
|---|
signSendConfirm(connection, wallet, ix, options?) | Privy-shaped sign + submit + confirm |
chainIdent(network) | "solana:mainnet" | "solana:devnet" |
detectNetworkFromUrl(url) | Best-effort detection from RPC endpoint |
Decoder
| Function | Purpose |
|---|
decodeOfferAccount(pda, data) | Borsh-decode raw account bytes |
isOfferAccount(data) | Check the 8-byte Anchor discriminator |
Constants
| Symbol | Value |
|---|
PROGRAM_ID | C9YABXJdHpiz4gjDuVrmCV7Qhq7uGGLNcdDnKu5UBiUV (devnet) |
TREASURY | GkwMZWc2yDomxMwNVsr9zDysXybyEQcz5RAGL4As6rCY |
PAYMENT_MINTS | USDC mainnet/devnet, USDT mainnet, wSOL |
FEE_BPS / FEE_DENOMINATOR | 20 / 10000 |
MAX_PRICE_SCALE | 18 |
MAX_EXPIRY_SECONDS | 30 × 24 × 60 × 60 |
EXPIRY_BOUNTY_LAMPORTS | 1_000_000 |