@epicentral/sos-sdk 0.10.4-beta → 0.10.5-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.
@@ -0,0 +1,415 @@
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
+ getAddressEncoder,
14
+ getBytesDecoder,
15
+ getBytesEncoder,
16
+ getProgramDerivedAddress,
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 {
37
+ expectAddress,
38
+ getAccountMetaFactory,
39
+ type ResolvedAccount,
40
+ } from "../shared";
41
+
42
+ export const PREPARE_MAKER_SETTLEMENT_DISCRIMINATOR = new Uint8Array([
43
+ 95, 202, 211, 28, 194, 177, 121, 39,
44
+ ]);
45
+
46
+ export function getPrepareMakerSettlementDiscriminatorBytes() {
47
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
48
+ PREPARE_MAKER_SETTLEMENT_DISCRIMINATOR,
49
+ );
50
+ }
51
+
52
+ export type PrepareMakerSettlementInstruction<
53
+ TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
54
+ TAccountCollateralPool extends string | AccountMeta<string> = string,
55
+ TAccountOptionAccount extends string | AccountMeta<string> = string,
56
+ TAccountMakerCollateralShare extends string | AccountMeta<string> = string,
57
+ TAccountWriterPosition extends string | AccountMeta<string> = string,
58
+ TAccountMakerSettlementClaim extends string | AccountMeta<string> = string,
59
+ TAccountKeeper extends string | AccountMeta<string> = string,
60
+ TAccountSystemProgram extends string | AccountMeta<string> =
61
+ "11111111111111111111111111111111",
62
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
63
+ > = Instruction<TProgram> &
64
+ InstructionWithData<ReadonlyUint8Array> &
65
+ InstructionWithAccounts<
66
+ [
67
+ TAccountCollateralPool extends string
68
+ ? WritableAccount<TAccountCollateralPool>
69
+ : TAccountCollateralPool,
70
+ TAccountOptionAccount extends string
71
+ ? WritableAccount<TAccountOptionAccount>
72
+ : TAccountOptionAccount,
73
+ TAccountMakerCollateralShare extends string
74
+ ? WritableAccount<TAccountMakerCollateralShare>
75
+ : TAccountMakerCollateralShare,
76
+ TAccountWriterPosition extends string
77
+ ? WritableAccount<TAccountWriterPosition>
78
+ : TAccountWriterPosition,
79
+ TAccountMakerSettlementClaim extends string
80
+ ? WritableAccount<TAccountMakerSettlementClaim>
81
+ : TAccountMakerSettlementClaim,
82
+ TAccountKeeper extends string
83
+ ? WritableSignerAccount<TAccountKeeper> &
84
+ AccountSignerMeta<TAccountKeeper>
85
+ : TAccountKeeper,
86
+ TAccountSystemProgram extends string
87
+ ? ReadonlyAccount<TAccountSystemProgram>
88
+ : TAccountSystemProgram,
89
+ ...TRemainingAccounts,
90
+ ]
91
+ >;
92
+
93
+ export type PrepareMakerSettlementInstructionData = {
94
+ discriminator: ReadonlyUint8Array;
95
+ };
96
+
97
+ export type PrepareMakerSettlementInstructionDataArgs = {};
98
+
99
+ export function getPrepareMakerSettlementInstructionDataEncoder(): FixedSizeEncoder<PrepareMakerSettlementInstructionDataArgs> {
100
+ return transformEncoder(
101
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
102
+ (value) => ({
103
+ ...value,
104
+ discriminator: PREPARE_MAKER_SETTLEMENT_DISCRIMINATOR,
105
+ }),
106
+ );
107
+ }
108
+
109
+ export function getPrepareMakerSettlementInstructionDataDecoder(): FixedSizeDecoder<PrepareMakerSettlementInstructionData> {
110
+ return getStructDecoder([
111
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
112
+ ]);
113
+ }
114
+
115
+ export function getPrepareMakerSettlementInstructionDataCodec(): FixedSizeCodec<
116
+ PrepareMakerSettlementInstructionDataArgs,
117
+ PrepareMakerSettlementInstructionData
118
+ > {
119
+ return combineCodec(
120
+ getPrepareMakerSettlementInstructionDataEncoder(),
121
+ getPrepareMakerSettlementInstructionDataDecoder(),
122
+ );
123
+ }
124
+
125
+ export type PrepareMakerSettlementAsyncInput<
126
+ TAccountCollateralPool extends string = string,
127
+ TAccountOptionAccount extends string = string,
128
+ TAccountMakerCollateralShare extends string = string,
129
+ TAccountWriterPosition extends string = string,
130
+ TAccountMakerSettlementClaim extends string = string,
131
+ TAccountKeeper extends string = string,
132
+ TAccountSystemProgram extends string = string,
133
+ > = {
134
+ collateralPool?: Address<TAccountCollateralPool>;
135
+ optionAccount: Address<TAccountOptionAccount>;
136
+ makerCollateralShare: Address<TAccountMakerCollateralShare>;
137
+ writerPosition: Address<TAccountWriterPosition>;
138
+ makerSettlementClaim?: Address<TAccountMakerSettlementClaim>;
139
+ keeper: TransactionSigner<TAccountKeeper>;
140
+ systemProgram?: Address<TAccountSystemProgram>;
141
+ };
142
+
143
+ export async function getPrepareMakerSettlementInstructionAsync<
144
+ TAccountCollateralPool extends string,
145
+ TAccountOptionAccount extends string,
146
+ TAccountMakerCollateralShare extends string,
147
+ TAccountWriterPosition extends string,
148
+ TAccountMakerSettlementClaim extends string,
149
+ TAccountKeeper extends string,
150
+ TAccountSystemProgram extends string,
151
+ TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
152
+ >(
153
+ input: PrepareMakerSettlementAsyncInput<
154
+ TAccountCollateralPool,
155
+ TAccountOptionAccount,
156
+ TAccountMakerCollateralShare,
157
+ TAccountWriterPosition,
158
+ TAccountMakerSettlementClaim,
159
+ TAccountKeeper,
160
+ TAccountSystemProgram
161
+ >,
162
+ config?: { programAddress?: TProgramAddress },
163
+ ): Promise<
164
+ PrepareMakerSettlementInstruction<
165
+ TProgramAddress,
166
+ TAccountCollateralPool,
167
+ TAccountOptionAccount,
168
+ TAccountMakerCollateralShare,
169
+ TAccountWriterPosition,
170
+ TAccountMakerSettlementClaim,
171
+ TAccountKeeper,
172
+ TAccountSystemProgram
173
+ >
174
+ > {
175
+ // Program address.
176
+ const programAddress =
177
+ config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
178
+
179
+ // Original accounts.
180
+ const originalAccounts = {
181
+ collateralPool: { value: input.collateralPool ?? null, isWritable: true },
182
+ optionAccount: { value: input.optionAccount ?? null, isWritable: true },
183
+ makerCollateralShare: {
184
+ value: input.makerCollateralShare ?? null,
185
+ isWritable: true,
186
+ },
187
+ writerPosition: { value: input.writerPosition ?? null, isWritable: true },
188
+ makerSettlementClaim: {
189
+ value: input.makerSettlementClaim ?? null,
190
+ isWritable: true,
191
+ },
192
+ keeper: { value: input.keeper ?? null, isWritable: true },
193
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
194
+ };
195
+ const accounts = originalAccounts as Record<
196
+ keyof typeof originalAccounts,
197
+ ResolvedAccount
198
+ >;
199
+
200
+ // Resolve default values.
201
+ if (!accounts.collateralPool.value) {
202
+ accounts.collateralPool.value = await getProgramDerivedAddress({
203
+ programAddress,
204
+ seeds: [
205
+ getBytesEncoder().encode(
206
+ new Uint8Array([
207
+ 99, 111, 108, 108, 97, 116, 101, 114, 97, 108, 95, 112, 111, 111,
208
+ 108,
209
+ ]),
210
+ ),
211
+ getAddressEncoder().encode(expectAddress(accounts.optionAccount.value)),
212
+ ],
213
+ });
214
+ }
215
+ if (!accounts.makerSettlementClaim.value) {
216
+ accounts.makerSettlementClaim.value = await getProgramDerivedAddress({
217
+ programAddress,
218
+ seeds: [
219
+ getBytesEncoder().encode(
220
+ new Uint8Array([
221
+ 109, 97, 107, 101, 114, 95, 115, 101, 116, 116, 108, 101, 109, 101,
222
+ 110, 116, 95, 99, 108, 97, 105, 109,
223
+ ]),
224
+ ),
225
+ getAddressEncoder().encode(
226
+ expectAddress(accounts.makerCollateralShare.value),
227
+ ),
228
+ ],
229
+ });
230
+ }
231
+ if (!accounts.systemProgram.value) {
232
+ accounts.systemProgram.value =
233
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
234
+ }
235
+
236
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
237
+ return Object.freeze({
238
+ accounts: [
239
+ getAccountMeta(accounts.collateralPool),
240
+ getAccountMeta(accounts.optionAccount),
241
+ getAccountMeta(accounts.makerCollateralShare),
242
+ getAccountMeta(accounts.writerPosition),
243
+ getAccountMeta(accounts.makerSettlementClaim),
244
+ getAccountMeta(accounts.keeper),
245
+ getAccountMeta(accounts.systemProgram),
246
+ ],
247
+ data: getPrepareMakerSettlementInstructionDataEncoder().encode({}),
248
+ programAddress,
249
+ } as PrepareMakerSettlementInstruction<
250
+ TProgramAddress,
251
+ TAccountCollateralPool,
252
+ TAccountOptionAccount,
253
+ TAccountMakerCollateralShare,
254
+ TAccountWriterPosition,
255
+ TAccountMakerSettlementClaim,
256
+ TAccountKeeper,
257
+ TAccountSystemProgram
258
+ >);
259
+ }
260
+
261
+ export type PrepareMakerSettlementInput<
262
+ TAccountCollateralPool extends string = string,
263
+ TAccountOptionAccount extends string = string,
264
+ TAccountMakerCollateralShare extends string = string,
265
+ TAccountWriterPosition extends string = string,
266
+ TAccountMakerSettlementClaim extends string = string,
267
+ TAccountKeeper extends string = string,
268
+ TAccountSystemProgram extends string = string,
269
+ > = {
270
+ collateralPool: Address<TAccountCollateralPool>;
271
+ optionAccount: Address<TAccountOptionAccount>;
272
+ makerCollateralShare: Address<TAccountMakerCollateralShare>;
273
+ writerPosition: Address<TAccountWriterPosition>;
274
+ makerSettlementClaim: Address<TAccountMakerSettlementClaim>;
275
+ keeper: TransactionSigner<TAccountKeeper>;
276
+ systemProgram?: Address<TAccountSystemProgram>;
277
+ };
278
+
279
+ export function getPrepareMakerSettlementInstruction<
280
+ TAccountCollateralPool extends string,
281
+ TAccountOptionAccount extends string,
282
+ TAccountMakerCollateralShare extends string,
283
+ TAccountWriterPosition extends string,
284
+ TAccountMakerSettlementClaim extends string,
285
+ TAccountKeeper extends string,
286
+ TAccountSystemProgram extends string,
287
+ TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
288
+ >(
289
+ input: PrepareMakerSettlementInput<
290
+ TAccountCollateralPool,
291
+ TAccountOptionAccount,
292
+ TAccountMakerCollateralShare,
293
+ TAccountWriterPosition,
294
+ TAccountMakerSettlementClaim,
295
+ TAccountKeeper,
296
+ TAccountSystemProgram
297
+ >,
298
+ config?: { programAddress?: TProgramAddress },
299
+ ): PrepareMakerSettlementInstruction<
300
+ TProgramAddress,
301
+ TAccountCollateralPool,
302
+ TAccountOptionAccount,
303
+ TAccountMakerCollateralShare,
304
+ TAccountWriterPosition,
305
+ TAccountMakerSettlementClaim,
306
+ TAccountKeeper,
307
+ TAccountSystemProgram
308
+ > {
309
+ // Program address.
310
+ const programAddress =
311
+ config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
312
+
313
+ // Original accounts.
314
+ const originalAccounts = {
315
+ collateralPool: { value: input.collateralPool ?? null, isWritable: true },
316
+ optionAccount: { value: input.optionAccount ?? null, isWritable: true },
317
+ makerCollateralShare: {
318
+ value: input.makerCollateralShare ?? null,
319
+ isWritable: true,
320
+ },
321
+ writerPosition: { value: input.writerPosition ?? null, isWritable: true },
322
+ makerSettlementClaim: {
323
+ value: input.makerSettlementClaim ?? null,
324
+ isWritable: true,
325
+ },
326
+ keeper: { value: input.keeper ?? null, isWritable: true },
327
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
328
+ };
329
+ const accounts = originalAccounts as Record<
330
+ keyof typeof originalAccounts,
331
+ ResolvedAccount
332
+ >;
333
+
334
+ // Resolve default values.
335
+ if (!accounts.systemProgram.value) {
336
+ accounts.systemProgram.value =
337
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
338
+ }
339
+
340
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
341
+ return Object.freeze({
342
+ accounts: [
343
+ getAccountMeta(accounts.collateralPool),
344
+ getAccountMeta(accounts.optionAccount),
345
+ getAccountMeta(accounts.makerCollateralShare),
346
+ getAccountMeta(accounts.writerPosition),
347
+ getAccountMeta(accounts.makerSettlementClaim),
348
+ getAccountMeta(accounts.keeper),
349
+ getAccountMeta(accounts.systemProgram),
350
+ ],
351
+ data: getPrepareMakerSettlementInstructionDataEncoder().encode({}),
352
+ programAddress,
353
+ } as PrepareMakerSettlementInstruction<
354
+ TProgramAddress,
355
+ TAccountCollateralPool,
356
+ TAccountOptionAccount,
357
+ TAccountMakerCollateralShare,
358
+ TAccountWriterPosition,
359
+ TAccountMakerSettlementClaim,
360
+ TAccountKeeper,
361
+ TAccountSystemProgram
362
+ >);
363
+ }
364
+
365
+ export type ParsedPrepareMakerSettlementInstruction<
366
+ TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
367
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
368
+ > = {
369
+ programAddress: Address<TProgram>;
370
+ accounts: {
371
+ collateralPool: TAccountMetas[0];
372
+ optionAccount: TAccountMetas[1];
373
+ makerCollateralShare: TAccountMetas[2];
374
+ writerPosition: TAccountMetas[3];
375
+ makerSettlementClaim: TAccountMetas[4];
376
+ keeper: TAccountMetas[5];
377
+ systemProgram: TAccountMetas[6];
378
+ };
379
+ data: PrepareMakerSettlementInstructionData;
380
+ };
381
+
382
+ export function parsePrepareMakerSettlementInstruction<
383
+ TProgram extends string,
384
+ TAccountMetas extends readonly AccountMeta[],
385
+ >(
386
+ instruction: Instruction<TProgram> &
387
+ InstructionWithAccounts<TAccountMetas> &
388
+ InstructionWithData<ReadonlyUint8Array>,
389
+ ): ParsedPrepareMakerSettlementInstruction<TProgram, TAccountMetas> {
390
+ if (instruction.accounts.length < 7) {
391
+ // TODO: Coded error.
392
+ throw new Error("Not enough accounts");
393
+ }
394
+ let accountIndex = 0;
395
+ const getNextAccount = () => {
396
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
397
+ accountIndex += 1;
398
+ return accountMeta;
399
+ };
400
+ return {
401
+ programAddress: instruction.programAddress,
402
+ accounts: {
403
+ collateralPool: getNextAccount(),
404
+ optionAccount: getNextAccount(),
405
+ makerCollateralShare: getNextAccount(),
406
+ writerPosition: getNextAccount(),
407
+ makerSettlementClaim: getNextAccount(),
408
+ keeper: getNextAccount(),
409
+ systemProgram: getNextAccount(),
410
+ },
411
+ data: getPrepareMakerSettlementInstructionDataDecoder().decode(
412
+ instruction.data,
413
+ ),
414
+ };
415
+ }
@@ -14,12 +14,18 @@ import {
14
14
  type ReadonlyUint8Array,
15
15
  } from "@solana/kit";
16
16
  import {
17
+ parseBuyFromPoolInstruction,
18
+ parseCloseLongToPoolInstruction,
19
+ parseOptionMintInstruction,
20
+ parseUnwindWriterUnsoldInstruction,
17
21
  type ParsedAcceptAdminInstruction,
18
22
  type ParsedAutoExerciseAllExpiredInstruction,
19
23
  type ParsedAutoExerciseExpiredInstruction,
20
24
  type ParsedBorrowFromPoolInstruction,
21
25
  type ParsedBuyFromPoolInstruction,
26
+ type ParsedClaimBuyerSettlementInstruction,
22
27
  type ParsedClaimMakerRemainingInstruction,
28
+ type ParsedClaimMakerSettlementInstruction,
23
29
  type ParsedCloseLongToPoolInstruction,
24
30
  type ParsedCloseOptionInstruction,
25
31
  type ParsedCreateEscrowV2Instruction,
@@ -44,6 +50,8 @@ import {
44
50
  type ParsedOptionExerciseInstruction,
45
51
  type ParsedOptionMintInstruction,
46
52
  type ParsedOptionValidateInstruction,
53
+ type ParsedPrepareBuyerSettlementInstruction,
54
+ type ParsedPrepareMakerSettlementInstruction,
47
55
  type ParsedRepayPoolLoanFromCollateralInstruction,
48
56
  type ParsedRepayPoolLoanFromWalletInstruction,
49
57
  type ParsedRepayPoolLoanInstruction,
@@ -61,11 +69,13 @@ export const OPTION_PROGRAM_PROGRAM_ADDRESS =
61
69
  "AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg" as Address<"AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg">;
62
70
 
63
71
  export enum OptionProgramAccount {
72
+ BuyerSettlementClaim,
64
73
  CollateralPool,
65
74
  Config,
66
75
  EscrowState,
67
76
  LenderPosition,
68
77
  MakerCollateralShare,
78
+ MakerSettlementClaim,
69
79
  MarketDataAccount,
70
80
  OptionAccount,
71
81
  OptionPool,
@@ -79,6 +89,17 @@ export function identifyOptionProgramAccount(
79
89
  account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
80
90
  ): OptionProgramAccount {
81
91
  const data = "data" in account ? account.data : account;
92
+ if (
93
+ containsBytes(
94
+ data,
95
+ fixEncoderSize(getBytesEncoder(), 8).encode(
96
+ new Uint8Array([225, 103, 137, 75, 32, 42, 45, 106]),
97
+ ),
98
+ 0,
99
+ )
100
+ ) {
101
+ return OptionProgramAccount.BuyerSettlementClaim;
102
+ }
82
103
  if (
83
104
  containsBytes(
84
105
  data,
@@ -134,6 +155,17 @@ export function identifyOptionProgramAccount(
134
155
  ) {
135
156
  return OptionProgramAccount.MakerCollateralShare;
136
157
  }
158
+ if (
159
+ containsBytes(
160
+ data,
161
+ fixEncoderSize(getBytesEncoder(), 8).encode(
162
+ new Uint8Array([195, 112, 137, 189, 12, 182, 197, 194]),
163
+ ),
164
+ 0,
165
+ )
166
+ ) {
167
+ return OptionProgramAccount.MakerSettlementClaim;
168
+ }
137
169
  if (
138
170
  containsBytes(
139
171
  data,
@@ -222,7 +254,9 @@ export enum OptionProgramInstruction {
222
254
  AutoExerciseExpired,
223
255
  BorrowFromPool,
224
256
  BuyFromPool,
257
+ ClaimBuyerSettlement,
225
258
  ClaimMakerRemaining,
259
+ ClaimMakerSettlement,
226
260
  CloseLongToPool,
227
261
  CloseOption,
228
262
  CreateEscrowV2,
@@ -247,6 +281,8 @@ export enum OptionProgramInstruction {
247
281
  OptionExercise,
248
282
  OptionMint,
249
283
  OptionValidate,
284
+ PrepareBuyerSettlement,
285
+ PrepareMakerSettlement,
250
286
  RepayPoolLoan,
251
287
  RepayPoolLoanFromCollateral,
252
288
  RepayPoolLoanFromWallet,
@@ -319,6 +355,17 @@ export function identifyOptionProgramInstruction(
319
355
  ) {
320
356
  return OptionProgramInstruction.BuyFromPool;
321
357
  }
358
+ if (
359
+ containsBytes(
360
+ data,
361
+ fixEncoderSize(getBytesEncoder(), 8).encode(
362
+ new Uint8Array([55, 220, 239, 89, 138, 112, 77, 246]),
363
+ ),
364
+ 0,
365
+ )
366
+ ) {
367
+ return OptionProgramInstruction.ClaimBuyerSettlement;
368
+ }
322
369
  if (
323
370
  containsBytes(
324
371
  data,
@@ -330,6 +377,17 @@ export function identifyOptionProgramInstruction(
330
377
  ) {
331
378
  return OptionProgramInstruction.ClaimMakerRemaining;
332
379
  }
380
+ if (
381
+ containsBytes(
382
+ data,
383
+ fixEncoderSize(getBytesEncoder(), 8).encode(
384
+ new Uint8Array([16, 218, 114, 253, 132, 17, 125, 37]),
385
+ ),
386
+ 0,
387
+ )
388
+ ) {
389
+ return OptionProgramInstruction.ClaimMakerSettlement;
390
+ }
333
391
  if (
334
392
  containsBytes(
335
393
  data,
@@ -594,6 +652,28 @@ export function identifyOptionProgramInstruction(
594
652
  ) {
595
653
  return OptionProgramInstruction.OptionValidate;
596
654
  }
655
+ if (
656
+ containsBytes(
657
+ data,
658
+ fixEncoderSize(getBytesEncoder(), 8).encode(
659
+ new Uint8Array([37, 99, 218, 43, 115, 142, 111, 119]),
660
+ ),
661
+ 0,
662
+ )
663
+ ) {
664
+ return OptionProgramInstruction.PrepareBuyerSettlement;
665
+ }
666
+ if (
667
+ containsBytes(
668
+ data,
669
+ fixEncoderSize(getBytesEncoder(), 8).encode(
670
+ new Uint8Array([95, 202, 211, 28, 194, 177, 121, 39]),
671
+ ),
672
+ 0,
673
+ )
674
+ ) {
675
+ return OptionProgramInstruction.PrepareMakerSettlement;
676
+ }
597
677
  if (
598
678
  containsBytes(
599
679
  data,
@@ -738,9 +818,15 @@ export type ParsedOptionProgramInstruction<
738
818
  | ({
739
819
  instructionType: OptionProgramInstruction.BuyFromPool;
740
820
  } & ParsedBuyFromPoolInstruction<TProgram>)
821
+ | ({
822
+ instructionType: OptionProgramInstruction.ClaimBuyerSettlement;
823
+ } & ParsedClaimBuyerSettlementInstruction<TProgram>)
741
824
  | ({
742
825
  instructionType: OptionProgramInstruction.ClaimMakerRemaining;
743
826
  } & ParsedClaimMakerRemainingInstruction<TProgram>)
827
+ | ({
828
+ instructionType: OptionProgramInstruction.ClaimMakerSettlement;
829
+ } & ParsedClaimMakerSettlementInstruction<TProgram>)
744
830
  | ({
745
831
  instructionType: OptionProgramInstruction.CloseLongToPool;
746
832
  } & ParsedCloseLongToPoolInstruction<TProgram>)
@@ -813,6 +899,12 @@ export type ParsedOptionProgramInstruction<
813
899
  | ({
814
900
  instructionType: OptionProgramInstruction.OptionValidate;
815
901
  } & ParsedOptionValidateInstruction<TProgram>)
902
+ | ({
903
+ instructionType: OptionProgramInstruction.PrepareBuyerSettlement;
904
+ } & ParsedPrepareBuyerSettlementInstruction<TProgram>)
905
+ | ({
906
+ instructionType: OptionProgramInstruction.PrepareMakerSettlement;
907
+ } & ParsedPrepareMakerSettlementInstruction<TProgram>)
816
908
  | ({
817
909
  instructionType: OptionProgramInstruction.RepayPoolLoan;
818
910
  } & ParsedRepayPoolLoanInstruction<TProgram>)
@@ -846,3 +938,36 @@ export type ParsedOptionProgramInstruction<
846
938
  | ({
847
939
  instructionType: OptionProgramInstruction.WriteToPool;
848
940
  } & ParsedWriteToPoolInstruction<TProgram>);
941
+
942
+
943
+ export function parseOptionProgramInstruction<
944
+ TProgram extends string = "AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg",
945
+ >(
946
+ instruction: Parameters<typeof parseBuyFromPoolInstruction>[0],
947
+ ): ParsedOptionProgramInstruction<TProgram> {
948
+ const instructionType = identifyOptionProgramInstruction(instruction);
949
+ switch (instructionType) {
950
+ case OptionProgramInstruction.BuyFromPool:
951
+ return {
952
+ instructionType,
953
+ ...parseBuyFromPoolInstruction(instruction),
954
+ } as ParsedOptionProgramInstruction<TProgram>;
955
+ case OptionProgramInstruction.CloseLongToPool:
956
+ return {
957
+ instructionType,
958
+ ...parseCloseLongToPoolInstruction(instruction),
959
+ } as ParsedOptionProgramInstruction<TProgram>;
960
+ case OptionProgramInstruction.OptionMint:
961
+ return {
962
+ instructionType,
963
+ ...parseOptionMintInstruction(instruction),
964
+ } as ParsedOptionProgramInstruction<TProgram>;
965
+ case OptionProgramInstruction.UnwindWriterUnsold:
966
+ return {
967
+ instructionType,
968
+ ...parseUnwindWriterUnsoldInstruction(instruction),
969
+ } as ParsedOptionProgramInstruction<TProgram>;
970
+ default:
971
+ throw new Error("Unsupported optionProgram instruction parser.");
972
+ }
973
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.10.4-beta",
3
+ "version": "0.10.5-beta",
4
4
  "private": false,
5
5
  "description": "Solana Option Standard SDK. The frontend-first SDK for Native Options Trading on Solana. Created by Epicentral Labs.",
6
6
  "type": "module",