IFeeDistributor
IFeeDistributor
Addresses
Chain | Address |
---|
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
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
Name | Type | Description |
---|---|---|
caller | address | Address 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
Name | Type | Description |
---|---|---|
recipient | address | Who these fees should be delivered to |
feeRatio | FPUnsigned | Fraction of incoming fees sent to this recipient. In range (0, 1] |
pendingFees | FPUnsigned | Accumulated fees that have not yet been delivered |
distributionType | enum IFeeDistributor.DistributionType | See 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
Name | Description |
---|---|
DELETED | Command only: Mark for fee distribution and deletion |
FORCE_DELETED | Command only: Mark for deletion. Any accrued fees will be lost!! |
DISABLED | State/Command: Temporarily disabled; does not accrue or distribute fees |
DIRECT | State/Command: Distribute fees via IERC20.transfer |
NOTIFY | State/Command: Distribute fees via IRewardRecipient.transferRewardAmount |
enum DistributionType {
DELETED,
FORCE_DELETED,
DISABLED,
DIRECT,
NOTIFY
}