Skip to main content

FeeManager

Git Source

Inherits: IFeeManager, ReentrancyGuard

Defines fees for auctions and manages the collection and distribution of fees

State Variables

_FEE_DECIMALS

Fees are in basis points (hundredths of a percent). 1% equals 100.

uint48 internal constant _FEE_DECIMALS = 100e2;

_protocol

Address the protocol receives fees at

address internal _protocol;

fees

Fees charged for each auction type

See Fees struct for more details

mapping(Keycode => Fees) public fees;

rewards

Fees earned by an address, by token

mapping(address => mapping(ERC20 => uint256)) public rewards;

Functions

constructor

constructor(address protocol_);

calculateQuoteFees

Calculates and allocates fees that are collected in the quote token

function calculateQuoteFees(
uint48 protocolFee_,
uint48 referrerFee_,
bool hasReferrer_,
uint256 amount_
) public pure returns (uint256 toReferrer, uint256 toProtocol);

Parameters

NameTypeDescription
protocolFee_uint48Fee charged by the protocol
referrerFee_uint48Fee charged by the referrer
hasReferrer_boolWhether the auction has a referrer
amount_uint256Amount to calculate fees for

Returns

NameTypeDescription
toReferreruint256Amount to send to the referrer
toProtocoluint256Amount to send to the protocol

_calculatePayoutFees

Calculates and allocates fees that are collected in the payout token

function _calculatePayoutFees(
bool curated_,
uint48 curatorFee_,
uint256 payout_
) internal pure returns (uint256 toCurator);

setCuratorFee

Sets the fee for a curator (the sender) for a specific auction type

function setCuratorFee(Keycode auctionType_, uint48 fee_) external;

Parameters

NameTypeDescription
auctionType_KeycodeAuction type to set fees for
fee_uint48Fee to charge

getFees

Gets the fees for a specific auction type

function getFees(
Keycode auctionType_
) external view override returns (uint48 protocol, uint48 maxReferrerFee, uint48 maxCuratorFee);

Parameters

NameTypeDescription
auctionType_KeycodeAuction type to get fees for

Returns

NameTypeDescription
protocoluint48Fee charged by the protocol
maxReferrerFeeuint48Maximum fee that can be paid to a referrer
maxCuratorFeeuint48Maximum fee that a curator can charge

getCuratorFee

Gets the fee for a specific auction type and curator

function getCuratorFee(
Keycode auctionType_,
address curator_
) external view override returns (uint48 curatorFee);

Parameters

NameTypeDescription
auctionType_KeycodeAuction type to get fees for
curator_addressCurator to get fees for

Returns

NameTypeDescription
curatorFeeuint48Fee charged by the curator

claimRewards

Claims the rewards for a specific token and the sender

This function reverts if:

  • re-entrancy is detected
function claimRewards(address token_) external nonReentrant;

Parameters

NameTypeDescription
token_addressToken to claim rewards for

getRewards

Gets the rewards for a specific recipient and token

function getRewards(
address recipient_,
address token_
) external view override returns (uint256 reward);

Parameters

NameTypeDescription
recipient_addressRecipient to get rewards for
token_addressToken to get rewards for

Returns

NameTypeDescription
rewarduint256Reward amount

getProtocol

Gets the protocol address

function getProtocol() public view returns (address);