Encumbra
Menu

SDK: views and types

The read-only EncumbraClient calls, and the LienView type that getLien returns.

Read and view methods

These are read-only calls — anyone can run them, and they change no state. Use them to decide whether to keep serving an agent, whether an asset should operate, or whether a lien can be liquidated.

Standing checks

available(id): Promise<bigint>
Spendable headroom a provider should honor right now — 0 if the agent is cut off.
isServiceable(id): Promise<boolean>
Whether a provider should keep serving this agent.
isAssetEnabled(id): Promise<boolean>
Whether a leased asset should operate — the flag a financed device polls as its kill-switch.
isLiquidatable(id): Promise<boolean>
Whether the lien is currently in a state a keeper can liquidate.

Lien data

getLien(id): Promise<LienView>
Fetch a lien's full live state, decoded into a LienView (asset class and status mapped to strings).
healthFactor(id): Promise<bigint>
The collateralization ratio in WAD (1e18 is 100%). Below 1e18 the debt exceeds the collateral; a lien can already be liquidatable above that, depending on its liqThresholdBps.
collateralValue(id): Promise<bigint>
The posted collateral valued in debt-token units (via the oracle when collateral differs from debt; the appraised value for a title).
nextId(): Promise<bigint>
The id the next lien will get, so ids 1..nextId-1 have already been created.
agentStats(agent): Promise<AgentStats>
An agent's on-chain repayment history (liens opened with this agent, settled, defaulted, closed after being late, total repaid, total bad debt). It is a reference signal for off-chain underwriting only. A third party can open liens that name any agent, so the record can be inflated or poisoned. Do not drive real credit limits from it.
// The registry pulls the collateral on open, so approve it first.
await usd.approve(encumbra.address, 1_000_000n, ACCOUNTS.owner);

const id = await encumbra.open(
  {
    agent: ACCOUNTS.agent,
    creditor: ACCOUNTS.provider,
    token: usd.address,
    collateral: 1_000_000n,
    creditLimit: 800_000n,
  },
  ACCOUNTS.owner,
);

await encumbra.charge(id, 50_000n, ACCOUNTS.provider);

const headroom = await encumbra.available(id);
const ok = await encumbra.isServiceable(id);
console.log(headroom, ok);
Approve, open a lien, draw on it, and check it is still serviceable

The LienView type

getLien returns a LienView — the decoded, live state of a single lien. Its fields are grouped below.

Parties

id: bigint
The lien's id.
owner: string
The party that posted the collateral and may close the lien.
agent: string
The party whose usage is charged against the credit line.
creditor: string
The provider that charges usage. On liquidation it is paid from the collateral after the keeper reward.

Collateral

collateralToken: string
The token (or non-fungible token) held as collateral.
collateral: bigint
Amount of collateral currently posted.
collateralIsNft: boolean
Whether the collateral is a whole-asset ERC-721 title.
collateralTokenId: bigint
The non-fungible token id when the collateral is a title.
assetValue: bigint
Appraised value of a leased asset in debt-token units.
assetClass: string
The book tag (for example equipment or agent-credit), decoded from bytes32; empty when unset.

Money

debtToken: string
The settlement token debt is denominated in.
debt: bigint
Total outstanding: the creditor's receivable plus accrued protocol fees.
protocolAccrued: bigint
Protocol fees accrued against the lien.
creditLimit: bigint
The ceiling the agent may draw up to. It is the value the owner passed to open, and no function lowers it afterward.

Terms and schedule

dueDate: bigint
Unix seconds the lien is due; 0 when open-ended.
liqThresholdBps: number
Liquidation threshold in basis points (9000 = 90%).
installmentAmount: bigint
The scheduled installment payment, if a lease schedule is set.
installmentPeriod: bigint
Seconds between installments.

State

status: LienStatus
One of None, Active, Liquidated, or Closed.
frozen: boolean
Whether the kill-switch is engaged and new charges are blocked.
everPastDue: boolean
Whether the lien went past due at some point. It stays true once set, so a lien that was late and later settled reads as a cured default.

Keep reading

The calls that change a lien are on SDK: lifecycle verbs, and the stand-in token, title, and oracle classes are on SDK: helper classes. The matching on-chain views are in the Contract reference.