GNSReferrals

Facet #2: Referral system

Methods

claimAllyRewards

function claimAllyRewards() external nonpayable

Claims pending GNS ally rewards of caller

claimReferrerRewards

function claimReferrerRewards() external nonpayable

Claims pending GNS referrer rewards of caller

distributeReferralReward

function distributeReferralReward(address _trader, uint256 _volumeUsd, uint256 _pairOpenFeeP, uint256 _gnsPriceUsd) external nonpayable returns (uint256)

Distributes ally and referrer rewards

Parameters

NameTypeDescription

_trader

address

trader address

_volumeUsd

uint256

trading volume in usd (1e18 precision)

_pairOpenFeeP

uint256

pair open fee in % (1e10 precision)

_gnsPriceUsd

uint256

token price in usd (1e10 precision)

Returns

NameTypeDescription

_0

uint256

USD value of distributed reward (referrer + ally)

getAllyDetails

function getAllyDetails(address _ally) external view returns (struct IReferrals.AllyDetails)

Returns ally details

Parameters

NameTypeDescription

_ally

address

address of ally

Returns

NameTypeDescription

_0

IReferrals.AllyDetails

getReferralsAllyFeeP

function getReferralsAllyFeeP() external view returns (uint256)

Returns ally fee % of total referral fee

Returns

NameTypeDescription

_0

uint256

getReferralsOpenFeeP

function getReferralsOpenFeeP() external view returns (uint256)

Returns % of opening fee going to referral fee

Returns

NameTypeDescription

_0

uint256

getReferralsStartReferrerFeeP

function getReferralsStartReferrerFeeP() external view returns (uint256)

Returns start referrer fee % of total referral fee when zero volume was referred

Returns

NameTypeDescription

_0

uint256

getReferralsTargetVolumeUsd

function getReferralsTargetVolumeUsd() external view returns (uint256)

Returns target volume in usd to reach 100% of referral fee

Returns

NameTypeDescription

_0

uint256

getReferrerDetails

function getReferrerDetails(address _referrer) external view returns (struct IReferrals.ReferrerDetails)

Returns referrer details

Parameters

NameTypeDescription

_referrer

address

address of referrer

Returns

NameTypeDescription

_0

IReferrals.ReferrerDetails

getReferrerFeeP

function getReferrerFeeP(uint256 _pairOpenFeeP, uint256 _volumeReferredUsd) external view returns (uint256)

Returns referrer fee % of trade position size

Parameters

NameTypeDescription

_pairOpenFeeP

uint256

pair open fee in % (1e10 precision)

_volumeReferredUsd

uint256

referred trading volume in usd (1e18 precision)

Returns

NameTypeDescription

_0

uint256

getReferrersReferred

function getReferrersReferred(address _ally) external view returns (address[])

Returns referrers referred by ally

Parameters

NameTypeDescription

_ally

address

address of ally

Returns

NameTypeDescription

_0

address[]

getTraderActiveReferrer

function getTraderActiveReferrer(address _trader) external view returns (address)

Returns active referrer of trader

Parameters

NameTypeDescription

_trader

address

address of trader

Returns

NameTypeDescription

_0

address

getTraderLastReferrer

function getTraderLastReferrer(address _trader) external view returns (address)

Returns last referrer of trader (whether referrer active or not)

Parameters

NameTypeDescription

_trader

address

address of trader

Returns

NameTypeDescription

_0

address

getTradersReferred

function getTradersReferred(address _referrer) external view returns (address[])

Returns traders referred by referrer

Parameters

NameTypeDescription

_referrer

address

address of referrer

Returns

NameTypeDescription

_0

address[]

initializeReferrals

function initializeReferrals(uint256 _allyFeeP, uint256 _startReferrerFeeP, uint256 _openFeeP, uint256 _targetVolumeUsd) external nonpayable

Parameters

NameTypeDescription

_allyFeeP

uint256

% of total referral fee going to ally

_startReferrerFeeP

uint256

initial % of total referral fee earned when zero volume referred

_openFeeP

uint256

% of open fee going to referral fee

_targetVolumeUsd

uint256

usd opening volume to refer to reach 100% of referral fee

registerPotentialReferrer

function registerPotentialReferrer(address _trader, address _referrer) external nonpayable

Registers potential referrer for trader (only works if trader wasn't referred yet by someone else)

Parameters

NameTypeDescription

_trader

address

trader address

_referrer

address

unwhitelistAllies

function unwhitelistAllies(address[] _allies) external nonpayable

Unwhitelists ally addresses

Parameters

NameTypeDescription

_allies

address[]

array of ally addresses

unwhitelistReferrers

function unwhitelistReferrers(address[] _referrers) external nonpayable

Unwhitelists referrer addresses

Parameters

NameTypeDescription

_referrers

address[]

array of referrer addresses

updateAllyFeeP

function updateAllyFeeP(uint256 _value) external nonpayable

Updates allyFeeP

Parameters

NameTypeDescription

_value

uint256

new ally fee %

updateReferralsOpenFeeP

function updateReferralsOpenFeeP(uint256 _value) external nonpayable

Updates openFeeP

Parameters

NameTypeDescription

_value

uint256

new open fee %

updateReferralsTargetVolumeUsd

function updateReferralsTargetVolumeUsd(uint256 _value) external nonpayable

Updates targetVolumeUsd

Parameters

NameTypeDescription

_value

uint256

new target volume in usd

updateStartReferrerFeeP

function updateStartReferrerFeeP(uint256 _value) external nonpayable

Updates startReferrerFeeP

Parameters

NameTypeDescription

_value

uint256

new start referrer fee %

whitelistAllies

function whitelistAllies(address[] _allies) external nonpayable

Whitelists ally addresses

Parameters

NameTypeDescription

_allies

address[]

array of ally addresses

whitelistReferrers

function whitelistReferrers(address[] _referrers, address[] _allies) external nonpayable

Whitelists referrer addresses

Parameters

NameTypeDescription

_referrers

address[]

array of referrer addresses

_allies

address[]

array of corresponding ally addresses

Events

AllyRewardDistributed

event AllyRewardDistributed(address indexed ally, address indexed trader, uint256 volumeUsd, uint256 amountGns, uint256 amountValueUsd)

Emitted when ally rewards are distributed for a trade

Parameters

NameTypeDescription

ally indexed

address

address of ally

trader indexed

address

address of trader

volumeUsd

uint256

trade volume in usd (1e18 precision)

amountGns

uint256

amount of GNS reward (1e18 precision)

amountValueUsd

uint256

USD value of GNS reward (1e18 precision)

AllyRewardsClaimed

event AllyRewardsClaimed(address indexed ally, uint256 amountGns)

Emitted when an ally claims his pending rewards

Parameters

NameTypeDescription

ally indexed

address

address of ally

amountGns

uint256

GNS pending rewards amount

AllyUnwhitelisted

event AllyUnwhitelisted(address indexed ally)

Emitted when an ally is unwhitelisted

Parameters

NameTypeDescription

ally indexed

address

ally address

AllyWhitelisted

event AllyWhitelisted(address indexed ally)

Emitted when an ally is whitelisted

Parameters

NameTypeDescription

ally indexed

address

ally address

ReferrerRegistered

event ReferrerRegistered(address indexed trader, address indexed referrer)

Emitted when a trader has a new active referrer

Parameters

NameTypeDescription

trader indexed

address

referrer indexed

address

ReferrerRewardDistributed

event ReferrerRewardDistributed(address indexed referrer, address indexed trader, uint256 volumeUsd, uint256 amountGns, uint256 amountValueUsd)

Emitted when referrer rewards are distributed for a trade

Parameters

NameTypeDescription

referrer indexed

address

address of referrer

trader indexed

address

address of trader

volumeUsd

uint256

trade volume in usd (1e18 precision)

amountGns

uint256

amount of GNS reward (1e18 precision)

amountValueUsd

uint256

USD value of GNS reward (1e18 precision)

ReferrerRewardsClaimed

event ReferrerRewardsClaimed(address indexed referrer, uint256 amountGns)

Emitted when a referrer claims his pending rewards

Parameters

NameTypeDescription

referrer indexed

address

address of referrer

amountGns

uint256

GNS pending rewards amount

ReferrerUnwhitelisted

event ReferrerUnwhitelisted(address indexed referrer)

Emitted when a referrer is unwhitelisted

Parameters

NameTypeDescription

referrer indexed

address

referrer address

ReferrerWhitelisted

event ReferrerWhitelisted(address indexed referrer, address indexed ally)

Emitted when a referrer is whitelisted

Parameters

NameTypeDescription

referrer indexed

address

referrer address

ally indexed

address

ally address

UpdatedAllyFeeP

event UpdatedAllyFeeP(uint256 value)

Emitted when allyFeeP is updated

Parameters

NameTypeDescription

value

uint256

new ally fee %

UpdatedOpenFeeP

event UpdatedOpenFeeP(uint256 value)

Emitted when openFeeP is updated

Parameters

NameTypeDescription

value

uint256

new open fee %

UpdatedStartReferrerFeeP

event UpdatedStartReferrerFeeP(uint256 value)

Emitted when startReferrerFeeP is updated

Parameters

NameTypeDescription

value

uint256

new start referrer fee %

UpdatedTargetVolumeUsd

event UpdatedTargetVolumeUsd(uint256 value)

Emitted when targetVolumeUsd is updated

Parameters

NameTypeDescription

value

uint256

new target volume in usd

Errors

AboveMax

error AboveMax()

AllyNotActive

error AllyNotActive()

AlreadyActive

error AlreadyActive()

AlreadyExists

error AlreadyExists()

AlreadyInactive

error AlreadyInactive()

BelowMin

error BelowMin()

BlockOrder

error BlockOrder()

DoesntExist

error DoesntExist()

InitError

error InitError()

InvalidAddresses

error InvalidAddresses()

InvalidCollateralIndex

error InvalidCollateralIndex()

InvalidInputLength

error InvalidInputLength()

NoPendingRewards

error NoPendingRewards()

NotAllowed

error NotAllowed()

NotAuthorized

error NotAuthorized()

Overflow

error Overflow()

Paused

error Paused()

WrongAccess

error WrongAccess()

WrongIndex

error WrongIndex()

WrongLength

error WrongLength()

WrongOrder

error WrongOrder()

WrongParams

error WrongParams()

WrongTradeType

error WrongTradeType()

ZeroAddress

error ZeroAddress()

ZeroValue

error ZeroValue()

Last updated