# Bonding Curve Token Market on Midnight

**URL:** <https://forum.midnight.network/t/bonding-curve-token-market-on-midnight/1075>\
**Category:** General\
**Tags:** learning, ecosytem\
**Created:** [March 12, 2026, 9:00am UTC](https://forum.midnight.network/t/bonding-curve-token-market-on-midnight/1075 "2026-03-12T09:00:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tusharpamnani](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.midnight.network/tusharpamnani/32/498_2.png) [@tusharpamnani](https://forum.midnight.network/u/tusharpamnani)\
**Post date:** [March 12, 2026, 9:00am UTC](https://forum.midnight.network/t/bonding-curve-token-market-on-midnight/1075/1 "2026-03-12T09:00:53Z")

</div>

> <https://x.com/Tushar_Pamnani_/status/2032013927664795700?s=20>

I’ve been experimenting with implementing a **bonding curve based token market** on Midnight as a core DeFi primitive.

The goal of this project is to demonstrate how **deterministic pricing mechanisms** can be implemented on Midnight using Compact, allowing tokens to be minted and burned according to a mathematical pricing curve.

### Overview

A bonding curve is a mechanism where the **price of a token is a function of its supply**. Instead of relying on order books or liquidity providers, the protocol itself acts as the counterparty for minting and burning tokens.

In this implementation:

- Users **buy tokens by depositing reserve assets**

- Users **sell tokens by burning them**

- The **price dynamically increases with supply** following a predefined curve

The protocol maintains two key state variables:

- **Total Token Supply**

- **Reserve Balance**

These determine the current price and ensure the system remains fully collateralized.

* * *

### Mathematical Model

This implementation uses a **linear bonding curve** :

`P(s) = a + bs`

Where:

- (P(s)) = price at supply (s)

- (a) = base price

- (b) = slope of the curve

The total cost to mint tokens is determined by integrating the price function.

This ensures:

- deterministic pricing

- smooth liquidity

- no reliance on external LPs

* * *

### Features

- Deterministic pricing via bonding curves

- Mint and burn functionality

- Fully collateralized reserve

- Implemented in **Compact on Midnight**

- Test suite covering edge cases and economic correctness

- CLI interface for interacting with the contract

* * *

### Why This Matters

Bonding curves are a powerful primitive that can enable:

- Continuous token launches

- Protocol-owned liquidity

- On-chain fundraising mechanisms

- Automated market making without traditional pools

Building this on Midnight demonstrates how **privacy-focused chains can still support advanced DeFi primitives with deterministic market mechanisms.**

* * *

### Next Steps

Some extensions I’m currently exploring:

- Non-linear curves (exponential / logarithmic)

- Liquidity-sensitive curves

- Integration with prediction markets

- Privacy-preserving trading flows on Midnight

* * *

If anyone is experimenting with **AMMs, bonding curves, or prediction markets on Midnight** , I’d love to discuss ideas or collaborate!
