Referral
Inherits: IReferral, OwnableInternal, ReentrancyGuard
State Variables
FACTORY
address internal immutable FACTORY;
Functions
constructor
constructor(address factory);
getReferrer
Returns the address of the referrer for a given user
function getReferrer(address user) public view returns (address);
Parameters
Name | Type | Description |
---|---|---|
user | address | The address of the user |
Returns
Name | Type | Description |
---|---|---|
<none> | address | referrer The address of the referrer |
getRebateTier
Returns the rebate tier for a given referrer
function getRebateTier(address referrer) public view returns (RebateTier);
Parameters
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
Returns
Name | Type | Description |
---|---|---|
<none> | RebateTier | tier 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
function getRebatePercents(address referrer)
public
view
returns (UD60x18 primaryRebatePercents, UD60x18 secondaryRebatePercent);
Returns
Name | Type | Description |
---|---|---|
primaryRebatePercents | UD60x18 | The primary rebate percents (18 decimals) |
secondaryRebatePercent | UD60x18 | The secondary rebate percent (18 decimals) |
getRebates
Returns the rebates for a given referrer
function getRebates(address referrer) public view returns (address[] memory, uint256[] memory);
Parameters
Name | Type | Description |
---|---|---|
referrer | address | The address of the referrer |
Returns
Name | Type | Description |
---|---|---|
<none> | address[] | tokens The tokens for which the referrer has rebates |
<none> | uint256[] | rebates 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 onlyOwner;
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 onlyOwner;
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 onlyOwner;
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
nonReentrant;
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 nonReentrant;
Parameters
Name | Type | Description |
---|---|---|
tokens | address[] | The tokens to claim |
_tryUpdateRebate
Updates the referrer
rebate balance and rebate tokens, if amount
is greater than zero
function _tryUpdateRebate(ReferralStorage.Layout storage l, address referrer, address token, UD60x18 amount) internal;
_trySetReferrer
Sets the referrer
for a user
if they don't already have one. If a referrer has already been set,
return the existing referrer.
function _trySetReferrer(address user, address referrer) internal returns (address);
_revertIfPoolNotAuthorized
Reverts if the caller is not an authorized pool
function _revertIfPoolNotAuthorized() internal view;