# PairsStorageUtils

*GNSPairsStorage facet internal library*

## initializeGroupLiquidationParams

```solidity
function initializeGroupLiquidationParams(struct IPairsStorage.GroupLiquidationParams[] _groupLiquidationParams) internal
```

*Check IPairsStorageUtils interface for documentation*

## initializeNewFees

```solidity
function initializeNewFees(struct IPairsStorage.GlobalTradeFeeParams _tradeFeeParams) internal
```

*Check IPairsStorageUtils interface for documentation*

## addPairs

```solidity
function addPairs(struct IPairsStorage.Pair[] _pairs) internal
```

*Check IPairsStorageUtils interface for documentation*

## updatePairs

```solidity
function updatePairs(uint256[] _pairIndices, struct IPairsStorage.Pair[] _pairs) internal
```

*Check IPairsStorageUtils interface for documentation*

## addGroups

```solidity
function addGroups(struct IPairsStorage.Group[] _groups) internal
```

*Check IPairsStorageUtils interface for documentation*

## updateGroups

```solidity
function updateGroups(uint256[] _ids, struct IPairsStorage.Group[] _groups) internal
```

*Check IPairsStorageUtils interface for documentation*

## addFees

```solidity
function addFees(struct IPairsStorage.FeeGroup[] _fees) internal
```

*Check IPairsStorageUtils interface for documentation*

## updateFees

```solidity
function updateFees(uint256[] _ids, struct IPairsStorage.FeeGroup[] _fees) internal
```

*Check IPairsStorageUtils interface for documentation*

## setPairCustomMaxLeverages

```solidity
function setPairCustomMaxLeverages(uint256[] _indices, uint256[] _values) internal
```

*Check IPairsStorageUtils interface for documentation*

## setGroupLiquidationParams

```solidity
function setGroupLiquidationParams(uint256 _groupIndex, struct IPairsStorage.GroupLiquidationParams _params) internal
```

*Check IPairsStorageUtils interface for documentation*

## setGlobalTradeFeeParams

```solidity
function setGlobalTradeFeeParams(struct IPairsStorage.GlobalTradeFeeParams _feeParams) internal
```

*Check IPairsStorageUtils interface for documentation*

## pairJob

```solidity
function pairJob(uint256 _pairIndex) internal view returns (string, string)
```

*Check IPairsStorageUtils interface for documentation*

## isPairListed

```solidity
function isPairListed(string _from, string _to) internal view returns (bool)
```

*Check IPairsStorageUtils interface for documentation*

## isPairIndexListed

```solidity
function isPairIndexListed(uint256 _pairIndex) internal view returns (bool)
```

*Check IPairsStorageUtils interface for documentation*

## pairs

```solidity
function pairs(uint256 _index) internal view returns (struct IPairsStorage.Pair)
```

*Check IPairsStorageUtils interface for documentation*

## pairsCount

```solidity
function pairsCount() internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairSpreadP

```solidity
function pairSpreadP(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairMinLeverage

```solidity
function pairMinLeverage(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairTotalPositionSizeFeeP

```solidity
function pairTotalPositionSizeFeeP(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairTotalLiqCollateralFeeP

```solidity
function pairTotalLiqCollateralFeeP(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairOraclePositionSizeFeeP

```solidity
function pairOraclePositionSizeFeeP(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairMinPositionSizeUsd

```solidity
function pairMinPositionSizeUsd(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## getGlobalTradeFeeParams

```solidity
function getGlobalTradeFeeParams() internal view returns (struct IPairsStorage.GlobalTradeFeeParams)
```

*Check IPairsStorageUtils interface for documentation*

## pairMinFeeUsd

```solidity
function pairMinFeeUsd(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairFeeIndex

```solidity
function pairFeeIndex(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## groups

```solidity
function groups(uint256 _index) internal view returns (struct IPairsStorage.Group)
```

*Check IPairsStorageUtils interface for documentation*

## groupsCount

```solidity
function groupsCount() internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## fees

```solidity
function fees(uint256 _index) internal view returns (struct IPairsStorage.FeeGroup)
```

*Check IPairsStorageUtils interface for documentation*

## feesCount

```solidity
function feesCount() internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairMaxLeverage

```solidity
function pairMaxLeverage(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## pairCustomMaxLeverage

```solidity
function pairCustomMaxLeverage(uint256 _pairIndex) internal view returns (uint256)
```

*Check IPairsStorageUtils interface for documentation*

## getAllPairsRestrictedMaxLeverage

```solidity
function getAllPairsRestrictedMaxLeverage() internal view returns (uint256[])
```

*Check IPairsStorageUtils interface for documentation*

## getGroupLiquidationParams

```solidity
function getGroupLiquidationParams(uint256 _groupIndex) internal view returns (struct IPairsStorage.GroupLiquidationParams)
```

*Check IPairsStorageUtils interface for documentation*

## getPairLiquidationParams

```solidity
function getPairLiquidationParams(uint256 _pairIndex) internal view returns (struct IPairsStorage.GroupLiquidationParams)
```

*Check IPairsStorageUtils interface for documentation*

## \_getSlot

```solidity
function _getSlot() internal pure returns (uint256)
```

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

## \_getStorage

```solidity
function _getStorage() internal pure returns (struct IPairsStorage.PairsStorage s)
```

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

## groupListed

```solidity
modifier groupListed(uint256 _groupIndex)
```

Reverts if group is not listed

### Parameters

| Name         | Type    | Description          |
| ------------ | ------- | -------------------- |
| \_groupIndex | uint256 | group index to check |

## feeListed

```solidity
modifier feeListed(uint256 _feeIndex)
```

Reverts if fee is not listed

### Parameters

| Name       | Type    | Description        |
| ---------- | ------- | ------------------ |
| \_feeIndex | uint256 | fee index to check |

## groupOk

```solidity
modifier groupOk(struct IPairsStorage.Group _group)
```

Reverts if group is not valid

### Parameters

| Name    | Type                       | Description    |
| ------- | -------------------------- | -------------- |
| \_group | struct IPairsStorage.Group | group to check |

## feeOk

```solidity
modifier feeOk(struct IPairsStorage.FeeGroup _fee)
```

*Reverts if fee is not valid*

### Parameters

| Name  | Type                          | Description  |
| ----- | ----------------------------- | ------------ |
| \_fee | struct IPairsStorage.FeeGroup | fee to check |

## \_addPair

```solidity
function _addPair(struct IPairsStorage.Pair _pair) internal
```

*Adds a new trading pair*

### Parameters

| Name   | Type                                                                                                  | Description |
| ------ | ----------------------------------------------------------------------------------------------------- | ----------- |
| \_pair | [IPairsStorage.Pair](/developer/technical-reference/contracts/interfaces/types/ipairsstorage.md#pair) | pair to add |

## \_updatePair

```solidity
function _updatePair(uint256 _pairIndex, struct IPairsStorage.Pair _pair) internal
```

*Updates an existing trading pair*

### Parameters

| Name        | Type                                                                                                  | Description             |
| ----------- | ----------------------------------------------------------------------------------------------------- | ----------------------- |
| \_pairIndex | uint256                                                                                               | index of pair to update |
| \_pair      | [IPairsStorage.Pair](/developer/technical-reference/contracts/interfaces/types/ipairsstorage.md#pair) | new pair value          |

## \_addGroup

```solidity
function _addGroup(struct IPairsStorage.Group _group) internal
```

*Adds a new pair group*

### Parameters

| Name    | Type                                                                                                    | Description  |
| ------- | ------------------------------------------------------------------------------------------------------- | ------------ |
| \_group | [IPairsStorage.Group](/developer/technical-reference/contracts/interfaces/types/ipairsstorage.md#group) | group to add |

## \_updateGroup

```solidity
function _updateGroup(uint256 _id, struct IPairsStorage.Group _group) internal
```

*Updates an existing pair group*

### Parameters

| Name    | Type                                                                                                    | Description              |
| ------- | ------------------------------------------------------------------------------------------------------- | ------------------------ |
| \_id    | uint256                                                                                                 | index of group to update |
| \_group | [IPairsStorage.Group](/developer/technical-reference/contracts/interfaces/types/ipairsstorage.md#group) | new group value          |

## \_addFee

```solidity
function _addFee(struct IPairsStorage.FeeGroup _fee) internal
```

*Adds a new pair fee group*

### Parameters

| Name  | Type                                                                                                          | Description |
| ----- | ------------------------------------------------------------------------------------------------------------- | ----------- |
| \_fee | [IPairsStorage.FeeGroup](/developer/technical-reference/contracts/interfaces/types/ipairsstorage.md#feegroup) | fee to add  |

## \_updateFee

```solidity
function _updateFee(uint256 _id, struct IPairsStorage.FeeGroup _fee) internal
```

*Updates an existing pair fee group*

### Parameters

| Name  | Type                                                                                                          | Description            |
| ----- | ------------------------------------------------------------------------------------------------------------- | ---------------------- |
| \_id  | uint256                                                                                                       | index of fee to update |
| \_fee | [IPairsStorage.FeeGroup](/developer/technical-reference/contracts/interfaces/types/ipairsstorage.md#feegroup) | new fee value          |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.gains.trade/developer/technical-reference/contracts/libraries/pairsstorageutils.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
