Bonding Curve
What is a Bonding Curve
Before migrating to Uniswap, each token launched on Toshi Mart is first traded on a bonding curve. When you buy tokens from the bonding curve, you send your ETH (or $TOSHI) to the bonding curve as a reserve, and the bonding curve contract sends tokens to your address. Or if you sell your tokens to the bonding curve, the bonding curve contract will send you ETH (or $TOSHI) and take your tokens.

A bonding curve defines the relationship between the trading token's circulating supply and the reserve (i.e. Quote tokens like ETH or $TOSHI). Toshi Mart's bonding curve is based on Flap Protocol's bonding curve, which is a constant product bonding curve. The bonding curve is designed to ensure that the price of the token increases as more tokens are bought, and decreases as tokens are sold.
You may even wonder what is the difference between a bonding curve token launching platform like Toshi Mart and Uniswap (especially Uniswap V3)? The answer is the liquidity. The liquidity does not change on the bonding curve. However, anyone can add liquidity to Uniswap pools.
Toshi Mart's Bonding Curve
Every token launched on Toshi Mart has the total supply of (i.e 1 billion) , with 18 decimals. On token creation, the total supply (i.e the 1 billion tokens) will be locked in the bonding curve contract, the user can then trade the token on the bonding curve, the bonding curve will send the tokens to the user when the user buys the token, and the bonding curve will take the tokens from the user when the user sells the token. When a token reaches a certain threshold, it will be migrated to Uniswap, where the remaining tokens will be added to the Uniswap pool as liquidity.
The constant product bonding curve of Toshi Mart's bonding curve is defined as follows:
is a constant parameter dependent on the quote token (i.e ETH or $TOSHI):
ETH
0.5
TOSHI
4_000_000
is the non circulating (i.e the amount of token that is still locked in bonding curve contract) of the token, initially, it is , which means all the tokens are not circulating in the beginning.
is the reserve of ETH or $TOSHI , it is 0 in the beginning, which means no ETH or $TOSHI is locked in the bonding curve contract.
To better understand the bonding curve, we use to denote the token's current (circulating) supply, which is the token that is not locked in the bonding curve contract, or the amount of token that is already sold to the users. is defined as follows:
Such that, the relationship between and is as follows:
Let's visualize the above equation to gain a better understanding of the bonding curve.
When half of the tokens are sold (i.e ), the reserve of TOSHI is 4M TOSHI
When 80% of the tokens are sold (i.e ), the reserve of TOSHI is 16M TOSHI, and the token is eligible to be migrated to Uniswap.
If the quote token is ETH, the Toshi Mart's bonding curve behaves like this:
When half of the tokens are sold (i.e ), the reserve of ETH is 0.5 ETH
When 80% of the tokens are sold (i.e ), the reserve of ETH is 2 ETH, and the token is eligible to be migrated to Uniswap.
A Short Note On Uniswap Migrations
On other launchpad, the threshold for migration is fixed (e.g: the circulating supply of the token reaches 80% of the total supply). If the user tries to buy more token than the threshold, the bonding curve will not allow the user to buy more token, it will refund the user. However, on Toshi Mart, although the threshold is also 80% by default, the bonding curve will not stop the user from buying more token than the threshold in the last transaction before migration.
Typescript Example
import { Decimal } from "decimal.js";
const BILLION: Decimal = new Decimal("1000000000");
export class CDPV1 {
// the initial virtual reserve
private r: number;
constructor(r: number) {
this.r = r;
}
// estimate the current circulating supply by the reserve
totalSupply(reserve: string): Decimal {
// (1e9 - supply) * (reserve + r) = r * 1e9
if (!reserve) return new Decimal(0);
return new Decimal(BILLION).sub(
new Decimal(this.r * 1e9).div(new Decimal(reserve).add(this.r))
);
}
// estimate the current reserve by the circulating supply
totalReserve(amount: string): Decimal {
// (1e9 - supply) * (reserve + r) = r * 1e9
if (!amount) return new Decimal(0);
return new Decimal(this.r * 1e9)
.div(new Decimal(1e9).sub(new Decimal(amount)))
.sub(this.r);
}
// esitmate the current marketcap denominated in Quote Token
mc(reserve: string): Decimal {
return this.fdv(this.totalSupply(reserve).toString());
}
// estimate thee current price denomiated in Quote Token
price(supply: string): Decimal {
// r * 1e9 /((1e9 - supply)^2)
const diff = new Decimal(1e9).sub(new Decimal(supply || 0));
return new Decimal(this.r * 1e9).div(diff.pow(2));
}
fdv(supply: string): Decimal {
return this.price(supply).mul(new Decimal(1e9));
}
}
Last updated