import { PublicKey, TransactionInstruction } from "@solana/web3.js"; import BN from "bn.js"; import type { PitProgram } from "../program.js"; import { PoolType } from "../types.js"; /** * Parameters for creating a redeem instruction */ export interface RedeemParams { /** Week number of the market */ weekNumber: number; /** Pool type (High or Low) */ poolType: PoolType; /** Strike index (0, 1, or 2) */ strikeIndex: number; /** Whether this is a HIT token (true) or MISS token (false) */ isHit: boolean; /** Amount of tokens to redeem (in raw units with 9 decimals) */ amount: BN; /** Whether this is a winning token (true = receives SOL, false = burn only) */ isWin: boolean; /** User's public key (signer) */ user: PublicKey; /** User's token account for the specific Hit/Miss token */ userTokenAccount: PublicKey; /** User's wSOL account (receives payout if winner) */ userWsolAccount: PublicKey; /** wSOL mint address */ wsolMint: PublicKey; /** wSOL vault (from MarketState.wsolVault) */ wsolVault: PublicKey; /** Token mint for the specific Hit/Miss token */ tokenMint: PublicKey; /** Token program (usually SPL Token) */ tokenProgram: PublicKey; } /** * Create a redeem instruction for burning tokens and receiving payout * * Redemption rules: * - Winner tokens: burn for 1:1 SOL payout * - Loser tokens: burn for 0 SOL (just removes tokens) * * Early redemption (before settlement): * - HIT tokens: Can redeem early if already confirmed winner (outcome won't decrease) * - MISS tokens: Must wait for settlement (outcome might still increase) * * @param program - Anchor Program instance * @param params - Redeem parameters * @returns Promise resolving to TransactionInstruction * * @example * ```typescript * import { createProgram, createRedeemInstruction, PoolType } from "@pit-protocol/sdk"; * * const program = createProgram(provider); * const ix = await createRedeemInstruction(program, { * weekNumber: 1, * poolType: PoolType.High, * strikeIndex: 0, * isHit: true, * user: wallet.publicKey, * userTokenAccount: hitTokenAta, * userWsolAccount: wsolAta, * wsolMint: WSOL_MINT, * wsolVault: market.wsolVault, * tokenMint: hitMint, * tokenProgram: TOKEN_PROGRAM_ID, * }); * * const tx = new Transaction().add(ix); * await sendAndConfirmTransaction(connection, tx, [wallet]); * ``` */ export declare function createRedeemInstruction(program: PitProgram, params: RedeemParams): Promise; //# sourceMappingURL=redeem.d.ts.map