Encumbra
Menu

Contract: verbs

Every state-changing call, grouped by lifecycle, credit, leases, kill-switch, enforcement, and admin.

Verbs

State-changing functions, with who may call each. Every lien verb except open and openAsset requires status Active. Every verb that moves tokens carries a reentrancy guard, and every verb that pulls tokens from the caller needs the relevant ERC-20 or ERC-721 approval to the contract first.

VerbWho can call itMoves tokens?
open, openAssetAnyone. The caller becomes the ownerYes: collateral or title in
chargeCreditorNo: records a receivable
chargeWithAuthCreditor, with the agent's signatureNo: records a receivable
repayAnyone, usually the ownerYes: debt token, from the payer
addCollateralAnyoneYes: collateral in
setLeaseScheduleOwnerNo
payInstallmentAnyoneYes: debt token, from the payer
freezeOwner, agent or creditorNo
unfreezeOwner or creditorNo
liquidateAnyone (a keeper)Yes: collateral out, in kind
liquidateAssetAnyone (a keeper)Yes: debt token in, title out
closeOwnerYes: collateral or title back to the owner
setParams, setOracle, transferAdminAdminNo

Lifecycle

open(agent, creditor, collateralToken, debtToken, collateralAmount, creditLimit, dueDate, liqThresholdBps, assetClass)
Anyone; the caller becomes the owner. Escrows ERC-20 collateral and authorizes a credit line. A cross-token lien needs an oracle address to be set, and open checks only that it is non-zero. The admin can replace it later, which changes the price the underwater check uses.
openAsset(agent, creditor, nftToken, tokenId, debtToken, assetValue, creditLimit, dueDate, liqThresholdBps, assetClass)
Anyone; the caller becomes the owner. Escrows a whole-asset ERC-721 title valued at assetValue in debt-token units.
close(id)
Owner only, and only once debt is zero. Returns the escrowed collateral or title.

Credit and settlement

charge(id, amount)
Creditor only. Records usage as a receivable, bounded by the owner's credit limit; no tokens move. Reverts if frozen or past due.
chargeWithAuth(id, amount, deadline, signature)
Creditor submits, but the draw is valid only with the agent's EIP-712 signature over the exact id, amount, nonce, and deadline. The creditor opts in by using this verb; charge is always available to it, so the owner cannot require a signature per draw.
repay(id, amount)
Anyone (usually the owner). Pays down debt; the creditor is senior, then the protocol's accrued usage fees.
addCollateral(id, amount)
Anyone. Adds ERC-20 collateral to improve the lien's health.
function charge(uint256 id, uint256 amount) external {
charge is the creditor-only receivable path; it moves no tokens.

Leases and installments

setLeaseSchedule(id, installmentAmount, installmentPeriod)
Owner only. Set-once, and not while liquidatable, so it cannot be used to cure a past-due lien. Sets the first due date one period out.
payInstallment(id)
Anyone. Pays the next installment and rolls dueDate forward; the creditor is senior to the protocol fee.

Kill-switch

freeze(id)
Owner, agent, or creditor. Blocks any further charges on the line.
unfreeze(id)
Owner or creditor only. Lifts a freeze and resumes the line. Either can lift a freeze set by anyone, including one the other set. No verb lowers creditLimit.

Enforcement

liquidate(id)
Anyone (a keeper), on a defaulted ERC-20-collateralized lien. Seizes collateral in-kind along the waterfall and returns any surplus to the owner. The waterfall pays the keeper reward first, then the creditor, then the protocol. It is designed so that even a deeply under-water lien attracts a keeper. The contract flags this keeper-first order as a policy choice that may be revisited, for example with a keeper auction.
liquidateAsset(id)
Anyone (a keeper), on a defaulted non-fungible token lease. The keeper pays the appraised value in the debt token and receives the whole title. This is a fixed-price sale at the appraised value, not an auction, and it uses the same keeper-first waterfall. The contract flags both as policy choices that may be revisited.

When a lien is liquidatable

Both enforcement verbs revert unless isLiquidatable is true. Two independent triggers can make it true, and either one is enough.

Trigger 1: past due
  1. Active, with debtstatus is Active and debt > 0
  2. Past duedueDate != 0 and block.timestamp > dueDate
  3. LiquidatableisLiquidatable is true
Trigger 2: under water
  1. Active, with debtstatus is Active and debt > 0
  2. Under waterdebt * 1e4 >= collateralValue * liqThresholdBps
  3. LiquidatableisLiquidatable is true
Both triggers only apply to a lien that is Active and has debt above zero.
  • A lien is past due as soon as block.timestamp is greater than dueDate. A dueDate of 0 is never past due.
  • collateralValue is oracle-priced for ERC-20 collateral and the appraised assetValue for a title.
  • A past-due lien also fails charge, reads 0 from available, and turns isAssetEnabled false.

Admin (bounded)

setParams(protocolFeeBps, keeperRewardBps, usageFeeBps, treasury)
Admin only. Each fee must stay at or below MAX_FEE_BPS (1000 bps). Emits ParamsUpdated.
setOracle(oracle)
Admin only. Sets the price oracle used for liens whose collateral and debt tokens differ. It cannot be set to zero, but any non-zero address is accepted, and the new oracle prices every live cross-token lien and so controls the underwater check. It emits no event.
transferAdmin(newAdmin)
Admin only. Hands the admin role to a new non-zero address in one step. It emits no event.