Bribe

Contract for third parties to bribe sDYSON holders into depositing their sDYSON in certain Gauge contract. Each Bribe contract is paired with one Gauge contract. Third parties can add multiple tokens as rewards. Please refer to Sponsorship section in our white paper to learn more.

addReward

Adds a reward of a given token to a specific week. Below is an introduction to what the function does:

  1. Require Statement:

    • Ensures that the specified week is either the present week or a future week.

  2. Token Transfer:

    • Transfers the specified amount of tokens from the caller's address to the Bribe contract.

  3. Update Total Reward:

    • Increases the total reward amount for the given token and week by the specified amount.

This function is designed to be used by third parties to contribute rewards to the Bribe contract for specific tokens and weeks. The require statement ensures that rewards cannot be added for past weeks. The function provides transparency by emitting an event for every reward addition.

function addReward(
    address token, 
    uint week, 
    uint amount) external

Parameters:

Name
Type
Description

token

address

Address of the token to add as a reward.

week

uint

The week to add the reward to (i-th week since 1970/01/01). It must be the present week or a future week.

amount

uint

Amount of the token to add as a reward.

_claimReward

Claims the reward by the user for a specific token and week. Below is the key actions in the function:

  1. Require Statements:

    • Ensures that the specified week is in the past.

    • Ensures that the user has not already claimed the reward for the given token and week.

  2. User and Total Votes Calculation:

    • Retrieves the user's voting power (userVotes) and the total voting power (totalVotes) for the specified week from the associated Gauge contract.

  3. Reward Calculation:

    • Calculates the amount of reward the user is eligible to claim based on their voting power relative to the total voting power.

  4. Mark as Claimed:

    • Marks the reward as claimed for the user, preventing duplicate claims.

This function is internal and is used internally by the contract. It calculates and facilitates the claiming of rewards for a user for a specific token and week.

function _claimReward(
    address token, 
    uint week) internal returns (uint amount)

Parameters:

Name
Type
Description

token

address

Address of the reward token.

week

uint

The week of the reward to claim (i-th week since 1970/01/01).

Return Values:

Name
Type
Description

amount

uint

Amount of the claimed reward.

claimReward

Enables sDYSON holders to claim rewards for a specific token and week based on _claimReward .

function claimReward(
    address token, 
    uint week) external returns (uint amount)

Parameters:

Name
Type
Description

token

address

Address of the reward token.

week

uint

The week of the reward to claim (i-th week since 1970/01/01).

Return Values:

Name
Type
Description

amount

uint

Amount of the claimed reward.

claimRewards

Claims multiple rewards by the user for a specific token and multiple weeks based on _claimReward.

function claimRewards(
    address token, 
    uint[] calldata week) public returns (uint amount)

Parameters:

Name
Type
Description

token

address

Address of the reward token.

week

uint[]

An array of weeks for which the user wants to claim rewards.

Return Values:

Name
Type
Description

amount

uint

Total amount of the claimed rewards.

claimRewardsMultipleTokens

Claims multiple rewards for multiple tokens and multiple weeks based on _claimReward.

function claimRewardsMultipleTokens(
    address[] calldata token, 
    uint[][] calldata week) external returns (uint[] memory amount)

Parameters:

Name
Type
Description

token

address[]

An array of addresses of reward tokens.

week

uint[][]

An array of arrays of weeks for which the user wants to claim rewards.

Return Values:

Name
Type
Description

amount

uint

An array of total amounts of the claimed rewards.

Last updated