> ## 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.

# ReferralsUtils

*GNSReferrals facet internal library*

## initializeReferrals

```solidity theme={null}
function initializeReferrals(uint256 _allyFeeP, uint256 _startReferrerFeeP, uint256 _targetVolumeUsd) internal
```

*Check IReferralsUtils interface for documentation*

## updateAllyFeeP

```solidity theme={null}
function updateAllyFeeP(uint256 _value) internal
```

*Check IReferralsUtils interface for documentation*

## updateStartReferrerFeeP

```solidity theme={null}
function updateStartReferrerFeeP(uint256 _value) internal
```

*Check IReferralsUtils interface for documentation*

## updateReferralsTargetVolumeUsd

```solidity theme={null}
function updateReferralsTargetVolumeUsd(uint256 _value) internal
```

*Check IReferralsUtils interface for documentation*

## whitelistAllies

```solidity theme={null}
function whitelistAllies(address[] _allies) internal
```

*Check IReferralsUtils interface for documentation*

## unwhitelistAllies

```solidity theme={null}
function unwhitelistAllies(address[] _allies) internal
```

*Check IReferralsUtils interface for documentation*

## whitelistReferrers

```solidity theme={null}
function whitelistReferrers(address[] _referrers, address[] _allies) internal
```

*Check IReferralsUtils interface for documentation*

## unwhitelistReferrers

```solidity theme={null}
function unwhitelistReferrers(address[] _referrers) internal
```

*Check IReferralsUtils interface for documentation*

## registerPotentialReferrer

```solidity theme={null}
function registerPotentialReferrer(address _trader, address _referrer) internal
```

*Check IReferralsUtils interface for documentation*

## distributeReferralReward

```solidity theme={null}
function distributeReferralReward(address _trader, uint256 _volumeUsd, uint256 _referrerFeeUsd, uint256 _gnsPriceUsd) internal
```

*Check IReferralsUtils interface for documentation*

## claimAllyRewards

```solidity theme={null}
function claimAllyRewards() internal
```

*Check IReferralsUtils interface for documentation*

## claimReferrerRewards

```solidity theme={null}
function claimReferrerRewards() internal
```

*Check IReferralsUtils interface for documentation*

## getReferrerFeeProgressP

```solidity theme={null}
function getReferrerFeeProgressP(address _referrer) internal view returns (uint256 progressP)
```

*Check IReferralsUtils interface for documentation*

## getTraderLastReferrer

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

*Check IReferralsUtils interface for documentation*

## getTraderActiveReferrer

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

*Check IReferralsUtils interface for documentation*

## getReferrersReferred

```solidity theme={null}
function getReferrersReferred(address _ally) internal view returns (address[])
```

*Check IReferralsUtils interface for documentation*

## getTradersReferred

```solidity theme={null}
function getTradersReferred(address _referrer) internal view returns (address[])
```

*Check IReferralsUtils interface for documentation*

## getReferralsAllyFeeP

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

*Check IReferralsUtils interface for documentation*

## getReferralsStartReferrerFeeP

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

*Check IReferralsUtils interface for documentation*

## getReferralsTargetVolumeUsd

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

*Check IReferralsUtils interface for documentation*

## getAllyDetails

```solidity theme={null}
function getAllyDetails(address _ally) internal view returns (struct IReferrals.AllyDetails)
```

*Check IReferralsUtils interface for documentation*

## getReferrerDetails

```solidity theme={null}
function getReferrerDetails(address _referrer) internal view returns (struct IReferrals.ReferrerDetails)
```

*Check IReferralsUtils 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 IReferrals.ReferralsStorage s)
```

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

## \_whitelistAlly

```solidity theme={null}
function _whitelistAlly(address _ally) internal
```

*Whitelists new ally*

### Parameters

| Name   | Type    | Description     |
| ------ | ------- | --------------- |
| \_ally | address | address of ally |

## \_unwhitelistAlly

```solidity theme={null}
function _unwhitelistAlly(address _ally) internal
```

*Unwhitelists ally*

### Parameters

| Name   | Type    | Description     |
| ------ | ------- | --------------- |
| \_ally | address | address of ally |

## \_whitelistReferrer

```solidity theme={null}
function _whitelistReferrer(address _referrer, address _ally) internal
```

*Whitelists new referrer*

### Parameters

| Name       | Type    | Description         |
| ---------- | ------- | ------------------- |
| \_referrer | address | address of referrer |
| \_ally     | address | address of ally     |

## \_unwhitelistReferrer

```solidity theme={null}
function _unwhitelistReferrer(address _referrer) internal
```

*Unwhitelists referrer*

### Parameters

| Name       | Type    | Description         |
| ---------- | ------- | ------------------- |
| \_referrer | address | address of referrer |
