GNSFeeTiers

Facet #3: Fee tiers

Methods

calculateFeeAmount

function calculateFeeAmount(address _trader, uint256 _normalFeeAmountCollateral) external view returns (uint256)

Returns fee amount after applying the trader's active fee tier multiplier

Parameters

NameTypeDescription

_trader

address

address of trader

_normalFeeAmountCollateral

uint256

base fee amount (collateral precision)

Returns

NameTypeDescription

_0

uint256

getFeeTier

function getFeeTier(uint256 _feeTierIndex) external view returns (struct IFeeTiers.FeeTier)

Returns a fee tier's details (feeMultiplier, pointsThreshold)

Parameters

NameTypeDescription

_feeTierIndex

uint256

fee tier index

Returns

NameTypeDescription

_0

getFeeTiersCount

function getFeeTiersCount() external view returns (uint256)

Returns the current number of active fee tiers

Returns

NameTypeDescription

_0

uint256

getFeeTiersTraderDailyInfo

function getFeeTiersTraderDailyInfo(address _trader, uint32 _day) external view returns (struct IFeeTiers.TraderDailyInfo)

Returns a trader's daily fee tier info (feeMultiplierCache, points)

Parameters

NameTypeDescription

_trader

address

trader address

_day

uint32

day

Returns

NameTypeDescription

_0

getFeeTiersTraderInfo

function getFeeTiersTraderInfo(address _trader) external view returns (struct IFeeTiers.TraderInfo)

Returns a trader's info (lastDayUpdated, trailingPoints)

Parameters

NameTypeDescription

_trader

address

trader address

Returns

NameTypeDescription

_0

getGroupVolumeMultiplier

function getGroupVolumeMultiplier(uint256 _groupIndex) external view returns (uint256)

Returns a group's volume multiplier

Parameters

NameTypeDescription

_groupIndex

uint256

group index (pairs storage fee index)

Returns

NameTypeDescription

_0

uint256

initializeFeeTiers

function initializeFeeTiers(uint256[] _groupIndices, uint256[] _groupVolumeMultipliers, uint256[] _feeTiersIndices, IFeeTiers.FeeTier[] _feeTiers) external nonpayable

Parameters

NameTypeDescription

_groupIndices

uint256[]

_groupVolumeMultipliers

uint256[]

_feeTiersIndices

uint256[]

_feeTiers

setFeeTiers

function setFeeTiers(uint256[] _feeTiersIndices, IFeeTiers.FeeTier[] _feeTiers) external nonpayable

Parameters

NameTypeDescription

_feeTiersIndices

uint256[]

_feeTiers

setGroupVolumeMultipliers

function setGroupVolumeMultipliers(uint256[] _groupIndices, uint256[] _groupVolumeMultipliers) external nonpayable

Updates groups volume multipliers

Parameters

NameTypeDescription

_groupIndices

uint256[]

indices of groups to update

_groupVolumeMultipliers

uint256[]

corresponding new volume multipliers (1e3)

updateTraderPoints

function updateTraderPoints(address _trader, uint256 _volumeUsd, uint256 _pairIndex) external nonpayable

Increases daily points from a new trade, re-calculate trailing points, and cache daily fee tier for a trader.

Parameters

NameTypeDescription

_trader

address

trader address

_volumeUsd

uint256

trading volume in USD (1e18)

_pairIndex

uint256

pair index

Events

FeeTiersUpdated

event FeeTiersUpdated(uint256[] feeTiersIndices, IFeeTiers.FeeTier[] feeTiers)

Emitted when fee tiers are updated

Parameters

NameTypeDescription

feeTiersIndices

uint256[]

indices of updated fee tiers

feeTiers

new corresponding fee tiers values (feeMultiplier, pointsThreshold)

GroupVolumeMultipliersUpdated

event GroupVolumeMultipliersUpdated(uint256[] groupIndices, uint256[] groupVolumeMultipliers)

Emitted when group volume multipliers are updated

Parameters

NameTypeDescription

groupIndices

uint256[]

indices of updated groups

groupVolumeMultipliers

uint256[]

new corresponding volume multipliers (1e3)

TraderDailyPointsIncreased

event TraderDailyPointsIncreased(address indexed trader, uint32 indexed day, uint224 points)

Emitted when a trader's daily points are updated

Parameters

NameTypeDescription

trader indexed

address

trader address

day indexed

uint32

day

points

uint224

points added (1e18 precision)

TraderFeeMultiplierCached

event TraderFeeMultiplierCached(address indexed trader, uint32 indexed day, uint32 feeMultiplier)

Emitted when a trader's cached fee multiplier is updated (this is the one used in fee calculations)

Parameters

NameTypeDescription

trader indexed

address

address of trader

day indexed

uint32

day

feeMultiplier

uint32

new fee multiplier (1e3 precision)

TraderInfoFirstUpdate

event TraderInfoFirstUpdate(address indexed trader, uint32 day)

Emitted when a trader info is updated for the first time

Parameters

NameTypeDescription

trader indexed

address

address of trader

day

uint32

day

TraderInfoUpdated

event TraderInfoUpdated(address indexed trader, IFeeTiers.TraderInfo traderInfo)

Emitted when a trader's info is updated

Parameters

NameTypeDescription

trader indexed

address

address of trader

traderInfo

new trader info value (lastDayUpdated, trailingPoints)

TraderTrailingPointsExpired

event TraderTrailingPointsExpired(address indexed trader, uint32 fromDay, uint32 toDay, uint224 expiredPoints)

Emitted when a trader's trailing points are updated

Parameters

NameTypeDescription

trader indexed

address

trader address

fromDay

uint32

from day

toDay

uint32

to day

expiredPoints

uint224

expired points amount (1e18 precision)

Errors

AboveMax

error AboveMax()

AlreadyExists

error AlreadyExists()

BelowMin

error BelowMin()

BlockOrder

error BlockOrder()

DoesntExist

error DoesntExist()

InitError

error InitError()

InvalidAddresses

error InvalidAddresses()

InvalidCollateralIndex

error InvalidCollateralIndex()

InvalidInputLength

error InvalidInputLength()

NotAllowed

error NotAllowed()

NotAuthorized

error NotAuthorized()

Overflow

error Overflow()

Paused

error Paused()

WrongAccess

error WrongAccess()

WrongFeeTier

error WrongFeeTier()

WrongIndex

error WrongIndex()

WrongLength

error WrongLength()

WrongOrder

error WrongOrder()

WrongParams

error WrongParams()

WrongTradeType

error WrongTradeType()

ZeroAddress

error ZeroAddress()

ZeroValue

error ZeroValue()

Last updated