Skip to main content

IFeeDistributor

IFeeDistributor

Addresses

ChainAddress

Functions

receiveFee

Notify FeeDistributor that caller has sent it some fees. Check FeeReferral to see who referred the caller, and send that referrer their share of fees. Then, proportionally increase pending fees of each active FeeAllocation.

function receiveFee(address caller) external
Dev note

Normally, a function like this would pull tokens straight from msg.sender. This push-and-notify model allows the exchange to collect fees without having to call approve() each time, and (in the case of deposits and increases) to transfer tokens straight from the user to FeeDistributor without an intermediary transfer to the exchange. EOAs and integrators calling receiveFee() should do so within the context of a single smart contract transaction - otherwise, anybody can call receiveFee() with a high gas payment to "take credit" for a previous transfer.

Parameters

NameTypeDescription
calleraddressAddress responsible for recent increase in collateral balance. For instance, a trader who has just paid a fee.

feeReferral

function feeReferral() external view returns (contract IFeeReferral)

Types

FeeAllocation

Share of incoming fees given to recipient.

Fields

NameTypeDescription
recipientaddressWho these fees should be delivered to
feeRatioFPUnsignedFraction of incoming fees sent to this recipient. In range (0, 1]
pendingFeesFPUnsignedAccumulated fees that have not yet been delivered
distributionTypeenum IFeeDistributor.DistributionTypeSee DistributionType
struct FeeAllocation {
address recipient;
FPUnsigned feeRatio;
FPUnsigned pendingFees;
enum IFeeDistributor.DistributionType distributionType;
}

DistributionType

Either the type of a stored fee allocation, or a command to change the state.

Values

NameDescription
DELETEDCommand only: Mark for fee distribution and deletion
FORCE_DELETEDCommand only: Mark for deletion. Any accrued fees will be lost!!
DISABLEDState/Command: Temporarily disabled; does not accrue or distribute fees
DIRECTState/Command: Distribute fees via IERC20.transfer
NOTIFYState/Command: Distribute fees via IRewardRecipient.transferRewardAmount
enum DistributionType {
DELETED,
FORCE_DELETED,
DISABLED,
DIRECT,
NOTIFY
}