This guide focusses on the most common patterns of interactions with the Bonding Curve Modules. Please refer to the Technical Reference 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.
Set up Inverter Network SDK: Refer to the Quick Start guides for detailed instructions. See the React SDK Guide or TypeScript SDK Guide for more information.
Deploy a Workflow: Refer to the Deploy a Workflow guide for detailed instructions. See the React SDK Guide or TypeScript SDK Guide for more information.
Retrieve a deployed Workflow: Refer to the Operate a Workflow guide for detailed instructions. See the React SDK Guide or TypeScript SDK Guide 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 Guide or TypeScript SDK Guide for more information.
These actions can be preformed by the workflow admin role
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.
// 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
)
// 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,
])