Skip to main content
A treasury policy may limit the native ETH lost in one transaction. The legacy EtherDrainAssertion intends to cap that loss at 10% of the starting balance.
The reviewed upstream example needs correction before production use. The limitation below is present in the linked source; the imported code is preserved for comparison.

Source limitation

The current source creates _preTx() and _postTx() identifiers but reads address(adopter).balance directly both times. Creating the identifiers does not switch state. The code therefore does not implement the intended before-and-after balance comparison. It also contains no destination allowlist. A local PCL test withdrew 90 ETH from a 100 ETH fixture without triggering the intended cap.

Adaptation requirements

Do not activate this example as an ETH drain limit. A replacement needs a supported native-balance observation at explicit snapshots, or a verified protocol getter read with ph.staticcallAt. The chosen getter must return actual custody rather than a mutable accounting counter. Native ETH is not an ERC-20: configuring a cumulative ERC-20 watcher with address(0) is not a substitute.

Scenarios

The table defines acceptance tests for a corrected adapter. It is not a claim that this source enforces them. Test withdrawals, forced receipts, value-bearing nested calls, and rollback. Wrapped ETH held as ERC-20 can use the ERC-20 outflow breaker, but that covers only the wrapped balance.

Legacy source

Reviewed source. See running and adapting examples for the pinned library revision.