Define the integration
Separate immutable admission rules from runtime account reads and action plans.
On this page
The TypeScript shape
import type { spot, PluginDefinition } from "@termbook/sdk";
export function create_exchange(definition: PluginDefinition,
account: spot["account"],
actions: spot["actions"],
exit: spot["exit"],
): spot {
return {
name: definition.name,
use_case: "spot",
chain_id: definition.chain_id,
markets: definition.markets,
definition,
account,
actions,
exit,
};
}This factory shows the public shape. Its callbacks must be real implementations; its definition must include approved reads and call policies. See Kuru for a complete implementation rather than placeholder functions.
Definition fields
| Field | Meaning |
|---|---|
| format: 1 | The current definition schema version. |
| name, use_case, chain_id | Metadata that must match the integration object. |
| settlement_asset | Non-native ERC-20 asset used by the House for lending and repayment. |
| markets | Market IDs, contract addresses, base and quote assets and their decimals. |
| actions | Standard capabilities mapped to exact calls, bounds and routing conditions. |
| contracts | Shared execution, reader, recovery and exit component addresses. |
| pins | Target code hash and, for proxies, implementation identity and slot. |
| verified_sources | Source identities for the pinned dependencies or an admitted runtime review. |
| assessment or atomic_spot | Shared verification and recovery configuration. Choose one. |
Definitions are strict: unknown fields, duplicate markets, missing dependency pins and incomplete recovery rules are rejected. Markets, actions, sources and the runtime callbacks must agree.
Package & version identity
import { package_integration } from "@termbook/sdk";
import { exchange } from "./integration";
const packaged = package_integration(exchange);
console.log(packaged.hash);
console.log(packaged.version_id);The canonical definition hash identifies the reviewed package. The version ID includes that hash and the chain. Editing limits, actions, markets or dependencies creates a different version. package_integration checks structure; it does not replace lifecycle validation.