# GNSOtc

*Facet #11: OTC (Handles buy backs and distribution)*

## constructor

```solidity
constructor() public
```

## initializeOtc

```solidity
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.md#otcconfig) | new OTC Config |

## updateOtcConfig

```solidity
function updateOtcConfig(struct IOtc.OtcConfig _config) external
```

*Updates OTC config*

### Parameters

| Name     | Type                                                                                          | Description                                                                                                                                        |
| -------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| \_config | [IOtc.OtcConfig](/developer/technical-reference/contracts/interfaces/types/iotc.md#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
function addOtcCollateralBalance(uint8 _collateralIndex, uint256 _collateralAmount) external virtual
```

*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
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
function getOtcConfig() external view returns (struct IOtc.OtcConfig)
```

*Returns OTC Config*

## getOtcBalance

```solidity
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
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 |


---

# 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/core/facets/gnsotc.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.
