Technical Specifications

Gauge Controller

Public functions

  1. voteForGaugeWeight - Users use this function to vote/ update the existing weight for a gauge. Voting is effective for the next cycle. Users have to vote only once, and can update and remove voting weight post that time. Users can vote/update_vote for a particular gauge only once per 10 days. At any point of time total user power used <= 100%. In case a user updates his veSPA deposit (increases amount / increases time), only the new votes consider the updates. The old votes are unaffected by it.

  2. checkpoint - Checkpoint to fill data common for all gauges

  3. checkpointGauge - Checkpoints data for a particular gauge and + checkpoint()

  4. gaugeRelativeWeightWrite - Gets the current week’s relative weight for the gauge

 /// @notice Allocate voting power for changing pool weights
   /// @param _gAddr Gauge which `msg.sender` votes for
   /// @param _userWeight Weight for a gauge in bps (units of 0.01%). Minimal is 0.01%. Ignored if 0
   function voteForGaugeWeight(address _gAddr, uint256 _userWeight);
       External;


/// @notice Checkpoint to fill data common for all gauges
   function checkpoint() external;


/// @notice checkpoints gauge weight for missing weeks
   function checkpointGauge(address _gAddr) external;


/// @notice Get gauge weight normalized to 1e18 and also fill all the unfilled
   //         values for type and gauge records
   /// @dev Any address can call, however nothing is recorded if the values are filled a   already
   /// @param _gAddr Gauge address
   /// @param _time Relative weight at the specified timestamp in the past or present
   /// @return Value of relative weight normalized to 1e18
   function gaugeRelativeWeightWrite(address _gAddr, uint256 _time)
       external
       returns (uint256);
   
   /// @notice Get gauge weight normalized to 1e18 and also fill all the unfilled
   //         values for type and gauge records
   /// @dev Gets the current week’s relative weight for the gauge.
   function gaugeRelativeWeightWrite(address _gAddr)
       external
       returns (uint256);

View functions

  1. userVoteData - Get the user's vote data for a gauge

  2. userVotePower - Returns the total vote power used by the user

  3. gaugeRelativeWeight - Gets the current week’s relative weight for the gauge

  4. getGaugeWeight - Gets the last check-pointed vote for a gauge.

  5. getGaugeList - Returns the list of registered gauges.

  6. gaugeBribe - Gets the bribe contract for the registered gauge.

  7. getTotalWeight - Get current total (type-weighted) weight

  8. getTypeWeight - Get current type weight

  9. getWeightsSumPerType - Get sum of gauge weights per gauge type

  10. gaugeType - Get gauge type for gauge address

 struct VoteData {
       uint256 slope;
       uint256 power;
       uint256 end;
       uint256 voteTime;
   }

   /// @notice Get the user's vote data for a gauge.
   /// @param _user Address of the user
   /// @param _gAddr Address of the gauge.
   /// @return Returns VoteData struct.
   function userVoteData(address _user, address _gAddr)
       external
       view
       returns (VoteData memory);


/// @notice Get Gauge relative weight (not more than 1.0) normalized to 1e18
   ///         (e.g. 1.0 == 1e18). Inflation which will be received by it is
   ///         inflation_rate * relative_weight / 1e18
   /// @param _gAddr Gauge address
   /// @param _time Relative weight at the specified timestamp in the past or present
   /// @return Value of relative weight normalized to 1e18
   function gaugeRelativeWeight(address _gAddr, uint256 _time)
       external
       view
       returns (uint256);
  /// @notice Get gauge weight normalized to 1e18 and also fill all the unfilled
   //         values for type and gauge records
   /// @dev Gets the current week’s relative weight for the gauge.
   function gaugeRelativeWeight(address _gAddr)
       external
       view
       returns (uint256);


  /// @notice Get current gauge weight
   /// @param _gAddr Gauge address
   /// @return Gauge weight
   function getGaugeWeight(address _gAddr) external view returns (uint256);


   /// @notice Get the gauge weight at a provided week timestamp.
   /// @param _gAddr Gauge address
   /// @param _time Required week timestamp
   /// @dev _time should be in ((time / WEEK) * WEEK) value.
   /// @return Returns gauge weight for a week.
   function getGaugeWeight(address _gAddr, uint256 _time)
       external
       view
       returns (uint256);

 /// @notice Returns address of all registered gauges.
   function getGaugeList() external view returns (address[] memory);
 

  /// @notice Get current total (type-weighted) weight
   /// @return Total weight
   function getTotalWeight() external view returns (uint256);


 /// @notice Get current type weight
   /// @param _gType Type id
   /// @return Type weight
   function getTypeWeight(uint128 _gType) external view returns (uint256);


 /// @notice Get sum of gauge weights per type
   /// @param _gType Type id
   /// @return Sum of gauge weights
   function getWeightsSumPerType(uint128 _gType)
       external
       view
       returns (uint256);


 /// @notice Get gauge type for address
   /// @param _gAddr Gauge address
   /// @return Gauge type id
   function gaugeType(address _gAddr) external view returns (uint128);

SPA Reward Manager

Public functions

  1. distributeRewards(gaugeAddr) - Function to send rewards and update the reward rates for a gauge

 /// @notice Function to send rewards and update the reward rates for a gauge.
   /// @param _gAddr Address of the gauge
   function distributeRewards(address _gAddr) external;

View functions

  1. currentReward(gaugeAddr) - gets the rewards for gauge, for current cycle

    • If the rewards are already distributed for the week, it returns 0

    • If the distribution is Off it returns 0

  2. globalSPAEmission() - Gets the global SPA emission rate per week

  3. nextRewardTime - Gets the next reward distribution time for a gauge

  /// @notice Function gets the rewards for gauge, for current cycle.
   /// @param _gAddr Address of the gauge.
   /// @return Returns the pending amount to be distributed.
   function currentRewards(address _gAddr) public view returns (uint256);
 
/// @notice Gets the global SPA emission rate per week.
   function globalSPAEmission() external view returns (uint256);


/// @notice Gets the next reward distribution time for a gauge.
   /// @param _gAddr Address of the gauge
   function nextRewardTime() external view returns (uint256)

Bribe Contract

Public functions

  1. addRewards - Funds bribe token pool. There was two ways to fund the bribe pool:

    1. Choose the total bribe amount to be funded and number of cycles the amount should be split

    2. Pass an array with the bribe amount for upto next 10 voting cycles

  2. claimRewards - Claims pending rewards for the user

 /// @param _token Address of the bribe token.
   /// @param _amount The total amount to be funded.
   /// @param _numCycles  number of cycles the amount should be split. (2 = 2 cycles).
   function addRewards(
       address _token,
       uint256 _amount,
       uint256 _numCycles
   ) external;

   /// @notice Funds bribe token pool.
   /// @dev Funds are allocated for the next voting cycle.
   /// @param _token address of the bribe token.
   /// @param _amounts array of specific amounts to be added for upcoming weeks
   ///         min number of items = 1, max number of items = 10 in amounts array.
   function addRewards(address _token, uint256[] memory _amounts)
       external;


 /// @notice Claims pending rewards for the user.
   /// @param _user Address of the user.
   function claimRewards(address _user) external nonReentrant

View functions

  1. computeRewards - Computes pending rewards for the user

  2. getAllBribeTokens - Returns all the bribe tokens registered

  /// @notice Computes pending rewards for the user.
   /// @param _user Address of the user.
   function computeRewards(address _user)
       external
       view
       returns (uint256[] memory)

 /// @notice Returns all the bribe tokens registered.
   function getAllBribeTokens() external view returns (address[] memory)

Last updated