Key Components

  1. BribeFactoryV3 Contract: The main contract for creating and managing bribe contracts.
  2. Bribe Contract: Individual contracts created for each pool, handling reward distribution.
  3. Voter Contract: Interacts with bribe contracts to allocate votes and distribute rewards.

How It Works

  1. Bribe contracts are created for each liquidity pool.
  2. External parties can add rewards (bribes) to these contracts.
  3. Voters allocate their voting power to pools.
  4. Rewards are distributed to voters based on their allocation.

Key Functions in BribeFactoryV3

Creating Bribes

function createBribe(address _owner, address _token0, address _token1, string memory _type) external returns (address)
  • Creates a new bribe contract for a pool.
  • Only callable by the voter contract or owner.
  • Automatically adds default reward tokens.

Managing Reward Tokens

function addRewardToBribe(address _token, address __bribe) external onlyAllowed
function addRewardsToBribe(address[] memory _token, address __bribe) external onlyAllowed
function addRewardToBribes(address _token, address[] memory __bribes) external onlyAllowed
function addRewardsToBribes(address[][] memory _token, address[] memory __bribes) external onlyAllowed
  • Add reward tokens to existing bribe contracts.
  • Restricted to owner or accounts with BRIBE_ADMIN role.

Updating Bribe Contract Settings

function setBribeVoter(address[] memory _bribe, address _voter) external onlyOwner
function setBribeMinter(address[] memory _bribe, address _minter) external onlyOwner
function setBribeOwner(address[] memory _bribe, address _owner) external onlyOwner
  • Update voter, minter, or owner of bribe contracts.
  • Only callable by the owner.

Emergency Functions

function recoverERC20From(address[] memory _bribe, address[] memory _tokens, uint[] memory _amounts) external onlyOwner
function recoverERC20AndUpdateData(address[] memory _bribe, address[] memory _tokens, uint[] memory _amounts) external onlyOwner
  • Recover ERC20 tokens from bribe contracts in case of emergencies.
  • Only callable by the owner.

Integration Points

  1. Voter Contract: Must be set correctly to interact with bribe contracts.
  2. Permissions Registry: Controls access to certain functions via the BRIBE_ADMIN role.
  3. Default Reward Tokens: Can be managed by the owner to add or remove tokens.

Best Practices for Development

  1. Always use the onlyAllowed modifier for sensitive functions.
  2. Ensure the voter address is correctly set and updated when necessary.
  3. Regularly audit the list of default reward tokens.
  4. Be cautious when using emergency recovery functions to avoid disrupting the reward system.