Skip to content

TradingRewards

Description

This contract is an implementation of SIP-63. It records exchange fees paid by users into periods, which, when closed with a given amount of SNX rewards, allows participants to claim such rewards pro-rata, according to the amount of fees recorded for them in such period.

The recording of such fees can be enabled by the ProtocolDAO, via SystemSettings.

Source: contracts/TradingRewards.sol

Architecture

Libraries

Inheritance Graph

graph TD TradingRewards[TradingRewards] --> Pausable[Pausable] TradingRewards[TradingRewards] --> MixinResolver[MixinResolver] Pausable[Pausable] --> Owned[Owned] MixinResolver[MixinResolver] --> Owned[Owned]

Structs

Period

Source

Field Type Description
isFinalized bool A period needs to be finalized for participants to be able to claim rewards.
recordedFees uint256 Total recorded fees for the period.
totalRewards uint256 Total SNX rewards assigned to the period when it's closed.
availableRewards uint256 Remaining SNX rewards after totalRewards have been assigned. Diminishes as participants claim their rewards.
unaccountedFeesForAccount mapping(address => uint256) Records fees for each participant during the period. Increases when fees are recorded, decreases when rewards are claimed.

Constructor

constructor

Source

Details

Signature

(address owner, address periodController, address resolver)

Visibility

public

State Mutability

nonpayable

Requires

Views

getAvailableRewards

Source

Details

Signature

getAvailableRewards() returns (uint256)

Visibility

external

State Mutability

view

getAvailableRewardsForAccountForPeriod

Source

Details

Signature

getAvailableRewardsForAccountForPeriod(address account, uint256 periodID) returns (uint256)

Visibility

external

State Mutability

view

getAvailableRewardsForAccountForPeriods

Source

Details

Signature

getAvailableRewardsForAccountForPeriods(address account, uint256[] periodIDs) returns (uint256)

Visibility

external

State Mutability

view

getCurrentPeriod

Source

Details

Signature

getCurrentPeriod() returns (uint256)

Visibility

external

State Mutability

view

getPeriodAvailableRewards

Source

Details

Signature

getPeriodAvailableRewards(uint256 periodID) returns (uint256)

Visibility

external

State Mutability

view

getPeriodController

Source

Details

Signature

getPeriodController() returns (address)

Visibility

external

State Mutability

view

getPeriodIsClaimable

Source

Details

Signature

getPeriodIsClaimable(uint256 periodID) returns (bool)

Visibility

external

State Mutability

view

getPeriodIsFinalized

Source

Details

Signature

getPeriodIsFinalized(uint256 periodID) returns (bool)

Visibility

external

State Mutability

view

getPeriodRecordedFees

Source

Details

Signature

getPeriodRecordedFees(uint256 periodID) returns (uint256)

Visibility

external

State Mutability

view

getPeriodTotalRewards

Source

Details

Signature

getPeriodTotalRewards(uint256 periodID) returns (uint256)

Visibility

external

State Mutability

view

getRewardsToken

Source

Details

Signature

getRewardsToken() returns (address)

Visibility

external

State Mutability

view

getUnaccountedFeesForAccountForPeriod

Source

Details

Signature

getUnaccountedFeesForAccountForPeriod(address account, uint256 periodID) returns (uint256)

Visibility

external

State Mutability

view

getUnassignedRewards

Source

Details

Signature

getUnassignedRewards() returns (uint256)

Visibility

external

State Mutability

view

Restricted Functions

closeCurrentPeriodWithRewards

Source

Details

Signature

closeCurrentPeriodWithRewards(uint256 rewards)

Visibility

external

State Mutability

nonpayable

Requires

Modifiers

Emits

recordExchangeFeeForAccount

Source

Details

Signature

recordExchangeFeeForAccount(uint256 usdFeeAmount, address account)

Visibility

external

State Mutability

nonpayable

Modifiers

Emits

recoverAssignedRewardTokensAndDestroyPeriod

Source

Details

Signature

recoverAssignedRewardTokensAndDestroyPeriod(address recoverAddress, uint256 periodID)

Visibility

external

State Mutability

nonpayable

Requires

Modifiers

Emits

recoverEther

Source

Details

Signature

recoverEther(address payable recoverAddress)

Visibility

external

State Mutability

nonpayable

Modifiers

Emits

recoverTokens

Source

Details

Signature

recoverTokens(address tokenAddress, address recoverAddress)

Visibility

external

State Mutability

nonpayable

Requires

Modifiers

Emits

recoverUnassignedRewardTokens

Source

Details

Signature

recoverUnassignedRewardTokens(address recoverAddress)

Visibility

external

State Mutability

nonpayable

Requires

Modifiers

Emits

setPeriodController

Source

Details

Signature

setPeriodController(address newPeriodController)

Visibility

external

State Mutability

nonpayable

Requires

Modifiers

Emits

Internal Functions

_calculateRewards

Source

Details

Signature

_calculateRewards(address account, uint256 periodID) returns (uint256)

Visibility

internal

State Mutability

view

_claimRewards

Source

Details

Signature

_claimRewards(address account, uint256 periodID)

Visibility

internal

State Mutability

nonpayable

Requires

Emits

_validateRecoverAddress

Source

Details

Signature

_validateRecoverAddress(address recoverAddress)

Visibility

internal

State Mutability

view

exchanger

Source

Details

Signature

exchanger() returns (contract IExchanger)

Visibility

internal

State Mutability

view

synthetix

Source

Details

Signature

synthetix() returns (contract IERC20)

Visibility

internal

State Mutability

view

External Functions

claimRewardsForPeriod

Source

Details

Signature

claimRewardsForPeriod(uint256 periodID)

Visibility

external

State Mutability

nonpayable

Modifiers

claimRewardsForPeriods

Source

Details

Signature

claimRewardsForPeriods(uint256[] periodIDs)

Visibility

external

State Mutability

nonpayable

Modifiers

Modifiers

onlyExchanger

Source

onlyPeriodController

Source

Events

AssignedRewardTokensRecovered

Source

Signature: AssignedRewardTokensRecovered(address recoverAddress, uint256 amount, uint256 periodID)

EtherRecovered

Source

Signature: EtherRecovered(address recoverAddress, uint256 amount)

ExchangeFeeRecorded

Source

Signature: ExchangeFeeRecorded(address account, uint256 amount, uint256 periodID)

NewPeriodStarted

Source

Signature: NewPeriodStarted(uint256 periodID)

PeriodControllerChanged

Source

Signature: PeriodControllerChanged(address newPeriodController)

PeriodFinalizedWithRewards

Source

Signature: PeriodFinalizedWithRewards(uint256 periodID, uint256 rewards)

RewardsClaimed

Source

Signature: RewardsClaimed(address account, uint256 amount, uint256 periodID)

TokensRecovered

Source

Signature: TokensRecovered(address tokenAddress, address recoverAddress, uint256 amount)

UnassignedRewardTokensRecovered

Source

Signature: UnassignedRewardTokensRecovered(address recoverAddress, uint256 amount)