Skip to content

internet-court/internet-court-skill / vendored/pnp/pnp-solana

pnp-markets-solana

Flagged

Create, trade, and settle permissionless prediction markets on Solana. Use when building prediction market infrastructure, creating social media markets (Twitter/YouTube/DeFiLlama), setting up custom oracle resolution, P2P betting, or autonomous agent-driven forecasting. Supports V2 AMM, P2P (V3), and custom oracle markets with any SPL token collateral (including Token-2022).

scripts/redeem.ts

View on GitHub
#!/usr/bin/env npx ts-node
/**
 * Redeem winning tokens for collateral after settlement on Solana
 * Run with --help for usage
 */

import { PNPClient } from "pnp-sdk";
import { PublicKey } from "@solana/web3.js";

interface Args {
  market: string;
  help?: boolean;
}

function printHelp(): void {
  console.log(`
PNP Markets (Solana) - Redeem Winnings

USAGE:
  npx ts-node redeem.ts --market <address>

REQUIRED:
  --market <address>        Market address (base58)

OPTIONAL:
  --help                    Show this help message

ENVIRONMENT:
  PRIVATE_KEY               Solana wallet private key (required)
  RPC_URL                   Solana RPC endpoint (optional)

NOTE:
  Can only redeem after market is settled.
  Must hold winning outcome tokens to redeem.

EXAMPLES:
  npx ts-node redeem.ts --market <address>
`);
}

function parseArgs(): Args {
  const args = process.argv.slice(2);
  const parsed: Partial<Args> = {};

  for (let i = 0; i < args.length; i++) {
    switch (args[i]) {
      case "--help":
      case "-h":
        parsed.help = true;
        break;
      case "--market":
        parsed.market = args[++i];
        break;
    }
  }

  return {
    market: parsed.market || "",
    help: parsed.help,
  };
}

async function main(): Promise<void> {
  const args = parseArgs();

  if (args.help) {
    printHelp();
    process.exit(0);
  }

  if (!args.market) {
    console.error("Error: --market is required");
    printHelp();
    process.exit(1);
  }

  if (!process.env.PRIVATE_KEY) {
    console.error("Error: PRIVATE_KEY environment variable is required");
    process.exit(1);
  }

  // Validate market address
  let marketPubkey: PublicKey;
  try {
    marketPubkey = new PublicKey(args.market);
  } catch {
    console.error("Error: Invalid market address");
    process.exit(1);
  }

  const rpcUrl = process.env.RPC_URL || "https://api.mainnet-beta.solana.com";
  const client = new PNPClient(rpcUrl, process.env.PRIVATE_KEY);

  // Check settlement status using trading module's getMarketInfo
  console.log("\n📊 Checking Market\n");

  try {
    const marketInfo = await client.trading!.getMarketInfo(marketPubkey);

    console.log(`Market:     ${args.market}`);

    if (!marketInfo.resolved) {
      console.error("\n❌ Market is not yet settled. Cannot redeem.");
      process.exit(1);
    }

    // winningTokenId: 0 = none, 1 = yes, 2 = no
    const winner = marketInfo.winningTokenId === 1 ? "YES" : (marketInfo.winningTokenId === 2 ? "NO" : "NONE");
    console.log(`Winner:     ${winner}`);
    console.log(`Collateral: ${marketInfo.collateralToken.toBase58()}`);

    // Execute redemption
    console.log(`\n💰 Redeeming Position\n`);

    await client.redeemPosition(marketPubkey);

    console.log("✅ Redemption Successful!\n");
    console.log(`\nSolscan:   Check wallet for transaction`);

    console.log("\n--- JSON OUTPUT ---");
    console.log(JSON.stringify({ redeemed: true }, null, 2));

  } catch (error: any) {
    console.error("\n❌ Redemption failed:", error.message);
    process.exit(1);
  }
}

main();
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 323kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall