TypeScript SDK
Typed discovery, reads, quotes, transaction builders, routing and migration helpers.
On this page
Module reference
| Module | Useful exports / purpose |
|---|---|
| manifest | Manifest: validate and normalize the deployment description. |
| market | launches, market, tokenMarket, isKnownHook, isVettedBacking. |
| reads | marketView, tokenMetadata, tokenClaimsChange, valueOf, floorExitOf, pendingActions. |
| prices | usdValue: backing-source valuation with published observation data. |
| quotes / paths | quoteTrade, quoteBuyWith, executable path and segment construction. |
| trade | approvals, tradeTx, ethBuyTx, limits, robinhoodChain. |
| launch / migration | openingValuation, launchTx, openings, legacyPrice, openTx, stageOf. |
| routes / rewards | Action/reward configuration, canonical route reads, round state and credits. |
| governance / actions | performGovernanceTx and typed creator/contract call builders. |
Read a consistent market snapshot
import { marketView, tokenClaimsChange } from '@sinjoh/sdk';
const block = await client.getBlockNumber();
const tokenClaims = await tokenClaimsChange(
client, manifest, token, launchBlock, block, 10_000n
);
const view = await marketView(client, manifest, id, block, { tokenClaims });
console.log(view.price, view.floor, view.treasury);Coverage depends on holder ERC-6909 claims as well as ERC-20 balances. Supply the reconciled claim amount or use an API response that performs this reconciliation. A read without required claim information must not be presented as independently complete coverage.
Quote and transaction types
| Field | Meaning |
|---|---|
side / exact | buy or sell; in or out. |
specified | The raw integer amount the user fixed. |
payAsset, amountIn | Actual quoted input token and amount. |
receiveAsset, amountOut | Final quoted output token and amount. |
unused | Exact-input amount not consumed by a partial fill. |
steps, stepAmounts | Ordered hop descriptors and their quoted input/output amounts. |
Transaction builders return to, data and native value; they do not send or sign. The direct SDK groups compatible consecutive v3/v4 hops into router commands and returns unused assets. Exact-output cross-command paths cannot reuse the same pool in different commands.
Migration and administration builders
openings and openingOfToken read the migration factory. legacyPrice reads the approved reference, and openTx encodes seed/price/deadline/configuration terms for open. performGovernanceTx constructs a current-Safe administrative call; encoding it does not authorize an ordinary wallet or supply a Safe signature.
import { performGovernanceTx } from '@sinjoh/sdk';
const tx = performGovernanceTx(manifest, 'AddSwapPath', encodedPath);
// tx must execute with a current Safe as msg.sender.
// Its existing owner-signature threshold still applies.Precision and unavailable results
Use bigint for raw amounts and ticks/price helpers for orientation. A six-decimal token and an eighteen-decimal token require different raw input scaling. JSON serialization needs an explicit bigint-to-string policy. Unavailable represents a route/quote the SDK cannot execute; it should not be replaced with a fabricated zero or a hand-calculated fill.
Account-path compatibility
Quotes need no funded account, approval or account code. The worked direct-router fork examples cover an EOA and a 1-of-1 Safe v1.4.1. ERC-4337 accounts, EIP-7702 delegations and other custom account execution paths need their own compatibility evidence. A valid quote alone does not verify a wallet’s signing, batching or execution behavior.
Skip to documentation