> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gains.trade/llms.txt
> Use this file to discover all available pages before exploring further.

# FeeTiersUtils

\_GNSFeeTiers facet internal library

This is a library to apply fee tiers to trading fees based on a trailing point system.\_

## initializeFeeTiers

```solidity theme={null}
function initializeFeeTiers(uint256[] _groupIndices, uint256[] _groupVolumeMultipliers, uint256[] _feeTiersIndices, struct IFeeTiers.FeeTier[] _feeTiers) internal
```

*Check IFeeTiersUtils interface for documentation*

## setGroupVolumeMultipliers

```solidity theme={null}
function setGroupVolumeMultipliers(uint256[] _groupIndices, uint256[] _groupVolumeMultipliers) internal
```

*Check IFeeTiersUtils interface for documentation*

## setFeeTiers

```solidity theme={null}
function setFeeTiers(uint256[] _feeTiersIndices, struct IFeeTiers.FeeTier[] _feeTiers) internal
```

*Check IFeeTiersUtils interface for documentation*

## setTradersFeeTiersEnrollment

```solidity theme={null}
function setTradersFeeTiersEnrollment(address[] _traders, struct IFeeTiers.TraderEnrollment[] _values) internal
```

*Check IFeeTiersUtils interface for documentation*

## addTradersUnclaimedPoints

```solidity theme={null}
function addTradersUnclaimedPoints(address[] _traders, enum IFeeTiers.CreditType[] _creditTypes, uint224[] _points) internal
```

*Check IFeeTiersUtils interface for documentation*

## updateTraderPoints

```solidity theme={null}
function updateTraderPoints(address _trader, uint256 _volumeUsd, uint256 _groupIndex) internal
```

*Check IFeeTiersUtils interface for documentation*

## calculateFeeAmount

```solidity theme={null}
function calculateFeeAmount(address _trader, uint256 _normalFeeAmountCollateral) internal view returns (uint256)
```

*Check IFeeTiersUtils interface for documentation*

## getFeeTiersCount

```solidity theme={null}
function getFeeTiersCount() internal view returns (uint256)
```

*Check IFeeTiersUtils interface for documentation*

## getFeeTier

```solidity theme={null}
function getFeeTier(uint256 _feeTierIndex) internal view returns (struct IFeeTiers.FeeTier)
```

*Check IFeeTiersUtils interface for documentation*

## getGroupVolumeMultiplier

```solidity theme={null}
function getGroupVolumeMultiplier(uint256 _groupIndex) internal view returns (uint256)
```

*Check IFeeTiersUtils interface for documentation*

## getFeeTiersTraderInfo

```solidity theme={null}
function getFeeTiersTraderInfo(address _trader) internal view returns (struct IFeeTiers.TraderInfo)
```

*Check IFeeTiersUtils interface for documentation*

## getTraderFeeTiersEnrollment

```solidity theme={null}
function getTraderFeeTiersEnrollment(address _trader) internal view returns (struct IFeeTiers.TraderEnrollment)
```

*Check IFeeTiersUtils interface for documentation*

## getTraderUnclaimedPoints

```solidity theme={null}
function getTraderUnclaimedPoints(address _trader) internal view returns (uint224)
```

*Check IFeeTiersUtils interface for documentation*

## getFeeTiersTraderDailyInfo

```solidity theme={null}
function getFeeTiersTraderDailyInfo(address _trader, uint32 _day) internal view returns (struct IFeeTiers.TraderDailyInfo)
```

*Check IFeeTiersUtils interface for documentation*

## \_getSlot

```solidity theme={null}
function _getSlot() internal pure returns (uint256)
```

*Returns storage slot to use when fetching storage relevant to library*

## \_getStorage

```solidity theme={null}
function _getStorage() internal pure returns (struct IFeeTiers.FeeTiersStorage s)
```

*Returns storage pointer for storage struct in diamond contract, at defined slot*

## \_checkFeeTierUpdateValid

```solidity theme={null}
function _checkFeeTierUpdateValid(uint256 _index, struct IFeeTiers.FeeTier _feeTier, struct IFeeTiers.FeeTier[8] _feeTiers) internal view
```

*Checks validity of a single fee tier update (feeMultiplier: descending, pointsThreshold: ascending, no gap)*

### Parameters

| Name       | Type                                                                                                  | Description                            |
| ---------- | ----------------------------------------------------------------------------------------------------- | -------------------------------------- |
| \_index    | uint256                                                                                               | index of the fee tier that was updated |
| \_feeTier  | [IFeeTiers.FeeTier](/developer/technical-reference/contracts/interfaces/types/ifeetiers#feetier)      | fee tier new value                     |
| \_feeTiers | [IFeeTiers.FeeTier\[8\]](/developer/technical-reference/contracts/interfaces/types/ifeetiers#feetier) | all fee tiers                          |

## \_getCurrentDay

```solidity theme={null}
function _getCurrentDay() internal view returns (uint32)
```

*Get current day (index of mapping traderDailyInfo)*

## \_claimUnclaimedPoints

```solidity theme={null}
function _claimUnclaimedPoints(address _trader) internal
```

*Claims unclaimed points for a trader and adds them to the daily points for the current day. In the event that it's the first points update for the trader, backdates points to yesterday so the tier discount becomes immediate.*

### Parameters

| Name     | Type    | Description    |
| -------- | ------- | -------------- |
| \_trader | address | trader address |
