Bonding Curve Token Market on Midnight

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!

1 Like