TriggerRecorder
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
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The function selector of the assertion function. |
registerStorageChangeTrigger
Registers storage change trigger for a slot
function registerStorageChangeTrigger(bytes4 fnSelector, bytes32 slot) external view;
Parameters
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The function selector of the assertion function. |
slot | bytes32 | The storage slot to trigger on. |
registerBalanceChangeTrigger
Registers balance change trigger for the AA
function registerBalanceChangeTrigger(bytes4 fnSelector) external view;
Parameters
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The 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
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The function selector of the assertion function. |
triggerSelector | bytes4 | The 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
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The 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
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The assertion function to invoke. |
triggerSelector | bytes4 | The 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
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The 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
| Name | Type | Description |
|---|---|---|
fnSelector | bytes4 | The assertion function to invoke. |
token | address | The 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
| Name | Type | Description |
|---|---|---|
token | address | The ERC20 token address to monitor. |
thresholdBps | uint256 | Maximum cumulative outflow as basis points of the TVL snapshot taken at window start. 1000 = 10%. |
windowDuration | uint256 | Rolling 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. |
fnSelector | bytes4 | The 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
| Name | Type | Description |
|---|---|---|
token | address | The ERC20 token address to monitor. |
thresholdBps | uint256 | Maximum cumulative inflow as basis points of the TVL snapshot taken at window start. 1000 = 10%. |
windowDuration | uint256 | Rolling 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. |
fnSelector | bytes4 | The assertion function to invoke when the threshold is breached. |