PUMP.FUN的Bonding Curve定价机制

PUMP.FUN 的代币定价系统中,采用了 Bonding Curve 作为定价机制,同时还引入了虚拟池的概念。通过这些机制,PUMP.FUN 确保了代币的供应、价格及资金募集的平衡。我们可以通过具体的公式和数据,来详细分析其工作原理。

代码:

<!DOCTYPE html>
<html>
<head>
    <title>PUMP.FUN Bonding Curve Analysis</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .chart-container {
            margin: 20px 0;
            padding: 20px;
            background-color: white;
            border-radius: 8px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin: 20px 0;
        }
        th, td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #ddd;
        }
        th {
            background-color: #f8f9fa;
        }
        .info-box {
            background-color: #f8f9fa;
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>PUMP.FUN Bonding Curve Analysis</h1>
        
        <div class="info-box">
            <h3>初始参数</h3>
            <ul>
                <li>虚拟池初始SOL: 30 SOL</li>
                <li>虚拟池初始代币: 1,073,000,191枚</li>
                <li>初始k值: 32,190,005,730</li>
                <li>初始代币价格: 0.000000028 SOL</li>
            </ul>
        </div>

        <div class="chart-container">
            <canvas id="bondingCurveChart"></canvas>
        </div>

        <div class="info-box">
            <h3>关键数据点</h3>
            <table id="dataTable">
                <thead>
                    <tr>
                        <th>SOL投入量</th>
                        <th>代币获得量</th>
                        <th>价格(SOL)</th>
                        <th>市值(SOL)</th>
                    </tr>
                </thead>
                <tbody id="tableBody">
                </tbody>
            </table>
        </div>
    </div>

    <script>
        // 计算函数
        function calculateData() {
            const initialX = 30;
            const initialY = 1073000191;
            const k = 32190005730;
            const data = [];

            for (let x = 0; x <= 85; x += 5) {
                const y = 1073000191 - (k / (initialX + x));
                //const price = k / Math.pow(initialX + x, 2);
                const price = Math.pow(initialX + x, 2)/ k;
				let marketCap= initialY * price;
			    //用户买进卖出最终募集资金85$SOL,经过置换得到8亿枚Memecoin代币。
                //募集的资金79 $SOL(6 $SOL 作为上币费)和额外2亿枚代币被添加作为初始流动性的交易池,发送至 Raydium,最终代币总量为10亿枚。
				if(x==85)
                {
				  marketCap= (1000000000 * price);
				}				
			    data.push({
                    solAmount: x,
                    tokenAmount: Math.floor(y),
                    price: price,
                    //marketCap: (initialX + x) * price
					marketCap: marketCap
                });
            }
            return data;
        }

        // 生成表格数据
        function populateTable(data) {
            const tbody = document.getElementById('tableBody');
            data.forEach(point => {
                const row = document.createElement('tr');
                row.innerHTML = `
                    <td>${point.solAmount.toFixed(2)}</td>
                    <td>${Math.floor(point.tokenAmount).toLocaleString()}</td>
                    <td>${point.price.toFixed(9)}</td>
                    <td>${point.marketCap.toFixed(9)}</td>
                `;
                tbody.appendChild(row);
            });
        }

        // 创建图表
		function createChart(data) {
			const ctx = document.getElementById('bondingCurveChart').getContext('2d');
			new Chart(ctx, {
				type: 'line',
				data: {
					labels: data.map(d => d.solAmount),
					datasets: [{
						label: '代币价格',
						data: data.map(d => d.price),
						borderColor: 'rgb(75, 192, 192)',
						tension: 0.1,
						yAxisID: 'y'
					}, {
						label: '代币数量',
						data: data.map(d => d.tokenAmount),
						borderColor: 'rgb(255, 99, 132)',
						tension: 0.1,
						yAxisID: 'y1'
					}]
				},
				options: {
					responsive: true,
					plugins: {
						tooltip: {
							callbacks: {
								label: function (context) {
									if (context.dataset.label === '代币价格') {
										return `代币价格: ${context.raw.toFixed(9)}`;
									} else if (context.dataset.label === '代币数量') {
										return `代币数量: ${context.raw.toLocaleString()}`;
									}
									return context.raw;
								}
							}
						}
					},
					scales: {
						x: {
							title: {
								display: true,
								text: 'SOL投入量'
							}
						},
						y: {
							type: 'linear',
							position: 'left',
							title: {
								display: true,
								text: '代币价格(SOL)'
							},
							ticks: {
								callback: function (value) {
									return value.toFixed(9); // 显示9位小数
								}
							}
						},
						y1: {
							type: 'linear',
							position: 'right',
							title: {
								display: true,
								text: '代币数量'
							},
							ticks: {
								callback: function (value) {
									return value.toLocaleString(); // 显示千分位
								}
							}
						}
					}
				}
			});
		}
		
        <!-- function createChart(data) { -->
            <!-- const ctx = document.getElementById('bondingCurveChart').getContext('2d'); -->
            <!-- new Chart(ctx, { -->
                <!-- type: 'line', -->
                <!-- data: { -->
                    <!-- labels: data.map(d => d.solAmount), -->
                    <!-- datasets: [{ -->
                        <!-- label: '代币价格', -->
                        <!-- data: data.map(d => d.price), -->
                        <!-- borderColor: 'rgb(75, 192, 192)', -->
                        <!-- tension: 0.1, -->
                        <!-- yAxisID: 'y' -->
                    <!-- }, { -->
                        <!-- label: '代币数量', -->
                        <!-- data: data.map(d => d.tokenAmount), -->
                        <!-- borderColor: 'rgb(255, 99, 132)', -->
                        <!-- tension: 0.1, -->
                        <!-- yAxisID: 'y1' -->
                    <!-- }] -->
                <!-- }, -->
                <!-- options: { -->
                    <!-- responsive: true, -->
                    <!-- scales: { -->
                        <!-- x: { -->
                            <!-- title: { -->
                                <!-- display: true, -->
                                <!-- text: 'SOL投入量' -->
                            <!-- } -->
                        <!-- }, -->
                        <!-- y: { -->
                            <!-- type: 'linear', -->
                            <!-- position: 'left', -->
                            <!-- title: { -->
                                <!-- display: true, -->
                                <!-- text: '代币价格(SOL)' -->
                            <!-- } -->
                        <!-- }, -->
                        <!-- y1: { -->
                            <!-- type: 'linear', -->
                            <!-- position: 'right', -->
                            <!-- title: { -->
                                <!-- display: true, -->
                                <!-- text: '代币数量' -->
                            <!-- } -->
                        <!-- } -->
                    <!-- } -->
                <!-- } -->
            <!-- }); -->
        <!-- } -->

        // 初始化
        const data = calculateData();
        populateTable(data);
        createChart(data);
    </script>
</body>
</html>

如图:

在这里插入图片描述

1. 初始设置与前置虚拟池

根据提供的数据,PUMP.FUN 的前置虚拟池设置如下:

  • 虚拟池初始设置
    • 初始 $SOL 数量:30 枚。
    • 初始代币数量:1,073,000,191 枚 Memecoin。
    • 初始常数 k k k:32,190,005,730。

这个初始虚拟池为后续的代币定价提供了基础。公式 x ⋅ y = k x \cdot y = k xy=k 用于表示虚拟池的关系,其中 x x x是池中的 $SOL 数量, y y y是池中的 Memecoin 代币数量,而 k k k是固定常数。

初始代币价格为:

每枚代币价格 = x y = 30 1 , 073 , 000 , 191 ≈ 0.000000028   $SOL \text{每枚代币价格} = \frac{x}{y} = \frac{30}{1,073,000,191} \approx 0.000000028 \, \text{\$SOL} 每枚代币价格=yx=1,073,000,191300.000000028$SOL

2. 定价曲线

定价曲线的公式为:

y = 1 , 073 , 000 , 191 − 32 , 190 , 005 , 730 30 + x y = 1,073,000,191 - \frac{32,190,005,730}{30 + x} y=1,073,000,19130+x32,190,005,730

其中:

  • y y y表示用户购买 x x x枚 $SOL 后所得到的 Memecoin 代币数量。
  • x x x表示用户购买的 $SOL 数量。

为了计算每枚代币的价格,我们需要对定价曲线进行求导。价格即为每增加一个单位 $SOL 时,代币价格的变化率:

价格 = ( 30 + x ) 2 32 , 190 , 005 , 730 \text{价格} = \frac{(30 + x)^2}{32,190,005,730} 价格=32,190,005,730(30+x)2

3. 用户买入的具体情况

假设有用户通过购买 $SOL 来获得 Memecoin 代币。根据公式,用户的买入数量 x x x和相应得到的代币数量 y y y会受到定价曲线的影响。以 用户购买 85 $SOL 为例,过程如下:

  • 用户买入 85 $SOL
    代币数量 y y y计算如下:

y = 1 , 073 , 000 , 191 − 32 , 190 , 005 , 730 30 + 85 = 1 , 073 , 000 , 191 − 32 , 190 , 005 , 730 115 ≈ 1 , 073 , 000 , 191 − 280 , 825 , 611 = 792 , 174 , 580  枚代币 y = 1,073,000,191 - \frac{32,190,005,730}{30 + 85} = 1,073,000,191 - \frac{32,190,005,730}{115} \approx 1,073,000,191 - 280,825,611 = 792,174,580 \text{ 枚代币} y=1,073,000,19130+8532,190,005,730=1,073,000,19111532,190,005,7301,073,000,191280,825,611=792,174,580 枚代币

这符合实际情况,用户在购买 85 $SOL 后大约获得了 8 亿枚 Memecoin 代币。

4. 流动性池的形成

在代币发行过程中,PUMP.FUN 使用了初始的 6 $SOL 上币费和剩余的资金(79 $SOL)来创建流动性池。

  • 募集资金:79 $SOL 用于生成新的流动性池,而 6 $SOL 被作为上币费用用于平台收取。
  • 新增流动性池:额外生成了 2 亿枚 Memecoin,且这部分 Memecoin 被添加到 Raydium 上的交易池中。

最终,总共的代币供应量为 10 亿枚,其中:

  • 8 亿枚 Memecoin 来自于用户购买 85 $SOL。
  • 2 亿枚 Memecoin 来自 PUMP.FUN 平台铸造,用于流动性池。

5. 上线 Raydium

通过以上过程,代币最终上线至 Raydium,并形成交易对。此时,代币的初始价格和平台募集的资金会决定代币在交易市场的定价。

  • 上线 Raydium 时的价格:根据募资金额和流动性池的增加,代币上线 Raydium 后的价格是:
计算:
  1. 募资完成后的总 SOL 数量:
    总 S O L 投入量 = 初始 S O L 投入量 + 募资 S O L 数量 = 30 + 85 = 115   S O L 总SOL投入量 = 初始SOL投入量 + 募资SOL数量 = 30 + 85 = 115 \, SOL SOL投入量=初始SOL投入量+募资SOL数量=30+85=115SOL

  2. 募资完成瞬间的代币价格:
    价格 = ( 总 S O L 投入量 ) 2 K = 11 5 2 32190005730 价格 = \frac{(总SOL投入量)^2} {K}= \frac{115^2}{32190005730} 价格=K(SOL投入量)2=321900057301152

  3. 计算 ( 115^2 ):
    11 5 2 = 13225 115^2 = 13225 1152=13225

  4. 代币价格计算:
    价格 = 13225 32190005730 ≈ 0.00000041   S O L 价格 = \frac{13225} {32190005730}\approx 0.00000041 \, SOL 价格=32190005730132250.00000041SOL

这个价格是上线瞬间的价格,相较于虚拟池中的初始价格(0.000000028 $SOL),它上升了约 14.64 倍,这符合实际的市场变化。

6. 总结

整个 PUMP.FUN 的代币发行和定价系统通过 Bonding Curve 和虚拟池的设计,实现了一个动态定价的机制,使得代币价格随着购买量和资金募集的增加而调整。通过以下关键步骤:

  1. 初始虚拟池:为后续的代币发行和价格设定提供了基础。
  2. 定价公式:通过 x ⋅ y = k x \cdot y = k xy=k 公式和曲线定价函数,控制了代币的价格随着市场需求的变化而波动。
  3. 流动性池:资金募集和代币铸造,最终形成了上线 Raydium 的交易对。
  4. 价格波动:上线后,代币的价格相较于初始价格大幅上涨,符合市场预期。

PUMP.FUN 系统的这种设计确保了代币发行的去中心化、公平性,同时也提供了激励机制,让早期投资者受益,并通过智能合约保障了整个过程的自动化和透明性。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值