Skip to content

FeeCollector

0x7Bb8DdaC7FbE3FFC0f4B3c73C4F158B06CF82650 | ABI JSON

Git Source

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.

solidity
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");

PAUSER_ROLE

The PAUSER role.

solidity
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.

solidity
uint256 public payoutAmount;

payoutToken

The ERC-20 token which must be used to pay for fees when claiming dapp fees.

solidity
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.

solidity
uint256 public queuedPayoutAmount;

rewardReceiver

The contract that receives the payout and is notified via method call, when dapp fees are claimed.

solidity
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.

solidity
function payoutAmount() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The 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.

solidity
function payoutToken() external view returns (address);

Returns

NameTypeDescription
<none>addressThe 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.

solidity
function queuedPayoutAmount() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The queued payout amount

rewardReceiver

The contract that receives the payout and is notified via method call, when dapp fees are claimed.

solidity
function rewardReceiver() external view returns (address);

Returns

NameTypeDescription
<none>addressThe 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:

solidity
function claimFees(address _recipient, address[] calldata _feeTokens) external whenNotPaused;

Parameters

NameTypeDescription
_recipientaddressThe address to which collected dapp fees will be transferred
_feeTokensaddress[]The addresses of the fee token to collect to the recipient

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:

solidity
function donate(uint256 amount) external whenNotPaused;

Parameters

NameTypeDescription
amountuint256The amount of fee token to directly send to the reward receiver

initialize

Initializes the FeeCollector contract.

solidity
function initialize(
    address governance,
    address _payoutToken,
    address _rewardReceiver,
    uint256 _payoutAmount
) external initializer;

Parameters

NameTypeDescription
governanceaddressThe governance address
_payoutTokenaddressThe payout token contract address
_rewardReceiveraddressThe reward receiver contract address
_payoutAmountuint256The initial payout amount

pause

Allows the pauser to pause the collector.

solidity
function pause() external onlyRole(PAUSER_ROLE);

queuePayoutAmountChange

Queues a new payout amount. Must be called by admin.

Emits:

solidity
function queuePayoutAmountChange(uint256 _newPayoutAmount) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
_newPayoutAmountuint256The value that will be the new payout amount

unpause

Allows the manager to unpause the collector.

solidity
function unpause() external onlyRole(MANAGER_ROLE);

Events

FeesClaimed

Emitted when the dapp fees are claimed.

solidity
event FeesClaimed(address indexed caller, address indexed recipient);

Parameters

NameTypeDescription
calleraddressCaller of the claimFees function
recipientaddressThe address to which collected dapp fees will be transferred

FeesClaimed

Emitted when the fees are claimed.

solidity
event FeesClaimed(address indexed caller, address indexed recipient, address indexed feeToken, uint256 amount);

Parameters

NameTypeDescription
calleraddressCaller of the claimFees function
recipientaddressThe address to which collected dapp fees will be transferred
feeTokenaddressThe address of the fee token to collect
amountuint256The amount of fee token to transfer

PayoutAmountSet

Emitted when the payout amount is updated.

solidity
event PayoutAmountSet(uint256 indexed oldPayoutAmount, uint256 indexed newPayoutAmount);

Parameters

NameTypeDescription
oldPayoutAmountuint256The previous payout amount
newPayoutAmountuint256The new payout amount

PayoutDonated

Emitted when the PayoutToken is donated.

solidity
event PayoutDonated(address indexed caller, uint256 amount);

Parameters

NameTypeDescription
calleraddressCaller of the donate function
amountuint256The amount of payout token that is transferred

QueuedPayoutAmount

Emitted when the admin queues the payout amount.

solidity
event QueuedPayoutAmount(uint256 queuedPayoutAmount, uint256 currentPayoutAmount);

Parameters

NameTypeDescription
queuedPayoutAmountuint256The queued payout amount
currentPayoutAmountuint256The current payout amount

Errors

DonateAmountLessThanPayoutAmount

Thrown when the donated amount is less than the required payout amount.

solidity
error DonateAmountLessThanPayoutAmount();

PayoutAmountIsZero

Thrown when the payout amount is zero.

solidity
error PayoutAmountIsZero();

ZeroAddress

Thrown when a zero address is provided where a valid address is required.

solidity
error ZeroAddress();