internet-court/internet-court-skill / vendored/pnp/pnp-solana
pnp-markets-solana
FlaggedCreate, 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).
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 272 B |
| LICENSE | other | 1.6 KB |
| README.md | markdown | 3.5 KB |
| SKILL.md | skill md | 29.5 KB |
| package-lock.json | manifest | 69.8 KB |
| package.json | manifest | 52 B |
| references/api-reference.md | markdown | 15.7 KB |
| references/examples.md | markdown | 6.3 KB |
| references/program-addresses.md | markdown | 7.4 KB |
| references/types-and-precision.md | markdown | 7.3 KB |
| references/use-cases.md | markdown | 4.1 KB |
| scripts/create-market-custom.ts | script | 1.5 KB |
| scripts/create-market-p2p.ts | script | 4.0 KB |
| scripts/create-market-x.ts | script | 1.5 KB |
| scripts/create-market-yt.ts | script | 1.4 KB |
| scripts/create-market.ts | script | 1.4 KB |
| scripts/market-data.ts | script | 3.5 KB |
| scripts/package.json | manifest | 549 B |
| scripts/redeem.ts | script | 3.0 KB |
| scripts/settle.ts | script | 5.5 KB |
| scripts/trade.ts | script | 5.8 KB |
| scripts/tsconfig.json | config | 346 B |
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();
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |
| 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: 119k | Updated | Claude CodeCodex | Verified | Install |
| 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: 118k | Updated | Claude CodeCodex | Verified | Install |