Fakturindocs

Automatic closing (keeper)

Why nobody presses "default" or "cancel" in Fakturin, and how the FakturKeeper contract and a Chainlink CRE cron close overdue vaults.

Two things must happen on time without anyone wanting to do them: cancel a vault whose funding window ended unfilled, and default a vault whose seller did not repay. Lenders should not have to press "Mark default" against a business. FakturKeeper plus a cron workflow do it.

The contract

FunctionWhoWhat
actionFor(vault)viewCancelFunding, MarkDefault or None, from the vault's state and deadlines
closable(max)viewUp to max vaults that can be closed now (scans the factory's vault list)
onReport(meta, report)Chainlink forwarder onlyCloses the vaults in abi.decode(report, (address[]))
closeDue(max)anyonePermissionless fallback: closes up to max due vaults

Each close runs in try/catch with a fixed gas budget (CLOSE_GAS = 250 000), so one vault that was already closed by somebody else never blocks the rest. If the remaining gas cannot cover another close, the loop stops; if it cannot cover even one, the call reverts with InsufficientGas instead of silently doing nothing.

The cron

sequenceDiagram
autonumber
participant Cron as CRE keeper workflow (cron)
participant K as FakturKeeper
participant F as Chainlink forwarder
participant V as FakturVault
participant R as FakturRegistry
loop every run
  Cron->>K: closable(10) (read)
  alt list empty
    K-->>Cron: [] → "No overdue vaults"
  else vaults due
    K-->>Cron: [vaultA, vaultB]
    Cron->>F: report abi.encode(address[])
    F->>K: onReport
    K->>V: cancelFunding() or markDefault() {gas: 250k}
    V->>R: onFundingFailed / onDefaulted
    R->>R: release limits, burn NFT, flag seller (default)
  end
end

Modes

ModeWho closesWhen
crekeeper workflow via scripts/keeper-loop.sh (pm2)Every KEEPER_INTERVAL seconds (default 60)
relayerThe app's /api/keeper, calling closeDueWhen a screen shows a vault past its deadline
AnyonecloseDue, cancelFunding, markDefault directlyAny time after the deadline

The deadlines are checked onchain in every path, so the keeper cannot close anything early, and needs no special role.

On this page