Skip to main content

@0xintuition/sdk

Version: V2
View Markdown

What it's for​

Application-level protocol actions, quote preparation, wallet workflows, and JSON-serializable action envelopes. It combines lower-level contracts and math into explicit workflows without owning your application's storage or transaction authorization.

When to use it​

Use actions for a deposit, redemption, creation, FeeProxy, or TrustBonding workflow; use pure envelope builders when another component will review and execute the plan. For indexed V2 graph data, query a Core node. Use protocol for individual contract wrappers and React for hooks.

Install​

npm install @0xintuition/sdk@4.1.0 viem@2.31.4

Use ESM import or CommonJS require() on Node 20+, including the public subpaths below. ESM also works in a compatible browser. Existing V2 imports are preserved. See module-format compatibility.

Entry points​

SubpathPurpose
.SDK-owned workflows, actions, utilities, and selected shared types
./apiRead-client exports; see the V1 boundary below
./actionsQuotes, transaction preparation, pure envelopes, and envelope schemas
./protocolExplicit low-level protocol escape hatch
./trust-swap-and-bridge-routerRouter workflows subject to deployment support
./utilsSDK formatting helpers

The ./api read client calls the V1 GraphQL API; see The SDK read client.

Depends on and works with​

Runtime package dependencies: curves, deployments, ids, periphery, and protocol. Peer dependency: viem ^2.0.0.

The root no longer re-exports the full protocol or ID packages. Import those APIs from their own packages, and canonical predicate data from predicates. Your application selects an upload provider and supplies any resulting content URI; the SDK does not upload it for you.

Example​

This pure builder accepts a synthetic quote as readContext and produces one deposit step. It performs no RPC request, simulation, signing, or submission. The recipient and quote are fixtures, and the computed term ID does not assert that the atom exists on testnet.

import { multiVaultDepositEnvelope } from '@0xintuition/sdk/actions';
import { calculateAtomId } from '@0xintuition/ids';
import { getMultiVaultAddressFromChainId as getEnvelopeTarget } from '@0xintuition/deployments';

// Synthetic quote and recipient; this atom has not been registered on-chain.
export const envelope = await multiVaultDepositEnvelope({
chainId: 13579,
multiVaultAddress: getEnvelopeTarget(13579),
receiver: '0x1111111111111111111111111111111111111111',
termId: calculateAtomId('Synthetic package reference'),
curveId: 1n,
assetsIn: 1000n,
slippageBps: 100n,
readContext: {
previewDeposit: { sharesOut: 500n, assetsAfterFees: 990n },
entryFeeAmount: 5n,
protocolFeeAmount: 5n,
currentSharePrice: 2_000_000_000_000_000_000n,
},
});
export const envelopeJson = JSON.stringify(envelope);
console.log(envelope.action, envelope.steps.length);

The result's action is multivault.deposit, its steps contain encoded calldata and decimal-string values, and JSON.stringify succeeds. Missing required read context rejects the builder. In a real workflow, obtain current context for the intended chain, address, term, and curve, then review and simulate before separately authorizing execution. A valid schema proves the envelope's shape, not its economic outcome or authority to spend.

Distinguish pure *Envelope builders from RPC-backed quote/preparation helpers and transaction executors such as feeProxyExecutePlan. An encoded plan is not a transaction receipt. Build action plans and envelopes explains the boundary; the generated action reference supplies exact parameter types.

See also migration guide.

Source​

Package README, action plans, envelope implementation, and root export migration. The upstream README's “v1 design” terminology names its integration design, not this site's V1 documentation generation.

Applies to V2 · @0xintuition/sdk 4.1.0