GaugeV1

Overview

GaugeV1 is a contract designed to handle reward distribution for a specific gauge in the EYWA ecosystem. A gauge typically represents a liquidity pool or strategy that can receive rewards based on votes cast by escrowed token holders. The GaugeV1 contract:

  • Integrates with the Escrow Vote Manager to ensure only authorized entities can notify new reward amounts.

  • Uses parameters defined in a CampaignParameters structure (from IDistributionCreator) to specify how rewards are distributed over a set duration.

  • Interfaces with a Distribution Creator contract to actually create and manage reward distribution campaigns on a separate distribution layer.

  • Utilizes the EYWA token for distributing rewards to participants in a fair and time-bound manner.

By setting up reward campaigns aligned with epochs (weekly intervals), GaugeV1 ensures that allocated rewards follow the emissions schedule and that participants receive tokens proportionally over the specified campaign duration.


Inherited Contracts and Interfaces

  • UUPSUpgradeable (OpenZeppelin): Provides upgrade functionality for UUPS-proxy-based contracts, enabling controlled contract upgrades.

  • OwnableUpgradeable (OpenZeppelin): Implements ownership control, restricting certain critical functions to the contract owner.

  • IGaugeV1: Interface defining the functions and events for a gauge contract, including initialization, updating campaign parameters, and notifying new reward amounts.

Additional External References:

  • SafeERC20, IERC20 (OpenZeppelin): Ensures secure ERC20 token interactions.

  • IEscrowVoteManagerV1: The escrow vote manager contract that authorizes who can call certain functions (e.g., notifyRewardAmount).

  • IDistributionCreator: Provides a method to create reward distribution campaigns with specified parameters.


Constants

EPOCH_DURATION

  • Type: uint256

  • Value: 1 weeks

  • Description: Duration of a single epoch, used to align reward distribution campaigns with a fixed time interval.

DISTRIBUTION_CREATOR

  • Type: IDistributionCreator

  • Value: 0x8BB4C975Ff3c250e0ceEA271728547f3802B36Fd (Arbitrum network)

  • Description: The on-chain reference to the Merkl distribution contract, responsible for creating and managing distribution campaigns with given parameters.


State Variables

  • s_escrowVoteManager

    • Type: address

    • Description: The address of the escrow vote manager contract. This contract is authorized to notify the gauge of new reward amounts.

  • s_eywa

    • Type: address

    • Description: The address of the EYWA token contract used for distributing rewards.

  • s_campaignParameters

    • Type: IDistributionCreator.CampaignParameters

    • Description: The campaign parameters defining how rewards are distributed, including total amount, start time, duration, and other specifics required by the distribution contract.


Constructor

  • constructor()

    • Description: Disables initializers for an upgradeable contract, preventing re-initialization.


External Functions

initialize(...)

Signature:

function initialize(
    address owner_,
    address escrowVoteManager_,
    address eywa_,
    IDistributionCreator.CampaignParameters calldata campaignParameters_
) external initializer

Description: Initializes the gauge contract, setting the owner, the escrow vote manager, the EYWA token address, and the initial campaign parameters. This function can only be called once, during the contract deployment process.

Parameters:

  • owner_: The address of the contract owner.

  • escrowVoteManager_: Address of the escrow vote manager, which authorizes reward notifications.

  • eywa_: Address of the EYWA token contract for distributing rewards.

  • campaignParameters_: Initial campaign parameters for reward distribution.

Effects:

  • Initializes UUPSUpgradeable and OwnableUpgradeable.

  • Sets s_escrowVoteManager, s_eywa, and s_campaignParameters.

  • Transfers contract ownership to owner_.


updateCampaignParameters(...)

Signature:

function updateCampaignParameters(
    IDistributionCreator.CampaignParameters calldata newCampaignParameters_
) external onlyOwner

Description: Updates the campaign parameters stored in s_campaignParameters. Only callable by the contract owner, this function allows adjustment of distribution parameters (except dynamically changing ones like total amount or actual timing that’s set at runtime).

Parameters:

  • newCampaignParameters_: The new campaign parameters to replace the existing ones.

Effects:

  • Emits CampaignParametersUpdated event with the old and new parameters.

  • Updates s_campaignParameters to newCampaignParameters_.


notifyRewardAmount(...)

Signature:

function notifyRewardAmount(uint256 amount_) external

Description: Notifies the gauge of a new reward amount to be distributed. Only callable by the escrow vote manager. When called, the function:

  1. Transfers amount_ of EYWA tokens from the caller (escrow vote manager) to the gauge contract.

  2. Checks if the transferred amount meets the minimum required threshold (calculated based on EPOCH_DURATION and DISTRIBUTION_CREATOR.rewardTokenMinAmounts).

  3. If the threshold is met, approves the DISTRIBUTION_CREATOR to spend the tokens, updates the campaign parameters to reflect the new amount, start time, and duration, and calls createCampaign on the DISTRIBUTION_CREATOR contract to initiate the reward distribution campaign.

Parameters:

  • amount_: The amount of EYWA tokens to add as new rewards for this epoch.

Checks & Constraints:

  • Caller must be s_escrowVoteManager. If not, UnauthorizedCaller() error is thrown.

Effects:

  • Transfers EYWA tokens into the contract.

  • Potentially initiates a new reward distribution campaign via DISTRIBUTION_CREATOR.

  • Emits RewardNotified event.


Internal Functions

_authorizeUpgrade(address)

Signature:

function _authorizeUpgrade(address) internal override onlyOwner

Description: Restricts contract upgrades to the owner, ensuring secure upgradeability.


Events

RewardNotified

Emitted when new rewards are notified and transferred into the gauge.

Parameters:

  • amount: The amount of tokens added as new rewards.

CampaignParametersUpdated

Emitted when the campaign parameters for the gauge are updated.

Parameters:

  • gauge: The gauge contract address (this contract’s address).

  • oldCampaignParameters: The previous campaign parameters before the update.

  • newCampaignParameters: The updated campaign parameters.


Errors

UnauthorizedCaller()

Thrown when a function that must only be called by a specific authorized entity (like the escrow vote manager) is called by someone else.


Summary

The GaugeV1 contract manages time-bound, epoch-aligned reward distributions for a particular gauge in the EYWA ecosystem. By leveraging the IDistributionCreator and IEscrowVoteManagerV1 interfaces, it ensures that rewards are assigned only through authorized calls and distributed according to predefined campaign parameters. It allows owners to update campaign parameters for flexibility and integrates seamlessly with the EYWA token and external distribution infrastructure, thus enabling a secure and efficient reward distribution process aligned with governance and voting outcomes.

Last updated