Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

LendingProtectionSuiteBase

Git Source

Inherits: ForkUtils, ILendingProtectionSuite

Title: LendingProtectionSuiteBase

Author: Phylax Systems

Shared default implementations for lending protection suites.

Functions

getConsumptionChecks

Default bounded-consumption implementation for suites with no extra resource checks.

Override this when the protocol needs withdraw, liquidation, or other consumption bounds. Returning an empty array keeps solvency-only suites source-compatible with the generic lending assertion.

function getConsumptionChecks(
    TriggeredCall calldata triggered,
    OperationContext calldata operation,
    PhEvm.ForkId calldata beforeFork,
    PhEvm.ForkId calldata afterFork
) external view virtual override returns (ConsumptionCheck[] memory checks);

Parameters

NameTypeDescription
triggeredTriggeredCallThe exact adopter frame that caused the assertion to run.
operationOperationContextThe decoded operation context.
beforeForkPhEvm.ForkIdThe pre-call snapshot fork.
afterForkPhEvm.ForkIdThe post-call snapshot fork.

Returns

NameTypeDescription
checksConsumptionCheck[]Empty by default.

getAccountSnapshot

Composes a full account snapshot from the step-oriented suite functions.

This is the default implementation for step-based suites. Override it only when the protocol exposes a materially cheaper or more direct way to answer the invariant than calling getAccountState(...), getAccountBalances(...), and evaluateSolvency(...) separately.

function getAccountSnapshot(address account, PhEvm.ForkId calldata fork)
    external
    view
    virtual
    override
    returns (AccountSnapshot memory snapshot);

Parameters

NameTypeDescription
accountaddressThe account whose post-operation state should be read.
forkPhEvm.ForkIdThe snapshot fork to query.

Returns

NameTypeDescription
snapshotAccountSnapshotAggregate state, balances, and solvency produced by the suite steps.

_viewFailureMessage

Returns the suite-specific revert string for failed fork-time static calls.

function _viewFailureMessage() internal pure virtual override returns (string memory);