Skip to main content
In this guide, you’ll learn how to estimate the initial buy token amount you receive when buying with SOL. This is useful to understand what percentage of the supply you would get for a given SOL amount before executing a buy.

Prerequisites

Before starting, make sure you have:
  • Node.js (v18 or higher) and npm.
  • A Solana RPC URL (e.g. from Helius, or a public endpoint).
  • Installed the required dependencies:

1. Set Your RPC and Curve Parameters

Create a file (e.g. estimate-allocation.ts) and set your RPC URL.

2. Token Allocation Script

The following script uses the Meteora Dynamic Bonding Curve SDK to get a swap quote for a given SOL amount (in lamports). The function returns the token amount you would receive (in token units, 9 decimals). You can then compute the percentage of supply as (tokenAmount / totalSupply) * 100 if you have the token’s total supply.

3. Using the Function

  • Input: initialBuyIn is the SOL amount in lamports (1 SOL = 1,000,000,000 lamports).
  • Output: The function returns the token amount you receive (in token base units, 9 decimals), or null on error.
Example: to see how many tokens you get for 1 SOL: