Skip to content

dustinstacy/boncurs

Repository files navigation

Boncurs Bonding Curve Library

OverviewInstallationUsageLearn MoreContributingLicenseDocs


Warning

These contracts have not been audited and are not intended for production. Use at your own risk.

Overview

A smart contract bonding curve library. For use with fungible and non-fungible token projects.


Current available curves:

  • Exponential
  • Linear
  • Exponential Token Based
  • Linear Token Based
  • Boncurs Curve

Installation

Using npm

$ npm install boncurs

Using Foundry

$ forge install dustinstacy/boncurs

Add @boncurs/=lib/boncurs/ in remappings.txt.

Usage

Once installed, you can use the contracts in the library by importing them:

pragma solidity ^0.8.28;

import {BoncursCurve} from "boncurs/experimental/BoncursCurve.sol";

// Couple with a token contract for ideal use case
contract ExampleImplementation is BoncursCurve {
    // Track the scalingFactor, initialCost, supply, and reserverBalance using desired method
    uint32 private immutable i_scalingFactor;
    uint256 private immutable i_initialCost;
    uint256 private supply;
    uint256 private reserveBalance;

    function exampleFunc(uint256 amount) public returns (uint256 examplePurchaseReturn) {
        // Call library functions to use pricing calculations
        examplePurchaseReturn = getPurchaseCost(supply, reserveBalance, initialCost, scalingFactor, amount);
    }
}

Learn More

Introducing the Boncurs Bonding Curve Library: Medium

Visit the documentation site: Docs

Tools for working with the library: Boncurs Bonding Curve Tools

Contributing

Interested in contirbuting? Check out the current issues or submit your own idea.

Follow these steps:

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -m 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

The MIT License (MIT)