# Bonding Curve

## **Introduction**

This guide focusses on the most common patterns of interactions with the Bonding Curve Modules. Please refer to the [Technical Reference](/contracts/technical-reference/modules/funding-manager/bonding-curve/fm_bc_bancor_redeeming_virtualsupply_v1.sol.md) section to see all public getters and setters.

## **Setup Requirements**

The guide includes code snippets for Inverter Network's TypeScript SDK. Please refer to the relevant code snippets based on the SDK you are using.

1. **Set up Inverter Network SDK**: Refer to the Quick Start guides for detailed instructions. See the [React SDK Guide](/sdk/react-sdk.md) or [TypeScript SDK Guide](/sdk/typescript-sdk.md) for more information.
2. **Deploy a Workflow**: Refer to the Deploy a Workflow guide for detailed instructions. See the [React SDK Guide ](/sdk/react-sdk/deploy-a-workflow.md)or [TypeScript SDK Guide](/sdk/typescript-sdk/deploy-a-workflow.md) for more information.
3. **Retrieve a deployed Workflow**: Refer to the Operate a Workflow guide for detailed instructions. See the [React SDK Guide](/sdk/react-sdk/operate-a-workflow.md) or [TypeScript SDK Guide](/sdk/typescript-sdk/operate-a-workflow.md) for more information.

* **Optionally if your setup needs a specific contract**: Refer to the Deploy a Contract Guide for detailed instructions. See the [React SDK](/sdk/react-sdk/deploy-a-contract.md) Guide or [TypeScript SDK](/sdk/typescript-sdk/deploy-a-contract.md) Guide for more information.

Bancor formula and supported chains can be found here: <https://github.com/InverterNetwork/deployments/tree/main/deployments>&#x20;

### Deployment Setup

* Deploy the `Issuance Token`
* Deploy the `Workflow`
* Retrieve the `Workflow`

### Post Deployment: Set the Curve as a minter

In order to perform this action you should be the deployer of the token

```typescript
await workflow.issuanceToken.module.write.setMinter([
    workflow.fundingManager.address, true
], { confirmations: 1 })
```

### Admin Actions

These actions can be preformed by the workflow admin role

```typescript
// Close/Open Buy/Sell
await workflow.fundingManager.write.closeBuy.run()
await workflow.fundingManager.write.openBuy.run()
await workflow.fundingManager.write.closeSell.run()
await workflow.fundingManager.write.openSell.run()

// Grant/Revoke Workflow Admin Role
const adminRole = await workflow.authorizer.read.DEFAULT_ADMIN_ROLE.run()
await workflow.authorizer.write.grantRole.run([adminRole, deployer])
await workflow.authorizer.write.revokeRole.run([adminRole, deployer])

// Fee Withdrawal
await workflow.fundingManager.write.withdrawProjectCollateralFee.run([
  '<address>' as `0x${string}`,
  '1000', // amount
])

// Update Parameters
await workflow.fundingManager.write.setBuyFee.run(
  '1000' // Fee in ( BPS ) Basis Points
)
await workflow.fundingManager.write.setSellFee.run(
  '1000' // Fee in ( BPS ) Basis Points
)
await workflow.fundingManager.write.setReserveRatioForBuying.run(
  333_333 // Reserve Ratio in ( PPM ) Parts Per Million
)
await workflow.fundingManager.write.setReserveRatioForSelling.run(
  333_333 // Reserve Ratio in ( PPM ) Parts Per Million
)
 await workflow.fundingManager.write.setVirtualCollateralSupply.run(
  '1000' // New Virtual Collateral Supply
)
await workflow.fundingManager.write.setVirtualIssuanceSupply.run(
  '1000' // New Virtual Issuance Supply
)
```

### Curve Actions

These actions can be performed by the users of the product | app. The bonding curve funding managers have a calculate function which uses the formula contract to define the minimum amount out from either buy or sell method.

```typescript
// Buy/Sell

// Amount to buy
const purchaseAmount = '1000'
// Min amount received from the buy
const purchaseReturn =
  await workflow.fundingManager.read.calculatePurchaseReturn.run(
    purchaseAmount
  )

// Buy using the connected account
await workflow.fundingManager.write.buy.run([
  purchaseAmount,
  purchaseReturn,
])
// Buy for another account
await workflow.fundingManager.write.buyFor.run([
  '<address>' as `0x${string}`,
  purchaseAmount,
  purchaseReturn,
])

// Amount to sell
const saleAmount = '1000'
// Min amount out of the sell
const saleReturn =
  await workflow.fundingManager.read.calculateSaleReturn.run(saleAmount)

// Sell using the connected account
await workflow.fundingManager.write.sell.run([saleAmount, saleReturn])
// Sell to another account
await workflow.fundingManager.write.sellTo.run([
  '<address>' as `0x${string}`,
  saleAmount,
  saleReturn,
])
```


---

# 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.inverter.network/sdk/guides/bonding-curve.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.
