FeeCollector

Git Source

Inherits: AccessControlEnumerable, Rescuable

Contract to collect fees from the BasketManager and distribute them to sponsors and the protocol treasury

State Variables

_BASKET_TOKEN_ROLE

CONSTANTS ///

bytes32 private constant _BASKET_TOKEN_ROLE = keccak256("BASKET_TOKEN_ROLE");

_FEE_SPLIT_DECIMALS

Fee split is denominated in 1e4. Also used as maximum fee split for the sponsor.

uint16 private constant _FEE_SPLIT_DECIMALS = 1e4;

protocolTreasury

STATE VARIABLES ///

The address of the protocol treasury

address public protocolTreasury;

_basketManager

The BasketManager contract

BasketManager internal immutable _basketManager;

basketTokenSponsors

Mapping of basket tokens to their sponsor addresses

mapping(address basketToken => address sponsor) public basketTokenSponsors;

basketTokenSponsorSplits

Mapping of basket tokens to their sponsor split percentages

mapping(address basketToken => uint16 sponsorSplit) public basketTokenSponsorSplits;

claimableTreasuryFees

Mapping of basket tokens to current claimable treasury fees

mapping(address basketToken => uint256 claimableFees) public claimableTreasuryFees;

claimableSponsorFees

Mapping of basket tokens to the current claimable sponsor fees

mapping(address basketToken => uint256 claimableFees) public claimableSponsorFees;

Functions

constructor

Constructor to set the admin, basket manager, and protocol treasury

constructor(address admin, address basketManager, address treasury) payable;

Parameters

NameTypeDescription
adminaddressThe address of the admin
basketManageraddressThe address of the BasketManager
treasuryaddressThe address of the protocol treasury

setProtocolTreasury

Set the protocol treasury address

function setProtocolTreasury(address treasury) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
treasuryaddressThe address of the new protocol treasury

setSponsor

Set the sponsor for a given basket token

function setSponsor(address basketToken, address sponsor) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token
sponsoraddressThe address of the sponsor

setSponsorSplit

Set the split of management fees given to the sponsor for a given basket token

function setSponsorSplit(address basketToken, uint16 sponsorSplit) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token
sponsorSplituint16The percentage of fees to give to the sponsor denominated in _FEE_SPLIT_DECIMALS

notifyHarvestFee

Notify the FeeCollector of the fees collected from the basket token

function notifyHarvestFee(uint256 shares) external;

Parameters

NameTypeDescription
sharesuint256The amount of shares collected

claimSponsorFee

Claim the sponsor fee for a given basket token, only callable by the sponsor

function claimSponsorFee(address basketToken) external;

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token

claimTreasuryFee

Claim the treasury fee for a given basket token, only callable by the protocol treasury or admin

function claimTreasuryFee(address basketToken) external;

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token

_claimSponsorFee

Internal function to claim the sponsor fee for a given basket token. Will immediately redeem the shares through a proRataRedeem.

function _claimSponsorFee(address basketToken, address sponsor) internal;

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token
sponsoraddressThe address of the sponsor

rescue

Rescue ERC20 tokens or ETH from the contract. Reverts if the balance trying to rescue exceeds the available balance minus claimable fees.

function rescue(IERC20 token, address to, uint256 amount) external onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
tokenIERC20address of the token to rescue. Use zero address for ETH.
toaddressaddress to send the rescued tokens to
amountuint256amount of tokens to rescue

_checkIfBasketToken

Internal function to check if a given address is a basket token

function _checkIfBasketToken(address token) internal view;

Parameters

NameTypeDescription
tokenaddressThe address to check

Events

SponsorSet

EVENTS ///

Emitted when the sponsor for a basket token is set.

event SponsorSet(address indexed basketToken, address indexed sponsor);

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token.
sponsoraddressThe address of the sponsor that was set.

SponsorSplitSet

Emitted when the sponsor fee split for a basket token is set.

event SponsorSplitSet(address indexed basketToken, uint16 sponsorSplit);

Parameters

NameTypeDescription
basketTokenaddressThe address of the basket token.
sponsorSplituint16The percentage of fees allocated to the sponsor, denominated in _FEE_SPLIT_DECIMALS.

TreasurySet

Emitted when the protocol treasury address is set.

event TreasurySet(address indexed treasury);

Parameters

NameTypeDescription
treasuryaddressThe address of the new protocol treasury.

Errors

ZeroAddress

ERRORS ///

Thrown when the address is zero.

error ZeroAddress();

SponsorSplitTooHigh

Thrown when attempting to set a sponsor fee split higher than _MAX_FEE.

error SponsorSplitTooHigh();

NoSponsor

Thrown when attempting to set a sponsor fee split for a basket token with no sponsor.

error NoSponsor();

Unauthorized

Thrown when an unauthorized address attempts to call a restricted function.

error Unauthorized();

NotBasketToken

Thrown when attempting to perform an action on an address that is not a basket token.

error NotBasketToken();

NotTreasury

Thrown when attempting to claim treasury fees from an address that is not the protocol treasury.

error NotTreasury();

InsufficientFundsToRescue

Thrown funds attempted to be rescued exceed the available balance.

error InsufficientFundsToRescue();