Skip to content

Conversation

@patidarmanoj10
Copy link

What?

  • Introduces ReturnValueComparisonEnforcer, a new enforcer contract for the delegation framework.
  • Allows enforcement of rules based on the return value of a staticcall to any contract.
  • Supports flexible comparison operators: EQ, NEQ, GTE, LTE.
  • Supports multiple value types: uint256, int256, uint128, int128, and bool.
  • Compares values using ABI encoding for equality and decodes for ordered comparisons.

Why?

  • Enables advanced delegation use cases where execution should be conditional on external contract state.
  • Example: Only allow a repay action if the collateral ratio (queried from a protocol) is below a threshold.
  • Increases security and flexibility for protocol integrations and automated account management.

How?

  • _terms encodes the target contract, calldata, comparison operator, value type, and expected value.
  • In beforeHook, the enforcer performs a staticcall to the target with the provided calldata.
  • For EQ/NEQ, compares the keccak256 hash of the ABI-encoded return value and expected value (supports any type, including structs).
  • For GTE/LTE, decodes the return and expected value to the specified type and performs the ordered comparison.
  • Reverts with clear error messages if the comparison fails or if the type/operator is unsupported.

@patidarmanoj10 patidarmanoj10 requested a review from a team as a code owner June 11, 2025 07:14
@patidarmanoj10 patidarmanoj10 changed the title Return value enforcer feat: Return value enforcer Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant