Skip to documentation
Resources/Docs
DevelopersSinjoh v2

TypeScript SDK

Typed discovery, reads, quotes, transaction builders, routing and migration helpers.

3 min read·
On this page

Module reference

ModuleUseful exports / purpose
manifestManifest: validate and normalize the deployment description.
marketlaunches, market, tokenMarket, isKnownHook, isVettedBacking.
readsmarketView, tokenMetadata, tokenClaimsChange, valueOf, floorExitOf, pendingActions.
pricesusdValue: backing-source valuation with published observation data.
quotes / pathsquoteTrade, quoteBuyWith, executable path and segment construction.
tradeapprovals, tradeTx, ethBuyTx, limits, robinhoodChain.
launch / migrationopeningValuation, launchTx, openings, legacyPrice, openTx, stageOf.
routes / rewardsAction/reward configuration, canonical route reads, round state and credits.
governance / actionsperformGovernanceTx and typed creator/contract call builders.

Read a consistent market snapshot

typescript
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

FieldMeaning
side / exactbuy or sell; in or out.
specifiedThe raw integer amount the user fixed.
payAsset, amountInActual quoted input token and amount.
receiveAsset, amountOutFinal quoted output token and amount.
unusedExact-input amount not consumed by a partial fill.
steps, stepAmountsOrdered 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.

typescript
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.