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

# IOtcUtils

*Interface for GNSOtc facet (inherits types and also contains functions, events, and custom errors)*

## initializeOtc

```solidity theme={null}
function initializeOtc(struct IOtc.OtcConfig _config) external
```

*Initializer for OTC facet*

### Parameters

| Name     | Type                                                                                       | Description    |
| -------- | ------------------------------------------------------------------------------------------ | -------------- |
| \_config | [IOtc.OtcConfig](/developer/technical-reference/contracts/interfaces/types/iotc#otcconfig) | new OTC Config |

## updateOtcConfig

```solidity theme={null}
function updateOtcConfig(struct IOtc.OtcConfig _config) external
```

*Updates OTC config*

### Parameters

| Name     | Type                                                                                       | Description                                                                                                                                        |
| -------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_config | [IOtc.OtcConfig](/developer/technical-reference/contracts/interfaces/types/iotc#otcconfig) | new OTC Config. Sum of `treasuryShareP`, `stakingShareP`, `burnShareP` must equal 100 and `premiumP` must be less than or equal to MAX\_PREMIUM\_P |

## addOtcCollateralBalance

```solidity theme={null}
function addOtcCollateralBalance(uint8 _collateralIndex, uint256 _collateralAmount) external
```

*Increases OTC balance for a collateral*

### Parameters

| Name               | Type    | Description                                             |
| ------------------ | ------- | ------------------------------------------------------- |
| \_collateralIndex  | uint8   | collateral index                                        |
| \_collateralAmount | uint256 | amount of collateral to increase (collateral precision) |

## sellGnsForCollateral

```solidity theme={null}
function sellGnsForCollateral(uint8 _collateralIndex, uint256 _collateralAmount) external
```

*OTC Buys GNS from caller for `_amountCollateral` of `_collateralIndex`*

### Parameters

| Name               | Type    | Description                                          |
| ------------------ | ------- | ---------------------------------------------------- |
| \_collateralIndex  | uint8   | collateral index                                     |
| \_collateralAmount | uint256 | amount of collateral to trade (collateral precision) |

## getOtcConfig

```solidity theme={null}
function getOtcConfig() external view returns (struct IOtc.OtcConfig)
```

*Returns OTC Config*

## getOtcBalance

```solidity theme={null}
function getOtcBalance(uint8 _collateralIndex) external view returns (uint256)
```

*Returns OTC balance for a collateral (collateral precision)*

### Parameters

| Name              | Type  | Description      |
| ----------------- | ----- | ---------------- |
| \_collateralIndex | uint8 | collateral index |

## getOtcRate

```solidity theme={null}
function getOtcRate(uint8 _collateralIndex) external view returns (uint256)
```

*Returns OTC rate (price + premium) of GNS in collateral (1e10)*

### Parameters

| Name              | Type  | Description      |
| ----------------- | ----- | ---------------- |
| \_collateralIndex | uint8 | collateral index |

## OtcConfigUpdated

```solidity theme={null}
event OtcConfigUpdated(struct IOtc.OtcConfig config)
```

*Emitted when OTCConfig is updated*

### Parameters

| Name   | Type                  | Description    |
| ------ | --------------------- | -------------- |
| config | struct IOtc.OtcConfig | new OTC config |

## OtcBalanceUpdated

```solidity theme={null}
event OtcBalanceUpdated(uint8 collateralIndex, uint256 balanceCollateral)
```

*Emitted when OTC balance is updated*

### Parameters

| Name              | Type    | Description                        |
| ----------------- | ------- | ---------------------------------- |
| collateralIndex   | uint8   | collateral index                   |
| balanceCollateral | uint256 | new balance (collateral precision) |

## OtcExecuted

```solidity theme={null}
event OtcExecuted(uint8 collateralIndex, uint256 collateralAmount, uint256 gnsPriceCollateral, uint256 treasuryAmountGns, uint256 stakingAmountGns, uint256 burnAmountGns)
```

*Emitted when an OTC trade is executed*

### Parameters

| Name               | Type    | Description                                              |
| ------------------ | ------- | -------------------------------------------------------- |
| collateralIndex    | uint8   | collateral index                                         |
| collateralAmount   | uint256 | amount of collateral traded (collateral precision)       |
| gnsPriceCollateral | uint256 | effective gns/collateral price, including premium (1e10) |
| treasuryAmountGns  | uint256 | amount of GNS sent to treasury (1e18)                    |
| stakingAmountGns   | uint256 | amount of GNS sent to GNS Staking (1e18)                 |
| burnAmountGns      | uint256 | amount of GNS burned (1e18)                              |

## InvalidShareSum

```solidity theme={null}
error InvalidShareSum()
```
