pnpfucius
v2.0.1
Published
PNPFUCIUS - The PNP Exchange SDK & CLI for Solana prediction markets
Maintainers
Readme
PNPFUCIUS
The PNP Exchange CLI & SDK for Solana prediction markets.
"The wise trader predicts with patience"
Features
- Full PNP Exchange Integration - Create, trade, and settle prediction markets on Solana
- PNP Oracle Settlement - Built-in LLM oracle for market resolution criteria
- AMM & P2P Markets - Support for both V2 (AMM) and V3 (P2P) market types
- Custom Odds - Create markets with custom starting odds
- Market Discovery - Browse all markets on PNP Exchange
- Trading Tools - Buy/sell YES/NO tokens with USDC
- Redemption - Redeem winning positions and claim refunds
- Interactive CLI - Purple-themed terminal interface with slash commands
- Helius RPC Integration - Reliable Solana access via Helius
- No External AI Required - Uses PNP's built-in LLM oracle
Installation
# Install from npm
npm install pnpfucius
# Or clone and install locally
git clone https://github.com/pnp-protocol/pnpfucius.git
cd pnpfucius
npm installQuick Start
# Run the interactive CLI
npm run pnpfucius
# Run the demo (no wallet required)
npm run demoConfiguration
Create a .env file:
# Required for trading/creating markets
WALLET_KEY=your_base58_private_key
# Helius API key (recommended)
HELIUS_API_KEY=your_helius_api_key
# Network (devnet or mainnet)
NETWORK=devnet
# Optional defaults
DEFAULT_LIQUIDITY=1000000
DEFAULT_DURATION_DAYS=30Get a free Helius API key at helius.dev
CLI Commands
| Command | Description |
|---------|-------------|
| /discover | Browse ALL PNP markets |
| /create [question] | Create AMM market |
| /p2p [question] | Create P2P market |
| /odds <percent> <question> | Market with custom odds |
| /info <address> | Get market details |
| /buy <address> <yes\|no> <usdc> | Buy YES/NO tokens |
| /sell <address> <yes\|no> <amount> | Sell tokens |
| /prices <address> | Get market prices |
| /balance <address> | Check your balances |
| /oracle <address> | Get LLM settlement criteria |
| /settle <address> <yes\|no> | Settle a market |
| /redeem <address> | Redeem winning position |
| /refund <address> | Claim refund |
| /config | Show configuration |
| /tools | List all available tools |
| /help | Show help |
| /exit | Exit PNPFUCIUS |
SDK Usage
import { createAgent, executeTool } from 'pnpfucius';
// Create an agent
const agent = await createAgent({ verbose: true });
// Create a market
const result = await agent.createMarket({
question: 'Will BTC reach $150k by March 2026?',
durationDays: 90,
liquidity: 1000000n
});
console.log('Market created:', result.market);
// Discover all markets
const markets = await agent.discoverMarkets();
console.log('Found markets:', markets.total);
// Get settlement criteria from PNP Oracle
const criteria = await agent.fetchSettlementCriteria(marketAddress);
console.log('Settlement criteria:', criteria);
// Buy tokens
const trade = await agent.buyTokens({
marketAddress: '7xKXw9...',
side: 'yes',
amountUsdc: 50
});
// Use tools directly
await executeTool('discover_all_markets', {});
await executeTool('get_settlement_criteria', { market_address: '...' });
await executeTool('buy_tokens', { market_address: '...', side: 'yes', amount_usdc: 10 });Available Tools
Market Creation
create_market- Create AMM marketcreate_p2p_market_simple- Create simple P2P marketcreate_amm_market_with_odds- AMM with custom oddscreate_p2p_market_with_odds- P2P with custom oddscreate_market_with_oracle- Market with custom oracle
Market Discovery
discover_all_markets- Find all PNP marketslist_markets- List your marketsget_market_info- Market detailsget_v2_market_info- V2 (AMM) detailsget_p2p_market_info- P2P detailsget_market_metadata- Market metadata
Trading
buy_tokens- Buy YES/NO tokenssell_tokens- Sell tokensbuy_v3_tokens- Buy V3 tokensget_market_prices- Current pricesget_balances- Your balances
Settlement (PNP Oracle)
get_settlement_criteria- LLM-generated criteriaget_settlement_data- Resolution resultwait_for_settlement- Wait for criteriasettle_market- Settle with outcome
Redemption
redeem_position- Redeem winningsredeem_v3_position- Redeem V3redeem_p2p_position- Redeem P2Pclaim_refund- Claim refundclaim_p2p_refund- Claim P2P refund
How It Works
Market Creation: Create prediction markets with YES/NO outcomes on Solana via PNP Exchange protocol
PNP Oracle: Markets use PNP's built-in LLM oracle for settlement criteria and resolution
Trading: Buy/sell outcome tokens using USDC through bonding curves (AMM) or direct P2P
Settlement: Oracle evaluates market conditions and provides resolution
Redemption: Winners redeem tokens for USDC
Testing
npm testLinks
License
MIT
