Encumbra
Menu

SDK: lifecycle verbs

The state-changing EncumbraClient calls that move a lien from open to closed or liquidated, plus the admin calls.

Lifecycle verbs

These are the state-changing calls that move a lien through its life.

  • Each takes the acting address as an explicit argument, so the caller is clear. It is the last argument, except in setParams, where an optional usageFeeBps follows it.
  • Unless noted, they return the transport's transaction result (parsed logs and return data).
  • The four that open a lien or liquidate one return a decoded value: open and openAsset return the new id, liquidate and liquidateAsset return a LiquidationResult.
  1. Openopen / openAsset
  2. Drawcharge / chargeWithAuth
  3. Repayrepay / payInstallment
  4. Close or liquidateclose / liquidate / liquidateAsset
Charge and repay can repeat while the lien is Active. A lien that defaults leaves through liquidate or liquidateAsset instead of close.

Opening

open(p: OpenParams, fromOwner): Promise<bigint>
Owner opens a fungible-collateral lien and gets back its id. The owner must have approved collateral to the contract first. collateralToken defaults to the debt token (same-asset lien), dueDate to 0 (open-ended), liqThresholdBps to 9000 (90%), and assetClass to agent-credit.
openAsset(p: OpenAssetParams, fromOwner): Promise<bigint>
Owner opens a lease backed by a whole-asset ERC-721 title and gets back its id. Approve the non-fungible token first. assetValue is the appraised value in debt-token units; assetClass defaults to equipment, and dueDate and liqThresholdBps default as in open.

Drawing and repaying

charge(id, amount, fromCreditor)
Creditor records usage rendered to the agent on credit, drawing down the available headroom.
chargeNonce(id): Promise<bigint>
Read the current per-lien charge nonce — the value an off-chain agent signature must bind to.
chargeWithAuth(id, amount, agentSigner, fromCreditor)
Charge usage with the agent's EIP-712 signature as per-draw consent. The agent signs off-chain (bounded authority) via an Eip712Signer; the creditor submits. Maps to ERC-7710/7715 delegated spending. The SDK reads the nonce and chain id, builds a one-hour deadline, and assembles the typed data for you. The creditor opts in by using this method; charge stays available to it, so the owner cannot force per-draw signatures.
repay(id, amount, fromPayer)
Pay down debt to the creditor. The payer must have approved amount first.
addCollateral(id, amount, fromOwner)
Adds collateral to improve the lien's health. Anyone can call it; the contract does not check that the caller is the owner, even though the last argument is named fromOwner. The caller must have approved the collateral token first.

Leasing and installments

setLeaseSchedule(id, installmentAmount, installmentPeriod, fromOwner)
Owner sets an installment schedule; the first payment falls due one period out.
payInstallment(id, fromPayer)
Pay the next installment, which rolls the due date forward one period.

Freeze, liquidate, close

freeze(id, from)
Kill-switch: the owner, agent, or creditor can freeze new charges on the lien.
unfreeze(id, from)
Lift a freeze and let charges resume. Only the owner or creditor can; the agent cannot. Either can lift a freeze set by anyone, including one the other set.
liquidate(id, fromKeeper): Promise<LiquidationResult>
Permissionless liquidation of a defaulted lien; anyone may act as keeper. It covers an ERC-20-collateral lien; a title lease uses liquidateAsset. Returns the payout split. The contract pays the keeper reward first, then the creditor, then the protocol, then any owner surplus. That keeper-first order is a policy choice the contract flags and may revisit.
liquidateAsset(id, fromKeeper): Promise<LiquidationResult>
Whole-asset repossession of a defaulted non-fungible token lease: the keeper pays the appraised value and takes the title. Returns the payout split. The sale is at the fixed appraised value, not an auction. The contract flags this as a policy choice that may be revisited.
close(id, fromOwner)
Owner closes a fully-repaid lien, releasing the remaining collateral back to them.

Admin

setParams(protocolFeeBps, keeperRewardBps, treasury, fromAdmin, usageFeeBps?)
Admin tunes the protocol, keeper, and usage fee bps (bounded by MAX_FEE_BPS) and the treasury address. If you omit usageFeeBps, the call resets the live usage fee to 0. It does not keep the current value, so pass all three fees every time. The contract emits ParamsUpdated.
setOracle(oracle, fromAdmin)
Admin points the registry at a price oracle, needed for liens whose collateral token differs from the debt token. The oracle cannot be set to the zero address, but any other address is accepted. It controls the price the underwater check uses for every live cross-token lien, and the call emits no event.
transferAdmin
The SDK has no wrapper for this call. The contract's transferAdmin hands the admin role to a new address in one step and emits no event.
Next step. For the raw Solidity behind these calls — events, admin bounds, and the liquidation waterfall — see the Contract reference. To hand an autonomous agent a revocable credit line, see For AI agents.

Keep reading

The read-only calls and the LienView type are on SDK: views and types, and the stand-in classes for tests are on SDK: helper classes. Roles and deploy are on the SDK reference.