@epicentral/sos-sdk 0.12.2-beta → 0.13.1-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/errors/optionProgram.ts +98 -94
- 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
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
combineCodec,
|
|
11
|
+
fixDecoderSize,
|
|
12
|
+
fixEncoderSize,
|
|
13
|
+
getAddressDecoder,
|
|
14
|
+
getAddressEncoder,
|
|
15
|
+
getBytesDecoder,
|
|
16
|
+
getBytesEncoder,
|
|
17
|
+
getStructDecoder,
|
|
18
|
+
getStructEncoder,
|
|
19
|
+
transformEncoder,
|
|
20
|
+
type AccountMeta,
|
|
21
|
+
type AccountSignerMeta,
|
|
22
|
+
type Address,
|
|
23
|
+
type FixedSizeCodec,
|
|
24
|
+
type FixedSizeDecoder,
|
|
25
|
+
type FixedSizeEncoder,
|
|
26
|
+
type Instruction,
|
|
27
|
+
type InstructionWithAccounts,
|
|
28
|
+
type InstructionWithData,
|
|
29
|
+
type ReadonlyAccount,
|
|
30
|
+
type ReadonlyUint8Array,
|
|
31
|
+
type TransactionSigner,
|
|
32
|
+
type WritableAccount,
|
|
33
|
+
type WritableSignerAccount,
|
|
34
|
+
} from "@solana/kit";
|
|
35
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
36
|
+
import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
|
|
37
|
+
|
|
38
|
+
export const MIGRATE_MARKET_DATA_VOL_ORACLE_DISCRIMINATOR = new Uint8Array([
|
|
39
|
+
230, 102, 218, 98, 194, 231, 97, 241,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export function getMigrateMarketDataVolOracleDiscriminatorBytes() {
|
|
43
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
44
|
+
MIGRATE_MARKET_DATA_VOL_ORACLE_DISCRIMINATOR,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type MigrateMarketDataVolOracleInstruction<
|
|
49
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
50
|
+
TAccountMarketData extends string | AccountMeta<string> = string,
|
|
51
|
+
TAccountUnderlyingAsset extends string | AccountMeta<string> = string,
|
|
52
|
+
TAccountAuthority extends string | AccountMeta<string> = string,
|
|
53
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
54
|
+
"11111111111111111111111111111111",
|
|
55
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
56
|
+
> = Instruction<TProgram> &
|
|
57
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
58
|
+
InstructionWithAccounts<
|
|
59
|
+
[
|
|
60
|
+
TAccountMarketData extends string
|
|
61
|
+
? WritableAccount<TAccountMarketData>
|
|
62
|
+
: TAccountMarketData,
|
|
63
|
+
TAccountUnderlyingAsset extends string
|
|
64
|
+
? ReadonlyAccount<TAccountUnderlyingAsset>
|
|
65
|
+
: TAccountUnderlyingAsset,
|
|
66
|
+
TAccountAuthority extends string
|
|
67
|
+
? WritableSignerAccount<TAccountAuthority> &
|
|
68
|
+
AccountSignerMeta<TAccountAuthority>
|
|
69
|
+
: TAccountAuthority,
|
|
70
|
+
TAccountSystemProgram extends string
|
|
71
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
72
|
+
: TAccountSystemProgram,
|
|
73
|
+
...TRemainingAccounts,
|
|
74
|
+
]
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
export type MigrateMarketDataVolOracleInstructionData = {
|
|
78
|
+
discriminator: ReadonlyUint8Array;
|
|
79
|
+
switchboardVolatilityFeedId: ReadonlyUint8Array;
|
|
80
|
+
volatilityQuoteAuthority: Address;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type MigrateMarketDataVolOracleInstructionDataArgs = {
|
|
84
|
+
switchboardVolatilityFeedId: ReadonlyUint8Array;
|
|
85
|
+
volatilityQuoteAuthority: Address;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export function getMigrateMarketDataVolOracleInstructionDataEncoder(): FixedSizeEncoder<MigrateMarketDataVolOracleInstructionDataArgs> {
|
|
89
|
+
return transformEncoder(
|
|
90
|
+
getStructEncoder([
|
|
91
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
92
|
+
["switchboardVolatilityFeedId", fixEncoderSize(getBytesEncoder(), 32)],
|
|
93
|
+
["volatilityQuoteAuthority", getAddressEncoder()],
|
|
94
|
+
]),
|
|
95
|
+
(value) => ({
|
|
96
|
+
...value,
|
|
97
|
+
discriminator: MIGRATE_MARKET_DATA_VOL_ORACLE_DISCRIMINATOR,
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function getMigrateMarketDataVolOracleInstructionDataDecoder(): FixedSizeDecoder<MigrateMarketDataVolOracleInstructionData> {
|
|
103
|
+
return getStructDecoder([
|
|
104
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
105
|
+
["switchboardVolatilityFeedId", fixDecoderSize(getBytesDecoder(), 32)],
|
|
106
|
+
["volatilityQuoteAuthority", getAddressDecoder()],
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export function getMigrateMarketDataVolOracleInstructionDataCodec(): FixedSizeCodec<
|
|
111
|
+
MigrateMarketDataVolOracleInstructionDataArgs,
|
|
112
|
+
MigrateMarketDataVolOracleInstructionData
|
|
113
|
+
> {
|
|
114
|
+
return combineCodec(
|
|
115
|
+
getMigrateMarketDataVolOracleInstructionDataEncoder(),
|
|
116
|
+
getMigrateMarketDataVolOracleInstructionDataDecoder(),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export type MigrateMarketDataVolOracleInput<
|
|
121
|
+
TAccountMarketData extends string = string,
|
|
122
|
+
TAccountUnderlyingAsset extends string = string,
|
|
123
|
+
TAccountAuthority extends string = string,
|
|
124
|
+
TAccountSystemProgram extends string = string,
|
|
125
|
+
> = {
|
|
126
|
+
marketData: Address<TAccountMarketData>;
|
|
127
|
+
underlyingAsset: Address<TAccountUnderlyingAsset>;
|
|
128
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
129
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
130
|
+
switchboardVolatilityFeedId: MigrateMarketDataVolOracleInstructionDataArgs["switchboardVolatilityFeedId"];
|
|
131
|
+
volatilityQuoteAuthority: MigrateMarketDataVolOracleInstructionDataArgs["volatilityQuoteAuthority"];
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export function getMigrateMarketDataVolOracleInstruction<
|
|
135
|
+
TAccountMarketData extends string,
|
|
136
|
+
TAccountUnderlyingAsset extends string,
|
|
137
|
+
TAccountAuthority extends string,
|
|
138
|
+
TAccountSystemProgram extends string,
|
|
139
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
140
|
+
>(
|
|
141
|
+
input: MigrateMarketDataVolOracleInput<
|
|
142
|
+
TAccountMarketData,
|
|
143
|
+
TAccountUnderlyingAsset,
|
|
144
|
+
TAccountAuthority,
|
|
145
|
+
TAccountSystemProgram
|
|
146
|
+
>,
|
|
147
|
+
config?: { programAddress?: TProgramAddress },
|
|
148
|
+
): MigrateMarketDataVolOracleInstruction<
|
|
149
|
+
TProgramAddress,
|
|
150
|
+
TAccountMarketData,
|
|
151
|
+
TAccountUnderlyingAsset,
|
|
152
|
+
TAccountAuthority,
|
|
153
|
+
TAccountSystemProgram
|
|
154
|
+
> {
|
|
155
|
+
// Program address.
|
|
156
|
+
const programAddress =
|
|
157
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
158
|
+
|
|
159
|
+
// Original accounts.
|
|
160
|
+
const originalAccounts = {
|
|
161
|
+
marketData: { value: input.marketData ?? null, isWritable: true },
|
|
162
|
+
underlyingAsset: {
|
|
163
|
+
value: input.underlyingAsset ?? null,
|
|
164
|
+
isWritable: false,
|
|
165
|
+
},
|
|
166
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
167
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
168
|
+
};
|
|
169
|
+
const accounts = originalAccounts as Record<
|
|
170
|
+
keyof typeof originalAccounts,
|
|
171
|
+
ResolvedAccount
|
|
172
|
+
>;
|
|
173
|
+
|
|
174
|
+
// Original args.
|
|
175
|
+
const args = { ...input };
|
|
176
|
+
|
|
177
|
+
// Resolve default values.
|
|
178
|
+
if (!accounts.systemProgram.value) {
|
|
179
|
+
accounts.systemProgram.value =
|
|
180
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
184
|
+
return Object.freeze({
|
|
185
|
+
accounts: [
|
|
186
|
+
getAccountMeta(accounts.marketData),
|
|
187
|
+
getAccountMeta(accounts.underlyingAsset),
|
|
188
|
+
getAccountMeta(accounts.authority),
|
|
189
|
+
getAccountMeta(accounts.systemProgram),
|
|
190
|
+
],
|
|
191
|
+
data: getMigrateMarketDataVolOracleInstructionDataEncoder().encode(
|
|
192
|
+
args as MigrateMarketDataVolOracleInstructionDataArgs,
|
|
193
|
+
),
|
|
194
|
+
programAddress,
|
|
195
|
+
} as MigrateMarketDataVolOracleInstruction<
|
|
196
|
+
TProgramAddress,
|
|
197
|
+
TAccountMarketData,
|
|
198
|
+
TAccountUnderlyingAsset,
|
|
199
|
+
TAccountAuthority,
|
|
200
|
+
TAccountSystemProgram
|
|
201
|
+
>);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export type ParsedMigrateMarketDataVolOracleInstruction<
|
|
205
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
206
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
207
|
+
> = {
|
|
208
|
+
programAddress: Address<TProgram>;
|
|
209
|
+
accounts: {
|
|
210
|
+
marketData: TAccountMetas[0];
|
|
211
|
+
underlyingAsset: TAccountMetas[1];
|
|
212
|
+
authority: TAccountMetas[2];
|
|
213
|
+
systemProgram: TAccountMetas[3];
|
|
214
|
+
};
|
|
215
|
+
data: MigrateMarketDataVolOracleInstructionData;
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export function parseMigrateMarketDataVolOracleInstruction<
|
|
219
|
+
TProgram extends string,
|
|
220
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
221
|
+
>(
|
|
222
|
+
instruction: Instruction<TProgram> &
|
|
223
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
224
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
225
|
+
): ParsedMigrateMarketDataVolOracleInstruction<TProgram, TAccountMetas> {
|
|
226
|
+
if (instruction.accounts.length < 4) {
|
|
227
|
+
// TODO: Coded error.
|
|
228
|
+
throw new Error("Not enough accounts");
|
|
229
|
+
}
|
|
230
|
+
let accountIndex = 0;
|
|
231
|
+
const getNextAccount = () => {
|
|
232
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
233
|
+
accountIndex += 1;
|
|
234
|
+
return accountMeta;
|
|
235
|
+
};
|
|
236
|
+
return {
|
|
237
|
+
programAddress: instruction.programAddress,
|
|
238
|
+
accounts: {
|
|
239
|
+
marketData: getNextAccount(),
|
|
240
|
+
underlyingAsset: getNextAccount(),
|
|
241
|
+
authority: getNextAccount(),
|
|
242
|
+
systemProgram: getNextAccount(),
|
|
243
|
+
},
|
|
244
|
+
data: getMigrateMarketDataVolOracleInstructionDataDecoder().decode(
|
|
245
|
+
instruction.data,
|
|
246
|
+
),
|
|
247
|
+
};
|
|
248
|
+
}
|
|
@@ -78,6 +78,7 @@ export type OptionMintInstruction<
|
|
|
78
78
|
TAccountLongMetadataAccount extends string | AccountMeta<string> = string,
|
|
79
79
|
TAccountShortMetadataAccount extends string | AccountMeta<string> = string,
|
|
80
80
|
TAccountMarketData extends string | AccountMeta<string> = string,
|
|
81
|
+
TAccountVolatilityQuoteAccount extends string | AccountMeta<string> = string,
|
|
81
82
|
TAccountUnderlyingMint extends string | AccountMeta<string> = string,
|
|
82
83
|
TAccountCollateralMint extends string | AccountMeta<string> = string,
|
|
83
84
|
TAccountOptionPool extends string | AccountMeta<string> = string,
|
|
@@ -136,6 +137,9 @@ export type OptionMintInstruction<
|
|
|
136
137
|
TAccountMarketData extends string
|
|
137
138
|
? ReadonlyAccount<TAccountMarketData>
|
|
138
139
|
: TAccountMarketData,
|
|
140
|
+
TAccountVolatilityQuoteAccount extends string
|
|
141
|
+
? ReadonlyAccount<TAccountVolatilityQuoteAccount>
|
|
142
|
+
: TAccountVolatilityQuoteAccount,
|
|
139
143
|
TAccountUnderlyingMint extends string
|
|
140
144
|
? ReadonlyAccount<TAccountUnderlyingMint>
|
|
141
145
|
: TAccountUnderlyingMint,
|
|
@@ -292,6 +296,7 @@ export type OptionMintAsyncInput<
|
|
|
292
296
|
TAccountLongMetadataAccount extends string = string,
|
|
293
297
|
TAccountShortMetadataAccount extends string = string,
|
|
294
298
|
TAccountMarketData extends string = string,
|
|
299
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
295
300
|
TAccountUnderlyingMint extends string = string,
|
|
296
301
|
TAccountCollateralMint extends string = string,
|
|
297
302
|
TAccountOptionPool extends string = string,
|
|
@@ -338,6 +343,7 @@ export type OptionMintAsyncInput<
|
|
|
338
343
|
shortMetadataAccount: Address<TAccountShortMetadataAccount>;
|
|
339
344
|
/** Market data account - provides baseline historical volatility for initial IV */
|
|
340
345
|
marketData?: Address<TAccountMarketData>;
|
|
346
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
341
347
|
/** Underlying asset mint (e.g., WSOL) - required for pricing and pool initialization */
|
|
342
348
|
underlyingMint: Address<TAccountUnderlyingMint>;
|
|
343
349
|
/**
|
|
@@ -400,6 +406,7 @@ export async function getOptionMintInstructionAsync<
|
|
|
400
406
|
TAccountLongMetadataAccount extends string,
|
|
401
407
|
TAccountShortMetadataAccount extends string,
|
|
402
408
|
TAccountMarketData extends string,
|
|
409
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
403
410
|
TAccountUnderlyingMint extends string,
|
|
404
411
|
TAccountCollateralMint extends string,
|
|
405
412
|
TAccountOptionPool extends string,
|
|
@@ -433,6 +440,7 @@ export async function getOptionMintInstructionAsync<
|
|
|
433
440
|
TAccountLongMetadataAccount,
|
|
434
441
|
TAccountShortMetadataAccount,
|
|
435
442
|
TAccountMarketData,
|
|
443
|
+
TAccountVolatilityQuoteAccount,
|
|
436
444
|
TAccountUnderlyingMint,
|
|
437
445
|
TAccountCollateralMint,
|
|
438
446
|
TAccountOptionPool,
|
|
@@ -468,6 +476,7 @@ export async function getOptionMintInstructionAsync<
|
|
|
468
476
|
TAccountLongMetadataAccount,
|
|
469
477
|
TAccountShortMetadataAccount,
|
|
470
478
|
TAccountMarketData,
|
|
479
|
+
TAccountVolatilityQuoteAccount,
|
|
471
480
|
TAccountUnderlyingMint,
|
|
472
481
|
TAccountCollateralMint,
|
|
473
482
|
TAccountOptionPool,
|
|
@@ -518,6 +527,10 @@ export async function getOptionMintInstructionAsync<
|
|
|
518
527
|
isWritable: true,
|
|
519
528
|
},
|
|
520
529
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
530
|
+
volatilityQuoteAccount: {
|
|
531
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
532
|
+
isWritable: false,
|
|
533
|
+
},
|
|
521
534
|
underlyingMint: { value: input.underlyingMint ?? null, isWritable: false },
|
|
522
535
|
collateralMint: { value: input.collateralMint ?? null, isWritable: false },
|
|
523
536
|
optionPool: { value: input.optionPool ?? null, isWritable: true },
|
|
@@ -795,6 +808,7 @@ export async function getOptionMintInstructionAsync<
|
|
|
795
808
|
getAccountMeta(accounts.longMetadataAccount),
|
|
796
809
|
getAccountMeta(accounts.shortMetadataAccount),
|
|
797
810
|
getAccountMeta(accounts.marketData),
|
|
811
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
798
812
|
getAccountMeta(accounts.underlyingMint),
|
|
799
813
|
getAccountMeta(accounts.collateralMint),
|
|
800
814
|
getAccountMeta(accounts.optionPool),
|
|
@@ -832,6 +846,7 @@ export async function getOptionMintInstructionAsync<
|
|
|
832
846
|
TAccountLongMetadataAccount,
|
|
833
847
|
TAccountShortMetadataAccount,
|
|
834
848
|
TAccountMarketData,
|
|
849
|
+
TAccountVolatilityQuoteAccount,
|
|
835
850
|
TAccountUnderlyingMint,
|
|
836
851
|
TAccountCollateralMint,
|
|
837
852
|
TAccountOptionPool,
|
|
@@ -866,6 +881,7 @@ export type OptionMintInput<
|
|
|
866
881
|
TAccountLongMetadataAccount extends string = string,
|
|
867
882
|
TAccountShortMetadataAccount extends string = string,
|
|
868
883
|
TAccountMarketData extends string = string,
|
|
884
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
869
885
|
TAccountUnderlyingMint extends string = string,
|
|
870
886
|
TAccountCollateralMint extends string = string,
|
|
871
887
|
TAccountOptionPool extends string = string,
|
|
@@ -912,6 +928,7 @@ export type OptionMintInput<
|
|
|
912
928
|
shortMetadataAccount: Address<TAccountShortMetadataAccount>;
|
|
913
929
|
/** Market data account - provides baseline historical volatility for initial IV */
|
|
914
930
|
marketData: Address<TAccountMarketData>;
|
|
931
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
915
932
|
/** Underlying asset mint (e.g., WSOL) - required for pricing and pool initialization */
|
|
916
933
|
underlyingMint: Address<TAccountUnderlyingMint>;
|
|
917
934
|
/**
|
|
@@ -974,6 +991,7 @@ export function getOptionMintInstruction<
|
|
|
974
991
|
TAccountLongMetadataAccount extends string,
|
|
975
992
|
TAccountShortMetadataAccount extends string,
|
|
976
993
|
TAccountMarketData extends string,
|
|
994
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
977
995
|
TAccountUnderlyingMint extends string,
|
|
978
996
|
TAccountCollateralMint extends string,
|
|
979
997
|
TAccountOptionPool extends string,
|
|
@@ -1007,6 +1025,7 @@ export function getOptionMintInstruction<
|
|
|
1007
1025
|
TAccountLongMetadataAccount,
|
|
1008
1026
|
TAccountShortMetadataAccount,
|
|
1009
1027
|
TAccountMarketData,
|
|
1028
|
+
TAccountVolatilityQuoteAccount,
|
|
1010
1029
|
TAccountUnderlyingMint,
|
|
1011
1030
|
TAccountCollateralMint,
|
|
1012
1031
|
TAccountOptionPool,
|
|
@@ -1041,6 +1060,7 @@ export function getOptionMintInstruction<
|
|
|
1041
1060
|
TAccountLongMetadataAccount,
|
|
1042
1061
|
TAccountShortMetadataAccount,
|
|
1043
1062
|
TAccountMarketData,
|
|
1063
|
+
TAccountVolatilityQuoteAccount,
|
|
1044
1064
|
TAccountUnderlyingMint,
|
|
1045
1065
|
TAccountCollateralMint,
|
|
1046
1066
|
TAccountOptionPool,
|
|
@@ -1090,6 +1110,10 @@ export function getOptionMintInstruction<
|
|
|
1090
1110
|
isWritable: true,
|
|
1091
1111
|
},
|
|
1092
1112
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
1113
|
+
volatilityQuoteAccount: {
|
|
1114
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
1115
|
+
isWritable: false,
|
|
1116
|
+
},
|
|
1093
1117
|
underlyingMint: { value: input.underlyingMint ?? null, isWritable: false },
|
|
1094
1118
|
collateralMint: { value: input.collateralMint ?? null, isWritable: false },
|
|
1095
1119
|
optionPool: { value: input.optionPool ?? null, isWritable: true },
|
|
@@ -1175,6 +1199,7 @@ export function getOptionMintInstruction<
|
|
|
1175
1199
|
getAccountMeta(accounts.longMetadataAccount),
|
|
1176
1200
|
getAccountMeta(accounts.shortMetadataAccount),
|
|
1177
1201
|
getAccountMeta(accounts.marketData),
|
|
1202
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
1178
1203
|
getAccountMeta(accounts.underlyingMint),
|
|
1179
1204
|
getAccountMeta(accounts.collateralMint),
|
|
1180
1205
|
getAccountMeta(accounts.optionPool),
|
|
@@ -1212,6 +1237,7 @@ export function getOptionMintInstruction<
|
|
|
1212
1237
|
TAccountLongMetadataAccount,
|
|
1213
1238
|
TAccountShortMetadataAccount,
|
|
1214
1239
|
TAccountMarketData,
|
|
1240
|
+
TAccountVolatilityQuoteAccount,
|
|
1215
1241
|
TAccountUnderlyingMint,
|
|
1216
1242
|
TAccountCollateralMint,
|
|
1217
1243
|
TAccountOptionPool,
|
|
@@ -1266,46 +1292,47 @@ export type ParsedOptionMintInstruction<
|
|
|
1266
1292
|
shortMetadataAccount: TAccountMetas[7];
|
|
1267
1293
|
/** Market data account - provides baseline historical volatility for initial IV */
|
|
1268
1294
|
marketData: TAccountMetas[8];
|
|
1295
|
+
volatilityQuoteAccount: TAccountMetas[9];
|
|
1269
1296
|
/** Underlying asset mint (e.g., WSOL) - required for pricing and pool initialization */
|
|
1270
|
-
underlyingMint: TAccountMetas[
|
|
1297
|
+
underlyingMint: TAccountMetas[10];
|
|
1271
1298
|
/**
|
|
1272
1299
|
* Collateral mint (e.g., USDC, BTC, SOL) - Writer's choice for backing the position
|
|
1273
1300
|
* Can differ from underlying_mint - enables multi-collateral settlement
|
|
1274
1301
|
* OMLP vault routing is based on this mint
|
|
1275
1302
|
*/
|
|
1276
|
-
collateralMint: TAccountMetas[
|
|
1303
|
+
collateralMint: TAccountMetas[11];
|
|
1277
1304
|
/** Option pool - aggregated liquidity pool for this option */
|
|
1278
|
-
optionPool: TAccountMetas[
|
|
1305
|
+
optionPool: TAccountMetas[12];
|
|
1279
1306
|
/** Pool's escrow for holding LONG tokens (for buyers to purchase) */
|
|
1280
|
-
escrowLongAccount: TAccountMetas[
|
|
1307
|
+
escrowLongAccount: TAccountMetas[13];
|
|
1281
1308
|
/** Pool vault for premiums (underlying when physical, collateral mint for cash) */
|
|
1282
|
-
premiumVault: TAccountMetas[
|
|
1309
|
+
premiumVault: TAccountMetas[14];
|
|
1283
1310
|
/** Collateral pool for this option */
|
|
1284
|
-
collateralPool: TAccountMetas[
|
|
1311
|
+
collateralPool: TAccountMetas[15];
|
|
1285
1312
|
/** Collateral vault (ATA holding collateral) */
|
|
1286
|
-
collateralVault: TAccountMetas[
|
|
1313
|
+
collateralVault: TAccountMetas[16];
|
|
1287
1314
|
/** Maker's collateral account (source of maker's own collateral) */
|
|
1288
|
-
makerCollateralAccount: TAccountMetas[
|
|
1315
|
+
makerCollateralAccount: TAccountMetas[17];
|
|
1289
1316
|
/** Writer's unified position account (single source of truth) */
|
|
1290
|
-
writerPosition: TAccountMetas[
|
|
1317
|
+
writerPosition: TAccountMetas[18];
|
|
1291
1318
|
/** OMLP vault (optional - only required if borrowing) */
|
|
1292
|
-
vault?: TAccountMetas[
|
|
1319
|
+
vault?: TAccountMetas[19] | undefined;
|
|
1293
1320
|
/** Vault's token account (optional - only required if borrowing) */
|
|
1294
|
-
vaultTokenAccount?: TAccountMetas[
|
|
1321
|
+
vaultTokenAccount?: TAccountMetas[20] | undefined;
|
|
1295
1322
|
/** Escrow state PDA (optional - only required if borrowing) */
|
|
1296
|
-
escrowState?: TAccountMetas[
|
|
1323
|
+
escrowState?: TAccountMetas[21] | undefined;
|
|
1297
1324
|
/** Escrow authority PDA (optional - only required if borrowing) */
|
|
1298
|
-
escrowAuthority?: TAccountMetas[
|
|
1325
|
+
escrowAuthority?: TAccountMetas[22] | undefined;
|
|
1299
1326
|
/** Escrow token account (optional - only required if borrowing) */
|
|
1300
|
-
escrowTokenAccount?: TAccountMetas[
|
|
1327
|
+
escrowTokenAccount?: TAccountMetas[23] | undefined;
|
|
1301
1328
|
/** Pool loan account (optional - only required if borrowing) */
|
|
1302
|
-
poolLoan?: TAccountMetas[
|
|
1303
|
-
maker: TAccountMetas[
|
|
1304
|
-
tokenProgram: TAccountMetas[
|
|
1305
|
-
associatedTokenProgram: TAccountMetas[
|
|
1306
|
-
tokenMetadataProgram: TAccountMetas[
|
|
1307
|
-
systemProgram: TAccountMetas[
|
|
1308
|
-
rent: TAccountMetas[
|
|
1329
|
+
poolLoan?: TAccountMetas[24] | undefined;
|
|
1330
|
+
maker: TAccountMetas[25];
|
|
1331
|
+
tokenProgram: TAccountMetas[26];
|
|
1332
|
+
associatedTokenProgram: TAccountMetas[27];
|
|
1333
|
+
tokenMetadataProgram: TAccountMetas[28];
|
|
1334
|
+
systemProgram: TAccountMetas[29];
|
|
1335
|
+
rent: TAccountMetas[30];
|
|
1309
1336
|
};
|
|
1310
1337
|
data: OptionMintInstructionData;
|
|
1311
1338
|
};
|
|
@@ -1318,7 +1345,7 @@ export function parseOptionMintInstruction<
|
|
|
1318
1345
|
InstructionWithAccounts<TAccountMetas> &
|
|
1319
1346
|
InstructionWithData<ReadonlyUint8Array>,
|
|
1320
1347
|
): ParsedOptionMintInstruction<TProgram, TAccountMetas> {
|
|
1321
|
-
if (instruction.accounts.length <
|
|
1348
|
+
if (instruction.accounts.length < 31) {
|
|
1322
1349
|
// TODO: Coded error.
|
|
1323
1350
|
throw new Error("Not enough accounts");
|
|
1324
1351
|
}
|
|
@@ -1346,6 +1373,7 @@ export function parseOptionMintInstruction<
|
|
|
1346
1373
|
longMetadataAccount: getNextAccount(),
|
|
1347
1374
|
shortMetadataAccount: getNextAccount(),
|
|
1348
1375
|
marketData: getNextAccount(),
|
|
1376
|
+
volatilityQuoteAccount: getNextAccount(),
|
|
1349
1377
|
underlyingMint: getNextAccount(),
|
|
1350
1378
|
collateralMint: getNextAccount(),
|
|
1351
1379
|
optionPool: getNextAccount(),
|
|
@@ -48,6 +48,7 @@ export type UpdateImpliedVolatilityInstruction<
|
|
|
48
48
|
TAccountOptionAccount extends string | AccountMeta<string> = string,
|
|
49
49
|
TAccountOptionPool extends string | AccountMeta<string> = string,
|
|
50
50
|
TAccountMarketData extends string | AccountMeta<string> = string,
|
|
51
|
+
TAccountVolatilityQuoteAccount extends string | AccountMeta<string> = string,
|
|
51
52
|
TAccountKeeper extends string | AccountMeta<string> = string,
|
|
52
53
|
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
53
54
|
> = Instruction<TProgram> &
|
|
@@ -63,6 +64,9 @@ export type UpdateImpliedVolatilityInstruction<
|
|
|
63
64
|
TAccountMarketData extends string
|
|
64
65
|
? ReadonlyAccount<TAccountMarketData>
|
|
65
66
|
: TAccountMarketData,
|
|
67
|
+
TAccountVolatilityQuoteAccount extends string
|
|
68
|
+
? ReadonlyAccount<TAccountVolatilityQuoteAccount>
|
|
69
|
+
: TAccountVolatilityQuoteAccount,
|
|
66
70
|
TAccountKeeper extends string
|
|
67
71
|
? ReadonlySignerAccount<TAccountKeeper> &
|
|
68
72
|
AccountSignerMeta<TAccountKeeper>
|
|
@@ -107,6 +111,7 @@ export type UpdateImpliedVolatilityInput<
|
|
|
107
111
|
TAccountOptionAccount extends string = string,
|
|
108
112
|
TAccountOptionPool extends string = string,
|
|
109
113
|
TAccountMarketData extends string = string,
|
|
114
|
+
TAccountVolatilityQuoteAccount extends string = string,
|
|
110
115
|
TAccountKeeper extends string = string,
|
|
111
116
|
> = {
|
|
112
117
|
/** The option account to update IV for */
|
|
@@ -115,6 +120,7 @@ export type UpdateImpliedVolatilityInput<
|
|
|
115
120
|
optionPool: Address<TAccountOptionPool>;
|
|
116
121
|
/** Market data - provides baseline historical volatility */
|
|
117
122
|
marketData: Address<TAccountMarketData>;
|
|
123
|
+
volatilityQuoteAccount: Address<TAccountVolatilityQuoteAccount>;
|
|
118
124
|
/** Keeper/anyone can call this instruction (permissionless update) */
|
|
119
125
|
keeper: TransactionSigner<TAccountKeeper>;
|
|
120
126
|
};
|
|
@@ -123,6 +129,7 @@ export function getUpdateImpliedVolatilityInstruction<
|
|
|
123
129
|
TAccountOptionAccount extends string,
|
|
124
130
|
TAccountOptionPool extends string,
|
|
125
131
|
TAccountMarketData extends string,
|
|
132
|
+
TAccountVolatilityQuoteAccount extends string,
|
|
126
133
|
TAccountKeeper extends string,
|
|
127
134
|
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
128
135
|
>(
|
|
@@ -130,6 +137,7 @@ export function getUpdateImpliedVolatilityInstruction<
|
|
|
130
137
|
TAccountOptionAccount,
|
|
131
138
|
TAccountOptionPool,
|
|
132
139
|
TAccountMarketData,
|
|
140
|
+
TAccountVolatilityQuoteAccount,
|
|
133
141
|
TAccountKeeper
|
|
134
142
|
>,
|
|
135
143
|
config?: { programAddress?: TProgramAddress },
|
|
@@ -138,6 +146,7 @@ export function getUpdateImpliedVolatilityInstruction<
|
|
|
138
146
|
TAccountOptionAccount,
|
|
139
147
|
TAccountOptionPool,
|
|
140
148
|
TAccountMarketData,
|
|
149
|
+
TAccountVolatilityQuoteAccount,
|
|
141
150
|
TAccountKeeper
|
|
142
151
|
> {
|
|
143
152
|
// Program address.
|
|
@@ -149,6 +158,10 @@ export function getUpdateImpliedVolatilityInstruction<
|
|
|
149
158
|
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
150
159
|
optionPool: { value: input.optionPool ?? null, isWritable: false },
|
|
151
160
|
marketData: { value: input.marketData ?? null, isWritable: false },
|
|
161
|
+
volatilityQuoteAccount: {
|
|
162
|
+
value: input.volatilityQuoteAccount ?? null,
|
|
163
|
+
isWritable: false,
|
|
164
|
+
},
|
|
152
165
|
keeper: { value: input.keeper ?? null, isWritable: false },
|
|
153
166
|
};
|
|
154
167
|
const accounts = originalAccounts as Record<
|
|
@@ -162,6 +175,7 @@ export function getUpdateImpliedVolatilityInstruction<
|
|
|
162
175
|
getAccountMeta(accounts.optionAccount),
|
|
163
176
|
getAccountMeta(accounts.optionPool),
|
|
164
177
|
getAccountMeta(accounts.marketData),
|
|
178
|
+
getAccountMeta(accounts.volatilityQuoteAccount),
|
|
165
179
|
getAccountMeta(accounts.keeper),
|
|
166
180
|
],
|
|
167
181
|
data: getUpdateImpliedVolatilityInstructionDataEncoder().encode({}),
|
|
@@ -171,6 +185,7 @@ export function getUpdateImpliedVolatilityInstruction<
|
|
|
171
185
|
TAccountOptionAccount,
|
|
172
186
|
TAccountOptionPool,
|
|
173
187
|
TAccountMarketData,
|
|
188
|
+
TAccountVolatilityQuoteAccount,
|
|
174
189
|
TAccountKeeper
|
|
175
190
|
>);
|
|
176
191
|
}
|
|
@@ -187,8 +202,9 @@ export type ParsedUpdateImpliedVolatilityInstruction<
|
|
|
187
202
|
optionPool: TAccountMetas[1];
|
|
188
203
|
/** Market data - provides baseline historical volatility */
|
|
189
204
|
marketData: TAccountMetas[2];
|
|
205
|
+
volatilityQuoteAccount: TAccountMetas[3];
|
|
190
206
|
/** Keeper/anyone can call this instruction (permissionless update) */
|
|
191
|
-
keeper: TAccountMetas[
|
|
207
|
+
keeper: TAccountMetas[4];
|
|
192
208
|
};
|
|
193
209
|
data: UpdateImpliedVolatilityInstructionData;
|
|
194
210
|
};
|
|
@@ -201,7 +217,7 @@ export function parseUpdateImpliedVolatilityInstruction<
|
|
|
201
217
|
InstructionWithAccounts<TAccountMetas> &
|
|
202
218
|
InstructionWithData<ReadonlyUint8Array>,
|
|
203
219
|
): ParsedUpdateImpliedVolatilityInstruction<TProgram, TAccountMetas> {
|
|
204
|
-
if (instruction.accounts.length <
|
|
220
|
+
if (instruction.accounts.length < 5) {
|
|
205
221
|
// TODO: Coded error.
|
|
206
222
|
throw new Error("Not enough accounts");
|
|
207
223
|
}
|
|
@@ -217,6 +233,7 @@ export function parseUpdateImpliedVolatilityInstruction<
|
|
|
217
233
|
optionAccount: getNextAccount(),
|
|
218
234
|
optionPool: getNextAccount(),
|
|
219
235
|
marketData: getNextAccount(),
|
|
236
|
+
volatilityQuoteAccount: getNextAccount(),
|
|
220
237
|
keeper: getNextAccount(),
|
|
221
238
|
},
|
|
222
239
|
data: getUpdateImpliedVolatilityInstructionDataDecoder().decode(
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
type ParsedLiquidateWriterPositionInstruction,
|
|
35
35
|
type ParsedLiquidateWriterPositionRescueInstruction,
|
|
36
36
|
type ParsedMigrateCollateralPoolV1ToV2Instruction,
|
|
37
|
+
type ParsedMigrateMarketDataVolOracleInstruction,
|
|
37
38
|
type ParsedOmlpCreateVaultInstruction,
|
|
38
39
|
type ParsedOmlpUpdateFeeWalletInstruction,
|
|
39
40
|
type ParsedOmlpUpdateInterestModelInstruction,
|
|
@@ -265,6 +266,7 @@ export enum OptionProgramInstruction {
|
|
|
265
266
|
LiquidateWriterPosition,
|
|
266
267
|
LiquidateWriterPositionRescue,
|
|
267
268
|
MigrateCollateralPoolV1ToV2,
|
|
269
|
+
MigrateMarketDataVolOracle,
|
|
268
270
|
OmlpCreateVault,
|
|
269
271
|
OmlpUpdateFeeWallet,
|
|
270
272
|
OmlpUpdateInterestModel,
|
|
@@ -516,6 +518,17 @@ export function identifyOptionProgramInstruction(
|
|
|
516
518
|
) {
|
|
517
519
|
return OptionProgramInstruction.MigrateCollateralPoolV1ToV2;
|
|
518
520
|
}
|
|
521
|
+
if (
|
|
522
|
+
containsBytes(
|
|
523
|
+
data,
|
|
524
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
525
|
+
new Uint8Array([230, 102, 218, 98, 194, 231, 97, 241]),
|
|
526
|
+
),
|
|
527
|
+
0,
|
|
528
|
+
)
|
|
529
|
+
) {
|
|
530
|
+
return OptionProgramInstruction.MigrateMarketDataVolOracle;
|
|
531
|
+
}
|
|
519
532
|
if (
|
|
520
533
|
containsBytes(
|
|
521
534
|
data,
|
|
@@ -859,6 +872,9 @@ export type ParsedOptionProgramInstruction<
|
|
|
859
872
|
| ({
|
|
860
873
|
instructionType: OptionProgramInstruction.MigrateCollateralPoolV1ToV2;
|
|
861
874
|
} & ParsedMigrateCollateralPoolV1ToV2Instruction<TProgram>)
|
|
875
|
+
| ({
|
|
876
|
+
instructionType: OptionProgramInstruction.MigrateMarketDataVolOracle;
|
|
877
|
+
} & ParsedMigrateMarketDataVolOracleInstruction<TProgram>)
|
|
862
878
|
| ({
|
|
863
879
|
instructionType: OptionProgramInstruction.OmlpCreateVault;
|
|
864
880
|
} & ParsedOmlpCreateVaultInstruction<TProgram>)
|
package/index.ts
CHANGED
|
@@ -64,6 +64,12 @@ export {
|
|
|
64
64
|
type SwitchboardNetwork,
|
|
65
65
|
} from "./oracle/switchboard";
|
|
66
66
|
|
|
67
|
+
export {
|
|
68
|
+
deriveVolatilityQuoteAddress,
|
|
69
|
+
deriveVolatilityQuoteAddressFromMarketData,
|
|
70
|
+
isVolOracleEnabled,
|
|
71
|
+
} from "./oracle/volatility-quote";
|
|
72
|
+
|
|
67
73
|
export {
|
|
68
74
|
getWrapSOLInstructions,
|
|
69
75
|
getUnwrapSOLInstructions,
|