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

TriggerRecorder

Git Source

Title: TriggerRecorder

Author: Phylax Systems

Precompile interface for registering assertion triggers

Used within the triggers() function of assertion contracts to specify when assertions should be executed. Supports call triggers, storage change triggers, and balance change triggers.

Functions

registerStorageChangeTrigger

Registers storage change trigger for all slots

function registerStorageChangeTrigger(bytes4 fnSelector) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The function selector of the assertion function.

registerStorageChangeTrigger

Registers storage change trigger for a slot

function registerStorageChangeTrigger(bytes4 fnSelector, bytes32 slot) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The function selector of the assertion function.
slotbytes32The storage slot to trigger on.

registerBalanceChangeTrigger

Registers balance change trigger for the AA

function registerBalanceChangeTrigger(bytes4 fnSelector) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The function selector of the assertion function.

registerCallTrigger

Registers a call trigger for calls to the AA.

function registerCallTrigger(bytes4 fnSelector, bytes4 triggerSelector) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The function selector of the assertion function.
triggerSelectorbytes4The function selector of the trigger function.

registerCallTrigger

Records a call trigger for the specified assertion function. A call trigger signifies that the assertion function should be called if the assertion adopter is called.

function registerCallTrigger(bytes4 fnSelector) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The function selector of the assertion function.

registerFnCallTrigger

Registers a trigger that fires when the adopter receives a call matching triggerSelector. The assertion fires once per matching call, with TriggerContext available via ph.context().

function registerFnCallTrigger(bytes4 fnSelector, bytes4 triggerSelector) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The assertion function to invoke.
triggerSelectorbytes4The 4-byte selector on the adopter to watch for.

registerTxEndTrigger

Registers a trigger that fires once after the entire transaction completes.

function registerTxEndTrigger(bytes4 fnSelector) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The assertion function to invoke.

registerErc20ChangeTrigger

Registers a trigger that fires when a token’s balances change.

function registerErc20ChangeTrigger(bytes4 fnSelector, address token) external view;

Parameters

NameTypeDescription
fnSelectorbytes4The assertion function to invoke.
tokenaddressThe ERC20 token address to watch.

watchCumulativeOutflow

Registers a circuit breaker trigger that fires when cumulative ERC20 outflow from the assertion adopter exceeds a percentage threshold within a rolling time window.

The executor handles all persistent state tracking, TVL snapshots, and threshold enforcement internally.

function watchCumulativeOutflow(address token, uint256 thresholdBps, uint256 windowDuration, bytes4 fnSelector)
    external
    view;

Parameters

NameTypeDescription
tokenaddressThe ERC20 token address to monitor.
thresholdBpsuint256Maximum cumulative outflow as basis points of the TVL snapshot taken at window start. 1000 = 10%.
windowDurationuint256Rolling window length in seconds. Balance deltas are stored in 10-second buckets; old buckets that fall outside the window are dropped as the window slides forward.
fnSelectorbytes4The assertion function to invoke when the threshold is breached.

watchCumulativeInflow

Registers a circuit breaker trigger that fires when cumulative ERC20 inflow into the assertion adopter exceeds a percentage threshold within a rolling time window.

The executor handles all persistent state tracking, TVL snapshots, and threshold enforcement internally.

function watchCumulativeInflow(address token, uint256 thresholdBps, uint256 windowDuration, bytes4 fnSelector)
    external
    view;

Parameters

NameTypeDescription
tokenaddressThe ERC20 token address to monitor.
thresholdBpsuint256Maximum cumulative inflow as basis points of the TVL snapshot taken at window start. 1000 = 10%.
windowDurationuint256Rolling window length in seconds. Balance deltas are stored in 10-second buckets; old buckets that fall outside the window are dropped as the window slides forward.
fnSelectorbytes4The assertion function to invoke when the threshold is breached.