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.
| Verb | Who can call it | Moves tokens? |
|---|---|---|
open, openAsset | Anyone. The caller becomes the owner | Yes: collateral or title in |
charge | Creditor | No: records a receivable |
chargeWithAuth | Creditor, with the agent's signature | No: records a receivable |
repay | Anyone, usually the owner | Yes: debt token, from the payer |
addCollateral | Anyone | Yes: collateral in |
setLeaseSchedule | Owner | No |
payInstallment | Anyone | Yes: debt token, from the payer |
freeze | Owner, agent or creditor | No |
unfreeze | Owner or creditor | No |
liquidate | Anyone (a keeper) | Yes: collateral out, in kind |
liquidateAsset | Anyone (a keeper) | Yes: debt token in, title out |
close | Owner | Yes: collateral or title back to the owner |
setParams, setOracle, transferAdmin | Admin | No |
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
openchecks 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
assetValuein 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;
chargeis 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 {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
dueDateforward; 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
- Active, with debtstatus is Active and debt > 0
- Past duedueDate != 0 and block.timestamp > dueDate
- LiquidatableisLiquidatable is true
Trigger 2: under water
- Active, with debtstatus is Active and debt > 0
- Under waterdebt * 1e4 >= collateralValue * liqThresholdBps
- LiquidatableisLiquidatable is true
- A lien is past due as soon as
block.timestampis greater thandueDate. AdueDateof0is never past due. collateralValueis oracle-priced for ERC-20 collateral and the appraisedassetValuefor a title.- A past-due lien also fails
charge, reads0fromavailable, and turnsisAssetEnabledfalse.
Admin (bounded)
- setParams(protocolFeeBps, keeperRewardBps, usageFeeBps, treasury)
- Admin only. Each fee must stay at or below
MAX_FEE_BPS(1000 bps). EmitsParamsUpdated. - 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.