IReferral
Functions
getReferrer
Returns the address of the referrer for a given user
function getReferrer(address user) external view returns (address referrer);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Returns
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
getRebateTier
Returns the rebate tier for a given referrer
function getRebateTier(address referrer) external view returns (RebateTier tier);
Parameters
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
Returns
Name | Type | Description |
---|---|---|
tier | RebateTier | The rebate tier |
getRebatePercents
Returns the primary and secondary rebate percents
function getRebatePercents()
external
view
returns (UD60x18[] memory primaryRebatePercents, UD60x18 secondaryRebatePercent);
Returns
Name | Type | Description |
---|---|---|
primaryRebatePercents | UD60x18[] | The primary rebate percents (18 decimals) |
secondaryRebatePercent | UD60x18 | The secondary rebate percent (18 decimals) |
getRebatePercents
Returns the primary and secondary rebate percents for a given referrer
function getRebatePercents(address referrer)
external
view
returns (UD60x18 primaryRebatePercent, UD60x18 secondaryRebatePercent);
Parameters
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
Returns
Name | Type | Description |
---|---|---|
primaryRebatePercent | UD60x18 | The primary rebate percent (18 decimals) |
secondaryRebatePercent | UD60x18 | The secondary rebate percent (18 decimals) |
getRebates
Returns the rebates for a given referrer
function getRebates(address referrer) external view returns (address[] memory tokens, uint256[] memory rebates);
Parameters
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
Returns
Name | Type | Description |
---|---|---|
tokens | address[] | The tokens for which the referrer has rebates |
rebates | uint256[] | The rebates for each token (token decimals) |
getRebateAmounts
Returns the primary and secondary rebate amounts for a given user
and referrer
function getRebateAmounts(address user, address referrer, UD60x18 tradingFee)
external
view
returns (UD60x18 primaryRebate, UD60x18 secondaryRebate);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user |
referrer | address | The address of the referrer |
tradingFee | UD60x18 | The trading fee (18 decimals) |
Returns
Name | Type | Description |
---|---|---|
primaryRebate | UD60x18 | The primary rebate amount (18 decimals) |
secondaryRebate | UD60x18 | The secondary rebate amount (18 decimals) |
setRebateTier
Sets the rebate tier for a given referrer - caller must be owner
function setRebateTier(address referrer, RebateTier tier) external;
Parameters
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
tier | RebateTier | The rebate tier |
setPrimaryRebatePercent
Sets the primary rebate percents - caller must be owner
function setPrimaryRebatePercent(UD60x18 percent, RebateTier tier) external;
Parameters
Name | Type | Description |
---|---|---|
percent | UD60x18 | The primary rebate percent (18 decimals) |
tier | RebateTier | The rebate tier |
setSecondaryRebatePercent
Sets the secondary rebate percent - caller must be owner
function setSecondaryRebatePercent(UD60x18 percent) external;
Parameters
Name | Type | Description |
---|---|---|
percent | UD60x18 | The secondary rebate percent (18 decimals) |
useReferral
Pulls the total rebate amount from msg.sender - caller must be an authorized pool
The tokens must be approved for transfer
function useReferral(address user, address referrer, address token, UD60x18 primaryRebate, UD60x18 secondaryRebate)
external;
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user |
referrer | address | The address of the primary referrer |
token | address | The address of the token |
primaryRebate | UD60x18 | The primary rebate amount (18 decimals) |
secondaryRebate | UD60x18 | The secondary rebate amount (18 decimals) |
claimRebate
Claims the rebates for the msg.sender
function claimRebate(address[] memory tokens) external;
Parameters
Name | Type | Description |
---|---|---|
tokens | address[] | The tokens to claim |
Events
ClaimRebate
event ClaimRebate(address indexed referrer, address indexed token, uint256 amount);
SetPrimaryRebatePercent
event SetPrimaryRebatePercent(RebateTier tier, UD60x18 oldPercent, UD60x18 newPercent);
SetRebateTier
event SetRebateTier(address indexed referrer, RebateTier oldTier, RebateTier newTier);
SetSecondaryRebatePercent
event SetSecondaryRebatePercent(UD60x18 oldPercent, UD60x18 newPercent);
Refer
event Refer(
address indexed user,
address indexed primaryReferrer,
address indexed secondaryReferrer,
address token,
UD60x18 primaryRebatePercent,
UD60x18 primaryRebate,
UD60x18 secondaryRebate
);
Errors
Referral__PoolNotAuthorized
error Referral__PoolNotAuthorized();
Enums
RebateTier
enum RebateTier {
PrimaryRebate1,
PrimaryRebate2,
PrimaryRebate3
}