> For the complete documentation index, see [llms.txt](https://docs.javsphere.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.javsphere.com/engineering/smart-contracts/leveragex/javfeetiers.md).

# JavFeeTiers

## General Description

The **JavFeeTiers** contract used for managing and calculating fee tiers and volume multipliers for a trading system. It supports defining and updating fee-related parameters for different trading groups and individual traders.

## Core Functionalities

### **`initializeFeeTiers`**

Initializes fee tiers and group volume multipliers.

* **Parameters**:
  * `_groupIndices`: Array of group indices (pairs storage fee index) to initialize.
  * `_groupVolumeMultipliers`: Corresponding group volume multipliers (scaled by 1e3).
  * `_feeTiersIndices`: Array of fee tier indices to initialize.
  * `_feeTiers`: Array of fee tier configurations, including `feeMultiplier` and `pointsThreshold`.

***

### **`setGroupVolumeMultipliers`**

Updates volume multipliers for specified groups.

* **Parameters**:
  * `_groupIndices`: Array of group indices to update.
  * `_groupVolumeMultipliers`: Array of new volume multipliers (scaled by 1e3).

***

### **`setFeeTiers`**

Updates fee tiers with new configurations.

* **Parameters**:
  * `_feeTiersIndices`: Array of fee tier indices to update.
  * `_feeTiers`: Array of updated fee tier configurations, including `feeMultiplier` and `pointsThreshold`.

***

### **`updateTraderPoints`**

Updates a trader’s daily points based on a new trade, recalculates trailing points, and caches the trader's daily fee tier.

* **Parameters**:
  * `_trader`: Address of the trader.
  * `_volumeUsd`: Trading volume in USD (scaled by 1e18).
  * `_pairIndex`: Pair index associated with the trade.

***

### **`calculateFeeAmount`**

Calculates the fee amount for a trader after applying their active fee tier multiplier.

* **Parameters**:
  * `_trader`: Address of the trader.
  * `_normalFeeAmountCollateral`: Base fee amount (in collateral precision).
* **Returns**: Adjusted fee amount after applying the active multiplier.

***

### **`getFeeTiersCount`**

Retrieves the total number of active fee tiers.

* **Returns**: The count of active fee tiers.

***

### **`getFeeTier`**

Fetches the details of a specific fee tier.

* **Parameters**:
  * `_feeTierIndex`: Index of the fee tier.
* **Returns**: Fee tier details including `feeMultiplier` and `pointsThreshold`.

***

### **`getGroupVolumeMultiplier`**

Retrieves the volume multiplier for a specific group.

* **Parameters**:
  * `_groupIndex`: Index of the group (pairs storage fee index).
* **Returns**: Volume multiplier for the specified group.

***

### **`getFeeTiersTraderInfo`**

Gets a trader’s general fee-related information, including the last day updated and trailing points.

* **Parameters**:
  * `_trader`: Address of the trader.
* **Returns**: Trader info as `lastDayUpdated` and `trailingPoints`.

***

### **`getFeeTiersTraderDailyInfo`**

Fetches a trader’s fee tier information for a specific day, including the cached fee multiplier and points.

* **Parameters**:
  * `_trader`: Address of the trader.
  * `_day`: Specific day for which to fetch the information.
* **Returns**: Daily fee tier information as `feeMultiplierCache` and `points`.
