IReferral

Git Source

Functions

getReferrer

Returns the address of the referrer for a given user

function getReferrer(address user) external view returns (address referrer);

Parameters

NameTypeDescription
useraddressThe address of the user

Returns

NameTypeDescription
referreraddressThe address of the referrer

getRebateTier

Returns the rebate tier for a given referrer

function getRebateTier(address referrer) external view returns (RebateTier tier);

Parameters

NameTypeDescription
referreraddressThe address of the referrer

Returns

NameTypeDescription
tierRebateTierThe rebate tier

getRebatePercents

Returns the primary and secondary rebate percents

function getRebatePercents()
    external
    view
    returns (UD60x18[] memory primaryRebatePercents, UD60x18 secondaryRebatePercent);

Returns

NameTypeDescription
primaryRebatePercentsUD60x18[]The primary rebate percents (18 decimals)
secondaryRebatePercentUD60x18The 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

NameTypeDescription
referreraddressThe address of the referrer

Returns

NameTypeDescription
primaryRebatePercentUD60x18The primary rebate percent (18 decimals)
secondaryRebatePercentUD60x18The 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

NameTypeDescription
referreraddressThe address of the referrer

Returns

NameTypeDescription
tokensaddress[]The tokens for which the referrer has rebates
rebatesuint256[]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

NameTypeDescription
useraddressThe address of the user
referreraddressThe address of the referrer
tradingFeeUD60x18The trading fee (18 decimals)

Returns

NameTypeDescription
primaryRebateUD60x18The primary rebate amount (18 decimals)
secondaryRebateUD60x18The 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

NameTypeDescription
referreraddressThe address of the referrer
tierRebateTierThe rebate tier

setPrimaryRebatePercent

Sets the primary rebate percents - caller must be owner

function setPrimaryRebatePercent(UD60x18 percent, RebateTier tier) external;

Parameters

NameTypeDescription
percentUD60x18The primary rebate percent (18 decimals)
tierRebateTierThe rebate tier

setSecondaryRebatePercent

Sets the secondary rebate percent - caller must be owner

function setSecondaryRebatePercent(UD60x18 percent) external;

Parameters

NameTypeDescription
percentUD60x18The 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

NameTypeDescription
useraddressThe address of the user
referreraddressThe address of the primary referrer
tokenaddressThe address of the token
primaryRebateUD60x18The primary rebate amount (18 decimals)
secondaryRebateUD60x18The secondary rebate amount (18 decimals)

claimRebate

Claims the rebates for the msg.sender

function claimRebate(address[] memory tokens) external;

Parameters

NameTypeDescription
tokensaddress[]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
}