Skip to main content

How to Get Refund Initial Liquidity

If a market cannot be resolved or becomes unresolvable, the market creator can claim a refund of their initial liquidity. This section provides complete working scripts for claiming refunds from both V2 AMM markets and P2P markets.
Important: Only the market creator can claim refunds, and the market must meet specific conditions (such as being unresolvable or past a buffer period).

Claiming Refund for V2 AMM Market

For V2 AMM markets, the creator who provided the initial liquidity can claim a refund if the market is deemed unresolvable. This script demonstrates the refund process for V2 markets.
import { PublicKey } from '@solana/web3.js';
import { PNPClient } from 'pnp-sdk';

// Configuration
const RPC_URL = 'https://api.mainnet-beta.solana.com';
const WALLET_SECRET_ARRAY = [/* Your 64-byte private key array goes here */];
const MARKET_ADDRESS = 'YourMarketAddressHere';

async function main() {
  // Initialize client with private key
  const client = new PNPClient(RPC_URL, Uint8Array.from(WALLET_SECRET_ARRAY));
  const market = new PublicKey(MARKET_ADDRESS);

  // Claim refund for unresolvable market
  const result = await client.claimMarketRefund(market);

  console.log('Refund claimed successfully!');
  console.log('Signature:', result.signature);
}

main().catch(console.error);
Key Points for V2 Market Refunds:
  • Only the market creator can claim a refund
  • The market must be unresolvable
  • Uses client.claimMarketRefund() method

Claiming Refund for P2P Market

For P2P markets, creators can claim refunds with additional checks including buffer period validation. This script demonstrates the complete refund process for P2P markets with detailed error handling.
import { PublicKey } from '@solana/web3.js';
import { PNPClient } from 'pnp-sdk';

// Configuration
const RPC_URL = 'https://api.mainnet-beta.solana.com';
const WALLET_SECRET_ARRAY = [/* Your 64-byte private key array goes here */];
const MARKET_ADDRESS = 'YourMarketAddressHere';

async function main() {
  // Initialize client with private key
  const client = new PNPClient(RPC_URL, Uint8Array.from(WALLET_SECRET_ARRAY));
  const market = new PublicKey(MARKET_ADDRESS);

  // Claim P2P market refund
  // Note: The SDK handles all PDA derivations and account validations internally
  const result = await client.claimP2PMarketRefund(market);

  console.log('P2P refund claimed successfully!');
  console.log('Signature:', result.signature);
}

main().catch(console.error);
Key Points for P2P Market Refunds:
  • Only the market creator can claim a refund
  • Must wait for the buffer period to pass before claiming
  • Uses client.claimP2PMarketRefund() for simplified refund claiming
  • SDK handles creator validation and token program detection automatically
Common Refund Errors:
ErrorDescriptionSolution
BufferPeriodNotPassedThe required waiting period hasn’t elapsedWait until the buffer period passes before retrying
Signer is not the creatorThe wallet attempting the refund is not the market creatorUse the creator’s wallet to claim the refund
Market account not foundInvalid market address providedVerify the market address is correct
Redemption module not availableNo wallet/signer configured in the clientInitialize PNPClient with a valid private key
Comparison: V2 AMM vs P2P Refund Process
FeatureV2 AMM Market RefundP2P Market Refund
SDK Methodclient.claimMarketRefund()client.claimP2PMarketRefund()
Buffer PeriodMay applyRequired waiting period
Creator ValidationAutomaticExplicit check in script
Token Program SupportStandard SPL TokenBoth SPL Token and Token-2022
Error DetailsBasic error messagesAdvanced error parsing with codes
ComplexitySimple, single method callMore complex, requires PDA derivation