Primary finding
Negative amounts/epochs produce malformed ABI calldata due to hex(-n)[2:] usage (can lead to failing or unintended transactions)
- agenticbets/scripts/agenticbets.py:226
- agenticbets/scripts/agenticbets.py:133-134
- agenticbets/scripts/agenticbets.py:141-143
- agenticbets/scripts/agenticbets.py:151-154
- agenticbets/scripts/agenticbets.py:161-163
Python’s hex() for negative integers returns strings like '-0x5'. Slicing with [2:] yields 'x5', which is not valid hex. The code passes user-provided amount/epoch values directly into hex()[2:], so negative inputs lead to malformed calldata for approve/bet/claim/claimable. This can cause wallet submit failures or unintended values if not rejected upstream. Amounts below 1 USDC should also be rejected preflight to avoid on-chain reverts and wasted gas.
Recommendation
- Validate inputs before encoding: - For bet: ensure amount is a positive number and at least 1 USDC; reject zero/negative/NaN with a clear error. - For claim: ensure epochs are positive integers (>= 0). - Guard against negative values before calling hex(); raise on invalid input. - Consider using a minimal ABI encoder or library to avoid manual mistakes. - Add explicit checks and helpful error messages for BelowMinBet (>= 1 USDC).