@tokemak/sdk-core
v0.3.0
Published
Shared runtime for Tokemak product SDKs (`@tokemak/autopools`, future product packages). viem + fetch only — no wagmi, no React, no API keys.
Readme
@tokemak/sdk-core
Shared runtime for Tokemak product SDKs (@tokemak/autopools, future product packages). viem + fetch only — no wagmi, no React, no API keys.
You usually don't install this directly; product packages depend on it and re-export what you need. It owns:
- Errors — every SDK function either returns valid data or throws a
TokemakSdkErrorsubclass (UnsupportedChainError,ApiError,PriceUnavailableError,DepositsDisabledError, …) with a machine-readablecode. An outage never looks like an empty result. - Prices —
getTokenPrices(client, { tokens })→ USD prices keyed by lowercased address, DeFiLlama fallback, unpriceable tokens reported inmissing(never silently 0). - Client factory —
createTokemakClient({ chainId, rpcUrl? }). OmittingrpcUrluses the viem chain's default public RPC: fine for trying things out, bring your own RPC for production. - Transaction primitives —
PreparedTransaction(unsigned{ chainId, to, data, value, from? }),sendTransaction/simulateTransactionhelpers,signErc2612Permit,applySlippageBps(basis points everywhere),txDeadline, and the ERC-8021 builder-code suffix (appendBuilderCode) so SDK-built transactions carry the same on-chain attribution as the Tokemak dapp (plain ERC-20 approve legs are the one exception — they stay exactly 68 bytes because Ledger's Ethereum app < 1.20.0 rejects longer approve calldata). - Endpoints — Tokemak's public keyless HTTP endpoints as an overridable
DEFAULT_ENDPOINTSobject.
Design rules (see .claude/rules/product-packages.md): product packages never import each other; this package never imports product packages; something lives here only once a second product needs it.
