> For the complete documentation index, see [llms.txt](https://docs.gofundmeme.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gofundmeme.io/developers/gfm-methods/fair-launch/pool-interaction.md).

# 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.

```typescript
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**.

```typescript
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.

```typescript
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.

```typescript
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**.

```typescript
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.

```typescript
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.

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

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

#### 📌 Example Response:

```json
{
  "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.

```typescript
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

{% hint style="danger" %}
NOT supported on **GFM-SDK-Frontend**
{% endhint %}

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

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

#### 📌 Example Response:

```bison
{
  "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.

```typescript
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}`);
```
