import { PublicKey, type Connection } from "@solana/web3.js"; import type { JperpSide } from "../perps/types.js"; import type { TransactionProofBuilder } from "../proofs/types.js"; import { type ClientProvingDeps, type ClientProvingFailure, type ClientProvingNote, type ClientProvingOutputNote, type ClientSpendRecovery, type NoteCipherRecipient } from "./shared.js"; export interface JperpOpenWithClientProofParams { connection: Connection; /** One or two notes of the collateral mint. Merge larger sets with `consolidateNotes` first. */ notes: ClientProvingNote[]; /** Collateral pool mint. Defaults to USDC; pass the system program id for a native-SOL pool. */ poolMint?: PublicKey; /** Base units of collateral the position receives. No relayer fee is charged on a perp open. */ depositAmount: bigint; /** Owns the position. With `withdrawalId` and the pool mint, it seeds the executor PDA. */ claimant: PublicKey; /** Exactly 32 bytes (or 64 hex). Derive a fresh one per open; `deriveJperpWithdrawalId` does. */ withdrawalId: Uint8Array | string; custody: PublicKey; collateralCustody: PublicKey; /** Position size in USD base units. */ sizeUsdDelta: bigint; side: JperpSide; /** * One-sided price bound, in the oracle's units. A long is bounded above and a * short below, so 0 is only ever safe for a long. */ priceSlippage?: bigint; /** Position-request counter. Use a fresh one per request against the same position. */ counter?: bigint; userPublicKey: string; /** Who can decrypt the change note from chain data. */ changeCipherRecipient: NoteCipherRecipient; /** Owner key of the change note. Defaults to the first input note's key. */ changeOwnerPrivateKey?: bigint; /** See `SwapWithClientProofParams.allowWithoutNoteCiphers`. Default false. */ allowWithoutNoteCiphers?: boolean; /** Awaited before proving; if it throws, nothing is submitted. */ persistRecovery(recovery: ClientSpendRecovery): Promise | void; prover?: TransactionProofBuilder; indexTimeoutMs?: number; } interface JperpOpenResultBase { quoteId: string; /** The PDA the collateral lands in, which Jupiter's keeper settles from. */ executor: PublicKey; position: PublicKey; positionRequest: PublicKey; /** Null when the notes are spent exactly. */ changeNote: ClientProvingOutputNote | null; recovery: ClientSpendRecovery; } /** * Same outcome semantics as `ClientWithdrawResult`, with one perps-specific * caveat: a `landed` open means the collateral reached the executor and the * position request exists, NOT that the position is open. Jupiter's keeper * settles the request afterwards and can reject it (for instance on price * bounds), which returns the collateral to the executor rather than the pool. */ export type ClientJperpOpenResult = (JperpOpenResultBase & { status: "landed"; txSignature: string; noteCiphersIncluded: boolean; }) | (JperpOpenResultBase & { status: "unconfirmed"; txSignature: string; }) | (JperpOpenResultBase & { status: "unknown"; error: ClientProvingFailure; }) | (JperpOpenResultBase & { status: "rejected"; error: ClientProvingFailure; }); /** * Open a Jupiter perps position from private notes, with the proof generated on * this device. * * A perp open is withdraw-shaped: the collateral leaves the pool to an executor * PDA that Jupiter's keeper settles from. The proof binds the deposit and, via * ExtData's recipient, the executor — whose seeds are the pool mint, the * claimant and the withdrawal id. * * It does NOT bind the trade. Size, side, slippage, counter and the market * accounts are instruction arguments the relayer supplies, so this derives the * executor, position and position request locally from what the caller asked * for and refuses any quote that names different ones. Without that check a * relayer could quote one trade and open another with the same proof. * * Throws only while nothing has been submitted; see `ClientJperpOpenResult`. */ export declare function jperpOpenWithClientProof(params: JperpOpenWithClientProofParams): Promise; /** @internal */ export declare function runJperpOpenWithClientProof(params: JperpOpenWithClientProofParams, deps: ClientProvingDeps): Promise; export {};