InviaInvia
App
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.

PropertyType
connectionConnection
programInviaProgramClient
apiInviaApiClient

Program client

InviaProgramClient

MethodDescription
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

MethodEndpoint
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

FunctionPurpose
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

FunctionPurpose
parseTokenAmount(input, decimals)Human → raw bigint
fmtTokenAmount(raw, decimals, maxFrac?)Raw → human string
shortAddress(addr, chars?)Truncated middle ellipsis

Derivation helpers

FunctionPurpose
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

FunctionPurpose
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

FunctionPurpose
decodeOfferAccount(pda, data)Borsh-decode raw account bytes
isOfferAccount(data)Check the 8-byte Anchor discriminator

Constants

SymbolValue
PROGRAM_IDC9YABXJdHpiz4gjDuVrmCV7Qhq7uGGLNcdDnKu5UBiUV (devnet)
TREASURYGkwMZWc2yDomxMwNVsr9zDysXybyEQcz5RAGL4As6rCY
PAYMENT_MINTSUSDC mainnet/devnet, USDT mainnet, wSOL
FEE_BPS / FEE_DENOMINATOR20 / 10000
MAX_PRICE_SCALE18
MAX_EXPIRY_SECONDS30 × 24 × 60 × 60
EXPIRY_BOUNTY_LAMPORTS1_000_000