> For the complete documentation index, see [llms.txt](https://boncurs.gitbook.io/boncurs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://boncurs.gitbook.io/boncurs/boncurs-bonding-curve-library.md).

# Boncurs Bonding Curve Library

&#x20;[![](https://img.shields.io/npm/v/boncurs)](https://www.npmjs.com/package/boncurs) ![](https://img.shields.io/badge/License-MIT-brightgreen)

[Overview](#overview) • [Installation](#installation) • [Usage](#usage) • [Tools](#tools) • [License](#license)

***

{% hint style="danger" %}
WARNING: These contracts have not been audited and are not intended for production. Use at your own risk.
{% endhint %}

## Overview

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

***

Current available curves:

* [Exponential](/boncurs/boncurs-bonding-curve-library/exponential-curves.md)
* [Linear](/boncurs/boncurs-bonding-curve-library/linear-curves.md)
* [Exponential Token Based](/boncurs/boncurs-bonding-curve-library/exponential-curves.md)
* [Linear Token Based](/boncurs/boncurs-bonding-curve-library/linear-curves.md)
* [Boncurs Curve](/boncurs/boncurs-bonding-curve-library/boncurs-curve.md)

## Installation

#### Hardhat (npm)

```
$ npm install boncurs
```

#### Foundry (git)

```
$ 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:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ExpCurve} from "@boncurs/contracts/exponential/ExpCurve.sol";

// Couple with a token contract for ideal use case
contract ExampleImplementation is ExpCurve {
    // Track the reserve ratio, reserve balance, and supply using desired method
    uint32 private reserveRatio;
    uint256 private reserveBalance;
    uint256 private supply;

    function exampleFunc(uint256 depositAmount) public {
        // Call library methods to use pricing calculations
        uint256 examplePurchaseReturn = getPurchaseReturn(supply, reserveBalance, reserveRatio, depositAmount);
    }
}
```

## Tools

[Boncurs Bonding Curve Tools](https://github.com/dustinstacy/boncurs-tools)

## License

The MIT License (MIT)
