SDK/Reference

Owner transactions

PREVIEW

Builders for owner actions. They return a Transaction; unsignedTx turns it into bytes for the owner's own device. Nothing here signs.

Signatures below are copied from the source; descriptions are the source's own doc comments.

From owner.ts#

Exported by index.ts.

OWNER_ACTIONS#

TypeScript
export const OWNER_ACTIONS = [
  "create",
  "set-mandate",
  "deposit",
  "revoke",
  "withdraw",
  "claim-default",
] as const;

OwnerAction#

TypeScript
export type OwnerAction = (typeof OWNER_ACTIONS)[number];

OwnerRefs#

TypeScript
export type OwnerRefs = {
  pkg: string;
  loanCoin: string;
  market: string;
  /** The oracle reader every claim starts with (deploy.ts Deployment.reader) and the feed it reads. */
  reader: string;
  /** Set when `reader` is published apart from `pkg` (deployment.oraclePkg). */
  oraclePkg?: string | null;
  feed: string;
  owner: string;
  agent: string;
  treasuryId: string | null;
  ownerCapId: string | null;
  agentCapId: string | null;
};

OwnerParams#

TypeScript
export type OwnerParams = {
  capExpiresAtMs?: number;
  mandate?: ChainMandate;
  amount?: bigint;
  claim?: ObjectRef;
  loanId?: string;
};

ChainMandate#

A lender's on-chain rules as set_mandate + set_collateral take them (the hosted form: services/selfserve/mandate.ts).

TypeScript
export type ChainMandate = {
  totalCap: bigint;
  minFill: bigint;
  maxFill: bigint;
  minRateBps: number;
  maxDurationMs: number;
  takerKind: TakerKind;
  takers: string[];
  maxLtvBps: number;
  capExpiresAtMs: number;
};

ObjectRef#

TypeScript
export type ObjectRef = { objectId: string; version: string; digest: string };

LENDER_CAP_LIMIT#

A lender's cap never spends (setup.ts capBody gives lenders 1/1 too): fills draw through treasury::draw, not spend.

TypeScript
export const LENDER_CAP_LIMIT = 1n;

ownerTx#

Every transaction the user signs for their agent. Built here, signed in their wallet, gas paid by the operator. Setup is one signature: create with the mandate and the amount makes the treasury and the agent's cap, sets the rules, funds it and shares it. Without them, create opens the account only and set-mandate adds both later.

TypeScript
export function ownerTx(action: OwnerAction, r: OwnerRefs, p: OwnerParams): Transaction

BORROWER_OWNER_ACTIONS#

TypeScript
export const BORROWER_OWNER_ACTIONS = [
  "create",
  "deposit",
  "revoke",
  "withdraw",
  "repay",
  "claim",
  "add-collateral",
] as const;

BorrowerOwnerAction#

TypeScript
export type BorrowerOwnerAction = (typeof BORROWER_OWNER_ACTIONS)[number];

BorrowerOwnerRefs#

A hosted borrower's two treasuries: SUI collateral and the loan-coin cash treasury, each with the agent's cap.

TypeScript
export type BorrowerOwnerRefs = Pick<OwnerRefs, "pkg" | "loanCoin" | "owner" | "agent"> & {
  sui: Side;
  cash: Side;
};

BorrowerOwnerParams#

TypeScript
export type BorrowerOwnerParams = {
  limits?: { suiBudget: bigint; cashBudget: bigint; capExpiresAtMs: number };
  /** Required with limits on a deposit, and with collateral on a create: the SUI cap's on-chain borrow bound. */
  borrow?: BorrowRules;
  collateral?: bigint;
  cashFloat?: bigint;
  withdraw?: { sui: bigint; cash: bigint };
  /** A loan whose deed the SUI treasury holds; repay draws `amount` of the loan coin, add-collateral `amount` of SUI. */
  loan?: { id: string; lenderKind?: "treasury" | "pool"; lenderId?: string };
  amount?: bigint;
};

borrowerOwnerTx#

Patch 16: a borrower's caps pay only the owner (recipients = [owner]); the agent moves funds only through the borrower desk (borrower.move), which takes collateral and repayments straight into loans and opens only loans inside the SUI cap's borrow mandate. The owner's own loan actions use the OwnerCap of the SUI treasury, so they work after a revoke too.

TypeScript
export function borrowerOwnerTx(
  action: BorrowerOwnerAction,
  r: BorrowerOwnerRefs,
  p: BorrowerOwnerParams,
): Transaction

RenewSide#

One cap to renew: its treasury's coin type, the OwnerCap that signs, and the limits it keeps.

TypeScript
export type RenewSide = {
  coinType: string;
  treasuryId: string;
  ownerCapId: string;
  agentCapId: string;
  perTx: bigint;
  perDay: bigint;
  recipients: string[];
};

renewTx#

set_limits with a new expiry and everything else as it is (treasury.move set_limits); one call per cap.

TypeScript
export function renewTx(pkg: string, sides: RenewSide[], expiresAtMs: number): Transaction

From unsigned.ts#

Exported by index.ts.

UnsignedTx#

An owner action for the owner's own device. kindBytes is the TransactionKind (for a sponsor or the owner page); txBytes is the full transaction with the owner's gas, or null when it could not be built (txError says why).

TypeScript
export type UnsignedTx = {
  kind: "unsigned";
  sender: string;
  kindBytes: string;
  txBytes: string | null;
  txError?: string;
};

unsignedTx#

TypeScript
export async function unsignedTx(
  client: SuiGrpcClient,
  tx: Transaction,
  sender: string,
): Promise<UnsignedTx>