@optionsfi/sdk 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3315 @@
1
+ import { PublicKey, Transaction, Connection, TransactionInstruction } from '@solana/web3.js';
2
+ import * as anchor from '@coral-xyz/anchor';
3
+
4
+ /**
5
+ * RFQ and quote type definitions.
6
+ */
7
+ /**
8
+ * Configuration for connecting to the OptionsFi RFQ infrastructure
9
+ */
10
+ interface RFQConfig {
11
+ /** Solana RPC URL */
12
+ rpcUrl: string;
13
+ /** WebSocket URL for the RFQ router (e.g., wss://rfq.optionsfi.xyz) */
14
+ rfqRouterUrl: string;
15
+ /** OptionsFi vault program ID */
16
+ programId: string;
17
+ /** Network environment */
18
+ network?: 'devnet' | 'mainnet-beta';
19
+ /** Optional timeout for RFQ requests in milliseconds (default: 30000) */
20
+ rfqTimeoutMs?: number;
21
+ }
22
+ /**
23
+ * Parameters for creating a new RFQ
24
+ */
25
+ interface RFQParams {
26
+ /** Asset identifier (e.g., "NVDAX", "SOL") */
27
+ asset: string;
28
+ /** Whether the protocol is buying or selling options */
29
+ side: 'buy' | 'sell';
30
+ /** Type of option */
31
+ optionType: 'call' | 'put';
32
+ /** Strike price in USD (e.g., 150.00) */
33
+ strike: number;
34
+ /** Expiry timestamp (Unix seconds) */
35
+ expiry: number;
36
+ /** Notional quantity in base asset tokens (scaled by decimals) */
37
+ quantity: bigint;
38
+ /** Vault address making the request */
39
+ vaultAddress: string;
40
+ /** Minimum acceptable premium (optional floor) */
41
+ premiumFloor?: bigint;
42
+ /** Whether to anonymize vault identity in RFQ broadcast (default: false) */
43
+ anonymous?: boolean;
44
+ /** Minimum number of quotes required (default: 1) */
45
+ minQuotes?: number;
46
+ /** Maximum time to wait for quotes in milliseconds (default: 30000) */
47
+ quoteTimeout?: number;
48
+ }
49
+ /**
50
+ * A quote from a market maker
51
+ */
52
+ interface Quote {
53
+ /** Unique quote identifier */
54
+ id: string;
55
+ /** RFQ this quote is for */
56
+ rfqId: string;
57
+ /** Market maker identifier */
58
+ marketMaker: string;
59
+ /** Premium amount in USDC (scaled by decimals, typically 6) */
60
+ premium: bigint;
61
+ /** Quote timestamp (Unix milliseconds) */
62
+ timestamp: number;
63
+ /** When this quote expires (Unix milliseconds) */
64
+ expiresAt: number;
65
+ /** Optional: Quote expiry duration in seconds (for validation) */
66
+ validUntil?: number;
67
+ }
68
+ /**
69
+ * RFQ status and state
70
+ */
71
+ interface RFQ {
72
+ /** Unique RFQ identifier */
73
+ id: string;
74
+ /** Original RFQ parameters */
75
+ params: RFQParams;
76
+ /** All quotes received */
77
+ quotes: Quote[];
78
+ /** Current status */
79
+ status: 'open' | 'filled' | 'cancelled' | 'expired';
80
+ /** Fill details if filled */
81
+ fill?: {
82
+ quoteId: string;
83
+ marketMaker: string;
84
+ premium: bigint;
85
+ filledAt: number;
86
+ transactionSignature?: string;
87
+ };
88
+ /** Creation timestamp (Unix milliseconds) */
89
+ createdAt: number;
90
+ }
91
+ /**
92
+ * RFQ event types for subscription callbacks
93
+ */
94
+ type RFQEventType = 'quote_received' | 'rfq_filled' | 'rfq_cancelled' | 'rfq_expired' | 'connection_error';
95
+ /**
96
+ * RFQ event payload
97
+ */
98
+ interface RFQEvent {
99
+ type: RFQEventType;
100
+ rfqId: string;
101
+ data: Quote | RFQ | Error;
102
+ timestamp: number;
103
+ }
104
+
105
+ /**
106
+ * Option pricing and position type definitions.
107
+ */
108
+ /**
109
+ * Option type (call or put)
110
+ */
111
+ type OptionType = 'call' | 'put';
112
+ /**
113
+ * Parameters for Black-Scholes pricing
114
+ */
115
+ interface BlackScholesParams {
116
+ /** Current underlying spot price */
117
+ spot: number;
118
+ /** Option strike price */
119
+ strike: number;
120
+ /** Time to expiry in years (e.g., 0.0833 for 1 month) */
121
+ timeToExpiry: number;
122
+ /** Risk-free rate as decimal (e.g., 0.05 for 5%) */
123
+ riskFreeRate: number;
124
+ /** Annualized volatility as decimal (e.g., 0.30 for 30%) */
125
+ volatility: number;
126
+ }
127
+ /**
128
+ * Option pricing results
129
+ */
130
+ interface OptionPrices {
131
+ /** Call option price */
132
+ call: number;
133
+ /** Put option price */
134
+ put: number;
135
+ /** Delta (rate of change vs underlying) */
136
+ delta: {
137
+ call: number;
138
+ put: number;
139
+ };
140
+ }
141
+ /**
142
+ * Parameters for premium calculation
143
+ */
144
+ interface PremiumParams {
145
+ /** Current spot price */
146
+ spot: number;
147
+ /** Strike as percentage of spot (e.g., 1.05 for 5% OTM call) */
148
+ strikePercent: number;
149
+ /** Days until expiry */
150
+ daysToExpiry: number;
151
+ /** Annualized volatility as decimal */
152
+ volatility: number;
153
+ /** Risk-free rate (default: 0.05) */
154
+ riskFreeRate?: number;
155
+ }
156
+ /**
157
+ * Option position details
158
+ */
159
+ interface OptionPosition {
160
+ /** Underlying asset */
161
+ asset: string;
162
+ /** Call or put */
163
+ optionType: OptionType;
164
+ /** Strike price */
165
+ strike: number;
166
+ /** Expiry timestamp (Unix seconds) */
167
+ expiry: number;
168
+ /** Notional amount in base tokens */
169
+ notional: bigint;
170
+ /** Premium paid/received in quote tokens (USDC) */
171
+ premium: bigint;
172
+ /** Whether this position is long or short */
173
+ side: 'long' | 'short';
174
+ }
175
+ /**
176
+ * Quote validation result
177
+ */
178
+ interface QuoteValidation {
179
+ /** Whether the quote is valid */
180
+ isValid: boolean;
181
+ /** Reason for invalidity (if any) */
182
+ reason?: string;
183
+ /** Calculated fair value for reference */
184
+ fairValue?: number;
185
+ /** Deviation from fair value in basis points */
186
+ deviationBps?: number;
187
+ }
188
+
189
+ /**
190
+ * Vault account and instruction parameter types.
191
+ */
192
+
193
+ /**
194
+ * Vault account data (on-chain state)
195
+ */
196
+ interface VaultData {
197
+ /** Vault authority (admin) */
198
+ authority: PublicKey;
199
+ /** Asset identifier (e.g., "NVDAX") */
200
+ assetId: string;
201
+ /** Underlying token mint (e.g., NVDAx) */
202
+ underlyingMint: PublicKey;
203
+ /** Share token mint (e.g., vNVDAx) */
204
+ shareMint: PublicKey;
205
+ /** Vault's token account for underlying */
206
+ vaultTokenAccount: PublicKey;
207
+ /** Premium token mint (typically USDC) */
208
+ premiumMint: PublicKey;
209
+ /** Vault's token account for premium */
210
+ premiumTokenAccount: PublicKey;
211
+ /** Escrow account for pending share burns */
212
+ shareEscrow: PublicKey;
213
+ /** Total underlying assets in vault */
214
+ totalAssets: bigint;
215
+ /** Total shares outstanding */
216
+ totalShares: bigint;
217
+ /** Virtual offset for share price calculation */
218
+ virtualOffset: bigint;
219
+ /** Current epoch number */
220
+ epoch: bigint;
221
+ /** Maximum percentage of assets that can be used (basis points) */
222
+ utilizationCapBps: number;
223
+ /** Minimum epoch duration in seconds */
224
+ minEpochDuration: bigint;
225
+ /** Timestamp of last epoch roll */
226
+ lastRollTimestamp: bigint;
227
+ /** Pending withdrawal amount in shares */
228
+ pendingWithdrawals: bigint;
229
+ /** Notional exposure for current epoch */
230
+ epochNotionalExposed: bigint;
231
+ /** Premium earned in current epoch */
232
+ epochPremiumEarned: bigint;
233
+ /** Premium per token for current epoch (basis points) */
234
+ epochPremiumPerTokenBps: number;
235
+ /** Whether the vault is paused */
236
+ isPaused: boolean;
237
+ /** PDA bump seed */
238
+ bump: number;
239
+ }
240
+ /**
241
+ * Parameters for recording notional exposure
242
+ */
243
+ interface RecordExposureParams {
244
+ /** Vault public key */
245
+ vault: PublicKey;
246
+ /** Vault authority (signer) */
247
+ authority: PublicKey;
248
+ /** Notional amount in underlying tokens */
249
+ notionalTokens: bigint;
250
+ /** Premium amount in quote tokens (USDC) */
251
+ premium: bigint;
252
+ }
253
+ /**
254
+ * Parameters for collecting premium
255
+ */
256
+ interface CollectPremiumParams {
257
+ /** Vault public key */
258
+ vault: PublicKey;
259
+ /** Authority (signer) */
260
+ authority: PublicKey;
261
+ /** Payer's token account for premium */
262
+ payerTokenAccount: PublicKey;
263
+ /** Amount to collect */
264
+ amount: bigint;
265
+ }
266
+ /**
267
+ * Parameters for paying settlement
268
+ */
269
+ interface PaySettlementParams {
270
+ /** Vault public key */
271
+ vault: PublicKey;
272
+ /** Authority (signer) */
273
+ authority: PublicKey;
274
+ /** Recipient's token account */
275
+ recipientTokenAccount: PublicKey;
276
+ /** Recipient public key */
277
+ recipient: PublicKey;
278
+ /** Settlement amount */
279
+ amount: bigint;
280
+ }
281
+ /**
282
+ * Parameters for advancing epoch
283
+ */
284
+ interface AdvanceEpochParams {
285
+ /** Vault public key */
286
+ vault: PublicKey;
287
+ /** Authority (signer) */
288
+ authority: PublicKey;
289
+ /** Premium earned this epoch (for share price appreciation) */
290
+ premiumEarned: bigint;
291
+ }
292
+ /**
293
+ * Withdrawal request account data
294
+ */
295
+ interface WithdrawalRequest {
296
+ /** User who requested withdrawal */
297
+ user: PublicKey;
298
+ /** Associated vault */
299
+ vault: PublicKey;
300
+ /** Epoch when withdrawal was requested */
301
+ epoch: bigint;
302
+ /** Number of shares to withdraw */
303
+ shares: bigint;
304
+ /** Whether the request has been processed */
305
+ processed: boolean;
306
+ }
307
+
308
+ /**
309
+ * WebSocket client for interacting with the RFQ router.
310
+ *
311
+ * @example
312
+ * ```typescript
313
+ * import { RFQClient, DEVNET_CONFIG } from '@optionsfi/sdk';
314
+ *
315
+ * const client = new RFQClient(DEVNET_CONFIG);
316
+ * await client.connect();
317
+ *
318
+ * const rfqId = await client.createRFQ({
319
+ * asset: 'NVDAX',
320
+ * side: 'sell',
321
+ * optionType: 'call',
322
+ * strike: 150,
323
+ * expiry: Math.floor(Date.now() / 1000) + 86400 * 7,
324
+ * quantity: BigInt(1000 * 1e6),
325
+ * vaultAddress: vaultPubkey.toString(),
326
+ * });
327
+ *
328
+ * client.subscribeToQuotes(rfqId, (quote) => {
329
+ * console.log('Quote received:', quote);
330
+ * });
331
+ * ```
332
+ */
333
+
334
+ /**
335
+ * RFQ Client for interacting with OptionsFi infrastructure
336
+ */
337
+ declare class RFQClient {
338
+ private connection;
339
+ private wsConnection;
340
+ private config;
341
+ private quoteCallbacks;
342
+ private eventCallbacks;
343
+ private activeRFQs;
344
+ private isConnected;
345
+ private reconnectAttempts;
346
+ private maxReconnectAttempts;
347
+ /**
348
+ * Create a new RFQ Client
349
+ *
350
+ * @param config - Configuration for connecting to OptionsFi
351
+ */
352
+ constructor(config: RFQConfig);
353
+ /**
354
+ * Connect to the RFQ router WebSocket
355
+ *
356
+ * @returns Promise that resolves when connected
357
+ * @throws Error if connection fails
358
+ */
359
+ connect(): Promise<void>;
360
+ /**
361
+ * Disconnect from the RFQ router
362
+ */
363
+ disconnect(): void;
364
+ /**
365
+ * Check if the client is connected
366
+ */
367
+ get connected(): boolean;
368
+ /**
369
+ * Create a new RFQ and broadcast to market makers
370
+ *
371
+ * @param params - RFQ parameters
372
+ * @returns RFQ ID
373
+ * @throws Error if not connected or params invalid
374
+ */
375
+ createRFQ(params: RFQParams): Promise<string>;
376
+ /**
377
+ * Subscribe to quotes for a specific RFQ
378
+ *
379
+ * @param rfqId - RFQ to subscribe to
380
+ * @param callback - Called when a quote is received
381
+ */
382
+ subscribeToQuotes(rfqId: string, callback: (quote: Quote) => void): void;
383
+ /**
384
+ * Unsubscribe from quotes for an RFQ
385
+ *
386
+ * @param rfqId - RFQ to unsubscribe from
387
+ */
388
+ unsubscribeFromQuotes(rfqId: string): void;
389
+ /**
390
+ * Accept a quote and execute the option trade
391
+ *
392
+ * @param rfqId - RFQ ID
393
+ * @param quoteId - Quote to accept
394
+ * @param wallet - Solana wallet for signing
395
+ * @returns Transaction signature
396
+ */
397
+ executeOption(rfqId: string, quoteId: string, wallet: {
398
+ signTransaction: (tx: Transaction) => Promise<Transaction>;
399
+ }): Promise<string>;
400
+ /**
401
+ * Cancel an open RFQ
402
+ *
403
+ * @param rfqId - RFQ to cancel
404
+ */
405
+ cancelRFQ(rfqId: string): Promise<void>;
406
+ /**
407
+ * Get an active RFQ by ID
408
+ *
409
+ * @param rfqId - RFQ ID
410
+ * @returns RFQ or undefined
411
+ */
412
+ getRFQ(rfqId: string): RFQ | undefined;
413
+ /**
414
+ * Get all active RFQs
415
+ */
416
+ getAllRFQs(): RFQ[];
417
+ /**
418
+ * Subscribe to all RFQ events
419
+ *
420
+ * @param callback - Called for each event
421
+ * @returns Unsubscribe function
422
+ */
423
+ onEvent(callback: (event: RFQEvent) => void): () => void;
424
+ private handleMessage;
425
+ private emitEvent;
426
+ private validateRFQParams;
427
+ private generateRFQId;
428
+ private buildExecutionTransaction;
429
+ private attemptReconnect;
430
+ }
431
+
432
+ /**
433
+ * Transaction builders for vault program instructions.
434
+ *
435
+ * @example
436
+ * ```typescript
437
+ * import { VaultInstructions, deriveVaultPda } from '@optionsfi/sdk';
438
+ * import { Connection, PublicKey } from '@solana/web3.js';
439
+ *
440
+ * const connection = new Connection('https://api.devnet.solana.com');
441
+ * const vaultInstructions = new VaultInstructions(connection);
442
+ * await vaultInstructions.initialize();
443
+ *
444
+ * // Fetch vault data
445
+ * const vault = await vaultInstructions.fetchVault('NVDAX');
446
+ * console.log('Total assets:', vault.totalAssets);
447
+ *
448
+ * // Build a transaction instruction
449
+ * const ix = await vaultInstructions.recordNotionalExposure({
450
+ * vault: vaultPda,
451
+ * authority: walletPublicKey,
452
+ * notionalTokens: BigInt(1000 * 1e6),
453
+ * premium: BigInt(50 * 1e6),
454
+ * });
455
+ * ```
456
+ */
457
+
458
+ /**
459
+ * Client for building vault program instructions
460
+ */
461
+ declare class VaultInstructions {
462
+ private connection;
463
+ private program;
464
+ private idl;
465
+ /**
466
+ * Create a new VaultInstructions client
467
+ *
468
+ * @param connection - Solana connection
469
+ * @param idl - Optional IDL (uses bundled vault IDL by default)
470
+ */
471
+ constructor(connection: Connection, idl?: any);
472
+ /**
473
+ * Initialize the Anchor program interface
474
+ *
475
+ * @param wallet - Optional wallet for signing (not required for instruction building)
476
+ */
477
+ initialize(wallet?: anchor.Wallet): Promise<void>;
478
+ /**
479
+ * Set the program IDL
480
+ *
481
+ * @param idl - Vault program IDL
482
+ */
483
+ setIDL(idl: any): void;
484
+ /**
485
+ * Check if the client is initialized
486
+ */
487
+ get isInitialized(): boolean;
488
+ /**
489
+ * Fetch vault account data
490
+ *
491
+ * @param assetId - Asset identifier (e.g., "NVDAX")
492
+ * @returns Vault data or null if not found
493
+ */
494
+ fetchVault(assetId: string): Promise<VaultData | null>;
495
+ /**
496
+ * Build instruction to record notional exposure after RFQ execution
497
+ *
498
+ * @param params - Exposure parameters
499
+ * @returns TransactionInstruction
500
+ */
501
+ recordNotionalExposure(params: RecordExposureParams): Promise<TransactionInstruction>;
502
+ /**
503
+ * Build instruction to collect premium from market maker
504
+ *
505
+ * @param params - Collection parameters
506
+ * @returns TransactionInstruction
507
+ */
508
+ collectPremium(params: CollectPremiumParams): Promise<TransactionInstruction>;
509
+ /**
510
+ * Build instruction to pay settlement to market maker
511
+ *
512
+ * @param params - Settlement parameters
513
+ * @returns TransactionInstruction
514
+ */
515
+ paySettlement(params: PaySettlementParams): Promise<TransactionInstruction>;
516
+ /**
517
+ * Build instruction to advance epoch
518
+ *
519
+ * @param params - Advance epoch parameters
520
+ * @returns TransactionInstruction
521
+ */
522
+ advanceEpoch(params: AdvanceEpochParams): Promise<TransactionInstruction>;
523
+ /**
524
+ * Calculate share price from vault data
525
+ *
526
+ * @param vault - Vault data
527
+ * @param decimals - Token decimals (default: 6)
528
+ * @returns Share price as a number
529
+ */
530
+ static calculateSharePrice(vault: VaultData, decimals?: number): number;
531
+ /**
532
+ * Calculate utilization percentage from vault data
533
+ *
534
+ * @param vault - Vault data
535
+ * @returns Utilization as decimal (0-1)
536
+ */
537
+ static calculateUtilization(vault: VaultData): number;
538
+ /**
539
+ * Check if vault can accept more exposure
540
+ *
541
+ * @param vault - Vault data
542
+ * @param additionalNotional - Additional notional to expose
543
+ * @returns Whether the vault can accept the exposure
544
+ */
545
+ static canAcceptExposure(vault: VaultData, additionalNotional: bigint): boolean;
546
+ /**
547
+ * Calculate remaining capacity for option writing
548
+ *
549
+ * @param vault - Vault data
550
+ * @returns Remaining notional capacity
551
+ */
552
+ static getRemainingCapacity(vault: VaultData): bigint;
553
+ }
554
+
555
+ /**
556
+ * Black-Scholes option pricing and volatility calculations.
557
+ *
558
+ * @example
559
+ * ```typescript
560
+ * import { OptionPricing } from '@optionsfi/sdk';
561
+ *
562
+ * const price = OptionPricing.blackScholes({
563
+ * spot: 145.50,
564
+ * strike: 150,
565
+ * timeToExpiry: 7 / 365,
566
+ * riskFreeRate: 0.05,
567
+ * volatility: 0.45,
568
+ * });
569
+ *
570
+ * console.log('Call price:', price.call);
571
+ * console.log('Put price:', price.put);
572
+ * console.log('Call delta:', price.delta.call);
573
+ * ```
574
+ */
575
+
576
+ /**
577
+ * Option pricing utilities using Black-Scholes model
578
+ */
579
+ declare class OptionPricing {
580
+ /**
581
+ * Calculate option prices using Black-Scholes formula
582
+ *
583
+ * @param params - Pricing parameters
584
+ * @returns Call and put prices with deltas
585
+ */
586
+ static blackScholes(params: BlackScholesParams): OptionPrices;
587
+ /**
588
+ * Calculate covered call premium
589
+ *
590
+ * @param params - Premium calculation parameters
591
+ * @returns Premium in same units as spot price
592
+ */
593
+ static calculateCoveredCallPremium(params: PremiumParams): number;
594
+ /**
595
+ * Calculate premium as basis points of notional
596
+ *
597
+ * @param premium - Premium amount
598
+ * @param spot - Spot price
599
+ * @returns Premium in basis points
600
+ */
601
+ static premiumToBps(premium: number, spot: number): number;
602
+ /**
603
+ * Convert basis points to premium
604
+ *
605
+ * @param bps - Basis points
606
+ * @param spot - Spot price
607
+ * @returns Premium amount
608
+ */
609
+ static bpsToPremium(bps: number, spot: number): number;
610
+ /**
611
+ * Calculate time to expiry in years
612
+ *
613
+ * @param expiryTimestamp - Expiry Unix timestamp (seconds)
614
+ * @returns Time in years
615
+ */
616
+ static timeToExpiry(expiryTimestamp: number): number;
617
+ /**
618
+ * Suggest a strike price based on delta target
619
+ *
620
+ * @param spotPrice - Current spot price
621
+ * @param deltaBps - Delta in basis points (e.g., 1000 = 10% OTM)
622
+ * @param optionType - 'call' or 'put'
623
+ * @returns Suggested strike price
624
+ */
625
+ static suggestStrike(spotPrice: number, deltaBps: number, optionType?: 'call' | 'put'): number;
626
+ /**
627
+ * Validate a quote against fair value
628
+ *
629
+ * @param quotePremium - Premium from quote
630
+ * @param fairValue - Calculated fair value
631
+ * @param maxDeviationBps - Maximum acceptable deviation in bps (default: 500)
632
+ * @returns Validation result
633
+ */
634
+ static validateQuote(quotePremium: number, fairValue: number, maxDeviationBps?: number): QuoteValidation;
635
+ /**
636
+ * Calculate historical volatility from price data
637
+ *
638
+ * @param prices - Array of closing prices (oldest first)
639
+ * @param tradingDaysPerYear - Trading days for annualization (default: 252)
640
+ * @returns Annualized volatility
641
+ */
642
+ static calculateHistoricalVolatility(prices: number[], tradingDaysPerYear?: number): number;
643
+ /**
644
+ * Calculate implied volatility from option price using Newton-Raphson
645
+ *
646
+ * @param optionPrice - Market price of option
647
+ * @param spot - Spot price
648
+ * @param strike - Strike price
649
+ * @param timeToExpiry - Time to expiry in years
650
+ * @param riskFreeRate - Risk-free rate
651
+ * @param optionType - 'call' or 'put'
652
+ * @param maxIterations - Maximum iterations (default: 100)
653
+ * @returns Implied volatility
654
+ */
655
+ static calculateImpliedVolatility(optionPrice: number, spot: number, strike: number, timeToExpiry: number, riskFreeRate: number, optionType: 'call' | 'put', maxIterations?: number): number;
656
+ /**
657
+ * Standard normal CDF using Abramowitz & Stegun approximation
658
+ */
659
+ private static normalCDF;
660
+ /**
661
+ * Standard normal PDF
662
+ */
663
+ private static normalPDF;
664
+ }
665
+
666
+ /**
667
+ * Input validation utilities with type checking.
668
+ */
669
+
670
+ /**
671
+ * Validation error with detailed message
672
+ */
673
+ declare class ValidationError extends Error {
674
+ readonly field: string;
675
+ constructor(field: string, message: string);
676
+ }
677
+ /**
678
+ * Validate RFQ parameters
679
+ *
680
+ * @param params - RFQ parameters to validate
681
+ * @throws ValidationError if any parameter is invalid
682
+ */
683
+ declare function validateRFQParams(params: RFQParams): void;
684
+ /**
685
+ * Validate Black-Scholes parameters
686
+ *
687
+ * @param params - Black-Scholes parameters to validate
688
+ * @throws ValidationError if any parameter is invalid
689
+ */
690
+ declare function validateBlackScholesParams(params: BlackScholesParams): void;
691
+ /**
692
+ * Validate a Solana public key string
693
+ *
694
+ * @param address - Address string to validate
695
+ * @param fieldName - Field name for error messages
696
+ * @throws ValidationError if address is invalid
697
+ */
698
+ declare function validatePublicKey(address: string, fieldName?: string): void;
699
+ /**
700
+ * Validate that an amount is a valid token amount
701
+ *
702
+ * @param amount - Amount to validate
703
+ * @param fieldName - Field name for error messages
704
+ * @param decimals - Token decimals (default: 6)
705
+ * @throws ValidationError if amount is invalid
706
+ */
707
+ declare function validateTokenAmount(amount: bigint, fieldName?: string, decimals?: number): void;
708
+ /**
709
+ * Validate a Unix timestamp
710
+ *
711
+ * @param timestamp - Timestamp to validate (seconds)
712
+ * @param fieldName - Field name for error messages
713
+ * @param options - Validation options
714
+ * @throws ValidationError if timestamp is invalid
715
+ */
716
+ declare function validateTimestamp(timestamp: number, fieldName?: string, options?: {
717
+ mustBeFuture?: boolean;
718
+ maxFutureDays?: number;
719
+ }): void;
720
+
721
+ /**
722
+ * Token amount and price formatting utilities.
723
+ */
724
+ /**
725
+ * Format a token amount from smallest unit to human-readable string
726
+ *
727
+ * @param amount - Amount in smallest unit (e.g., lamports)
728
+ * @param decimals - Token decimals
729
+ * @param maxDecimals - Maximum decimals to display (default: 2)
730
+ * @returns Formatted string
731
+ *
732
+ * @example
733
+ * formatTokenAmount(1500000n, 6); // "1.50"
734
+ * formatTokenAmount(1234567890n, 9); // "1.23"
735
+ */
736
+ declare function formatTokenAmount(amount: bigint, decimals: number, maxDecimals?: number): string;
737
+ /**
738
+ * Parse a human-readable token amount to smallest unit
739
+ *
740
+ * @param amount - Human-readable amount (e.g., "1.5")
741
+ * @param decimals - Token decimals
742
+ * @returns Amount in smallest unit
743
+ *
744
+ * @example
745
+ * parseTokenAmount("1.5", 6); // 1500000n
746
+ * parseTokenAmount("100", 6); // 100000000n
747
+ */
748
+ declare function parseTokenAmount(amount: string, decimals: number): bigint;
749
+ /**
750
+ * Format USDC amount (6 decimals)
751
+ */
752
+ declare function formatUSDC(amount: bigint, maxDecimals?: number): string;
753
+ /**
754
+ * Parse USDC amount to smallest unit
755
+ */
756
+ declare function parseUSDC(amount: string): bigint;
757
+ /**
758
+ * Format a price in USD with appropriate precision
759
+ *
760
+ * @param price - Price as number
761
+ * @param decimals - Decimal places (default: 2)
762
+ * @returns Formatted price string
763
+ */
764
+ declare function formatPrice(price: number, decimals?: number): string;
765
+ /**
766
+ * Format a percentage
767
+ *
768
+ * @param value - Decimal value (e.g., 0.15 for 15%)
769
+ * @param decimals - Decimal places (default: 2)
770
+ * @returns Formatted percentage string
771
+ */
772
+ declare function formatPercent(value: number, decimals?: number): string;
773
+ /**
774
+ * Format basis points
775
+ *
776
+ * @param bps - Basis points value
777
+ * @returns Formatted string with "bps" suffix
778
+ */
779
+ declare function formatBps(bps: number): string;
780
+ /**
781
+ * Convert basis points to percentage
782
+ */
783
+ declare function bpsToPercent(bps: number): number;
784
+ /**
785
+ * Convert percentage to basis points
786
+ */
787
+ declare function percentToBps(percent: number): number;
788
+ /**
789
+ * Format a Unix timestamp to ISO date string
790
+ *
791
+ * @param timestamp - Unix timestamp (seconds)
792
+ * @returns ISO date string
793
+ */
794
+ declare function formatTimestamp(timestamp: number): string;
795
+ /**
796
+ * Format a Unix timestamp to human-readable date
797
+ *
798
+ * @param timestamp - Unix timestamp (seconds)
799
+ * @param options - Intl.DateTimeFormat options
800
+ * @returns Localized date string
801
+ */
802
+ declare function formatDate(timestamp: number, options?: Intl.DateTimeFormatOptions): string;
803
+ /**
804
+ * Format time until expiry
805
+ *
806
+ * @param expiryTimestamp - Expiry Unix timestamp (seconds)
807
+ * @returns Human-readable duration string
808
+ */
809
+ declare function formatTimeToExpiry(expiryTimestamp: number): string;
810
+ /**
811
+ * Shorten a public key for display
812
+ *
813
+ * @param address - Full public key string
814
+ * @param chars - Characters to show on each end (default: 4)
815
+ * @returns Shortened address (e.g., "ABCD...WXYZ")
816
+ */
817
+ declare function shortenAddress(address: string, chars?: number): string;
818
+ /**
819
+ * Format an RFQ ID for display
820
+ *
821
+ * @param rfqId - Full RFQ ID
822
+ * @returns Shortened ID
823
+ */
824
+ declare function formatRFQId(rfqId: string): string;
825
+
826
+ /**
827
+ * Program addresses and mint constants.
828
+ */
829
+
830
+ /**
831
+ * OptionsFi Vault Program ID (mainnet/devnet)
832
+ */
833
+ declare const VAULT_PROGRAM_ID: PublicKey;
834
+ /**
835
+ * USDC mint address (devnet)
836
+ *
837
+ * Note: This is the official Circle USDC devnet mint.
838
+ * For mainnet, use: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
839
+ */
840
+ declare const DEVNET_USDC_MINT: PublicKey;
841
+ /**
842
+ * USDC mint address (mainnet)
843
+ */
844
+ declare const MAINNET_USDC_MINT: PublicKey;
845
+ /**
846
+ * Pyth Price Feed IDs (Hermes API)
847
+ */
848
+ declare const PYTH_PRICE_FEEDS: {
849
+ /** NVDA/USD price feed */
850
+ readonly NVDA: "0x4244d07890e4610f46bbde67de8f43a4bf8b569eebe904f136b469f148503b7f";
851
+ /** SOL/USD price feed */
852
+ readonly SOL: "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d";
853
+ /** BTC/USD price feed */
854
+ readonly BTC: "0xe62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43";
855
+ /** ETH/USD price feed */
856
+ readonly ETH: "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace";
857
+ };
858
+ /**
859
+ * Pyth Hermes API URL
860
+ */
861
+ declare const PYTH_HERMES_URL = "https://hermes.pyth.network";
862
+ /**
863
+ * Derive vault PDA from asset ID
864
+ */
865
+ declare function deriveVaultPda(assetId: string): [PublicKey, number];
866
+ /**
867
+ * Derive withdrawal request PDA
868
+ */
869
+ declare function deriveWithdrawalPda(vault: PublicKey, user: PublicKey, epoch: bigint): [PublicKey, number];
870
+ /**
871
+ * Derive share escrow PDA
872
+ */
873
+ declare function deriveShareEscrowPda(vault: PublicKey): [PublicKey, number];
874
+ /**
875
+ * Derive whitelist PDA
876
+ */
877
+ declare function deriveWhitelistPda(vault: PublicKey): [PublicKey, number];
878
+
879
+ /**
880
+ * Default configuration for devnet and mainnet.
881
+ */
882
+
883
+ /**
884
+ * Default configuration for devnet
885
+ */
886
+ declare const DEVNET_CONFIG: RFQConfig;
887
+ /**
888
+ * Default configuration for mainnet
889
+ */
890
+ declare const MAINNET_CONFIG: RFQConfig;
891
+ /**
892
+ * Default option pricing parameters
893
+ */
894
+ declare const DEFAULT_PRICING_PARAMS: {
895
+ /** Default risk-free rate (5%) */
896
+ riskFreeRate: number;
897
+ /** Default volatility lookback period in days */
898
+ volatilityLookbackDays: number;
899
+ /** Maximum acceptable deviation from fair value (5%) */
900
+ maxQuoteDeviationBps: number;
901
+ /** Trading days per year for volatility annualization */
902
+ tradingDaysPerYear: number;
903
+ };
904
+ /**
905
+ * RFQ timing defaults
906
+ */
907
+ declare const RFQ_DEFAULTS: {
908
+ /** Default RFQ timeout in milliseconds */
909
+ timeoutMs: number;
910
+ /** Minimum quote collection time */
911
+ minQuoteTimeMs: number;
912
+ /** Quote expiry buffer (how long before expiry to stop accepting) */
913
+ quoteExpiryBufferMs: number;
914
+ };
915
+ /**
916
+ * Token decimals for common tokens.
917
+ *
918
+ * Note: NVDAX is shown as an example tokenized stock with 6 decimals.
919
+ * Add your own token configurations as needed.
920
+ */
921
+ declare const TOKEN_DECIMALS: {
922
+ readonly USDC: 6;
923
+ readonly SOL: 9;
924
+ readonly NVDAX: 6;
925
+ };
926
+
927
+ var address = "A4jgqct3bwTwRmHECHdPpbH3a8ksaVb7rny9pMUGFo94";
928
+ var metadata = {
929
+ name: "vault",
930
+ version: "0.1.0",
931
+ spec: "0.1.0",
932
+ description: "OptionsFi V2 - Covered Call Vault"
933
+ };
934
+ var instructions = [
935
+ {
936
+ name: "add_market_maker",
937
+ docs: [
938
+ "Add a market maker to the whitelist"
939
+ ],
940
+ discriminator: [
941
+ 24,
942
+ 255,
943
+ 135,
944
+ 32,
945
+ 193,
946
+ 2,
947
+ 112,
948
+ 44
949
+ ],
950
+ accounts: [
951
+ {
952
+ name: "vault",
953
+ pda: {
954
+ seeds: [
955
+ {
956
+ kind: "const",
957
+ value: [
958
+ 118,
959
+ 97,
960
+ 117,
961
+ 108,
962
+ 116
963
+ ]
964
+ },
965
+ {
966
+ kind: "account",
967
+ path: "vault.asset_id",
968
+ account: "Vault"
969
+ }
970
+ ]
971
+ },
972
+ relations: [
973
+ "whitelist"
974
+ ]
975
+ },
976
+ {
977
+ name: "whitelist",
978
+ writable: true,
979
+ pda: {
980
+ seeds: [
981
+ {
982
+ kind: "const",
983
+ value: [
984
+ 119,
985
+ 104,
986
+ 105,
987
+ 116,
988
+ 101,
989
+ 108,
990
+ 105,
991
+ 115,
992
+ 116
993
+ ]
994
+ },
995
+ {
996
+ kind: "account",
997
+ path: "vault"
998
+ }
999
+ ]
1000
+ }
1001
+ },
1002
+ {
1003
+ name: "authority",
1004
+ writable: true,
1005
+ signer: true,
1006
+ relations: [
1007
+ "vault",
1008
+ "whitelist"
1009
+ ]
1010
+ }
1011
+ ],
1012
+ args: [
1013
+ {
1014
+ name: "market_maker",
1015
+ type: "pubkey"
1016
+ }
1017
+ ]
1018
+ },
1019
+ {
1020
+ name: "advance_epoch",
1021
+ docs: [
1022
+ "Advance epoch (called by keeper after settlement)",
1023
+ "Premium earned is credited to total_assets, increasing share value"
1024
+ ],
1025
+ discriminator: [
1026
+ 93,
1027
+ 138,
1028
+ 234,
1029
+ 218,
1030
+ 241,
1031
+ 230,
1032
+ 132,
1033
+ 38
1034
+ ],
1035
+ accounts: [
1036
+ {
1037
+ name: "vault",
1038
+ writable: true,
1039
+ pda: {
1040
+ seeds: [
1041
+ {
1042
+ kind: "const",
1043
+ value: [
1044
+ 118,
1045
+ 97,
1046
+ 117,
1047
+ 108,
1048
+ 116
1049
+ ]
1050
+ },
1051
+ {
1052
+ kind: "account",
1053
+ path: "vault.asset_id",
1054
+ account: "Vault"
1055
+ }
1056
+ ]
1057
+ }
1058
+ },
1059
+ {
1060
+ name: "authority",
1061
+ signer: true,
1062
+ relations: [
1063
+ "vault"
1064
+ ]
1065
+ }
1066
+ ],
1067
+ args: [
1068
+ {
1069
+ name: "premium_earned",
1070
+ type: "u64"
1071
+ }
1072
+ ]
1073
+ },
1074
+ {
1075
+ name: "cancel_param_change",
1076
+ docs: [
1077
+ "Cancel a queued parameter change"
1078
+ ],
1079
+ discriminator: [
1080
+ 150,
1081
+ 147,
1082
+ 92,
1083
+ 108,
1084
+ 72,
1085
+ 160,
1086
+ 224,
1087
+ 55
1088
+ ],
1089
+ accounts: [
1090
+ {
1091
+ name: "vault",
1092
+ writable: true,
1093
+ pda: {
1094
+ seeds: [
1095
+ {
1096
+ kind: "const",
1097
+ value: [
1098
+ 118,
1099
+ 97,
1100
+ 117,
1101
+ 108,
1102
+ 116
1103
+ ]
1104
+ },
1105
+ {
1106
+ kind: "account",
1107
+ path: "vault.asset_id",
1108
+ account: "Vault"
1109
+ }
1110
+ ]
1111
+ }
1112
+ },
1113
+ {
1114
+ name: "authority",
1115
+ signer: true,
1116
+ relations: [
1117
+ "vault"
1118
+ ]
1119
+ }
1120
+ ],
1121
+ args: [
1122
+ ]
1123
+ },
1124
+ {
1125
+ name: "close_orphaned_token_account",
1126
+ docs: [
1127
+ "Close an orphaned token account that was owned by a vault PDA",
1128
+ "This is used to clean up old share escrows, vault token accounts, etc.",
1129
+ "after a vault has been force-closed, enabling reuse of asset IDs.",
1130
+ "",
1131
+ "The caller must provide the correct asset_id that was used to derive the vault PDA.",
1132
+ "The vault PDA must NOT exist anymore (force-closed)."
1133
+ ],
1134
+ discriminator: [
1135
+ 232,
1136
+ 127,
1137
+ 173,
1138
+ 13,
1139
+ 92,
1140
+ 144,
1141
+ 116,
1142
+ 98
1143
+ ],
1144
+ accounts: [
1145
+ {
1146
+ name: "vault_pda",
1147
+ docs: [
1148
+ "We verify this matches the derived PDA in the instruction"
1149
+ ],
1150
+ writable: true
1151
+ },
1152
+ {
1153
+ name: "token_account",
1154
+ docs: [
1155
+ "The token account to close (share escrow, vault token account, etc.)"
1156
+ ],
1157
+ writable: true
1158
+ },
1159
+ {
1160
+ name: "authority",
1161
+ docs: [
1162
+ "Authority receiving the lamports"
1163
+ ],
1164
+ writable: true,
1165
+ signer: true
1166
+ },
1167
+ {
1168
+ name: "token_program",
1169
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1170
+ }
1171
+ ],
1172
+ args: [
1173
+ {
1174
+ name: "asset_id",
1175
+ type: "string"
1176
+ }
1177
+ ]
1178
+ },
1179
+ {
1180
+ name: "close_vault",
1181
+ docs: [
1182
+ "Close a vault and recover rent (authority only)",
1183
+ "Vault must be empty (no assets, shares, or pending withdrawals)"
1184
+ ],
1185
+ discriminator: [
1186
+ 141,
1187
+ 103,
1188
+ 17,
1189
+ 126,
1190
+ 72,
1191
+ 75,
1192
+ 29,
1193
+ 29
1194
+ ],
1195
+ accounts: [
1196
+ {
1197
+ name: "vault",
1198
+ writable: true,
1199
+ pda: {
1200
+ seeds: [
1201
+ {
1202
+ kind: "const",
1203
+ value: [
1204
+ 118,
1205
+ 97,
1206
+ 117,
1207
+ 108,
1208
+ 116
1209
+ ]
1210
+ },
1211
+ {
1212
+ kind: "account",
1213
+ path: "vault.asset_id",
1214
+ account: "Vault"
1215
+ }
1216
+ ]
1217
+ }
1218
+ },
1219
+ {
1220
+ name: "authority",
1221
+ writable: true,
1222
+ signer: true,
1223
+ relations: [
1224
+ "vault"
1225
+ ]
1226
+ }
1227
+ ],
1228
+ args: [
1229
+ ]
1230
+ },
1231
+ {
1232
+ name: "collect_premium",
1233
+ docs: [
1234
+ "Collect premium from market maker (called during epoch roll)",
1235
+ "Transfers USDC from payer to vault's premium account",
1236
+ "SECURITY FIX M-1: Now requires authority signature to prevent front-running"
1237
+ ],
1238
+ discriminator: [
1239
+ 166,
1240
+ 199,
1241
+ 123,
1242
+ 128,
1243
+ 71,
1244
+ 141,
1245
+ 223,
1246
+ 204
1247
+ ],
1248
+ accounts: [
1249
+ {
1250
+ name: "vault",
1251
+ pda: {
1252
+ seeds: [
1253
+ {
1254
+ kind: "const",
1255
+ value: [
1256
+ 118,
1257
+ 97,
1258
+ 117,
1259
+ 108,
1260
+ 116
1261
+ ]
1262
+ },
1263
+ {
1264
+ kind: "account",
1265
+ path: "vault.asset_id",
1266
+ account: "Vault"
1267
+ }
1268
+ ]
1269
+ }
1270
+ },
1271
+ {
1272
+ name: "vault_premium_account",
1273
+ writable: true
1274
+ },
1275
+ {
1276
+ name: "payer_token_account",
1277
+ writable: true
1278
+ },
1279
+ {
1280
+ name: "payer",
1281
+ writable: true,
1282
+ signer: true
1283
+ },
1284
+ {
1285
+ name: "authority",
1286
+ docs: [
1287
+ "SECURITY FIX M-1: Authority must sign to prevent front-running premium collection"
1288
+ ],
1289
+ signer: true,
1290
+ relations: [
1291
+ "vault"
1292
+ ]
1293
+ },
1294
+ {
1295
+ name: "token_program",
1296
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1297
+ }
1298
+ ],
1299
+ args: [
1300
+ {
1301
+ name: "amount",
1302
+ type: "u64"
1303
+ }
1304
+ ]
1305
+ },
1306
+ {
1307
+ name: "create_share_metadata",
1308
+ docs: [
1309
+ "Create metadata for the share token (vNVDAx, etc.)",
1310
+ "Only callable by vault authority since vault PDA is the mint authority"
1311
+ ],
1312
+ discriminator: [
1313
+ 176,
1314
+ 243,
1315
+ 233,
1316
+ 202,
1317
+ 218,
1318
+ 168,
1319
+ 53,
1320
+ 158
1321
+ ],
1322
+ accounts: [
1323
+ {
1324
+ name: "vault",
1325
+ pda: {
1326
+ seeds: [
1327
+ {
1328
+ kind: "const",
1329
+ value: [
1330
+ 118,
1331
+ 97,
1332
+ 117,
1333
+ 108,
1334
+ 116
1335
+ ]
1336
+ },
1337
+ {
1338
+ kind: "account",
1339
+ path: "vault.asset_id",
1340
+ account: "Vault"
1341
+ }
1342
+ ]
1343
+ }
1344
+ },
1345
+ {
1346
+ name: "share_mint",
1347
+ relations: [
1348
+ "vault"
1349
+ ]
1350
+ },
1351
+ {
1352
+ name: "metadata",
1353
+ writable: true
1354
+ },
1355
+ {
1356
+ name: "payer",
1357
+ writable: true,
1358
+ signer: true
1359
+ },
1360
+ {
1361
+ name: "authority",
1362
+ signer: true,
1363
+ relations: [
1364
+ "vault"
1365
+ ]
1366
+ },
1367
+ {
1368
+ name: "system_program",
1369
+ address: "11111111111111111111111111111111"
1370
+ },
1371
+ {
1372
+ name: "rent",
1373
+ address: "SysvarRent111111111111111111111111111111111"
1374
+ },
1375
+ {
1376
+ name: "token_metadata_program",
1377
+ address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
1378
+ }
1379
+ ],
1380
+ args: [
1381
+ {
1382
+ name: "name",
1383
+ type: "string"
1384
+ },
1385
+ {
1386
+ name: "symbol",
1387
+ type: "string"
1388
+ },
1389
+ {
1390
+ name: "uri",
1391
+ type: "string"
1392
+ }
1393
+ ]
1394
+ },
1395
+ {
1396
+ name: "deposit",
1397
+ docs: [
1398
+ "Deposit underlying tokens and receive vault shares"
1399
+ ],
1400
+ discriminator: [
1401
+ 242,
1402
+ 35,
1403
+ 198,
1404
+ 137,
1405
+ 82,
1406
+ 225,
1407
+ 242,
1408
+ 182
1409
+ ],
1410
+ accounts: [
1411
+ {
1412
+ name: "vault",
1413
+ writable: true,
1414
+ pda: {
1415
+ seeds: [
1416
+ {
1417
+ kind: "const",
1418
+ value: [
1419
+ 118,
1420
+ 97,
1421
+ 117,
1422
+ 108,
1423
+ 116
1424
+ ]
1425
+ },
1426
+ {
1427
+ kind: "account",
1428
+ path: "vault.asset_id",
1429
+ account: "Vault"
1430
+ }
1431
+ ]
1432
+ }
1433
+ },
1434
+ {
1435
+ name: "share_mint",
1436
+ writable: true
1437
+ },
1438
+ {
1439
+ name: "vault_token_account",
1440
+ writable: true
1441
+ },
1442
+ {
1443
+ name: "user_token_account",
1444
+ writable: true
1445
+ },
1446
+ {
1447
+ name: "user_share_account",
1448
+ writable: true
1449
+ },
1450
+ {
1451
+ name: "share_escrow",
1452
+ writable: true
1453
+ },
1454
+ {
1455
+ name: "user",
1456
+ writable: true,
1457
+ signer: true
1458
+ },
1459
+ {
1460
+ name: "token_program",
1461
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1462
+ }
1463
+ ],
1464
+ args: [
1465
+ {
1466
+ name: "amount",
1467
+ type: "u64"
1468
+ }
1469
+ ]
1470
+ },
1471
+ {
1472
+ name: "execute_param_change",
1473
+ docs: [
1474
+ "SECURITY FIX M-3: Execute queued parameter changes after timelock"
1475
+ ],
1476
+ discriminator: [
1477
+ 162,
1478
+ 166,
1479
+ 56,
1480
+ 243,
1481
+ 168,
1482
+ 135,
1483
+ 66,
1484
+ 175
1485
+ ],
1486
+ accounts: [
1487
+ {
1488
+ name: "vault",
1489
+ writable: true,
1490
+ pda: {
1491
+ seeds: [
1492
+ {
1493
+ kind: "const",
1494
+ value: [
1495
+ 118,
1496
+ 97,
1497
+ 117,
1498
+ 108,
1499
+ 116
1500
+ ]
1501
+ },
1502
+ {
1503
+ kind: "account",
1504
+ path: "vault.asset_id",
1505
+ account: "Vault"
1506
+ }
1507
+ ]
1508
+ }
1509
+ },
1510
+ {
1511
+ name: "authority",
1512
+ signer: true,
1513
+ relations: [
1514
+ "vault"
1515
+ ]
1516
+ }
1517
+ ],
1518
+ args: [
1519
+ ]
1520
+ },
1521
+ {
1522
+ name: "force_close_vault",
1523
+ docs: [
1524
+ "Force close a vault account (bypasses deserialization)",
1525
+ "USE WITH CAUTION: Only for recovering from incompatible account structures",
1526
+ "SECURITY FIX C-2: Now verifies caller is the stored vault authority"
1527
+ ],
1528
+ discriminator: [
1529
+ 229,
1530
+ 45,
1531
+ 206,
1532
+ 4,
1533
+ 96,
1534
+ 129,
1535
+ 140,
1536
+ 24
1537
+ ],
1538
+ accounts: [
1539
+ {
1540
+ name: "vault",
1541
+ writable: true
1542
+ },
1543
+ {
1544
+ name: "authority",
1545
+ writable: true,
1546
+ signer: true
1547
+ }
1548
+ ],
1549
+ args: [
1550
+ {
1551
+ name: "asset_id",
1552
+ type: "string"
1553
+ }
1554
+ ]
1555
+ },
1556
+ {
1557
+ name: "initialize_vault",
1558
+ docs: [
1559
+ "Initialize a new vault for a specific xStock asset"
1560
+ ],
1561
+ discriminator: [
1562
+ 48,
1563
+ 191,
1564
+ 163,
1565
+ 44,
1566
+ 71,
1567
+ 129,
1568
+ 63,
1569
+ 164
1570
+ ],
1571
+ accounts: [
1572
+ {
1573
+ name: "vault",
1574
+ writable: true,
1575
+ pda: {
1576
+ seeds: [
1577
+ {
1578
+ kind: "const",
1579
+ value: [
1580
+ 118,
1581
+ 97,
1582
+ 117,
1583
+ 108,
1584
+ 116
1585
+ ]
1586
+ },
1587
+ {
1588
+ kind: "arg",
1589
+ path: "asset_id"
1590
+ }
1591
+ ]
1592
+ }
1593
+ },
1594
+ {
1595
+ name: "underlying_mint"
1596
+ },
1597
+ {
1598
+ name: "premium_mint"
1599
+ },
1600
+ {
1601
+ name: "share_mint",
1602
+ writable: true,
1603
+ signer: true
1604
+ },
1605
+ {
1606
+ name: "vault_token_account",
1607
+ writable: true,
1608
+ signer: true
1609
+ },
1610
+ {
1611
+ name: "premium_token_account",
1612
+ writable: true,
1613
+ signer: true
1614
+ },
1615
+ {
1616
+ name: "share_escrow",
1617
+ writable: true,
1618
+ pda: {
1619
+ seeds: [
1620
+ {
1621
+ kind: "const",
1622
+ value: [
1623
+ 115,
1624
+ 104,
1625
+ 97,
1626
+ 114,
1627
+ 101,
1628
+ 95,
1629
+ 101,
1630
+ 115,
1631
+ 99,
1632
+ 114,
1633
+ 111,
1634
+ 119
1635
+ ]
1636
+ },
1637
+ {
1638
+ kind: "account",
1639
+ path: "vault"
1640
+ }
1641
+ ]
1642
+ }
1643
+ },
1644
+ {
1645
+ name: "authority",
1646
+ writable: true,
1647
+ signer: true
1648
+ },
1649
+ {
1650
+ name: "system_program",
1651
+ address: "11111111111111111111111111111111"
1652
+ },
1653
+ {
1654
+ name: "token_program",
1655
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1656
+ },
1657
+ {
1658
+ name: "rent",
1659
+ address: "SysvarRent111111111111111111111111111111111"
1660
+ }
1661
+ ],
1662
+ args: [
1663
+ {
1664
+ name: "asset_id",
1665
+ type: "string"
1666
+ },
1667
+ {
1668
+ name: "utilization_cap_bps",
1669
+ type: "u16"
1670
+ },
1671
+ {
1672
+ name: "min_epoch_duration",
1673
+ type: "i64"
1674
+ }
1675
+ ]
1676
+ },
1677
+ {
1678
+ name: "initialize_whitelist",
1679
+ docs: [
1680
+ "Initialize the market maker whitelist"
1681
+ ],
1682
+ discriminator: [
1683
+ 223,
1684
+ 228,
1685
+ 11,
1686
+ 219,
1687
+ 112,
1688
+ 174,
1689
+ 108,
1690
+ 18
1691
+ ],
1692
+ accounts: [
1693
+ {
1694
+ name: "vault",
1695
+ pda: {
1696
+ seeds: [
1697
+ {
1698
+ kind: "const",
1699
+ value: [
1700
+ 118,
1701
+ 97,
1702
+ 117,
1703
+ 108,
1704
+ 116
1705
+ ]
1706
+ },
1707
+ {
1708
+ kind: "account",
1709
+ path: "vault.asset_id",
1710
+ account: "Vault"
1711
+ }
1712
+ ]
1713
+ }
1714
+ },
1715
+ {
1716
+ name: "whitelist",
1717
+ writable: true,
1718
+ pda: {
1719
+ seeds: [
1720
+ {
1721
+ kind: "const",
1722
+ value: [
1723
+ 119,
1724
+ 104,
1725
+ 105,
1726
+ 116,
1727
+ 101,
1728
+ 108,
1729
+ 105,
1730
+ 115,
1731
+ 116
1732
+ ]
1733
+ },
1734
+ {
1735
+ kind: "account",
1736
+ path: "vault"
1737
+ }
1738
+ ]
1739
+ }
1740
+ },
1741
+ {
1742
+ name: "authority",
1743
+ writable: true,
1744
+ signer: true,
1745
+ relations: [
1746
+ "vault"
1747
+ ]
1748
+ },
1749
+ {
1750
+ name: "system_program",
1751
+ address: "11111111111111111111111111111111"
1752
+ }
1753
+ ],
1754
+ args: [
1755
+ ]
1756
+ },
1757
+ {
1758
+ name: "pay_settlement",
1759
+ docs: [
1760
+ "Pay out to market maker for ITM settlement",
1761
+ "Only callable by vault authority",
1762
+ "SECURITY: Settlement capped at epoch premium earned"
1763
+ ],
1764
+ discriminator: [
1765
+ 65,
1766
+ 54,
1767
+ 44,
1768
+ 166,
1769
+ 205,
1770
+ 55,
1771
+ 164,
1772
+ 205
1773
+ ],
1774
+ accounts: [
1775
+ {
1776
+ name: "vault",
1777
+ pda: {
1778
+ seeds: [
1779
+ {
1780
+ kind: "const",
1781
+ value: [
1782
+ 118,
1783
+ 97,
1784
+ 117,
1785
+ 108,
1786
+ 116
1787
+ ]
1788
+ },
1789
+ {
1790
+ kind: "account",
1791
+ path: "vault.asset_id",
1792
+ account: "Vault"
1793
+ }
1794
+ ]
1795
+ },
1796
+ relations: [
1797
+ "whitelist"
1798
+ ]
1799
+ },
1800
+ {
1801
+ name: "whitelist",
1802
+ pda: {
1803
+ seeds: [
1804
+ {
1805
+ kind: "const",
1806
+ value: [
1807
+ 119,
1808
+ 104,
1809
+ 105,
1810
+ 116,
1811
+ 101,
1812
+ 108,
1813
+ 105,
1814
+ 115,
1815
+ 116
1816
+ ]
1817
+ },
1818
+ {
1819
+ kind: "account",
1820
+ path: "vault"
1821
+ }
1822
+ ]
1823
+ }
1824
+ },
1825
+ {
1826
+ name: "vault_premium_account",
1827
+ writable: true
1828
+ },
1829
+ {
1830
+ name: "recipient_token_account",
1831
+ writable: true
1832
+ },
1833
+ {
1834
+ name: "recipient"
1835
+ },
1836
+ {
1837
+ name: "authority",
1838
+ signer: true,
1839
+ relations: [
1840
+ "vault"
1841
+ ]
1842
+ },
1843
+ {
1844
+ name: "token_program",
1845
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
1846
+ }
1847
+ ],
1848
+ args: [
1849
+ {
1850
+ name: "amount",
1851
+ type: "u64"
1852
+ }
1853
+ ]
1854
+ },
1855
+ {
1856
+ name: "process_withdrawal",
1857
+ docs: [
1858
+ "Process withdrawal after epoch settles",
1859
+ "SECURITY FIX H-3: Added min_expected_amount for slippage protection"
1860
+ ],
1861
+ discriminator: [
1862
+ 51,
1863
+ 97,
1864
+ 236,
1865
+ 17,
1866
+ 37,
1867
+ 33,
1868
+ 196,
1869
+ 64
1870
+ ],
1871
+ accounts: [
1872
+ {
1873
+ name: "vault",
1874
+ writable: true,
1875
+ pda: {
1876
+ seeds: [
1877
+ {
1878
+ kind: "const",
1879
+ value: [
1880
+ 118,
1881
+ 97,
1882
+ 117,
1883
+ 108,
1884
+ 116
1885
+ ]
1886
+ },
1887
+ {
1888
+ kind: "account",
1889
+ path: "vault.asset_id",
1890
+ account: "Vault"
1891
+ }
1892
+ ]
1893
+ },
1894
+ relations: [
1895
+ "withdrawal_request"
1896
+ ]
1897
+ },
1898
+ {
1899
+ name: "withdrawal_request",
1900
+ writable: true
1901
+ },
1902
+ {
1903
+ name: "share_mint",
1904
+ writable: true
1905
+ },
1906
+ {
1907
+ name: "vault_token_account",
1908
+ writable: true
1909
+ },
1910
+ {
1911
+ name: "user_token_account",
1912
+ writable: true
1913
+ },
1914
+ {
1915
+ name: "share_escrow",
1916
+ writable: true
1917
+ },
1918
+ {
1919
+ name: "vault_premium_account",
1920
+ writable: true
1921
+ },
1922
+ {
1923
+ name: "user_premium_account",
1924
+ writable: true,
1925
+ pda: {
1926
+ seeds: [
1927
+ {
1928
+ kind: "account",
1929
+ path: "user"
1930
+ },
1931
+ {
1932
+ kind: "const",
1933
+ value: [
1934
+ 6,
1935
+ 221,
1936
+ 246,
1937
+ 225,
1938
+ 215,
1939
+ 101,
1940
+ 161,
1941
+ 147,
1942
+ 217,
1943
+ 203,
1944
+ 225,
1945
+ 70,
1946
+ 206,
1947
+ 235,
1948
+ 121,
1949
+ 172,
1950
+ 28,
1951
+ 180,
1952
+ 133,
1953
+ 237,
1954
+ 95,
1955
+ 91,
1956
+ 55,
1957
+ 145,
1958
+ 58,
1959
+ 140,
1960
+ 245,
1961
+ 133,
1962
+ 126,
1963
+ 255,
1964
+ 0,
1965
+ 169
1966
+ ]
1967
+ },
1968
+ {
1969
+ kind: "account",
1970
+ path: "premium_mint"
1971
+ }
1972
+ ],
1973
+ program: {
1974
+ kind: "const",
1975
+ value: [
1976
+ 140,
1977
+ 151,
1978
+ 37,
1979
+ 143,
1980
+ 78,
1981
+ 36,
1982
+ 137,
1983
+ 241,
1984
+ 187,
1985
+ 61,
1986
+ 16,
1987
+ 41,
1988
+ 20,
1989
+ 142,
1990
+ 13,
1991
+ 131,
1992
+ 11,
1993
+ 90,
1994
+ 19,
1995
+ 153,
1996
+ 218,
1997
+ 255,
1998
+ 16,
1999
+ 132,
2000
+ 4,
2001
+ 142,
2002
+ 123,
2003
+ 216,
2004
+ 219,
2005
+ 233,
2006
+ 248,
2007
+ 89
2008
+ ]
2009
+ }
2010
+ }
2011
+ },
2012
+ {
2013
+ name: "premium_mint"
2014
+ },
2015
+ {
2016
+ name: "user",
2017
+ writable: true,
2018
+ signer: true,
2019
+ relations: [
2020
+ "withdrawal_request"
2021
+ ]
2022
+ },
2023
+ {
2024
+ name: "token_program",
2025
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
2026
+ },
2027
+ {
2028
+ name: "associated_token_program",
2029
+ address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
2030
+ },
2031
+ {
2032
+ name: "system_program",
2033
+ address: "11111111111111111111111111111111"
2034
+ }
2035
+ ],
2036
+ args: [
2037
+ {
2038
+ name: "min_expected_amount",
2039
+ type: "u64"
2040
+ }
2041
+ ]
2042
+ },
2043
+ {
2044
+ name: "queue_param_change",
2045
+ docs: [
2046
+ "SECURITY FIX M-3: Queue a parameter change with timelock",
2047
+ "Changes take effect after TIMELOCK_DURATION (24 hours)"
2048
+ ],
2049
+ discriminator: [
2050
+ 140,
2051
+ 242,
2052
+ 124,
2053
+ 63,
2054
+ 143,
2055
+ 237,
2056
+ 195,
2057
+ 231
2058
+ ],
2059
+ accounts: [
2060
+ {
2061
+ name: "vault",
2062
+ writable: true,
2063
+ pda: {
2064
+ seeds: [
2065
+ {
2066
+ kind: "const",
2067
+ value: [
2068
+ 118,
2069
+ 97,
2070
+ 117,
2071
+ 108,
2072
+ 116
2073
+ ]
2074
+ },
2075
+ {
2076
+ kind: "account",
2077
+ path: "vault.asset_id",
2078
+ account: "Vault"
2079
+ }
2080
+ ]
2081
+ }
2082
+ },
2083
+ {
2084
+ name: "authority",
2085
+ signer: true,
2086
+ relations: [
2087
+ "vault"
2088
+ ]
2089
+ }
2090
+ ],
2091
+ args: [
2092
+ {
2093
+ name: "new_min_epoch_duration",
2094
+ type: {
2095
+ option: "i64"
2096
+ }
2097
+ },
2098
+ {
2099
+ name: "new_utilization_cap_bps",
2100
+ type: {
2101
+ option: "u16"
2102
+ }
2103
+ }
2104
+ ]
2105
+ },
2106
+ {
2107
+ name: "record_notional_exposure",
2108
+ docs: [
2109
+ "Record notional exposure when an RFQ is filled (fractional options)",
2110
+ "Premium is in premium_mint tokens (USDC)"
2111
+ ],
2112
+ discriminator: [
2113
+ 26,
2114
+ 180,
2115
+ 108,
2116
+ 160,
2117
+ 15,
2118
+ 34,
2119
+ 179,
2120
+ 128
2121
+ ],
2122
+ accounts: [
2123
+ {
2124
+ name: "vault",
2125
+ writable: true,
2126
+ pda: {
2127
+ seeds: [
2128
+ {
2129
+ kind: "const",
2130
+ value: [
2131
+ 118,
2132
+ 97,
2133
+ 117,
2134
+ 108,
2135
+ 116
2136
+ ]
2137
+ },
2138
+ {
2139
+ kind: "account",
2140
+ path: "vault.asset_id",
2141
+ account: "Vault"
2142
+ }
2143
+ ]
2144
+ }
2145
+ },
2146
+ {
2147
+ name: "authority",
2148
+ signer: true,
2149
+ relations: [
2150
+ "vault"
2151
+ ]
2152
+ }
2153
+ ],
2154
+ args: [
2155
+ {
2156
+ name: "notional_tokens",
2157
+ type: "u64"
2158
+ },
2159
+ {
2160
+ name: "premium",
2161
+ type: "u64"
2162
+ }
2163
+ ]
2164
+ },
2165
+ {
2166
+ name: "remove_market_maker",
2167
+ docs: [
2168
+ "SECURITY FIX M-4: Remove a market maker from the whitelist"
2169
+ ],
2170
+ discriminator: [
2171
+ 101,
2172
+ 241,
2173
+ 39,
2174
+ 132,
2175
+ 210,
2176
+ 208,
2177
+ 183,
2178
+ 254
2179
+ ],
2180
+ accounts: [
2181
+ {
2182
+ name: "vault",
2183
+ pda: {
2184
+ seeds: [
2185
+ {
2186
+ kind: "const",
2187
+ value: [
2188
+ 118,
2189
+ 97,
2190
+ 117,
2191
+ 108,
2192
+ 116
2193
+ ]
2194
+ },
2195
+ {
2196
+ kind: "account",
2197
+ path: "vault.asset_id",
2198
+ account: "Vault"
2199
+ }
2200
+ ]
2201
+ },
2202
+ relations: [
2203
+ "whitelist"
2204
+ ]
2205
+ },
2206
+ {
2207
+ name: "whitelist",
2208
+ writable: true,
2209
+ pda: {
2210
+ seeds: [
2211
+ {
2212
+ kind: "const",
2213
+ value: [
2214
+ 119,
2215
+ 104,
2216
+ 105,
2217
+ 116,
2218
+ 101,
2219
+ 108,
2220
+ 105,
2221
+ 115,
2222
+ 116
2223
+ ]
2224
+ },
2225
+ {
2226
+ kind: "account",
2227
+ path: "vault"
2228
+ }
2229
+ ]
2230
+ }
2231
+ },
2232
+ {
2233
+ name: "authority",
2234
+ writable: true,
2235
+ signer: true,
2236
+ relations: [
2237
+ "vault",
2238
+ "whitelist"
2239
+ ]
2240
+ }
2241
+ ],
2242
+ args: [
2243
+ {
2244
+ name: "market_maker",
2245
+ type: "pubkey"
2246
+ }
2247
+ ]
2248
+ },
2249
+ {
2250
+ name: "request_withdrawal",
2251
+ docs: [
2252
+ "Request withdrawal (queued until epoch end)"
2253
+ ],
2254
+ discriminator: [
2255
+ 251,
2256
+ 85,
2257
+ 121,
2258
+ 205,
2259
+ 56,
2260
+ 201,
2261
+ 12,
2262
+ 177
2263
+ ],
2264
+ accounts: [
2265
+ {
2266
+ name: "vault",
2267
+ writable: true,
2268
+ pda: {
2269
+ seeds: [
2270
+ {
2271
+ kind: "const",
2272
+ value: [
2273
+ 118,
2274
+ 97,
2275
+ 117,
2276
+ 108,
2277
+ 116
2278
+ ]
2279
+ },
2280
+ {
2281
+ kind: "account",
2282
+ path: "vault.asset_id",
2283
+ account: "Vault"
2284
+ }
2285
+ ]
2286
+ }
2287
+ },
2288
+ {
2289
+ name: "withdrawal_request",
2290
+ writable: true,
2291
+ pda: {
2292
+ seeds: [
2293
+ {
2294
+ kind: "const",
2295
+ value: [
2296
+ 119,
2297
+ 105,
2298
+ 116,
2299
+ 104,
2300
+ 100,
2301
+ 114,
2302
+ 97,
2303
+ 119,
2304
+ 97,
2305
+ 108
2306
+ ]
2307
+ },
2308
+ {
2309
+ kind: "account",
2310
+ path: "vault"
2311
+ },
2312
+ {
2313
+ kind: "account",
2314
+ path: "user"
2315
+ },
2316
+ {
2317
+ kind: "account",
2318
+ path: "vault.epoch",
2319
+ account: "Vault"
2320
+ }
2321
+ ]
2322
+ }
2323
+ },
2324
+ {
2325
+ name: "share_escrow",
2326
+ writable: true
2327
+ },
2328
+ {
2329
+ name: "user_share_account",
2330
+ writable: true
2331
+ },
2332
+ {
2333
+ name: "user",
2334
+ writable: true,
2335
+ signer: true
2336
+ },
2337
+ {
2338
+ name: "system_program",
2339
+ address: "11111111111111111111111111111111"
2340
+ },
2341
+ {
2342
+ name: "token_program",
2343
+ address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
2344
+ }
2345
+ ],
2346
+ args: [
2347
+ {
2348
+ name: "shares",
2349
+ type: "u64"
2350
+ }
2351
+ ]
2352
+ },
2353
+ {
2354
+ name: "set_min_epoch_duration",
2355
+ docs: [
2356
+ "DEPRECATED: Direct parameter changes now require timelock",
2357
+ "Kept for backwards compatibility but will fail"
2358
+ ],
2359
+ discriminator: [
2360
+ 172,
2361
+ 45,
2362
+ 116,
2363
+ 18,
2364
+ 195,
2365
+ 137,
2366
+ 80,
2367
+ 225
2368
+ ],
2369
+ accounts: [
2370
+ {
2371
+ name: "vault",
2372
+ writable: true,
2373
+ pda: {
2374
+ seeds: [
2375
+ {
2376
+ kind: "const",
2377
+ value: [
2378
+ 118,
2379
+ 97,
2380
+ 117,
2381
+ 108,
2382
+ 116
2383
+ ]
2384
+ },
2385
+ {
2386
+ kind: "account",
2387
+ path: "vault.asset_id",
2388
+ account: "Vault"
2389
+ }
2390
+ ]
2391
+ }
2392
+ },
2393
+ {
2394
+ name: "authority",
2395
+ signer: true,
2396
+ relations: [
2397
+ "vault"
2398
+ ]
2399
+ }
2400
+ ],
2401
+ args: [
2402
+ {
2403
+ name: "_duration",
2404
+ type: "i64"
2405
+ }
2406
+ ]
2407
+ },
2408
+ {
2409
+ name: "set_pause",
2410
+ docs: [
2411
+ "SECURITY: Pause or unpause the vault (emergency control)",
2412
+ "When paused, deposits and withdrawal requests are blocked"
2413
+ ],
2414
+ discriminator: [
2415
+ 63,
2416
+ 32,
2417
+ 154,
2418
+ 2,
2419
+ 56,
2420
+ 103,
2421
+ 79,
2422
+ 45
2423
+ ],
2424
+ accounts: [
2425
+ {
2426
+ name: "vault",
2427
+ writable: true,
2428
+ pda: {
2429
+ seeds: [
2430
+ {
2431
+ kind: "const",
2432
+ value: [
2433
+ 118,
2434
+ 97,
2435
+ 117,
2436
+ 108,
2437
+ 116
2438
+ ]
2439
+ },
2440
+ {
2441
+ kind: "account",
2442
+ path: "vault.asset_id",
2443
+ account: "Vault"
2444
+ }
2445
+ ]
2446
+ }
2447
+ },
2448
+ {
2449
+ name: "authority",
2450
+ signer: true,
2451
+ relations: [
2452
+ "vault"
2453
+ ]
2454
+ }
2455
+ ],
2456
+ args: [
2457
+ {
2458
+ name: "paused",
2459
+ type: "bool"
2460
+ }
2461
+ ]
2462
+ },
2463
+ {
2464
+ name: "set_utilization_cap",
2465
+ docs: [
2466
+ "DEPRECATED: Direct parameter changes now require timelock",
2467
+ "Kept for backwards compatibility but will fail"
2468
+ ],
2469
+ discriminator: [
2470
+ 54,
2471
+ 143,
2472
+ 110,
2473
+ 156,
2474
+ 48,
2475
+ 172,
2476
+ 7,
2477
+ 64
2478
+ ],
2479
+ accounts: [
2480
+ {
2481
+ name: "vault",
2482
+ writable: true,
2483
+ pda: {
2484
+ seeds: [
2485
+ {
2486
+ kind: "const",
2487
+ value: [
2488
+ 118,
2489
+ 97,
2490
+ 117,
2491
+ 108,
2492
+ 116
2493
+ ]
2494
+ },
2495
+ {
2496
+ kind: "account",
2497
+ path: "vault.asset_id",
2498
+ account: "Vault"
2499
+ }
2500
+ ]
2501
+ }
2502
+ },
2503
+ {
2504
+ name: "authority",
2505
+ signer: true,
2506
+ relations: [
2507
+ "vault"
2508
+ ]
2509
+ }
2510
+ ],
2511
+ args: [
2512
+ {
2513
+ name: "_cap_bps",
2514
+ type: "u16"
2515
+ }
2516
+ ]
2517
+ }
2518
+ ];
2519
+ var accounts = [
2520
+ {
2521
+ name: "Vault",
2522
+ discriminator: [
2523
+ 211,
2524
+ 8,
2525
+ 232,
2526
+ 43,
2527
+ 2,
2528
+ 152,
2529
+ 117,
2530
+ 119
2531
+ ]
2532
+ },
2533
+ {
2534
+ name: "VaultWhitelist",
2535
+ discriminator: [
2536
+ 82,
2537
+ 19,
2538
+ 233,
2539
+ 96,
2540
+ 174,
2541
+ 0,
2542
+ 57,
2543
+ 17
2544
+ ]
2545
+ },
2546
+ {
2547
+ name: "WithdrawalRequest",
2548
+ discriminator: [
2549
+ 242,
2550
+ 88,
2551
+ 147,
2552
+ 173,
2553
+ 182,
2554
+ 62,
2555
+ 229,
2556
+ 193
2557
+ ]
2558
+ }
2559
+ ];
2560
+ var events = [
2561
+ {
2562
+ name: "DepositEvent",
2563
+ discriminator: [
2564
+ 120,
2565
+ 248,
2566
+ 61,
2567
+ 83,
2568
+ 31,
2569
+ 142,
2570
+ 107,
2571
+ 144
2572
+ ]
2573
+ },
2574
+ {
2575
+ name: "EpochAdvancedEvent",
2576
+ discriminator: [
2577
+ 26,
2578
+ 197,
2579
+ 195,
2580
+ 116,
2581
+ 126,
2582
+ 48,
2583
+ 210,
2584
+ 42
2585
+ ]
2586
+ },
2587
+ {
2588
+ name: "MarketMakerRemovedEvent",
2589
+ discriminator: [
2590
+ 238,
2591
+ 48,
2592
+ 105,
2593
+ 84,
2594
+ 228,
2595
+ 245,
2596
+ 204,
2597
+ 75
2598
+ ]
2599
+ },
2600
+ {
2601
+ name: "NotionalExposureEvent",
2602
+ discriminator: [
2603
+ 220,
2604
+ 74,
2605
+ 165,
2606
+ 136,
2607
+ 237,
2608
+ 183,
2609
+ 23,
2610
+ 38
2611
+ ]
2612
+ },
2613
+ {
2614
+ name: "ParamChangeExecutedEvent",
2615
+ discriminator: [
2616
+ 208,
2617
+ 23,
2618
+ 211,
2619
+ 151,
2620
+ 8,
2621
+ 56,
2622
+ 124,
2623
+ 26
2624
+ ]
2625
+ },
2626
+ {
2627
+ name: "ParamChangeQueuedEvent",
2628
+ discriminator: [
2629
+ 44,
2630
+ 143,
2631
+ 34,
2632
+ 222,
2633
+ 153,
2634
+ 125,
2635
+ 73,
2636
+ 23
2637
+ ]
2638
+ },
2639
+ {
2640
+ name: "PremiumCollectedEvent",
2641
+ discriminator: [
2642
+ 76,
2643
+ 52,
2644
+ 166,
2645
+ 111,
2646
+ 182,
2647
+ 211,
2648
+ 215,
2649
+ 144
2650
+ ]
2651
+ },
2652
+ {
2653
+ name: "SettlementPaidEvent",
2654
+ discriminator: [
2655
+ 97,
2656
+ 3,
2657
+ 234,
2658
+ 177,
2659
+ 141,
2660
+ 83,
2661
+ 59,
2662
+ 26
2663
+ ]
2664
+ },
2665
+ {
2666
+ name: "VaultPausedEvent",
2667
+ discriminator: [
2668
+ 75,
2669
+ 189,
2670
+ 120,
2671
+ 167,
2672
+ 117,
2673
+ 229,
2674
+ 155,
2675
+ 60
2676
+ ]
2677
+ },
2678
+ {
2679
+ name: "WithdrawalProcessedEvent",
2680
+ discriminator: [
2681
+ 23,
2682
+ 252,
2683
+ 30,
2684
+ 4,
2685
+ 24,
2686
+ 110,
2687
+ 166,
2688
+ 133
2689
+ ]
2690
+ },
2691
+ {
2692
+ name: "WithdrawalRequestedEvent",
2693
+ discriminator: [
2694
+ 82,
2695
+ 227,
2696
+ 155,
2697
+ 140,
2698
+ 223,
2699
+ 124,
2700
+ 77,
2701
+ 243
2702
+ ]
2703
+ }
2704
+ ];
2705
+ var errors = [
2706
+ {
2707
+ code: 6000,
2708
+ name: "ZeroAmount",
2709
+ msg: "Amount must be greater than zero"
2710
+ },
2711
+ {
2712
+ code: 6001,
2713
+ name: "ZeroShares",
2714
+ msg: "Calculated shares must be greater than zero"
2715
+ },
2716
+ {
2717
+ code: 6002,
2718
+ name: "InsufficientShares",
2719
+ msg: "Insufficient shares"
2720
+ },
2721
+ {
2722
+ code: 6003,
2723
+ name: "AlreadyProcessed",
2724
+ msg: "Withdrawal already processed"
2725
+ },
2726
+ {
2727
+ code: 6004,
2728
+ name: "EpochNotSettled",
2729
+ msg: "Epoch has not settled yet"
2730
+ },
2731
+ {
2732
+ code: 6005,
2733
+ name: "Overflow",
2734
+ msg: "Arithmetic overflow"
2735
+ },
2736
+ {
2737
+ code: 6006,
2738
+ name: "ExceedsUtilizationCap",
2739
+ msg: "Exceeds utilization cap"
2740
+ },
2741
+ {
2742
+ code: 6007,
2743
+ name: "NotWhitelisted",
2744
+ msg: "Recipient is not whitelisted"
2745
+ },
2746
+ {
2747
+ code: 6008,
2748
+ name: "WhitelistFull",
2749
+ msg: "Whitelist is full"
2750
+ },
2751
+ {
2752
+ code: 6009,
2753
+ name: "AlreadyWhitelisted",
2754
+ msg: "Market maker already whitelisted"
2755
+ },
2756
+ {
2757
+ code: 6010,
2758
+ name: "InsufficientLiquidity",
2759
+ msg: "Insufficient liquidity for first deposit"
2760
+ },
2761
+ {
2762
+ code: 6011,
2763
+ name: "EpochTooShort",
2764
+ msg: "Epoch duration too short"
2765
+ },
2766
+ {
2767
+ code: 6012,
2768
+ name: "ExcessivePremium",
2769
+ msg: "Premium exceeds safety limits"
2770
+ },
2771
+ {
2772
+ code: 6013,
2773
+ name: "ExcessiveYield",
2774
+ msg: "Implied yield too high"
2775
+ },
2776
+ {
2777
+ code: 6014,
2778
+ name: "ExcessiveSettlement",
2779
+ msg: "Settlement exceeds epoch premium earned"
2780
+ },
2781
+ {
2782
+ code: 6015,
2783
+ name: "InsufficientVaultBalance",
2784
+ msg: "Insufficient vault balance for withdrawal"
2785
+ },
2786
+ {
2787
+ code: 6016,
2788
+ name: "VaultPaused",
2789
+ msg: "Vault is paused"
2790
+ },
2791
+ {
2792
+ code: 6017,
2793
+ name: "VaultNotEmpty",
2794
+ msg: "Vault must be empty to close"
2795
+ },
2796
+ {
2797
+ code: 6018,
2798
+ name: "InvalidVaultPda",
2799
+ msg: "Invalid vault PDA"
2800
+ },
2801
+ {
2802
+ code: 6019,
2803
+ name: "SlippageExceeded",
2804
+ msg: "Withdrawal amount below minimum expected (slippage protection)"
2805
+ },
2806
+ {
2807
+ code: 6020,
2808
+ name: "DivisionByZero",
2809
+ msg: "Division by zero"
2810
+ },
2811
+ {
2812
+ code: 6021,
2813
+ name: "TimelockNotExpired",
2814
+ msg: "Timelock has not expired yet"
2815
+ },
2816
+ {
2817
+ code: 6022,
2818
+ name: "UseTimelockForParamChange",
2819
+ msg: "Direct param changes deprecated - use queue_param_change"
2820
+ },
2821
+ {
2822
+ code: 6023,
2823
+ name: "InvalidParameter",
2824
+ msg: "Invalid parameter value"
2825
+ },
2826
+ {
2827
+ code: 6024,
2828
+ name: "UnauthorizedForceClose",
2829
+ msg: "Caller is not the vault authority"
2830
+ },
2831
+ {
2832
+ code: 6025,
2833
+ name: "VaultStillExists",
2834
+ msg: "Vault still exists - close it first before cleaning up token accounts"
2835
+ }
2836
+ ];
2837
+ var types = [
2838
+ {
2839
+ name: "DepositEvent",
2840
+ type: {
2841
+ kind: "struct",
2842
+ fields: [
2843
+ {
2844
+ name: "vault",
2845
+ type: "pubkey"
2846
+ },
2847
+ {
2848
+ name: "user",
2849
+ type: "pubkey"
2850
+ },
2851
+ {
2852
+ name: "amount",
2853
+ type: "u64"
2854
+ },
2855
+ {
2856
+ name: "shares_minted",
2857
+ type: "u64"
2858
+ },
2859
+ {
2860
+ name: "epoch",
2861
+ type: "u64"
2862
+ }
2863
+ ]
2864
+ }
2865
+ },
2866
+ {
2867
+ name: "EpochAdvancedEvent",
2868
+ type: {
2869
+ kind: "struct",
2870
+ fields: [
2871
+ {
2872
+ name: "vault",
2873
+ type: "pubkey"
2874
+ },
2875
+ {
2876
+ name: "new_epoch",
2877
+ type: "u64"
2878
+ },
2879
+ {
2880
+ name: "premium_earned",
2881
+ type: "u64"
2882
+ },
2883
+ {
2884
+ name: "notional_exposed",
2885
+ type: "u64"
2886
+ },
2887
+ {
2888
+ name: "avg_premium_bps",
2889
+ type: "u32"
2890
+ },
2891
+ {
2892
+ name: "total_assets",
2893
+ type: "u64"
2894
+ },
2895
+ {
2896
+ name: "total_shares",
2897
+ type: "u64"
2898
+ },
2899
+ {
2900
+ name: "premium_balance_usdc",
2901
+ type: "u64"
2902
+ }
2903
+ ]
2904
+ }
2905
+ },
2906
+ {
2907
+ name: "MarketMakerRemovedEvent",
2908
+ docs: [
2909
+ "SECURITY FIX M-4: Event emitted when a market maker is removed"
2910
+ ],
2911
+ type: {
2912
+ kind: "struct",
2913
+ fields: [
2914
+ {
2915
+ name: "vault",
2916
+ type: "pubkey"
2917
+ },
2918
+ {
2919
+ name: "market_maker",
2920
+ type: "pubkey"
2921
+ }
2922
+ ]
2923
+ }
2924
+ },
2925
+ {
2926
+ name: "NotionalExposureEvent",
2927
+ type: {
2928
+ kind: "struct",
2929
+ fields: [
2930
+ {
2931
+ name: "vault",
2932
+ type: "pubkey"
2933
+ },
2934
+ {
2935
+ name: "epoch",
2936
+ type: "u64"
2937
+ },
2938
+ {
2939
+ name: "notional_tokens",
2940
+ type: "u64"
2941
+ },
2942
+ {
2943
+ name: "premium",
2944
+ type: "u64"
2945
+ },
2946
+ {
2947
+ name: "total_notional_this_epoch",
2948
+ type: "u64"
2949
+ },
2950
+ {
2951
+ name: "total_premium_this_epoch",
2952
+ type: "u64"
2953
+ },
2954
+ {
2955
+ name: "avg_premium_bps",
2956
+ type: "u32"
2957
+ }
2958
+ ]
2959
+ }
2960
+ },
2961
+ {
2962
+ name: "ParamChangeExecutedEvent",
2963
+ type: {
2964
+ kind: "struct",
2965
+ fields: [
2966
+ {
2967
+ name: "vault",
2968
+ type: "pubkey"
2969
+ },
2970
+ {
2971
+ name: "new_min_epoch_duration",
2972
+ type: "i64"
2973
+ },
2974
+ {
2975
+ name: "new_utilization_cap_bps",
2976
+ type: "u16"
2977
+ }
2978
+ ]
2979
+ }
2980
+ },
2981
+ {
2982
+ name: "ParamChangeQueuedEvent",
2983
+ type: {
2984
+ kind: "struct",
2985
+ fields: [
2986
+ {
2987
+ name: "vault",
2988
+ type: "pubkey"
2989
+ },
2990
+ {
2991
+ name: "new_min_epoch_duration",
2992
+ type: {
2993
+ option: "i64"
2994
+ }
2995
+ },
2996
+ {
2997
+ name: "new_utilization_cap_bps",
2998
+ type: {
2999
+ option: "u16"
3000
+ }
3001
+ },
3002
+ {
3003
+ name: "unlock_time",
3004
+ type: "i64"
3005
+ }
3006
+ ]
3007
+ }
3008
+ },
3009
+ {
3010
+ name: "PremiumCollectedEvent",
3011
+ type: {
3012
+ kind: "struct",
3013
+ fields: [
3014
+ {
3015
+ name: "vault",
3016
+ type: "pubkey"
3017
+ },
3018
+ {
3019
+ name: "payer",
3020
+ type: "pubkey"
3021
+ },
3022
+ {
3023
+ name: "amount",
3024
+ type: "u64"
3025
+ },
3026
+ {
3027
+ name: "epoch",
3028
+ type: "u64"
3029
+ }
3030
+ ]
3031
+ }
3032
+ },
3033
+ {
3034
+ name: "SettlementPaidEvent",
3035
+ type: {
3036
+ kind: "struct",
3037
+ fields: [
3038
+ {
3039
+ name: "vault",
3040
+ type: "pubkey"
3041
+ },
3042
+ {
3043
+ name: "recipient",
3044
+ type: "pubkey"
3045
+ },
3046
+ {
3047
+ name: "amount",
3048
+ type: "u64"
3049
+ },
3050
+ {
3051
+ name: "epoch",
3052
+ type: "u64"
3053
+ }
3054
+ ]
3055
+ }
3056
+ },
3057
+ {
3058
+ name: "Vault",
3059
+ type: {
3060
+ kind: "struct",
3061
+ fields: [
3062
+ {
3063
+ name: "authority",
3064
+ type: "pubkey"
3065
+ },
3066
+ {
3067
+ name: "asset_id",
3068
+ type: "string"
3069
+ },
3070
+ {
3071
+ name: "underlying_mint",
3072
+ type: "pubkey"
3073
+ },
3074
+ {
3075
+ name: "share_mint",
3076
+ type: "pubkey"
3077
+ },
3078
+ {
3079
+ name: "vault_token_account",
3080
+ type: "pubkey"
3081
+ },
3082
+ {
3083
+ name: "premium_mint",
3084
+ type: "pubkey"
3085
+ },
3086
+ {
3087
+ name: "premium_token_account",
3088
+ type: "pubkey"
3089
+ },
3090
+ {
3091
+ name: "share_escrow",
3092
+ type: "pubkey"
3093
+ },
3094
+ {
3095
+ name: "total_assets",
3096
+ type: "u64"
3097
+ },
3098
+ {
3099
+ name: "total_shares",
3100
+ type: "u64"
3101
+ },
3102
+ {
3103
+ name: "virtual_offset",
3104
+ docs: [
3105
+ "Virtual offset for share calculations (prevents first-depositor attacks)",
3106
+ "effective_shares = total_shares + virtual_offset"
3107
+ ],
3108
+ type: "u64"
3109
+ },
3110
+ {
3111
+ name: "epoch",
3112
+ type: "u64"
3113
+ },
3114
+ {
3115
+ name: "utilization_cap_bps",
3116
+ type: "u16"
3117
+ },
3118
+ {
3119
+ name: "min_epoch_duration",
3120
+ type: "i64"
3121
+ },
3122
+ {
3123
+ name: "last_roll_timestamp",
3124
+ type: "i64"
3125
+ },
3126
+ {
3127
+ name: "pending_withdrawals",
3128
+ type: "u64"
3129
+ },
3130
+ {
3131
+ name: "epoch_notional_exposed",
3132
+ type: "u64"
3133
+ },
3134
+ {
3135
+ name: "epoch_premium_earned",
3136
+ type: "u64"
3137
+ },
3138
+ {
3139
+ name: "epoch_premium_per_token_bps",
3140
+ type: "u32"
3141
+ },
3142
+ {
3143
+ name: "premium_balance_usdc",
3144
+ docs: [
3145
+ "Accumulated USDC premium balance (separate from underlying TVL)"
3146
+ ],
3147
+ type: "u64"
3148
+ },
3149
+ {
3150
+ name: "is_paused",
3151
+ docs: [
3152
+ "SECURITY: Emergency pause flag"
3153
+ ],
3154
+ type: "bool"
3155
+ },
3156
+ {
3157
+ name: "pending_min_epoch_duration",
3158
+ docs: [
3159
+ "SECURITY FIX M-3: Timelock for parameter changes"
3160
+ ],
3161
+ type: "i64"
3162
+ },
3163
+ {
3164
+ name: "pending_utilization_cap",
3165
+ type: "u16"
3166
+ },
3167
+ {
3168
+ name: "param_change_unlock_time",
3169
+ type: "i64"
3170
+ },
3171
+ {
3172
+ name: "bump",
3173
+ type: "u8"
3174
+ }
3175
+ ]
3176
+ }
3177
+ },
3178
+ {
3179
+ name: "VaultPausedEvent",
3180
+ type: {
3181
+ kind: "struct",
3182
+ fields: [
3183
+ {
3184
+ name: "vault",
3185
+ type: "pubkey"
3186
+ },
3187
+ {
3188
+ name: "paused",
3189
+ type: "bool"
3190
+ },
3191
+ {
3192
+ name: "timestamp",
3193
+ type: "i64"
3194
+ }
3195
+ ]
3196
+ }
3197
+ },
3198
+ {
3199
+ name: "VaultWhitelist",
3200
+ type: {
3201
+ kind: "struct",
3202
+ fields: [
3203
+ {
3204
+ name: "authority",
3205
+ type: "pubkey"
3206
+ },
3207
+ {
3208
+ name: "vault",
3209
+ type: "pubkey"
3210
+ },
3211
+ {
3212
+ name: "market_makers",
3213
+ type: {
3214
+ vec: "pubkey"
3215
+ }
3216
+ },
3217
+ {
3218
+ name: "bump",
3219
+ type: "u8"
3220
+ }
3221
+ ]
3222
+ }
3223
+ },
3224
+ {
3225
+ name: "WithdrawalProcessedEvent",
3226
+ type: {
3227
+ kind: "struct",
3228
+ fields: [
3229
+ {
3230
+ name: "vault",
3231
+ type: "pubkey"
3232
+ },
3233
+ {
3234
+ name: "user",
3235
+ type: "pubkey"
3236
+ },
3237
+ {
3238
+ name: "shares",
3239
+ type: "u64"
3240
+ },
3241
+ {
3242
+ name: "amount",
3243
+ type: "u64"
3244
+ },
3245
+ {
3246
+ name: "epoch",
3247
+ type: "u64"
3248
+ }
3249
+ ]
3250
+ }
3251
+ },
3252
+ {
3253
+ name: "WithdrawalRequest",
3254
+ type: {
3255
+ kind: "struct",
3256
+ fields: [
3257
+ {
3258
+ name: "user",
3259
+ type: "pubkey"
3260
+ },
3261
+ {
3262
+ name: "vault",
3263
+ type: "pubkey"
3264
+ },
3265
+ {
3266
+ name: "shares",
3267
+ type: "u64"
3268
+ },
3269
+ {
3270
+ name: "request_epoch",
3271
+ type: "u64"
3272
+ },
3273
+ {
3274
+ name: "processed",
3275
+ type: "bool"
3276
+ }
3277
+ ]
3278
+ }
3279
+ },
3280
+ {
3281
+ name: "WithdrawalRequestedEvent",
3282
+ type: {
3283
+ kind: "struct",
3284
+ fields: [
3285
+ {
3286
+ name: "vault",
3287
+ type: "pubkey"
3288
+ },
3289
+ {
3290
+ name: "user",
3291
+ type: "pubkey"
3292
+ },
3293
+ {
3294
+ name: "shares",
3295
+ type: "u64"
3296
+ },
3297
+ {
3298
+ name: "epoch",
3299
+ type: "u64"
3300
+ }
3301
+ ]
3302
+ }
3303
+ }
3304
+ ];
3305
+ var vault = {
3306
+ address: address,
3307
+ metadata: metadata,
3308
+ instructions: instructions,
3309
+ accounts: accounts,
3310
+ events: events,
3311
+ errors: errors,
3312
+ types: types
3313
+ };
3314
+
3315
+ export { type AdvanceEpochParams, type BlackScholesParams, type CollectPremiumParams, DEFAULT_PRICING_PARAMS, DEVNET_CONFIG, DEVNET_USDC_MINT, MAINNET_CONFIG, MAINNET_USDC_MINT, type OptionPosition, type OptionPrices, OptionPricing, type OptionType, PYTH_HERMES_URL, PYTH_PRICE_FEEDS, type PaySettlementParams, type PremiumParams, type Quote, type QuoteValidation, type RFQ, RFQClient, type RFQConfig, type RFQEvent, type RFQEventType, type RFQParams, RFQ_DEFAULTS, type RecordExposureParams, TOKEN_DECIMALS, vault as VAULT_IDL, VAULT_PROGRAM_ID, ValidationError, type VaultData, VaultInstructions, type WithdrawalRequest, bpsToPercent, deriveShareEscrowPda, deriveVaultPda, deriveWhitelistPda, deriveWithdrawalPda, formatBps, formatDate, formatPercent, formatPrice, formatRFQId, formatTimeToExpiry, formatTimestamp, formatTokenAmount, formatUSDC, parseTokenAmount, parseUSDC, percentToBps, shortenAddress, validateBlackScholesParams, validatePublicKey, validateRFQParams, validateTimestamp, validateTokenAmount };