Skip to content

Conversation

malgus01
Copy link
Contributor

@malgus01 malgus01 commented Oct 1, 2025

PR Description

Summary

This PR introduces two important safety and access-control mechanisms in TestArbitrage.sol:

  1. An authorizedTraders mapping for whitelisting addresses that can execute trades.
  2. A configurable minFlashAmount threshold to prevent dust-level flash loan requests.

Both additions are documented with NatSpec comments for clarity and maintainability.


Changes

  • Authorized Traders Mapping

    • Added mapping(address => bool) public authorizedTraders;
    • Restricts execution of trade logic to only approved addresses.
    • Provides flexibility for controlled testing and production scenarios.
  • Minimum Flash Loan Amount

    • Introduced uint256 public minFlashAmount = 1000;
    • Ensures flash loan requests below this threshold are disallowed.
    • Protects against dust attacks and avoids unprofitable transactions.
  • Documentation

    • Added NatSpec comments for both features (authorizedTraders and minFlashAmount).
  • Formatting

    • Ran forge fmt to maintain code consistency.

Rationale

  • Access Control:
    Without restrictions, any address could potentially trigger arbitrage logic, which introduces security and testing risks. Whitelisting ensures only trusted accounts can interact.

  • Economic Safety:
    Very small flash loans can waste gas and pose potential DoS risks. Enforcing a minimum flash loan amount improves efficiency and safety.


Impact

  • No breaking changes to existing deployment or logic.
  • Future contracts or tests may rely on authorizedTraders to enforce role-based permissions.
  • minFlashAmount provides a configurable safety net but does not alter higher-level arbitrage logic.

Next Steps

  • Implement functions for:
    • Adding/removing authorizedTraders.
    • Updating minFlashAmount dynamically via governance or owner functions.
  • Integrate these checks into trade execution and flash loan entry points.
  • Extend test coverage for:
    • Unauthorized access attempts.
    • Flash loans below the minimum threshold.

@0xRiz0 0xRiz0 self-requested a review October 1, 2025 18:18
@0xRiz0 0xRiz0 added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 1, 2025
@0xRiz0 0xRiz0 merged commit d59bb76 into FlashArb-AI:main Oct 1, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants