Skip to content

Conversation

@ilikesymmetry
Copy link
Collaborator

@ilikesymmetry ilikesymmetry commented Dec 5, 2025

Description

We have to absolutely minimize any possible reverts through execution of BridgeReferralFees.

The following cases have been identified and mitigated:

  1. removed revert for zero bridged amount, let silently pass through (Flywheel will filter it out)
  2. wrap all calls to BuidlerCodes in try-catch and remove fees if any issues
  3. mitigate possibility of bridgedAmount - feeAmount underflow by enforcing MAX_FEE_BASIS_POINTS < 1e4 via uint8 type
  4. adjust feeAmount calculation to handle potential overflow case

The following cases have been identified, but not deemed worth addressing:

  1. invalid token argument leading to failing balanceOf calls
  2. malicious token that could violate accounting invariants, making underflow on bridgedAmount calculation possible

Additionally, we are removing footguns for the developer by replacing the bytes32 code representation with the simpler string code.

Asks

Update unit tests to align with recent BridgeReferralFees contract changes:
- Change feeBps type from uint16 to uint8 across all tests
- Change builder code encoding from bytes32 to string
- Update fee calculation to use _safePercent formula
- Remove obsolete zero amount revert test (behavior changed)
- Update error handling tests for graceful failures

Add 20 new test function skeletons with proper NatSpec:
- Invalid builder code handling (5 tests)
- _safePercent overflow protection (5 tests)
- Zero bridged amount behavior (1 test)
- BuilderCodes external call failures (2 tests)
- Error handling in onDistributeFees (5 tests)
- uint8 MAX_FEE_BASIS_POINTS validation (2 tests)

All 73 tests passing.
- Add _percent() and _safePercent() helper functions to BridgeReferralFeesTest
- Remove 17 unused parameters from 13 test functions
- Implement 19 test stubs for new BridgeReferralFees functionality
- All 73 BridgeReferralFees tests passing
@ilikesymmetry ilikesymmetry marked this pull request as ready for review December 10, 2025 04:30
@ilikesymmetry ilikesymmetry changed the title Check code is valid before checking is registered Increase fault tolerance of BridgeReferralFees hooks Dec 10, 2025
@ilikesymmetry ilikesymmetry merged commit 30266bb into main Dec 16, 2025
3 of 4 checks passed
@ilikesymmetry ilikesymmetry deleted the conner/bridge-referral-fees-hotfix branch December 16, 2025 18:20
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.

2 participants