> For the complete documentation index, see [llms.txt](https://docs.inverter.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inverter.network/contracts/technical-reference/modules/funding-manager/bonding-curve/interfaces/ifm_bc_bancor_redeeming_virtualsupply_v1.sol.md).

# IFM\_BC\_Bancor\_Redeeming\_VirtualSupply\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/fundingManager/bondingCurve/interfaces/IFM_BC_Bancor_Redeeming_VirtualSupply_v1.sol)

**Author:** Inverter Network

This contract enables the issuance and redeeming of tokens on a bonding curve, using a virtual supply for both the issuance and the collateral as input.

### Functions

#### setReserveRatioForBuying

Set the reserve ratio used for issuing tokens on a bonding curve.

*This function can only be called by the {Orchestrator\_v1} admin.*

```solidity
function setReserveRatioForBuying(uint32 _reserveRatio) external;
```

**Parameters**

| Name            | Type     | Description                                         |
| --------------- | -------- | --------------------------------------------------- |
| `_reserveRatio` | `uint32` | The new reserve ratio for buying, expressed in PPM. |

#### setReserveRatioForSelling

Set the reserve ratio used for redeeming tokens on a bonding curve.

*This function can only be called by the {Orchestrator\_v1} admin.*

```solidity
function setReserveRatioForSelling(uint32 _reserveRatio) external;
```

**Parameters**

| Name            | Type     | Description                                          |
| --------------- | -------- | ---------------------------------------------------- |
| `_reserveRatio` | `uint32` | The new reserve ratio for selling, expressed in PPM. |

#### getReserveRatioForBuying

Returns reserve ratio set for buying, used in the {BancorFormula} contract.

```solidity
function getReserveRatioForBuying() external view returns (uint32);
```

**Returns**

| Name     | Type     | Description               |
| -------- | -------- | ------------------------- |
| `<none>` | `uint32` | Reserve Ratio for buying. |

#### getReserveRatioForSelling

Returns reserve ratio set for selling, used in the {BancorFormula} contract.

```solidity
function getReserveRatioForSelling() external view returns (uint32);
```

**Returns**

| Name     | Type     | Description                |
| -------- | -------- | -------------------------- |
| `<none>` | `uint32` | Reserve Ratio for selling. |

### Events

#### BuyReserveRatioSet

Event emitted when the reserve ratio for buying is updated.

```solidity
event BuyReserveRatioSet(uint32 newBuyReserveRatio, uint32 oldBuyReserveRatio);
```

**Parameters**

| Name                 | Type     | Description                       |
| -------------------- | -------- | --------------------------------- |
| `newBuyReserveRatio` | `uint32` | The new reserve ratio for buying. |
| `oldBuyReserveRatio` | `uint32` | The old reserve ratio for buying. |

#### SellReserveRatioSet

Event emitted when the reserve ratio for selling is updated.

```solidity
event SellReserveRatioSet(
    uint32 newSellReserveRatio, uint32 oldSellReserveRatio
);
```

**Parameters**

| Name                  | Type     | Description                        |
| --------------------- | -------- | ---------------------------------- |
| `newSellReserveRatio` | `uint32` | The new reserve ratio for selling. |
| `oldSellReserveRatio` | `uint32` | The old reserve ratio for selling. |

### Errors

#### Module\_\_FM\_BC\_Bancor\_Redeeming\_VirtualSupply\_\_InvalidReserveRatio

Reserve ratio can not be be bigger than 100% expressed in PPM.

```solidity
error Module__FM_BC_Bancor_Redeeming_VirtualSupply__InvalidReserveRatio();
```

#### Module\_\_FM\_BC\_Bancor\_Redeeming\_VirtualSupply\_\_InvalidTokenDecimal

To avoid destructive precision loss when using the Bancor Formula, the Token decimals should:

* Not be lower than 7 decimals.
* Higher or equal to the collateral token decimals.

```solidity
error Module__FM_BC_Bancor_Redeeming_VirtualSupply__InvalidTokenDecimal();
```

#### Module\_\_FM\_BC\_Bancor\_Redeeming\_VirtualSupply\_\_InvalidBancorFormula

Invalid Bancor Formula contract

```solidity
error Module__FM_BC_Bancor_Redeeming_VirtualSupply__InvalidBancorFormula();
```

#### Module\_\_FM\_BC\_Bancor\_Redeeming\_VirtualSupply\_\_CurveInteractionsMustBeClosed

Buying and Selling must be closed before changing the virtual supply.

```solidity
error Module__FM_BC_Bancor_Redeeming_VirtualSupply__CurveInteractionsMustBeClosed(
);
```

#### Module\_\_FM\_BC\_Bancor\_Redeeming\_VirtualSupply\_\_InvalidOrchestratorTokenWithdrawAmount

Funding manager does not hold the amount of collateral the payment client tries to transfer.

```solidity
error Module__FM_BC_Bancor_Redeeming_VirtualSupply__InvalidOrchestratorTokenWithdrawAmount(
);
```

### Structs

#### BondingCurveProperties

Struct used to store information about the bonding curve properties.

```solidity
struct BondingCurveProperties {
    address formula;
    uint32 reserveRatioForBuying;
    uint32 reserveRatioForSelling;
    uint buyFee;
    uint sellFee;
    bool buyIsOpen;
    bool sellIsOpen;
    uint initialIssuanceSupply;
    uint initialCollateralSupply;
}
```

**Properties**

| Name                      | Type      | Description                                                                          |
| ------------------------- | --------- | ------------------------------------------------------------------------------------ |
| `formula`                 | `address` | The formula contract used to calculate the issuance and redemption rate.             |
| `reserveRatioForBuying`   | `uint32`  | The reserve ratio, expressed in PPM, used for issuance on the bonding curve.         |
| `reserveRatioForSelling`  | `uint32`  | The reserve ratio, expressed in PPM, used for redeeming on the bonding curve.        |
| `buyFee`                  | `uint256` | The buy fee expressed in base points.                                                |
| `sellFee`                 | `uint256` | The sell fee expressed in base points.                                               |
| `buyIsOpen`               | `bool`    | The indicator used for enabling/disabling the buying functionalities on deployment.  |
| `sellIsOpen`              | `bool`    | The indicator used for enabling/disabling the selling functionalities on deployment. |
| `initialIssuanceSupply`   | `uint256` | The initial virtual issuance token supply.                                           |
| `initialCollateralSupply` | `uint256` | The initial virtual collateral token supply.                                         |
