src is the domain layer for orders and intents.
It owns:
- Order data models and type guards.
- Intent creation and conversion logic.
- Order id and hashing logic for standard + multichain flows.
- Core validation/parsing used by higher-level libraries/screens.
- Dependency-injected domain behavior (for chain/oracle policy), without importing app config.
It does not own:
- UI behavior from app workspaces (
app/*). - External orchestration wrappers that live outside this package (except core parsing helpers in
api/).
npm install @lifi/intentRuntime target: Node.js 20+.
Solana public keys and mint addresses use base58 externally and 32-byte hex internally. Convert native Solana addresses before building an intent, and convert back to base58 when displaying them:
import { bytes32ToSolanaBase58, solanaBase58ToBytes32 } from "@lifi/intent";
const recipient = solanaBase58ToBytes32(
"FWBFarytmqKQajUDiqH6VCAJ2bt4d2Q4X4g38zKQehCy",
);
const mint = solanaBase58ToBytes32(
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
);
const token = {
address: mint,
name: "USDC",
chainId: 1151111081099710n,
decimals: 6,
chainNamespace: "solana" as const,
};
console.log(bytes32ToSolanaBase58(recipient));When requesting a quote, set namespace: "solana" on every Solana input or
output. The API client accepts either native base58 or internal bytes32 hex and
normalizes the wire representation. An omitted namespace defaults to
eip155, so a 32-byte Solana address under that namespace is rejected locally.
Current Solana support is limited to standard single-input orders on mainnet and devnet. Testnet has no configured deployment. Solana inputs are not supported in multichain or compact orders.
Stellar accounts (G…) and contracts (C…) use strkeys externally and their
raw 32-byte key internally. Token addresses are the Stellar Asset Contract id:
import {
STELLAR_MAINNET_CHAIN_ID,
bytes32ToStellarAccount,
stellarStrkeyToBytes32,
} from "@lifi/intent";
const user = stellarStrkeyToBytes32(
"GACECBP42TXJ27YBF76XKLITYIE2ATBSHKV7CS2OQ6K6NAYXTSRHQPBV",
);
const xlm = {
address: stellarStrkeyToBytes32(
"CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
),
name: "xlm",
chainId: STELLAR_MAINNET_CHAIN_ID,
decimals: 7,
chainNamespace: "stellar" as const,
};
console.log(bytes32ToStellarAccount(user));A Stellar input yields a StandardStellarIntent, which escrows on the
intent-soroban InputEscrow. Its account must be the user's 32-byte account key.
encodeStellarOrder / encodeStellarSolves / encodeStellarMandateOutput
produce the ScVal XDR the contracts take (xdr.ScVal.fromXDR turns them into
stellar-sdk values). orderId() matches the escrow's order_identifier,
pinned by tests/vectors/stellarClientOrder.json from intent-soroban.
Stellar outputs settle on the Soroban OutputSettler and always carry the
account recipient tag (context ends in 0x00). Stellar routes require the
axelar verifier. A Stellar-origin order pays the solver whose
stellarAddressCommitment(claimant) was recorded at fill time, so fill and
exclusivity identities for those orders are commitments, not padded EVM
addresses.
Builders support G-account users and recipients, escrow orders with 1–4 inputs
and outputs, and no same-chain Stellar orders. Mainnet deployments remain the
defaults. STELLAR_TESTNET_CHAIN_ID (1201081091099711n) has the testnet
passphrase hash configured, but no default deployment addresses.
Supply validated raw contract ids per Intent instance through IntentDeps:
import { STELLAR_TESTNET_CHAIN_ID, type IntentDeps } from "@lifi/intent";
type StellarResolver = NonNullable<IntentDeps["getStellarDeployment"]>;
// deployment is the validated public handoff, not credentials or predicted activation data.
const getStellarDeployment: StellarResolver = (chainId) =>
chainId === STELLAR_TESTNET_CHAIN_ID
? {
inputEscrow: stellarStrkeyToBytes32(deployment.stellar.inputEscrow),
outputSettler: stellarStrkeyToBytes32(deployment.stellar.outputSettler),
}
: undefined;Pass { getOracle, getStellarDeployment } as the constructor's dependencies.
The same optional resolver is accepted as the second argument of
inputSettlerForStellar(chainId, resolver) and
outputSettlerForStellar(chainId, resolver). Explicit values win, undefined
falls back to the known mainnet defaults, and an unresolved testnet fails with
Unsupported Stellar chain id. No exported registry is mutated. Keep oracle
selection in getOracle; this resolver selects only the two settlers.
IntentApi.getQuotes accepts oracle: { chainId: number | bigint; namespace?: Namespace; address: string }[]. Omitted namespaces remain eip155.
Set namespace: "stellar" for Stellar filters, using a C-StrKey or raw bytes32
contract id (converted to C-StrKey). G-account oracles and filters conflicting
with a route's namespace are rejected before HTTP. Use new IntentApi(false)
for the development API; explicitly allow both corridor oracle deployments.
Stellar testnet USDC has 7 decimals, Base Sepolia USDC 6.
GetQuoteOptions and GetQuoteResponse are exported. A selected quote can also
be typed as Awaited<ReturnType<IntentApi["getQuotes"]>>["quotes"][number].
Keep the whole quote, including quoteId, optional validUntil (Unix seconds),
metadata.oracle, metadata.quoteReference, allowances, and openIntentTx.
The order type is oif-user-open-v0. Stellar data is base64 order ScVal
XDR, not a signed envelope; it has no gasRequired. Decode and pass the exact
ScVal to open on returned to, then simulate/sign on the selected network.
EVM returns calldata, gas and optional native value; Solana and Tron retain
their compute-unit and fee-limit fields. Do not reconstruct a nonce or re-encode
API payloads from preview amounts. This SDK returns quote payloads unchanged.
Order-status/list imports accept G/C-StrKeys as well as existing hex/base58.
Stellar output recipient kinds remain bound to their context tag (00 account,
01 contract); conflicting or missing tags fail instead of silently changing
identity. Contract-account users are explicitly unsupported by the G-account
order encoder. Hex claimant commitments remain opaque, never decoded as keys.
Git dependencies run the normal prepare build to generate _esm, _cjs and
_types exports (requires Bun and the package's development build dependencies).
Bun consumers must allow this package's lifecycle explicitly with
"trustedDependencies": ["@lifi/intent"] in their package manifest; merge that
entry with any existing audited trust list, not a blanket allow-all. The build
also supports Bun's in-place Git preparation under node_modules, while
transforming only this package's src tree.
Bun 1.4.2 does not install a Git dependency's own devDependencies for this
in-place build. Bun Git consumers must therefore declare these build tools in
their own devDependencies: rollup: "^4.61.0",
rollup-plugin-esbuild: "^6.2.1", typescript: "^5.6.3", and
@types/bun: "^1.3.8" (keep compatible existing entries). Install with dev
dependencies enabled. No additional lifecycle trust was needed for those
tools in the verified install; esbuild's optional platform binary worked with
its postinstall still blocked. npm Git installation prepares in its temporary
checkout with the SDK's devDependencies and needs no consumer build-tool entries.
Consumers can pin the final SDK Git commit before a release; replacing that pin
with an npm version requires a later release/tag publication. No new
EVM/Stellar Axelar transport API or private-relay support is introduced here.
@lifi/intent/axelar builds unsigned instructions for the Solana
oracle_axelar program (FHMjUtWovj3KvMea62D2api8HaJy8oGye4UFzsGKZHvw) and the
pinned Axelar 1.1.1 gateway and gas service. It never loads keys, contacts RPC
or broadcasts. Instructions are { programId, keys, data } with base58 keys and
0x hex data.
- Deployment:
axelarInitializeInstruction,axelarSetChainMappingInstruction,axelarConfigAddress,axelarRouteAddress,decodeAxelarConfig,decodeAxelarRoute. - Source:
axelarSubmitInstruction(Relayedwith positive gas orSelfRelaywith zero;consumeselectssubmit_consume),axelarFundInstruction. - Destination:
axelarApprovalStepsturns proverexecute_datainto gateway session, signature and approval transactions, refusing any approval other than the expected single message;axelarReceiveStepsreturnsexecuteandregister_proof. The standard Axelar executor cannot fundregister_proof, so settlement after paid relaying still needs a caller to submit it. - Before funding an order:
checkSolanaAxelarAdmission(one proof of at most 320 bytes per message, nonzero u128 chain IDs).
Outputs are byte-identical to the reference builder in lifi-intent-svm
(axelar_litesvm/src/client_vectors.rs); tests/vectors/axelarClientVectors.json
is copied from there and must be refreshed whenever the program ABI changes.
The caller-operated relay that drives these steps end to end lives in
relay/axelar (private workspace package).
types.ts- Canonical types such as
StandardOrder,MultichainOrder, andOrderContainer. - Core token model is chain-id based (
token.chainId), not chain-name based.
- Canonical types such as
deps.ts- Minimal dependency interfaces consumed by core constructors/functions.
intent/create.ts: High-levelIntentbuilder.fromOrder.ts:orderToIntent(...)andisStandardOrder(...).standard.ts/multichain.ts: Concrete intent implementations and order-id derivation.compact/*: Compact conversions/signing/claims helpers used by intent flows.
orderLib.ts- Validation helpers (
validateOrder...) and output encoding/hash helpers. - Multi-argument helpers accept object params, e.g.
validateOrderWithReason({ order, deps }).
- Validation helpers (
api/intentApi.ts- Normalization/parsing for intent-api payloads.
typedMessage.ts- EIP-712 type definitions and precomputed type hashes used in compact flows.
helpers/andcompact/- Shared low-level helpers (conversions and compact lock/id utilities).
Most contributors start with intent/index.ts:
orderToIntent(...)isStandardOrder(...)StandardOrderIntentMultichainOrderIntentcomputeStandardOrderId(...)computeMultichainEscrowOrderId(...)computeMultichainCompactOrderId(...)hashMultichainInputs(...)
OrderContainer wraps:
inputSettlerorder(StandardOrder | MultichainOrder)- sponsor/allocator signatures
Use isStandardOrder(...) as the canonical discriminator for branching between single-chain and multichain order logic.
Typical contributor path:
- Build an intent with
Intentinintent/create.tsand injectIntentDeps. - Convert/hydrate with
orderToIntent(...)fromintent/fromOrder.ts. - Compute
orderId()and chain-specific behavior throughStandardOrderIntentorMultichainOrderIntent.
Example: create/convert and derive order id.
import { orderToIntent } from "@lifi/intent";
import type { OrderContainer } from "@lifi/intent";
function getOrderId(orderContainer: OrderContainer): `0x${string}` {
return orderToIntent(orderContainer).orderId();
}Example: branch behavior by order type during creation/execution logic.
import { isStandardOrder, orderToIntent } from "@lifi/intent";
import type { OrderContainer } from "@lifi/intent";
function getInputCount(orderContainer: OrderContainer): number {
if (isStandardOrder(orderContainer.order))
return orderContainer.order.inputs.length;
return orderContainer.order.inputs.reduce(
(sum, v) => sum + v.inputs.length,
0,
);
}
function getInputChains(orderContainer: OrderContainer): bigint[] {
return orderToIntent(orderContainer).inputChains();
}typedMessage.ts defines EIP-712 type structures and verifies that computed type hashes match expected on-chain constants. Any change here can break compact claim/signature compatibility.
When touching compact hashing or typed message definitions:
- Keep encodings aligned with contracts.
- Treat hash constant changes as protocol-level changes.
orderLib.tsvalidateOrderWithReason(...)validateOrderContainerWithReason(...)
api/intentApi.tsparseOrderStatusPayload(...)
These utilities are the core gate for normalizing and validating inbound order data before execution paths consume it.
- Core has no direct imports from app config/util modules.
- Dependencies are passed in scope at creation time (constructor/function), never via global mutable runtime.
- Keep dependencies minimal:
IntentreceivesIntentDeps.- Standard order validation receives
StandardOrderValidationDeps({ order, deps }). - Container validation receives
OrderContainerValidationDeps({ orderContainer, deps }), addinginputSettlersfor compact input-settler policy. - Core-internal protocol constants live in
constants.ts.
- Unit tests are colocated with features in
src/**/<feature>.spec.ts. - Every non-
index.tsruntime module insrc/must have a sibling.spec.ts. index.tsbarrel files are excluded from that requirement.- Type-only modules (for example
src/types/**andsrc/intent/types.ts) should not have individual.spec.tscoverage. - Rely on TypeScript checks and behavior tests that consume those types.
- Integration tests live under
tests/. - Bare spec files in
src/(no sibling source module) are not allowed.
- Use
isStandardOrder(...)for order branching, not ad-hoc property checks. - Keep hashing/encoding behavior stable unless you are intentionally changing protocol semantics.
- Keep core APIs chain-id based. Map app chain names to ids at app boundaries.
- Update/add tests when changing order construction, parsing, or hashing behavior.
- Run
bun run checkand relevant unit tests before merging.
src/types/index.tssrc/intent/index.tssrc/intent/create.tssrc/intent/fromOrder.tssrc/intent/standard.tssrc/intent/multichain.tssrc/output.tssrc/validation.tssrc/api/intentApi.tssrc/typedMessage.tssrc/axelar/index.ts
Pass oracle: [{ chainId: 1, address: vowAdapter }, { chainId: 8453, address: vowAdapter }] to IntentApi.getQuotes to require the listed oracle contracts on both sides of a cross-chain route. The SDK sends these as intent.metadata.oracle with eip155 chain identifiers, alongside any exclusiveFor metadata. Omitting the option preserves the API's default oracle selection; an empty list also allows the API defaults. Same-chain swaps ignore oracle selection.