Key Components

  1. GaugeFactoryV2: The main contract for creating and managing gauges.
  2. GaugeV2: Individual gauge contracts created by the factory.
  3. Voting Mechanism: Allows ve3,3 token holders to allocate votes to gauges.
  4. Reward Distribution: Handles the emission of rewards based on gauge weights.

GaugeFactoryV2 Contract

The GaugeFactoryV2 contract is responsible for creating and managing gauges. It includes functions for:

  • Creating new gauges
  • Managing emergency modes
  • Setting reward parameters
  • Updating gauge configurations

Key Functions

function createGaugeV2(
    address _rewardToken,
    address _ve,
    address _token,
    address _distribution,
    address _internal_bribe,
    address _external_bribe,
    bool _isPair
) external returns (address)

Creates a new gauge and returns its address.

function activateEmergencyMode(address[] memory _gauges) external
function stopEmergencyMode(address[] memory _gauges) external

Activates or deactivates emergency mode for specified gauges.

function setRewarderPid(address[] memory _gauges, uint[] memory _pids) external
function setGaugeRewarder(address[] memory _gauges, address[] memory _rewarder) external
function setDistribution(address[] memory _gauges, address distro) external
function setInternalBribe(address[] memory _gauges, address[] memory int_bribe) external

Configure reward-related parameters for gauges.

Using Gauges

Creating a New Gauge

To create a new gauge for a liquidity pool:

  1. Call createGaugeV2 on the GaugeFactoryV2 contract.
  2. Store the returned gauge address for future reference.
const newGaugeAddress = await gaugeFactory.createGaugeV2(
  rewardTokenAddress,
  veTokenAddress,
  poolTokenAddress,
  distributionAddress,
  internalBribeAddress,
  externalBribeAddress,
  isPair
);

Voting on Gauges

Users with locked ve3,3 tokens can vote on gauges:

  1. Implement a voting interface in the frontend.
  2. Call the voting function on the gauge controller contract.
await gaugeController.vote(gaugeAddress, weight);

Distributing Rewards

Rewards are distributed based on gauge weights:

  1. The system calculates gauge weights periodically.
  2. Rewards are emitted to gauges based on their relative weights.
  3. Users can claim rewards from gauges they’ve provided liquidity to.

Maintenance and Upgrades

Emergency Mode

In case of critical issues:

  1. Call activateEmergencyMode on GaugeFactoryV2.
  2. This will pause reward emissions and certain gauge functions.
  3. Use stopEmergencyMode to resume normal operations.

Updating Gauge Parameters

To modify gauge settings:

  1. Use the appropriate setter function in GaugeFactoryV2.
  2. Ensure you have the necessary permissions (GAUGE_ADMIN role).

Example:

await gaugeFactory.setDistribution([gauge1Address, gauge2Address], newDistributionAddress);

Integration with Other Components

  • ve3,3 Token: Provides voting power for gauge voting.
  • Liquidity Pools: Gauges are associated with specific liquidity pools.
  • Merkl: Handles efficient reward distribution from gauges to users.