Skip to main content
The builders return a @mysten/sui Transaction you sign and submit yourself (with an Executor, dapp-kit, or guardedSubmit). AltheiaSui wraps them; reach for the builders when you want to inspect, dry-run, or compose a PTB before submitting. All agent-action builders take a SuiRefs (from agentRefs).

Agent actions

BuilderMove callNotes
buildSwap(refs, amount)deepbook_adapter::execute_swap_quote_for_baseBuy: spend the capped quote, receive base into the vault.
buildSellSwap(refs, amount)deepbook_adapter::execute_swap_base_for_quoteSell: unwind a base position back to quote.
buildPlaceLimit(refs, params)trading_account::place_limit_orderNeeds tradingAccount + balanceManager refs.
buildCancelAll(refs)trading_account::cancel_allNeeds tradingAccount + balanceManager refs.
import { buildSwap, keypairExecutor } from "@altheia-xyz/sui";

const tx = buildSwap(refs, 50_000_000n);     // 0.05 SUI
const res = await keypairExecutor(client, kp)(tx);

LimitParams

type LimitParams = {
  clientOrderId: bigint; orderType: number; selfMatching: number;
  price: bigint; quantity: bigint; isBid: boolean; payWithDeep: boolean;
  expireTimestampMs: bigint;
};

Owner lifecycle

Signed with the owner key; refs must carry ownerCap.
BuilderMove callNotes
buildRevoke(refs)vault::admin_revoke_policyTerminal.
buildPause(refs)vault::admin_pause_policyFreeze without revoking.
buildUnpause(refs)vault::admin_unpause_policyResume a paused agent.
buildSetActions(refs, actionIds)vault::admin_set_actionsReplace the allowed-action set.
buildSetValueGuard(refs, maxSlippageBps, baseScalar)vault::admin_set_value_guardGlobal swap price-band.
buildKillDrain(refs, ownerAddr, coinTypes?)revoke + drainRevoke and sweep the vault to the owner.
buildKillDrain drains the held coin types. Pass coinTypes from vaultBalances to drain exactly what the vault holds — draining a type with no balance aborts.

Provisioning

provisionAgentMulti(exec, params) composes the whole agent in one owner signature: vault, deposit, policy, asset cap, value-guard, agent cap, and an agent gas top-up. It returns { vault, ownerCap, policy, cap }. The dashboard does this for you; the builder is for programmatic provisioning.
const prov = await provisionAgentMulti(ownerExec, {
  corePkg, quoteType: "0x2::sui::SUI", agentAddr, ownerAddr,
  fundAmount: 600_000_000n, agentGas: 100_000_000n,
  cfg: {
    agentId: "agent-1",
    perDayCap: 2_000_000_000n,
    perTxCap: 600_000_000n,
    allowedPackages: [poolId],
    allowedActions: [SUI_ACTIONS.deepbookSwap],
    expiresAtMs: 4_102_444_800_000n,
    swapMinRate: 15_000_000n,
  },
});

SuiPolicyConfig

FieldTypeNotes
agentIdstringLabel, becomes agent_id on chain.
perDayCapbigintRequired. Max cumulative spend per rolling 24h, base units.
perTxCapbigint?Per-tx ceiling. 0 disables the per-tx check.
allowedPackagesstring[]Protocol scope (package/pool ids).
allowedActionsSuiActionId[]Capability allowlist, default-deny.
expiresAtMsbigintAbsolute expiry.
swapMinRatebigint?Min output per input unit ×1e9. Required if deepbookSwap is allowed.

SUI_ACTIONS

const SUI_ACTIONS = { transfer: 0, deepbookSwap: 1, deepbookLimitOrder: 2, deepbookCancel: 3 };

Chain reads

Read the live policy, vault balances, and the audit log straight from chain.