@epicentral/sos-sdk 0.12.2-beta → 0.13.0-beta
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.
- package/generated/accounts/marketDataAccount.ts +13 -1
- package/generated/instructions/buyFromPool.ts +43 -15
- package/generated/instructions/closeLongToPool.ts +40 -12
- package/generated/instructions/index.ts +1 -0
- package/generated/instructions/initializeMarketData.ts +13 -0
- package/generated/instructions/liquidateWriterPosition.ts +39 -11
- package/generated/instructions/migrateMarketDataVolOracle.ts +248 -0
- package/generated/instructions/optionMint.ts +50 -22
- package/generated/instructions/updateImpliedVolatility.ts +19 -2
- package/generated/programs/optionProgram.ts +16 -0
- package/index.ts +6 -0
- package/long/builders.ts +36 -10
- package/oracle/volatility-quote.ts +65 -0
- package/package.json +7 -1
- package/shared/option-program-parser.ts +6 -0
- package/short/builders.ts +93 -0
|
@@ -57,6 +57,10 @@ export type MarketDataAccount = {
|
|
|
57
57
|
lastUpdated: bigint;
|
|
58
58
|
authority: Address;
|
|
59
59
|
switchboardFeedId: ReadonlyUint8Array;
|
|
60
|
+
/** Authority-updated HV feed ID (zeros = use historical_volatility only) */
|
|
61
|
+
switchboardVolatilityFeedId: ReadonlyUint8Array;
|
|
62
|
+
/** Keeper pubkey that publishes vol authority quotes */
|
|
63
|
+
volatilityQuoteAuthority: Address;
|
|
60
64
|
};
|
|
61
65
|
|
|
62
66
|
export type MarketDataAccountArgs = {
|
|
@@ -66,6 +70,10 @@ export type MarketDataAccountArgs = {
|
|
|
66
70
|
lastUpdated: number | bigint;
|
|
67
71
|
authority: Address;
|
|
68
72
|
switchboardFeedId: ReadonlyUint8Array;
|
|
73
|
+
/** Authority-updated HV feed ID (zeros = use historical_volatility only) */
|
|
74
|
+
switchboardVolatilityFeedId: ReadonlyUint8Array;
|
|
75
|
+
/** Keeper pubkey that publishes vol authority quotes */
|
|
76
|
+
volatilityQuoteAuthority: Address;
|
|
69
77
|
};
|
|
70
78
|
|
|
71
79
|
/** Gets the encoder for {@link MarketDataAccountArgs} account data. */
|
|
@@ -79,6 +87,8 @@ export function getMarketDataAccountEncoder(): FixedSizeEncoder<MarketDataAccoun
|
|
|
79
87
|
["lastUpdated", getI64Encoder()],
|
|
80
88
|
["authority", getAddressEncoder()],
|
|
81
89
|
["switchboardFeedId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
90
|
+
["switchboardVolatilityFeedId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
91
|
+
["volatilityQuoteAuthority", getAddressEncoder()],
|
|
82
92
|
]),
|
|
83
93
|
(value) => ({ ...value, discriminator: MARKET_DATA_ACCOUNT_DISCRIMINATOR }),
|
|
84
94
|
);
|
|
@@ -94,6 +104,8 @@ export function getMarketDataAccountDecoder(): FixedSizeDecoder<MarketDataAccoun
|
|
|
94
104
|
["lastUpdated", getI64Decoder()],
|
|
95
105
|
["authority", getAddressDecoder()],
|
|
96
106
|
["switchboardFeedId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
107
|
+
["switchboardVolatilityFeedId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
108
|
+
["volatilityQuoteAuthority", getAddressDecoder()],
|
|
97
109
|
]);
|
|
98
110
|
}
|
|
99
111
|
|
|
@@ -172,5 +184,5 @@ export async function fetchAllMaybeMarketDataAccount(
|
|
|
172
184
|
}
|
|
173
185
|
|
|
174
186
|
export function getMarketDataAccountSize(): number {
|
|
175
|
-
return
|
|
187
|
+
return 192;
|
|
176
188
|
}
|
|
@@ -58,6 +58,7 @@ export type BuyFromPoolInstruction<
|
|
|
58
58
|
TAccountLongMint extends string | AccountMeta<string> = string,
|
|
59
59
|
TAccountUnderlyingMint extends string | AccountMeta<string> = string,
|
|
60
60
|
TAccountMarketData extends string | AccountMeta<string> = string,
|
|
61
|
+
TAccountVolatilityQuoteAccount extends string | AccountMeta<string> = string,
|
|
61
62
|
TAccountSwitchboardQueue extends string | AccountMeta<string> = string,
|
|
62
63
|
TAccountSlotHashesSysvar extends string | AccountMeta<string> =
|
|
63
64
|
"SysvarS1otHashes111111111111111111111111111",
|
|
@@ -97,6 +98,9 @@ export type BuyFromPoolInstruction<
|
|
|
97
98
|
TAccountMarketData extends string
|
|
98
99
|
? ReadonlyAccount<TAccountMarketData>
|
|
99
100
|
: TAccountMarketData,
|
|
101
|
+
TAccountVolatilityQuoteAccount extends string
|
|
102
|
+
? ReadonlyAccount<TAccountVolatilityQuoteAccount>
|
|
103
|
+
: TAccountVolatilityQuoteAccount,
|
|
100
104
|
TAccountSwitchboardQueue extends string
|
|
101
105
|
? ReadonlyAccount<TAccountSwitchboardQueue>
|
|
102
106
|
: TAccountSwitchboardQueue,
|
|
@@ -190,6 +194,7 @@ export type BuyFromPoolAsyncInput<
|
|
|
190
194
|
TAccountLongMint extends string = string,
|
|
191
195
|
TAccountUnderlyingMint extends string = string,
|
|
192
196
|
TAccountMarketData extends string = string,
|
|
197
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
193
198
|
TAccountSwitchboardQueue extends string = string,
|
|
194
199
|
TAccountSlotHashesSysvar extends string = string,
|
|
195
200
|
TAccountInstructionsSysvar extends string = string,
|
|
@@ -218,6 +223,7 @@ export type BuyFromPoolAsyncInput<
|
|
|
218
223
|
underlyingMint: Address<TAccountUnderlyingMint>;
|
|
219
224
|
/** Market data account (provides risk-free rate and switchboard_feed_id) */
|
|
220
225
|
marketData: Address<TAccountMarketData>;
|
|
226
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
221
227
|
switchboardQueue: Address<TAccountSwitchboardQueue>;
|
|
222
228
|
slotHashesSysvar?: Address<TAccountSlotHashesSysvar>;
|
|
223
229
|
instructionsSysvar?: Address<TAccountInstructionsSysvar>;
|
|
@@ -249,6 +255,7 @@ export async function getBuyFromPoolInstructionAsync<
|
|
|
249
255
|
TAccountLongMint extends string,
|
|
250
256
|
TAccountUnderlyingMint extends string,
|
|
251
257
|
TAccountMarketData extends string,
|
|
258
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
252
259
|
TAccountSwitchboardQueue extends string,
|
|
253
260
|
TAccountSlotHashesSysvar extends string,
|
|
254
261
|
TAccountInstructionsSysvar extends string,
|
|
@@ -271,6 +278,7 @@ export async function getBuyFromPoolInstructionAsync<
|
|
|
271
278
|
TAccountLongMint,
|
|
272
279
|
TAccountUnderlyingMint,
|
|
273
280
|
TAccountMarketData,
|
|
281
|
+
TAccountVolatilityQuoteAccount,
|
|
274
282
|
TAccountSwitchboardQueue,
|
|
275
283
|
TAccountSlotHashesSysvar,
|
|
276
284
|
TAccountInstructionsSysvar,
|
|
@@ -295,6 +303,7 @@ export async function getBuyFromPoolInstructionAsync<
|
|
|
295
303
|
TAccountLongMint,
|
|
296
304
|
TAccountUnderlyingMint,
|
|
297
305
|
TAccountMarketData,
|
|
306
|
+
TAccountVolatilityQuoteAccount,
|
|
298
307
|
TAccountSwitchboardQueue,
|
|
299
308
|
TAccountSlotHashesSysvar,
|
|
300
309
|
TAccountInstructionsSysvar,
|
|
@@ -322,6 +331,10 @@ export async function getBuyFromPoolInstructionAsync<
|
|
|
322
331
|
longMint: { value: input.longMint ?? null, isWritable: false },
|
|
323
332
|
underlyingMint: { value: input.underlyingMint ?? null, isWritable: false },
|
|
324
333
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
334
|
+
volatilityQuoteAccount: {
|
|
335
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
336
|
+
isWritable: false,
|
|
337
|
+
},
|
|
325
338
|
switchboardQueue: {
|
|
326
339
|
value: input.switchboardQueue ?? null,
|
|
327
340
|
isWritable: false,
|
|
@@ -439,6 +452,7 @@ export async function getBuyFromPoolInstructionAsync<
|
|
|
439
452
|
getAccountMeta(accounts.longMint),
|
|
440
453
|
getAccountMeta(accounts.underlyingMint),
|
|
441
454
|
getAccountMeta(accounts.marketData),
|
|
455
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
442
456
|
getAccountMeta(accounts.switchboardQueue),
|
|
443
457
|
getAccountMeta(accounts.slotHashesSysvar),
|
|
444
458
|
getAccountMeta(accounts.instructionsSysvar),
|
|
@@ -465,6 +479,7 @@ export async function getBuyFromPoolInstructionAsync<
|
|
|
465
479
|
TAccountLongMint,
|
|
466
480
|
TAccountUnderlyingMint,
|
|
467
481
|
TAccountMarketData,
|
|
482
|
+
TAccountVolatilityQuoteAccount,
|
|
468
483
|
TAccountSwitchboardQueue,
|
|
469
484
|
TAccountSlotHashesSysvar,
|
|
470
485
|
TAccountInstructionsSysvar,
|
|
@@ -488,6 +503,7 @@ export type BuyFromPoolInput<
|
|
|
488
503
|
TAccountLongMint extends string = string,
|
|
489
504
|
TAccountUnderlyingMint extends string = string,
|
|
490
505
|
TAccountMarketData extends string = string,
|
|
506
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
491
507
|
TAccountSwitchboardQueue extends string = string,
|
|
492
508
|
TAccountSlotHashesSysvar extends string = string,
|
|
493
509
|
TAccountInstructionsSysvar extends string = string,
|
|
@@ -516,6 +532,7 @@ export type BuyFromPoolInput<
|
|
|
516
532
|
underlyingMint: Address<TAccountUnderlyingMint>;
|
|
517
533
|
/** Market data account (provides risk-free rate and switchboard_feed_id) */
|
|
518
534
|
marketData: Address<TAccountMarketData>;
|
|
535
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
519
536
|
switchboardQueue: Address<TAccountSwitchboardQueue>;
|
|
520
537
|
slotHashesSysvar?: Address<TAccountSlotHashesSysvar>;
|
|
521
538
|
instructionsSysvar?: Address<TAccountInstructionsSysvar>;
|
|
@@ -547,6 +564,7 @@ export function getBuyFromPoolInstruction<
|
|
|
547
564
|
TAccountLongMint extends string,
|
|
548
565
|
TAccountUnderlyingMint extends string,
|
|
549
566
|
TAccountMarketData extends string,
|
|
567
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
550
568
|
TAccountSwitchboardQueue extends string,
|
|
551
569
|
TAccountSlotHashesSysvar extends string,
|
|
552
570
|
TAccountInstructionsSysvar extends string,
|
|
@@ -569,6 +587,7 @@ export function getBuyFromPoolInstruction<
|
|
|
569
587
|
TAccountLongMint,
|
|
570
588
|
TAccountUnderlyingMint,
|
|
571
589
|
TAccountMarketData,
|
|
590
|
+
TAccountVolatilityQuoteAccount,
|
|
572
591
|
TAccountSwitchboardQueue,
|
|
573
592
|
TAccountSlotHashesSysvar,
|
|
574
593
|
TAccountInstructionsSysvar,
|
|
@@ -592,6 +611,7 @@ export function getBuyFromPoolInstruction<
|
|
|
592
611
|
TAccountLongMint,
|
|
593
612
|
TAccountUnderlyingMint,
|
|
594
613
|
TAccountMarketData,
|
|
614
|
+
TAccountVolatilityQuoteAccount,
|
|
595
615
|
TAccountSwitchboardQueue,
|
|
596
616
|
TAccountSlotHashesSysvar,
|
|
597
617
|
TAccountInstructionsSysvar,
|
|
@@ -618,6 +638,10 @@ export function getBuyFromPoolInstruction<
|
|
|
618
638
|
longMint: { value: input.longMint ?? null, isWritable: false },
|
|
619
639
|
underlyingMint: { value: input.underlyingMint ?? null, isWritable: false },
|
|
620
640
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
641
|
+
volatilityQuoteAccount: {
|
|
642
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
643
|
+
isWritable: false,
|
|
644
|
+
},
|
|
621
645
|
switchboardQueue: {
|
|
622
646
|
value: input.switchboardQueue ?? null,
|
|
623
647
|
isWritable: false,
|
|
@@ -692,6 +716,7 @@ export function getBuyFromPoolInstruction<
|
|
|
692
716
|
getAccountMeta(accounts.longMint),
|
|
693
717
|
getAccountMeta(accounts.underlyingMint),
|
|
694
718
|
getAccountMeta(accounts.marketData),
|
|
719
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
695
720
|
getAccountMeta(accounts.switchboardQueue),
|
|
696
721
|
getAccountMeta(accounts.slotHashesSysvar),
|
|
697
722
|
getAccountMeta(accounts.instructionsSysvar),
|
|
@@ -718,6 +743,7 @@ export function getBuyFromPoolInstruction<
|
|
|
718
743
|
TAccountLongMint,
|
|
719
744
|
TAccountUnderlyingMint,
|
|
720
745
|
TAccountMarketData,
|
|
746
|
+
TAccountVolatilityQuoteAccount,
|
|
721
747
|
TAccountSwitchboardQueue,
|
|
722
748
|
TAccountSlotHashesSysvar,
|
|
723
749
|
TAccountInstructionsSysvar,
|
|
@@ -754,27 +780,28 @@ export type ParsedBuyFromPoolInstruction<
|
|
|
754
780
|
underlyingMint: TAccountMetas[3];
|
|
755
781
|
/** Market data account (provides risk-free rate and switchboard_feed_id) */
|
|
756
782
|
marketData: TAccountMetas[4];
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
783
|
+
volatilityQuoteAccount: TAccountMetas[5];
|
|
784
|
+
switchboardQueue: TAccountMetas[6];
|
|
785
|
+
slotHashesSysvar: TAccountMetas[7];
|
|
786
|
+
instructionsSysvar: TAccountMetas[8];
|
|
760
787
|
/** Buyer's position account (created for tracking) */
|
|
761
|
-
buyerPosition: TAccountMetas[
|
|
788
|
+
buyerPosition: TAccountMetas[9];
|
|
762
789
|
/** Buyer's LONG token account (receives LONG tokens) */
|
|
763
|
-
buyerOptionAccount: TAccountMetas[
|
|
790
|
+
buyerOptionAccount: TAccountMetas[10];
|
|
764
791
|
/** Premium payment mint (must match premium_vault.mint on-chain) */
|
|
765
|
-
paymentMint: TAccountMetas[
|
|
792
|
+
paymentMint: TAccountMetas[11];
|
|
766
793
|
/** Buyer's payment account (source of premium) */
|
|
767
|
-
buyerPaymentAccount: TAccountMetas[
|
|
794
|
+
buyerPaymentAccount: TAccountMetas[12];
|
|
768
795
|
/** Pool's LONG escrow (source of LONG tokens) */
|
|
769
|
-
escrowLongAccount: TAccountMetas[
|
|
796
|
+
escrowLongAccount: TAccountMetas[13];
|
|
770
797
|
/** Pool's premium vault (receives premium) */
|
|
771
|
-
premiumVault: TAccountMetas[
|
|
798
|
+
premiumVault: TAccountMetas[14];
|
|
772
799
|
/** Collateral pool (settlement mint for buyer position tracking) */
|
|
773
|
-
collateralPool: TAccountMetas[
|
|
774
|
-
buyer: TAccountMetas[
|
|
775
|
-
tokenProgram: TAccountMetas[
|
|
776
|
-
associatedTokenProgram: TAccountMetas[
|
|
777
|
-
systemProgram: TAccountMetas[
|
|
800
|
+
collateralPool: TAccountMetas[15];
|
|
801
|
+
buyer: TAccountMetas[16];
|
|
802
|
+
tokenProgram: TAccountMetas[17];
|
|
803
|
+
associatedTokenProgram: TAccountMetas[18];
|
|
804
|
+
systemProgram: TAccountMetas[19];
|
|
778
805
|
};
|
|
779
806
|
data: BuyFromPoolInstructionData;
|
|
780
807
|
};
|
|
@@ -787,7 +814,7 @@ export function parseBuyFromPoolInstruction<
|
|
|
787
814
|
InstructionWithAccounts<TAccountMetas> &
|
|
788
815
|
InstructionWithData<ReadonlyUint8Array>,
|
|
789
816
|
): ParsedBuyFromPoolInstruction<TProgram, TAccountMetas> {
|
|
790
|
-
if (instruction.accounts.length <
|
|
817
|
+
if (instruction.accounts.length < 20) {
|
|
791
818
|
// TODO: Coded error.
|
|
792
819
|
throw new Error("Not enough accounts");
|
|
793
820
|
}
|
|
@@ -805,6 +832,7 @@ export function parseBuyFromPoolInstruction<
|
|
|
805
832
|
longMint: getNextAccount(),
|
|
806
833
|
underlyingMint: getNextAccount(),
|
|
807
834
|
marketData: getNextAccount(),
|
|
835
|
+
volatilityQuoteAccount: getNextAccount(),
|
|
808
836
|
switchboardQueue: getNextAccount(),
|
|
809
837
|
slotHashesSysvar: getNextAccount(),
|
|
810
838
|
instructionsSysvar: getNextAccount(),
|
|
@@ -62,6 +62,7 @@ export type CloseLongToPoolInstruction<
|
|
|
62
62
|
TAccountEscrowLongAccount extends string | AccountMeta<string> = string,
|
|
63
63
|
TAccountPremiumVault extends string | AccountMeta<string> = string,
|
|
64
64
|
TAccountMarketData extends string | AccountMeta<string> = string,
|
|
65
|
+
TAccountVolatilityQuoteAccount extends string | AccountMeta<string> = string,
|
|
65
66
|
TAccountSwitchboardQueue extends string | AccountMeta<string> = string,
|
|
66
67
|
TAccountSlotHashesSysvar extends string | AccountMeta<string> =
|
|
67
68
|
"SysvarS1otHashes111111111111111111111111111",
|
|
@@ -110,6 +111,9 @@ export type CloseLongToPoolInstruction<
|
|
|
110
111
|
TAccountMarketData extends string
|
|
111
112
|
? ReadonlyAccount<TAccountMarketData>
|
|
112
113
|
: TAccountMarketData,
|
|
114
|
+
TAccountVolatilityQuoteAccount extends string
|
|
115
|
+
? ReadonlyAccount<TAccountVolatilityQuoteAccount>
|
|
116
|
+
: TAccountVolatilityQuoteAccount,
|
|
113
117
|
TAccountSwitchboardQueue extends string
|
|
114
118
|
? ReadonlyAccount<TAccountSwitchboardQueue>
|
|
115
119
|
: TAccountSwitchboardQueue,
|
|
@@ -198,6 +202,7 @@ export type CloseLongToPoolAsyncInput<
|
|
|
198
202
|
TAccountEscrowLongAccount extends string = string,
|
|
199
203
|
TAccountPremiumVault extends string = string,
|
|
200
204
|
TAccountMarketData extends string = string,
|
|
205
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
201
206
|
TAccountSwitchboardQueue extends string = string,
|
|
202
207
|
TAccountSlotHashesSysvar extends string = string,
|
|
203
208
|
TAccountInstructionsSysvar extends string = string,
|
|
@@ -228,6 +233,7 @@ export type CloseLongToPoolAsyncInput<
|
|
|
228
233
|
premiumVault: Address<TAccountPremiumVault>;
|
|
229
234
|
/** Market data account (provides risk-free rate and switchboard_feed_id) */
|
|
230
235
|
marketData: Address<TAccountMarketData>;
|
|
236
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
231
237
|
switchboardQueue: Address<TAccountSwitchboardQueue>;
|
|
232
238
|
slotHashesSysvar?: Address<TAccountSlotHashesSysvar>;
|
|
233
239
|
instructionsSysvar?: Address<TAccountInstructionsSysvar>;
|
|
@@ -258,6 +264,7 @@ export async function getCloseLongToPoolInstructionAsync<
|
|
|
258
264
|
TAccountEscrowLongAccount extends string,
|
|
259
265
|
TAccountPremiumVault extends string,
|
|
260
266
|
TAccountMarketData extends string,
|
|
267
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
261
268
|
TAccountSwitchboardQueue extends string,
|
|
262
269
|
TAccountSlotHashesSysvar extends string,
|
|
263
270
|
TAccountInstructionsSysvar extends string,
|
|
@@ -281,6 +288,7 @@ export async function getCloseLongToPoolInstructionAsync<
|
|
|
281
288
|
TAccountEscrowLongAccount,
|
|
282
289
|
TAccountPremiumVault,
|
|
283
290
|
TAccountMarketData,
|
|
291
|
+
TAccountVolatilityQuoteAccount,
|
|
284
292
|
TAccountSwitchboardQueue,
|
|
285
293
|
TAccountSlotHashesSysvar,
|
|
286
294
|
TAccountInstructionsSysvar,
|
|
@@ -306,6 +314,7 @@ export async function getCloseLongToPoolInstructionAsync<
|
|
|
306
314
|
TAccountEscrowLongAccount,
|
|
307
315
|
TAccountPremiumVault,
|
|
308
316
|
TAccountMarketData,
|
|
317
|
+
TAccountVolatilityQuoteAccount,
|
|
309
318
|
TAccountSwitchboardQueue,
|
|
310
319
|
TAccountSlotHashesSysvar,
|
|
311
320
|
TAccountInstructionsSysvar,
|
|
@@ -337,6 +346,10 @@ export async function getCloseLongToPoolInstructionAsync<
|
|
|
337
346
|
},
|
|
338
347
|
premiumVault: { value: input.premiumVault ?? null, isWritable: true },
|
|
339
348
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
349
|
+
volatilityQuoteAccount: {
|
|
350
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
351
|
+
isWritable: false,
|
|
352
|
+
},
|
|
340
353
|
switchboardQueue: {
|
|
341
354
|
value: input.switchboardQueue ?? null,
|
|
342
355
|
isWritable: false,
|
|
@@ -431,6 +444,7 @@ export async function getCloseLongToPoolInstructionAsync<
|
|
|
431
444
|
getAccountMeta(accounts.escrowLongAccount),
|
|
432
445
|
getAccountMeta(accounts.premiumVault),
|
|
433
446
|
getAccountMeta(accounts.marketData),
|
|
447
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
434
448
|
getAccountMeta(accounts.switchboardQueue),
|
|
435
449
|
getAccountMeta(accounts.slotHashesSysvar),
|
|
436
450
|
getAccountMeta(accounts.instructionsSysvar),
|
|
@@ -458,6 +472,7 @@ export async function getCloseLongToPoolInstructionAsync<
|
|
|
458
472
|
TAccountEscrowLongAccount,
|
|
459
473
|
TAccountPremiumVault,
|
|
460
474
|
TAccountMarketData,
|
|
475
|
+
TAccountVolatilityQuoteAccount,
|
|
461
476
|
TAccountSwitchboardQueue,
|
|
462
477
|
TAccountSlotHashesSysvar,
|
|
463
478
|
TAccountInstructionsSysvar,
|
|
@@ -482,6 +497,7 @@ export type CloseLongToPoolInput<
|
|
|
482
497
|
TAccountEscrowLongAccount extends string = string,
|
|
483
498
|
TAccountPremiumVault extends string = string,
|
|
484
499
|
TAccountMarketData extends string = string,
|
|
500
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
485
501
|
TAccountSwitchboardQueue extends string = string,
|
|
486
502
|
TAccountSlotHashesSysvar extends string = string,
|
|
487
503
|
TAccountInstructionsSysvar extends string = string,
|
|
@@ -512,6 +528,7 @@ export type CloseLongToPoolInput<
|
|
|
512
528
|
premiumVault: Address<TAccountPremiumVault>;
|
|
513
529
|
/** Market data account (provides risk-free rate and switchboard_feed_id) */
|
|
514
530
|
marketData: Address<TAccountMarketData>;
|
|
531
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
515
532
|
switchboardQueue: Address<TAccountSwitchboardQueue>;
|
|
516
533
|
slotHashesSysvar?: Address<TAccountSlotHashesSysvar>;
|
|
517
534
|
instructionsSysvar?: Address<TAccountInstructionsSysvar>;
|
|
@@ -542,6 +559,7 @@ export function getCloseLongToPoolInstruction<
|
|
|
542
559
|
TAccountEscrowLongAccount extends string,
|
|
543
560
|
TAccountPremiumVault extends string,
|
|
544
561
|
TAccountMarketData extends string,
|
|
562
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
545
563
|
TAccountSwitchboardQueue extends string,
|
|
546
564
|
TAccountSlotHashesSysvar extends string,
|
|
547
565
|
TAccountInstructionsSysvar extends string,
|
|
@@ -565,6 +583,7 @@ export function getCloseLongToPoolInstruction<
|
|
|
565
583
|
TAccountEscrowLongAccount,
|
|
566
584
|
TAccountPremiumVault,
|
|
567
585
|
TAccountMarketData,
|
|
586
|
+
TAccountVolatilityQuoteAccount,
|
|
568
587
|
TAccountSwitchboardQueue,
|
|
569
588
|
TAccountSlotHashesSysvar,
|
|
570
589
|
TAccountInstructionsSysvar,
|
|
@@ -589,6 +608,7 @@ export function getCloseLongToPoolInstruction<
|
|
|
589
608
|
TAccountEscrowLongAccount,
|
|
590
609
|
TAccountPremiumVault,
|
|
591
610
|
TAccountMarketData,
|
|
611
|
+
TAccountVolatilityQuoteAccount,
|
|
592
612
|
TAccountSwitchboardQueue,
|
|
593
613
|
TAccountSlotHashesSysvar,
|
|
594
614
|
TAccountInstructionsSysvar,
|
|
@@ -619,6 +639,10 @@ export function getCloseLongToPoolInstruction<
|
|
|
619
639
|
},
|
|
620
640
|
premiumVault: { value: input.premiumVault ?? null, isWritable: true },
|
|
621
641
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
642
|
+
volatilityQuoteAccount: {
|
|
643
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
644
|
+
isWritable: false,
|
|
645
|
+
},
|
|
622
646
|
switchboardQueue: {
|
|
623
647
|
value: input.switchboardQueue ?? null,
|
|
624
648
|
isWritable: false,
|
|
@@ -687,6 +711,7 @@ export function getCloseLongToPoolInstruction<
|
|
|
687
711
|
getAccountMeta(accounts.escrowLongAccount),
|
|
688
712
|
getAccountMeta(accounts.premiumVault),
|
|
689
713
|
getAccountMeta(accounts.marketData),
|
|
714
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
690
715
|
getAccountMeta(accounts.switchboardQueue),
|
|
691
716
|
getAccountMeta(accounts.slotHashesSysvar),
|
|
692
717
|
getAccountMeta(accounts.instructionsSysvar),
|
|
@@ -714,6 +739,7 @@ export function getCloseLongToPoolInstruction<
|
|
|
714
739
|
TAccountEscrowLongAccount,
|
|
715
740
|
TAccountPremiumVault,
|
|
716
741
|
TAccountMarketData,
|
|
742
|
+
TAccountVolatilityQuoteAccount,
|
|
717
743
|
TAccountSwitchboardQueue,
|
|
718
744
|
TAccountSlotHashesSysvar,
|
|
719
745
|
TAccountInstructionsSysvar,
|
|
@@ -752,22 +778,23 @@ export type ParsedCloseLongToPoolInstruction<
|
|
|
752
778
|
premiumVault: TAccountMetas[7];
|
|
753
779
|
/** Market data account (provides risk-free rate and switchboard_feed_id) */
|
|
754
780
|
marketData: TAccountMetas[8];
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
781
|
+
volatilityQuoteAccount: TAccountMetas[9];
|
|
782
|
+
switchboardQueue: TAccountMetas[10];
|
|
783
|
+
slotHashesSysvar: TAccountMetas[11];
|
|
784
|
+
instructionsSysvar: TAccountMetas[12];
|
|
758
785
|
/** Buyer's position account */
|
|
759
|
-
buyerPosition: TAccountMetas[
|
|
786
|
+
buyerPosition: TAccountMetas[13];
|
|
760
787
|
/** Buyer's LONG token account (source of tokens to return) */
|
|
761
|
-
buyerLongAccount: TAccountMetas[
|
|
788
|
+
buyerLongAccount: TAccountMetas[14];
|
|
762
789
|
/** Buyer's settlement token account (receives collateral-vault payout leg) */
|
|
763
|
-
buyerPayoutAccount: TAccountMetas[
|
|
790
|
+
buyerPayoutAccount: TAccountMetas[15];
|
|
764
791
|
/** Buyer's underlying token account (receives premium-vault payout leg; same ATA when physical) */
|
|
765
|
-
buyerUnderlyingPayoutAccount: TAccountMetas[
|
|
792
|
+
buyerUnderlyingPayoutAccount: TAccountMetas[16];
|
|
766
793
|
/** Collateral vault (source of payout) */
|
|
767
|
-
collateralVault: TAccountMetas[
|
|
768
|
-
buyer: TAccountMetas[
|
|
769
|
-
tokenProgram: TAccountMetas[
|
|
770
|
-
systemProgram: TAccountMetas[
|
|
794
|
+
collateralVault: TAccountMetas[17];
|
|
795
|
+
buyer: TAccountMetas[18];
|
|
796
|
+
tokenProgram: TAccountMetas[19];
|
|
797
|
+
systemProgram: TAccountMetas[20];
|
|
771
798
|
};
|
|
772
799
|
data: CloseLongToPoolInstructionData;
|
|
773
800
|
};
|
|
@@ -780,7 +807,7 @@ export function parseCloseLongToPoolInstruction<
|
|
|
780
807
|
InstructionWithAccounts<TAccountMetas> &
|
|
781
808
|
InstructionWithData<ReadonlyUint8Array>,
|
|
782
809
|
): ParsedCloseLongToPoolInstruction<TProgram, TAccountMetas> {
|
|
783
|
-
if (instruction.accounts.length <
|
|
810
|
+
if (instruction.accounts.length < 21) {
|
|
784
811
|
// TODO: Coded error.
|
|
785
812
|
throw new Error("Not enough accounts");
|
|
786
813
|
}
|
|
@@ -802,6 +829,7 @@ export function parseCloseLongToPoolInstruction<
|
|
|
802
829
|
escrowLongAccount: getNextAccount(),
|
|
803
830
|
premiumVault: getNextAccount(),
|
|
804
831
|
marketData: getNextAccount(),
|
|
832
|
+
volatilityQuoteAccount: getNextAccount(),
|
|
805
833
|
switchboardQueue: getNextAccount(),
|
|
806
834
|
slotHashesSysvar: getNextAccount(),
|
|
807
835
|
instructionsSysvar: getNextAccount(),
|
|
@@ -26,6 +26,7 @@ export * from "./initOptionPool";
|
|
|
26
26
|
export * from "./liquidateWriterPosition";
|
|
27
27
|
export * from "./liquidateWriterPositionRescue";
|
|
28
28
|
export * from "./migrateCollateralPoolV1ToV2";
|
|
29
|
+
export * from "./migrateMarketDataVolOracle";
|
|
29
30
|
export * from "./omlpCreateVault";
|
|
30
31
|
export * from "./omlpUpdateFeeWallet";
|
|
31
32
|
export * from "./omlpUpdateInterestModel";
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
combineCodec,
|
|
11
11
|
fixDecoderSize,
|
|
12
12
|
fixEncoderSize,
|
|
13
|
+
getAddressDecoder,
|
|
13
14
|
getAddressEncoder,
|
|
14
15
|
getBytesDecoder,
|
|
15
16
|
getBytesEncoder,
|
|
@@ -85,12 +86,16 @@ export type InitializeMarketDataInstructionData = {
|
|
|
85
86
|
riskFreeRate: number;
|
|
86
87
|
historicalVolatility: number;
|
|
87
88
|
switchboardFeedId: ReadonlyUint8Array;
|
|
89
|
+
switchboardVolatilityFeedId: ReadonlyUint8Array;
|
|
90
|
+
volatilityQuoteAuthority: Address;
|
|
88
91
|
};
|
|
89
92
|
|
|
90
93
|
export type InitializeMarketDataInstructionDataArgs = {
|
|
91
94
|
riskFreeRate: number;
|
|
92
95
|
historicalVolatility: number;
|
|
93
96
|
switchboardFeedId: ReadonlyUint8Array;
|
|
97
|
+
switchboardVolatilityFeedId: ReadonlyUint8Array;
|
|
98
|
+
volatilityQuoteAuthority: Address;
|
|
94
99
|
};
|
|
95
100
|
|
|
96
101
|
export function getInitializeMarketDataInstructionDataEncoder(): FixedSizeEncoder<InitializeMarketDataInstructionDataArgs> {
|
|
@@ -100,6 +105,8 @@ export function getInitializeMarketDataInstructionDataEncoder(): FixedSizeEncode
|
|
|
100
105
|
["riskFreeRate", getF64Encoder()],
|
|
101
106
|
["historicalVolatility", getF64Encoder()],
|
|
102
107
|
["switchboardFeedId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
108
|
+
["switchboardVolatilityFeedId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
109
|
+
["volatilityQuoteAuthority", getAddressEncoder()],
|
|
103
110
|
]),
|
|
104
111
|
(value) => ({
|
|
105
112
|
...value,
|
|
@@ -114,6 +121,8 @@ export function getInitializeMarketDataInstructionDataDecoder(): FixedSizeDecode
|
|
|
114
121
|
["riskFreeRate", getF64Decoder()],
|
|
115
122
|
["historicalVolatility", getF64Decoder()],
|
|
116
123
|
["switchboardFeedId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
124
|
+
["switchboardVolatilityFeedId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
125
|
+
["volatilityQuoteAuthority", getAddressDecoder()],
|
|
117
126
|
]);
|
|
118
127
|
}
|
|
119
128
|
|
|
@@ -140,6 +149,8 @@ export type InitializeMarketDataAsyncInput<
|
|
|
140
149
|
riskFreeRate: InitializeMarketDataInstructionDataArgs["riskFreeRate"];
|
|
141
150
|
historicalVolatility: InitializeMarketDataInstructionDataArgs["historicalVolatility"];
|
|
142
151
|
switchboardFeedId: InitializeMarketDataInstructionDataArgs["switchboardFeedId"];
|
|
152
|
+
switchboardVolatilityFeedId: InitializeMarketDataInstructionDataArgs["switchboardVolatilityFeedId"];
|
|
153
|
+
volatilityQuoteAuthority: InitializeMarketDataInstructionDataArgs["volatilityQuoteAuthority"];
|
|
143
154
|
};
|
|
144
155
|
|
|
145
156
|
export async function getInitializeMarketDataInstructionAsync<
|
|
@@ -240,6 +251,8 @@ export type InitializeMarketDataInput<
|
|
|
240
251
|
riskFreeRate: InitializeMarketDataInstructionDataArgs["riskFreeRate"];
|
|
241
252
|
historicalVolatility: InitializeMarketDataInstructionDataArgs["historicalVolatility"];
|
|
242
253
|
switchboardFeedId: InitializeMarketDataInstructionDataArgs["switchboardFeedId"];
|
|
254
|
+
switchboardVolatilityFeedId: InitializeMarketDataInstructionDataArgs["switchboardVolatilityFeedId"];
|
|
255
|
+
volatilityQuoteAuthority: InitializeMarketDataInstructionDataArgs["volatilityQuoteAuthority"];
|
|
243
256
|
};
|
|
244
257
|
|
|
245
258
|
export function getInitializeMarketDataInstruction<
|