GoFundMeme
  • GoFundMeme - Launch the next viral meme
  • FAQs
  • Getting Started
    • Referral Program
    • Reward System
    • Point System
    • Fees
  • GoFundMeme
    • Launch a Memecoin
      • Bonding Curve
        • Intro
      • Fair Launch
        • Tokenomics
        • Target Target
        • Boosters & Vesting
    • Harvest (LP LOCK)
      • How it works
      • Harvesting LP Fees
      • Claim Rewards
    • GFM Protocol
    • Defi x Memecoins
    • Staking
    • KYC Gating
    • SocialFi
      • Community Bubbles
  • Developers
    • GFM for Builders
    • Installation Guide
    • Init gfmSDK
    • GFM Methods
      • Bonding Curve
        • Pool Interaction
        • Pool Staking Network
      • Fair Launch
        • Pool Interaction
    • APIs
      • Create Pools
    • WebSockets
      • Subscriptions
Powered by GitBook
On this page
  • Fetching a Fair Launch Pool
  • 📊 Checking Pool Status
  • 💰 Funding the Pool
  • 💸 Defunding (Withdrawing Contributions)
  • 🎟️ Claiming Presale Allocations
  • 🎯 Claiming Preallocation (Marketing, Team, etc.)
  • 🎁 Fetching Presaler Rewards Summary
  • 💎 Claiming Presaler LP Rewards
  • 🏦 Fetching LP Fees & Harvester Rewards
  • 🌾 Harvesting LP Fees
  1. Developers
  2. GFM Methods
  3. Fair Launch

Pool Interaction

The Fair Launch mechanism in the GoFundMeme Protocol enables decentralized, transparent, and community-driven token launches. This system ensures equitable access to presale allocations while dynamically adjusting fundraising based on demand.

With the GoFundMeme SDK, you can seamlessly: ✅ Fetch Fair Launch pool details ✅ Fund or defund a pool ✅ Claim presale allocations ✅ Claim preallocations (marketing, team, etc.) ✅ Harvest LP fees and rewards


Fetching a Fair Launch Pool

To interact with a Fair Launch pool, you must first fetch its data using the mint address of the token being launched.

import { Connection, PublicKey } from "@solana/web3.js";
import { initGoFundMemeSDK } from "@gofundmeme/sdk";

const connection = new Connection("https://api.mainnet-beta.solana.com");

(async () => {
  const gfmSDK = await initGoFundMemeSDK({ connection });

  // Replace with your token mint address
  const mintAddress = new PublicKey("THE TOKEN MINT ADDRESS");

  // Fetch the Fair Launch Pool
  const pool = await gfmSDK.pools.fairLaunch.fetchFairLaunchPool({
    mintB: mintAddress,
  });

  console.log("Fair Launch Pool Data:", pool);
})();

📊 Checking Pool Status

Once you've fetched the Fair Launch pool, you can check its status, expiration, and funding progress.

import moment from "moment";

const { poolStatus, expirationTimestamp, targetRaise, totalRaised } =
  pool.poolData;

if (poolStatus.raising) {
  console.log("✅ The pool is still in the raising phase.");
}

if (moment(expirationTimestamp.toNumber() * 1000).isAfter(moment())) {
  console.log("⏳ The pool has not expired yet!");
}

if (targetRaise.toNumber() > totalRaised.toNumber()) {
  const remainingSolToRaise =
    (targetRaise.toNumber() - totalRaised.toNumber()) / LAMPORTS_PER_SOL;
  console.log("⚠️ Pool is NOT fully funded yet!", { remainingSolToRaise });
}

💰 Funding the Pool

Participants can contribute SOL to the Fair Launch pool before it reaches its target.

import { Keypair, sendAndConfirmTransaction } from "@solana/web3.js";

const payer = Keypair.generate(); // Replace with your actual signer

// Create a funding transaction (1 SOL in this example)
const fundTransaction = await pool.actions.fund({
  solAmount: 1,
  funder: payer.publicKey,
});

// Sign and send the transaction
const fundTxid = await sendAndConfirmTransaction(connection, fundTransaction, [
  payer,
]);

console.log(`🎉 Successfully funded the pool! TXID: ${fundTxid}`);

💸 Defunding (Withdrawing Contributions)

If the pool is still in the raising phase, participants can withdraw their contributions.

const defundTransaction = await pool.actions.defund({
  funder: payer.publicKey,
});

const defundTxid = await sendAndConfirmTransaction(
  connection,
  defundTransaction,
  [payer]
);

console.log(`💸 Successfully defunded the pool! TXID: ${defundTxid}`);

🎟️ Claiming Presale Allocations

After the Fair Launch concludes, contributors can claim their presale tokens.

const claimPresaleTransaction = await pool.actions.claimPresale({
  funder: payer.publicKey,
});

const claimPresaleTxid = await sendAndConfirmTransaction(
  connection,
  claimPresaleTransaction,
  [payer]
);

console.log(`🎟️ Presale tokens claimed! TXID: ${claimPresaleTxid}`);

🎯 Claiming Preallocation (Marketing, Team, etc.)

Some tokens are reserved for marketing, partnerships, or team allocations. These can be claimed separately.

const claimPreallocationTransaction = await pool.actions.claimPreallocation({
  funder: payer.publicKey,
});

const claimPreallocationTxid = await sendAndConfirmTransaction(
  connection,
  claimPreallocationTransaction,
  [payer]
);

console.log(`🚀 Preallocation tokens claimed! TXID: ${claimPreallocationTxid}`);


🎁 Fetching Presaler Rewards Summary

Presale contributors can check their unclaimed LP rewards before claiming.

const presalerRewardsSummary =
  await pool.actions.funderRewardsUtils.fetchFunderRewardsSummary({
    funder: payer.publicKey,
  });

console.log("🎁 Presaler Rewards Summary:", presalerRewardsSummary);

📌 Example Response:

{
  "funded": 2.9,
  "claimed": {
    "tokenA": 6.090397809,
    "tokenB": 3987429.885834387
  },
  "available": {
    "tokenA": 0.503932604,
    "tokenB": 618413.982264954
  }
}

💎 Claiming Presaler LP Rewards

Once rewards are available, contributors can claim them.

const claimPresalerRewardsTransaction =
  await pool.actions.funderRewardsUtils.claimRewards({
    funder: payer.publicKey,
  });

const claimPresalerRewardsTxid = await sendAndConfirmTransaction(
  connection,
  claimPresalerRewardsTransaction,
  [payer]
);

console.log(
  `💎 Successfully claimed LP rewards! TXID: ${claimPresalerRewardsTxid}`
);


🏦 Fetching LP Fees & Harvester Rewards

NOT supported on GFM-SDK-Frontend

Once the Fair Launch concludes, LP fees and harvester rewards can be tracked.

const summary = await pool.actions.harvestUtils.getLpStateSummary();
console.log("📊 LP Fee Summary:", summary);

📌 Example Response:

{
  "totalHarvested": {
    "tokenA": 33.013248883,
    "tokenB": 56016886.86489466
  },
  "availableForHarvest": {
    "tokenA": 0,
    "tokenB": 885.540800497
  },
  "harvesterRewards": {
    "tokenA": 0,
    "tokenB": 8.85540800497
  }
}

🌾 Harvesting LP Fees

LP fees collected in the pool can be harvested by authorized crankers.

const harvestTransaction = await pool.actions.harvestUtils.harvest({
  cranker: payer.publicKey,
});

const harvestTxid = await sendAndConfirmTransaction(
  connection,
  harvestTransaction,
  [payer]
);

console.log(`🌾 LP fees successfully harvested! TXID: ${harvestTxid}`);
PreviousFair LaunchNextAPIs

Last updated 2 months ago