rabbitholegg / quest-protocol

Quests Protocol is a protocol to distribute token rewards for completing on-chain tasks.
GNU General Public License v3.0
88 stars 22 forks source link

[BOOST-4672] implement flexible fee structures for `QuestBudget` #291

Closed mmackz closed 1 day ago

mmackz commented 5 days ago

Management Fee Implementation for QuestBudget

Overview

This PR implements the management fee feature for the QuestBudget contract, allowing boost creators to earn a fee for managing boosts.

Key Changes

  1. Management Fee Setting:

    • Added setManagementFee function to allow the contract owner to set the management fee percentage.
    • Implemented managementFee state variable to store the fee percentage.
  2. Boost Creation with Management Fee:

    • Modified createERC20Quest to calculate and reserve the management fee during quest creation.
    • Added reservedFunds state variable to track funds reserved for management fees.
    • Updated available function to account for reserved funds.
  3. Management Fee Payment:

    • Implemented payManagementFee function to allow boost creators to claim their management fee after completion.
    • Added checks to ensure only the boost creator can claim the fee and only after the remaining rewards have been withdrawn.
  4. Manager Tracking:

    • Added questManagers mapping to associate quest IDs with their creators' addresses.
  5. Events:

    • Added ManagementFeeSet event for logging changes to the management fee percentage.
    • Added ManagementFeePaid event for logging management fee payments.
  6. Testing:

    • Implemented comprehensive test suite for new management fee functionality.
    • Added helper functions and structs to streamline quest creation using common parameters.

Implementation Details

Security Considerations

Testing