> 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/ibondingcurvebase_v1.sol.md).

# IBondingCurveBase\_v1.sol

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

### Functions

#### buyFor

Buy tokens on behalf of a specified receiver address.

*Redirects to the internal function `_buyOrder` by passing the receiver address and deposit amount.*

```solidity
function buyFor(address _receiver, uint _depositAmount, uint _minAmountOut)
    external;
```

**Parameters**

| Name             | Type      | Description                                                                     |
| ---------------- | --------- | ------------------------------------------------------------------------------- |
| `_receiver`      | `address` | The address that will receive the bought tokens.                                |
| `_depositAmount` | `uint256` | The amount of collateral token deposited.                                       |
| `_minAmountOut`  | `uint256` | The minimum acceptable amount the user expects to receive from the transaction. |

#### buy

Buy tokens for the sender's address.

*Redirects to the internal function `_buyOrder` by passing the sender's address and deposit amount.*

```solidity
function buy(uint _depositAmount, uint _minAmountOut) external;
```

**Parameters**

| Name             | Type      | Description                                                                     |
| ---------------- | --------- | ------------------------------------------------------------------------------- |
| `_depositAmount` | `uint256` | The amount of collateral token depoisited.                                      |
| `_minAmountOut`  | `uint256` | The minimum acceptable amount the user expects to receive from the transaction. |

#### openBuy

Opens the buying functionality for the token.

*Only callable by the {Orchestrator\_v1} admin. Reverts if buying is already open.*

```solidity
function openBuy() external;
```

#### closeBuy

Closes the buying functionality for the token.

*Only callable by the {Orchestrator\_v1} admin. Reverts if buying is already closed.*

```solidity
function closeBuy() external;
```

#### setBuyFee

Sets the fee percentage for buying tokens, payed in collateral.

*Only callable by the {Orchestrator\_v1} admin. The fee cannot exceed 10000 basis points. Reverts if an invalid fee is provided.*

```solidity
function setBuyFee(uint _fee) external;
```

**Parameters**

| Name   | Type      | Description              |
| ------ | --------- | ------------------------ |
| `_fee` | `uint256` | The fee in basis points. |

#### getStaticPriceForBuying

Calculates and returns the static price for buying the issuance token.

```solidity
function getStaticPriceForBuying() external view returns (uint);
```

**Returns**

| Name     | Type      | Description                                          |
| -------- | --------- | ---------------------------------------------------- |
| `<none>` | `uint256` | uint The static price for buying the issuance token. |

#### calculatePurchaseReturn

Calculates the amount of tokens to be minted based on a given deposit amount.

*This function takes into account any applicable buy fees before computing the token amount to be minted. Revert when `_depositAmount` is zero.*

```solidity
function calculatePurchaseReturn(uint _depositAmount)
    external
    returns (uint mintAmount);
```

**Parameters**

| Name             | Type      | Description                                 |
| ---------------- | --------- | ------------------------------------------- |
| `_depositAmount` | `uint256` | The amount of tokens deposited by the user. |

**Returns**

| Name         | Type      | Description                                                              |
| ------------ | --------- | ------------------------------------------------------------------------ |
| `mintAmount` | `uint256` | The amount of new tokens that will be minted as a result of the deposit. |

#### withdrawProjectCollateralFee

Withdraw project collateral fee to the receiver address.

```solidity
function withdrawProjectCollateralFee(address _receiver, uint _amount)
    external;
```

**Parameters**

| Name        | Type      | Description                            |
| ----------- | --------- | -------------------------------------- |
| `_receiver` | `address` | The address that will receive the fee. |
| `_amount`   | `uint256` | The amount of fee to withdraw.         |

#### projectCollateralFeeCollected

Returns the amount of fee in collateral token collected by the project.

```solidity
function projectCollateralFeeCollected() external view returns (uint);
```

#### getIssuanceToken

Returns the address of the issuance token.

```solidity
function getIssuanceToken() external view returns (address);
```

### Events

#### BuyingEnabled

Event emitted when buying is opened.

```solidity
event BuyingEnabled();
```

#### BuyingDisabled

Event emitted when buying is closed.

```solidity
event BuyingDisabled();
```

#### BuyFeeUpdated

Event emitted when buy fee is updated.

```solidity
event BuyFeeUpdated(uint newBuyFee, uint oldBuyFee);
```

#### IssuanceTokenSet

Event emitted when the issuance token is updated.

```solidity
event IssuanceTokenSet(address indexed issuanceToken, uint8 decimals);
```

#### ProjectCollateralFeeWithdrawn

Event emitted when project collateral fee is withdrawn.

```solidity
event ProjectCollateralFeeWithdrawn(address receiver, uint amount);
```

#### ProjectCollateralFeeAdded

Event emitted when project collateral fee is added.

```solidity
event ProjectCollateralFeeAdded(uint amount);
```

#### TokensBought

Event emitted when tokens have been succesfully issued.

```solidity
event TokensBought(
    address indexed receiver,
    uint depositAmount,
    uint receivedAmount,
    address buyer
);
```

**Parameters**

| Name             | Type      | Description                                      |
| ---------------- | --------- | ------------------------------------------------ |
| `receiver`       | `address` | The address that will receive the issued tokens. |
| `depositAmount`  | `uint256` | The amount of collateral token deposited.        |
| `receivedAmount` | `uint256` | The amount of issued token received.             |
| `buyer`          | `address` | The address that initiated the buy order.        |

#### TokenDecimalsUpdated

Event emitted when the decimals of the issuance token are updated.

```solidity
event TokenDecimalsUpdated(uint8 oldDecimals, uint8 newDecimals);
```

**Parameters**

| Name          | Type    | Description                             |
| ------------- | ------- | --------------------------------------- |
| `oldDecimals` | `uint8` | The old decimals of the issuance token. |
| `newDecimals` | `uint8` | The new decimals of the issuance token. |

#### ProtocolFeeMinted

Event emitted when protocol fee has been minted to the treasury.

```solidity
event ProtocolFeeMinted(
    address indexed token, address indexed treasury, uint feeAmount
);
```

**Parameters**

| Name        | Type      | Description                                                   |
| ----------- | --------- | ------------------------------------------------------------- |
| `token`     | `address` | The token minted as protocol fee.                             |
| `treasury`  | `address` | The protocol treasury address receiving the token fee amount. |
| `feeAmount` | `uint256` | The fee amount minted to the treasury.                        |

### Errors

#### Module\_\_BondingCurveBase\_\_InvalidFeePercentage

Percentage amount is bigger than 100%, i.e. 10\_000.

```solidity
error Module__BondingCurveBase__InvalidFeePercentage();
```

#### Module\_\_BondingCurveBase\_\_InvalidDepositAmount

Deposit amount has to be larger than zero.

```solidity
error Module__BondingCurveBase__InvalidDepositAmount();
```

#### Module\_\_BondingCurveBase\_\_BuyingFunctionaltiesClosed

Buying functionalities are set to closed.

```solidity
error Module__BondingCurveBase__BuyingFunctionaltiesClosed();
```

#### Module\_\_BondingCurveBase\_\_InvalidRecipient

Receiver address can not be zero address or. Bonding Curve Funding Manager itself.

```solidity
error Module__BondingCurveBase__InvalidRecipient();
```

#### Module\_\_BondingCurveBase\_\_InsufficientOutputAmount

Actual buy amount is lower than the minimum acceptable amount.

```solidity
error Module__BondingCurveBase__InsufficientOutputAmount();
```

#### Module\_\_BondingCurveBase\_\_FeeAmountToHigh

The combination of protocol fee and workflow fee cant be higher than 100%.

```solidity
error Module__BondingCurveBase__FeeAmountToHigh();
```

#### Module\_\_BondingCurveBase\_\_InvalidWithdrawAmount

Withdrawl amount is bigger than project fee collected.

```solidity
error Module__BondingCurveBase__InvalidWithdrawAmount();
```

#### Module\_\_BondingCurveBase\_\_TradeAmountTooLow

Buy amount in relation to fee percentage to small, results in round down fee amount to zero.

```solidity
error Module__BondingCurveBase__TradeAmountTooLow();
```

#### Module\_\_BondingCurveBase\_\_InvalidMinAmountOut

The minimum amount out cannot be zero.

```solidity
error Module__BondingCurveBase__InvalidMinAmountOut();
```

### Structs

#### IssuanceToken

Struct used to store information about the issuance token.

```solidity
struct IssuanceToken {
    string name;
    string symbol;
    uint8 decimals;
    uint maxSupply;
}
```

**Properties**

| Name        | Type      | Description                                  |
| ----------- | --------- | -------------------------------------------- |
| `name`      | `string`  | The name of the issuance token.              |
| `symbol`    | `string`  | The symbol of the issuance token.            |
| `decimals`  | `uint8`   | The decimals used within the issuance token. |
| `maxSupply` | `uint256` | The maximum supply of the issuance token.    |
