FeeCollector
The Fee Collector contract is responsible for collecting fees from Berachain Dapps and auctioning them for a Payout token, which then is distributed among the BGT stakers.
Inherits: IFeeCollector, PausableUpgradeable, AccessControlUpgradeable, UUPSUpgradeable
Constants
MANAGER_ROLE
The MANAGER role.
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
PAUSER_ROLE
The PAUSER role.
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
State Variables
payoutAmount
The amount of payout token that is required to claim dapp fees of a particular token.
This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees.
uint256 public payoutAmount;
payoutToken
The ERC-20 token which must be used to pay for fees when claiming dapp fees.
address public payoutToken;
queuedPayoutAmount
The amount of payout token that is queued to be set as the payout amount.
It becomes the payout amount after the next claim.
uint256 public queuedPayoutAmount;
rewardReceiver
The contract that receives the payout and is notified via method call, when dapp fees are claimed.
address public rewardReceiver;
View Functions
payoutAmount
The amount of payout token that is required to claim dapp fees of a particular token.
This works as first come first serve basis. whoever pays this much amount of the payout amount first will get the fees.
function payoutAmount() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The amount of payout token required to claim fees |
payoutToken
The ERC-20 token which must be used to pay for fees when claiming dapp fees.
function payoutToken() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | The payout token contract address |
queuedPayoutAmount
The amount of payout token that is queued to be set as the payout amount.
It becomes the payout amount after the next claim.
function queuedPayoutAmount() external view returns (uint256);
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | The queued payout amount |
rewardReceiver
The contract that receives the payout and is notified via method call, when dapp fees are claimed.
function rewardReceiver() external view returns (address);
Returns
Name | Type | Description |
---|---|---|
<none> | address | The reward receiver contract address |
Functions
claimFees
Claim collected dapp fees and transfer them to the recipient.
Caller needs to pay the PAYMENT_AMOUNT of PAYOUT_TOKEN tokens. This function is NOT implementing slippage protection. Caller has to check that received amounts match the minimum expected.
Emits:
function claimFees(address _recipient, address[] calldata _feeTokens) external whenNotPaused;
Parameters
Name | Type | Description |
---|---|---|
_recipient | address | The address to which collected dapp fees will be transferred |
_feeTokens | address[] | The addresses of the fee token to collect to the recipient |
donate
Directly sends dapp fees from msg.sender to the BGTStaker reward receiver.
The dapp fee ERC20 token MUST be the payoutToken. The amount must be at least payoutAmount to notify the reward receiver.
Emits:
function donate(uint256 amount) external whenNotPaused;
Parameters
Name | Type | Description |
---|---|---|
amount | uint256 | The amount of fee token to directly send to the reward receiver |
initialize
Initializes the FeeCollector contract.
function initialize(
address governance,
address _payoutToken,
address _rewardReceiver,
uint256 _payoutAmount
) external initializer;
Parameters
Name | Type | Description |
---|---|---|
governance | address | The governance address |
_payoutToken | address | The payout token contract address |
_rewardReceiver | address | The reward receiver contract address |
_payoutAmount | uint256 | The initial payout amount |
pause
Allows the pauser to pause the collector.
function pause() external onlyRole(PAUSER_ROLE);
queuePayoutAmountChange
Queues a new payout amount. Must be called by admin.
Emits:
function queuePayoutAmountChange(uint256 _newPayoutAmount) external onlyRole(DEFAULT_ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
_newPayoutAmount | uint256 | The value that will be the new payout amount |
unpause
Allows the manager to unpause the collector.
function unpause() external onlyRole(MANAGER_ROLE);
Events
FeesClaimed
Emitted when the dapp fees are claimed.
event FeesClaimed(address indexed caller, address indexed recipient);
Parameters
Name | Type | Description |
---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected dapp fees will be transferred |
FeesClaimed
Emitted when the fees are claimed.
event FeesClaimed(address indexed caller, address indexed recipient, address indexed feeToken, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
caller | address | Caller of the claimFees function |
recipient | address | The address to which collected dapp fees will be transferred |
feeToken | address | The address of the fee token to collect |
amount | uint256 | The amount of fee token to transfer |
PayoutAmountSet
Emitted when the payout amount is updated.
event PayoutAmountSet(uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount);
Parameters
Name | Type | Description |
---|---|---|
oldPayoutAmount | uint256 | The previous payout amount |
newPayoutAmount | uint256 | The new payout amount |
PayoutDonated
Emitted when the PayoutToken
is donated.
event PayoutDonated(address indexed caller, uint256 amount);
Parameters
Name | Type | Description |
---|---|---|
caller | address | Caller of the donate function |
amount | uint256 | The amount of payout token that is transferred |
QueuedPayoutAmount
Emitted when the admin queues the payout amount.
event QueuedPayoutAmount(uint256 queuedPayoutAmount, uint256 currentPayoutAmount);
Parameters
Name | Type | Description |
---|---|---|
queuedPayoutAmount | uint256 | The queued payout amount |
currentPayoutAmount | uint256 | The current payout amount |
Errors
DonateAmountLessThanPayoutAmount
Thrown when the donated amount is less than the required payout amount.
error DonateAmountLessThanPayoutAmount();
PayoutAmountIsZero
Thrown when the payout amount is zero.
error PayoutAmountIsZero();
ZeroAddress
Thrown when a zero address is provided where a valid address is required.
error ZeroAddress();