@epicentral/sos-sdk 0.9.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.
Files changed (113) hide show
  1. package/.env.example +1 -0
  2. package/AGENTS.md +7 -0
  3. package/LICENSE +21 -0
  4. package/README.md +568 -0
  5. package/accounts/fetchers.ts +196 -0
  6. package/accounts/list.ts +184 -0
  7. package/accounts/pdas.ts +325 -0
  8. package/accounts/resolve-option.ts +104 -0
  9. package/client/lookup-table.ts +114 -0
  10. package/client/program.ts +13 -0
  11. package/client/types.ts +9 -0
  12. package/generated/accounts/collateralPool.ts +217 -0
  13. package/generated/accounts/config.ts +156 -0
  14. package/generated/accounts/escrowState.ts +183 -0
  15. package/generated/accounts/index.ts +20 -0
  16. package/generated/accounts/lenderPosition.ts +211 -0
  17. package/generated/accounts/makerCollateralShare.ts +229 -0
  18. package/generated/accounts/marketDataAccount.ts +176 -0
  19. package/generated/accounts/optionAccount.ts +247 -0
  20. package/generated/accounts/optionPool.ts +285 -0
  21. package/generated/accounts/poolLoan.ts +232 -0
  22. package/generated/accounts/positionAccount.ts +201 -0
  23. package/generated/accounts/vault.ts +366 -0
  24. package/generated/accounts/writerPosition.ts +327 -0
  25. package/generated/errors/index.ts +9 -0
  26. package/generated/errors/optionProgram.ts +476 -0
  27. package/generated/index.ts +13 -0
  28. package/generated/instructions/acceptAdmin.ts +230 -0
  29. package/generated/instructions/autoExerciseAllExpired.ts +685 -0
  30. package/generated/instructions/autoExerciseExpired.ts +754 -0
  31. package/generated/instructions/borrowFromPool.ts +619 -0
  32. package/generated/instructions/buyFromPool.ts +761 -0
  33. package/generated/instructions/closeLongToPool.ts +762 -0
  34. package/generated/instructions/closeOption.ts +235 -0
  35. package/generated/instructions/createEscrowV2.ts +518 -0
  36. package/generated/instructions/depositCollateral.ts +624 -0
  37. package/generated/instructions/depositToPosition.ts +429 -0
  38. package/generated/instructions/index.ts +47 -0
  39. package/generated/instructions/initCollateralPool.ts +513 -0
  40. package/generated/instructions/initConfig.ts +279 -0
  41. package/generated/instructions/initOptionPool.ts +587 -0
  42. package/generated/instructions/initializeMarketData.ts +359 -0
  43. package/generated/instructions/liquidateWriterPosition.ts +750 -0
  44. package/generated/instructions/liquidateWriterPositionRescue.ts +623 -0
  45. package/generated/instructions/omlpCreateVault.ts +553 -0
  46. package/generated/instructions/omlpUpdateFeeWallet.ts +473 -0
  47. package/generated/instructions/omlpUpdateInterestModel.ts +322 -0
  48. package/generated/instructions/omlpUpdateLiquidationThreshold.ts +304 -0
  49. package/generated/instructions/omlpUpdateMaintenanceBuffer.ts +304 -0
  50. package/generated/instructions/omlpUpdateMaxBorrowCap.ts +304 -0
  51. package/generated/instructions/omlpUpdateMaxLeverage.ts +304 -0
  52. package/generated/instructions/omlpUpdateProtocolFee.ts +304 -0
  53. package/generated/instructions/omlpUpdateSupplyLimit.ts +304 -0
  54. package/generated/instructions/optionExercise.ts +617 -0
  55. package/generated/instructions/optionMint.ts +1373 -0
  56. package/generated/instructions/optionValidate.ts +302 -0
  57. package/generated/instructions/repayPoolLoan.ts +558 -0
  58. package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
  59. package/generated/instructions/repayPoolLoanFromWallet.ts +542 -0
  60. package/generated/instructions/settleMakerCollateral.ts +509 -0
  61. package/generated/instructions/syncWriterPosition.ts +206 -0
  62. package/generated/instructions/transferAdmin.ts +245 -0
  63. package/generated/instructions/unwindWriterUnsold.ts +764 -0
  64. package/generated/instructions/updateImpliedVolatility.ts +226 -0
  65. package/generated/instructions/updateMarketData.ts +315 -0
  66. package/generated/instructions/withdrawFromPosition.ts +405 -0
  67. package/generated/instructions/writeToPool.ts +619 -0
  68. package/generated/programs/index.ts +9 -0
  69. package/generated/programs/optionProgram.ts +1144 -0
  70. package/generated/shared/index.ts +164 -0
  71. package/generated/types/impliedVolatilityUpdated.ts +73 -0
  72. package/generated/types/index.ts +28 -0
  73. package/generated/types/liquidationExecuted.ts +73 -0
  74. package/generated/types/liquidationRescueEvent.ts +82 -0
  75. package/generated/types/marketDataInitialized.ts +61 -0
  76. package/generated/types/marketDataUpdated.ts +69 -0
  77. package/generated/types/optionClosed.ts +56 -0
  78. package/generated/types/optionExercised.ts +62 -0
  79. package/generated/types/optionExpired.ts +49 -0
  80. package/generated/types/optionMinted.ts +78 -0
  81. package/generated/types/optionType.ts +38 -0
  82. package/generated/types/optionValidated.ts +82 -0
  83. package/generated/types/poolLoanCreated.ts +74 -0
  84. package/generated/types/poolLoanRepaid.ts +74 -0
  85. package/generated/types/positionDeposited.ts +73 -0
  86. package/generated/types/positionWithdrawn.ts +81 -0
  87. package/generated/types/protocolFeeUpdated.ts +69 -0
  88. package/generated/types/vaultCreated.ts +60 -0
  89. package/generated/types/vaultFeeWalletUpdated.ts +67 -0
  90. package/generated/types/vaultInterestModelUpdated.ts +77 -0
  91. package/generated/types/vaultLiquidationThresholdUpdated.ts +69 -0
  92. package/index.ts +68 -0
  93. package/long/builders.ts +690 -0
  94. package/long/exercise.ts +123 -0
  95. package/long/preflight.ts +214 -0
  96. package/long/quotes.ts +48 -0
  97. package/long/remaining-accounts.ts +111 -0
  98. package/omlp/builders.ts +94 -0
  99. package/omlp/service.ts +136 -0
  100. package/oracle/switchboard.ts +315 -0
  101. package/package.json +34 -0
  102. package/shared/amounts.ts +53 -0
  103. package/shared/balances.ts +57 -0
  104. package/shared/errors.ts +12 -0
  105. package/shared/remaining-accounts.ts +41 -0
  106. package/shared/trade-config.ts +27 -0
  107. package/shared/transactions.ts +121 -0
  108. package/short/builders.ts +874 -0
  109. package/short/close-option.ts +34 -0
  110. package/short/pool.ts +189 -0
  111. package/short/preflight.ts +619 -0
  112. package/tsconfig.json +13 -0
  113. package/wsol/instructions.ts +247 -0
@@ -0,0 +1,1144 @@
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
+ assertIsInstructionWithAccounts,
11
+ containsBytes,
12
+ fixEncoderSize,
13
+ getBytesEncoder,
14
+ type Address,
15
+ type Instruction,
16
+ type InstructionWithData,
17
+ type ReadonlyUint8Array,
18
+ } from "@solana/kit";
19
+ import {
20
+ parseAcceptAdminInstruction,
21
+ parseAutoExerciseAllExpiredInstruction,
22
+ parseAutoExerciseExpiredInstruction,
23
+ parseBorrowFromPoolInstruction,
24
+ parseBuyFromPoolInstruction,
25
+ parseCloseLongToPoolInstruction,
26
+ parseCloseOptionInstruction,
27
+ parseCreateEscrowV2Instruction,
28
+ parseDepositCollateralInstruction,
29
+ parseDepositToPositionInstruction,
30
+ parseInitCollateralPoolInstruction,
31
+ parseInitConfigInstruction,
32
+ parseInitializeMarketDataInstruction,
33
+ parseInitOptionPoolInstruction,
34
+ parseLiquidateWriterPositionInstruction,
35
+ parseLiquidateWriterPositionRescueInstruction,
36
+ parseOmlpCreateVaultInstruction,
37
+ parseOmlpUpdateFeeWalletInstruction,
38
+ parseOmlpUpdateInterestModelInstruction,
39
+ parseOmlpUpdateLiquidationThresholdInstruction,
40
+ parseOmlpUpdateMaintenanceBufferInstruction,
41
+ parseOmlpUpdateMaxBorrowCapInstruction,
42
+ parseOmlpUpdateMaxLeverageInstruction,
43
+ parseOmlpUpdateProtocolFeeInstruction,
44
+ parseOmlpUpdateSupplyLimitInstruction,
45
+ parseOptionExerciseInstruction,
46
+ parseOptionMintInstruction,
47
+ parseOptionValidateInstruction,
48
+ parseRepayPoolLoanFromCollateralInstruction,
49
+ parseRepayPoolLoanFromWalletInstruction,
50
+ parseRepayPoolLoanInstruction,
51
+ parseSettleMakerCollateralInstruction,
52
+ parseSyncWriterPositionInstruction,
53
+ parseTransferAdminInstruction,
54
+ parseUnwindWriterUnsoldInstruction,
55
+ parseUpdateImpliedVolatilityInstruction,
56
+ parseUpdateMarketDataInstruction,
57
+ parseWithdrawFromPositionInstruction,
58
+ parseWriteToPoolInstruction,
59
+ type ParsedAcceptAdminInstruction,
60
+ type ParsedAutoExerciseAllExpiredInstruction,
61
+ type ParsedAutoExerciseExpiredInstruction,
62
+ type ParsedBorrowFromPoolInstruction,
63
+ type ParsedBuyFromPoolInstruction,
64
+ type ParsedCloseLongToPoolInstruction,
65
+ type ParsedCloseOptionInstruction,
66
+ type ParsedCreateEscrowV2Instruction,
67
+ type ParsedDepositCollateralInstruction,
68
+ type ParsedDepositToPositionInstruction,
69
+ type ParsedInitCollateralPoolInstruction,
70
+ type ParsedInitConfigInstruction,
71
+ type ParsedInitializeMarketDataInstruction,
72
+ type ParsedInitOptionPoolInstruction,
73
+ type ParsedLiquidateWriterPositionInstruction,
74
+ type ParsedLiquidateWriterPositionRescueInstruction,
75
+ type ParsedOmlpCreateVaultInstruction,
76
+ type ParsedOmlpUpdateFeeWalletInstruction,
77
+ type ParsedOmlpUpdateInterestModelInstruction,
78
+ type ParsedOmlpUpdateLiquidationThresholdInstruction,
79
+ type ParsedOmlpUpdateMaintenanceBufferInstruction,
80
+ type ParsedOmlpUpdateMaxBorrowCapInstruction,
81
+ type ParsedOmlpUpdateMaxLeverageInstruction,
82
+ type ParsedOmlpUpdateProtocolFeeInstruction,
83
+ type ParsedOmlpUpdateSupplyLimitInstruction,
84
+ type ParsedOptionExerciseInstruction,
85
+ type ParsedOptionMintInstruction,
86
+ type ParsedOptionValidateInstruction,
87
+ type ParsedRepayPoolLoanFromCollateralInstruction,
88
+ type ParsedRepayPoolLoanFromWalletInstruction,
89
+ type ParsedRepayPoolLoanInstruction,
90
+ type ParsedSettleMakerCollateralInstruction,
91
+ type ParsedSyncWriterPositionInstruction,
92
+ type ParsedTransferAdminInstruction,
93
+ type ParsedUnwindWriterUnsoldInstruction,
94
+ type ParsedUpdateImpliedVolatilityInstruction,
95
+ type ParsedUpdateMarketDataInstruction,
96
+ type ParsedWithdrawFromPositionInstruction,
97
+ type ParsedWriteToPoolInstruction,
98
+ } from "../instructions";
99
+
100
+ export const OPTION_PROGRAM_PROGRAM_ADDRESS =
101
+ "AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg" as Address<"AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg">;
102
+
103
+ export enum OptionProgramAccount {
104
+ CollateralPool,
105
+ Config,
106
+ EscrowState,
107
+ LenderPosition,
108
+ MakerCollateralShare,
109
+ MarketDataAccount,
110
+ OptionAccount,
111
+ OptionPool,
112
+ PoolLoan,
113
+ PositionAccount,
114
+ Vault,
115
+ WriterPosition,
116
+ }
117
+
118
+ export function identifyOptionProgramAccount(
119
+ account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
120
+ ): OptionProgramAccount {
121
+ const data = "data" in account ? account.data : account;
122
+ if (
123
+ containsBytes(
124
+ data,
125
+ fixEncoderSize(getBytesEncoder(), 8).encode(
126
+ new Uint8Array([186, 4, 253, 240, 93, 243, 212, 195]),
127
+ ),
128
+ 0,
129
+ )
130
+ ) {
131
+ return OptionProgramAccount.CollateralPool;
132
+ }
133
+ if (
134
+ containsBytes(
135
+ data,
136
+ fixEncoderSize(getBytesEncoder(), 8).encode(
137
+ new Uint8Array([155, 12, 170, 224, 30, 250, 204, 130]),
138
+ ),
139
+ 0,
140
+ )
141
+ ) {
142
+ return OptionProgramAccount.Config;
143
+ }
144
+ if (
145
+ containsBytes(
146
+ data,
147
+ fixEncoderSize(getBytesEncoder(), 8).encode(
148
+ new Uint8Array([19, 90, 148, 111, 55, 130, 229, 108]),
149
+ ),
150
+ 0,
151
+ )
152
+ ) {
153
+ return OptionProgramAccount.EscrowState;
154
+ }
155
+ if (
156
+ containsBytes(
157
+ data,
158
+ fixEncoderSize(getBytesEncoder(), 8).encode(
159
+ new Uint8Array([165, 98, 244, 204, 209, 158, 88, 19]),
160
+ ),
161
+ 0,
162
+ )
163
+ ) {
164
+ return OptionProgramAccount.LenderPosition;
165
+ }
166
+ if (
167
+ containsBytes(
168
+ data,
169
+ fixEncoderSize(getBytesEncoder(), 8).encode(
170
+ new Uint8Array([44, 113, 163, 132, 92, 188, 13, 158]),
171
+ ),
172
+ 0,
173
+ )
174
+ ) {
175
+ return OptionProgramAccount.MakerCollateralShare;
176
+ }
177
+ if (
178
+ containsBytes(
179
+ data,
180
+ fixEncoderSize(getBytesEncoder(), 8).encode(
181
+ new Uint8Array([181, 15, 209, 146, 116, 22, 98, 208]),
182
+ ),
183
+ 0,
184
+ )
185
+ ) {
186
+ return OptionProgramAccount.MarketDataAccount;
187
+ }
188
+ if (
189
+ containsBytes(
190
+ data,
191
+ fixEncoderSize(getBytesEncoder(), 8).encode(
192
+ new Uint8Array([82, 44, 195, 42, 219, 57, 18, 92]),
193
+ ),
194
+ 0,
195
+ )
196
+ ) {
197
+ return OptionProgramAccount.OptionAccount;
198
+ }
199
+ if (
200
+ containsBytes(
201
+ data,
202
+ fixEncoderSize(getBytesEncoder(), 8).encode(
203
+ new Uint8Array([100, 175, 136, 125, 88, 244, 169, 209]),
204
+ ),
205
+ 0,
206
+ )
207
+ ) {
208
+ return OptionProgramAccount.OptionPool;
209
+ }
210
+ if (
211
+ containsBytes(
212
+ data,
213
+ fixEncoderSize(getBytesEncoder(), 8).encode(
214
+ new Uint8Array([31, 179, 93, 157, 68, 113, 2, 128]),
215
+ ),
216
+ 0,
217
+ )
218
+ ) {
219
+ return OptionProgramAccount.PoolLoan;
220
+ }
221
+ if (
222
+ containsBytes(
223
+ data,
224
+ fixEncoderSize(getBytesEncoder(), 8).encode(
225
+ new Uint8Array([60, 125, 250, 193, 181, 109, 238, 86]),
226
+ ),
227
+ 0,
228
+ )
229
+ ) {
230
+ return OptionProgramAccount.PositionAccount;
231
+ }
232
+ if (
233
+ containsBytes(
234
+ data,
235
+ fixEncoderSize(getBytesEncoder(), 8).encode(
236
+ new Uint8Array([211, 8, 232, 43, 2, 152, 117, 119]),
237
+ ),
238
+ 0,
239
+ )
240
+ ) {
241
+ return OptionProgramAccount.Vault;
242
+ }
243
+ if (
244
+ containsBytes(
245
+ data,
246
+ fixEncoderSize(getBytesEncoder(), 8).encode(
247
+ new Uint8Array([195, 252, 56, 77, 221, 13, 8, 69]),
248
+ ),
249
+ 0,
250
+ )
251
+ ) {
252
+ return OptionProgramAccount.WriterPosition;
253
+ }
254
+ throw new Error(
255
+ "The provided account could not be identified as a optionProgram account.",
256
+ );
257
+ }
258
+
259
+ export enum OptionProgramInstruction {
260
+ AcceptAdmin,
261
+ AutoExerciseAllExpired,
262
+ AutoExerciseExpired,
263
+ BorrowFromPool,
264
+ BuyFromPool,
265
+ CloseLongToPool,
266
+ CloseOption,
267
+ CreateEscrowV2,
268
+ DepositCollateral,
269
+ DepositToPosition,
270
+ InitCollateralPool,
271
+ InitConfig,
272
+ InitOptionPool,
273
+ InitializeMarketData,
274
+ LiquidateWriterPosition,
275
+ LiquidateWriterPositionRescue,
276
+ OmlpCreateVault,
277
+ OmlpUpdateFeeWallet,
278
+ OmlpUpdateInterestModel,
279
+ OmlpUpdateLiquidationThreshold,
280
+ OmlpUpdateMaintenanceBuffer,
281
+ OmlpUpdateMaxBorrowCap,
282
+ OmlpUpdateMaxLeverage,
283
+ OmlpUpdateProtocolFee,
284
+ OmlpUpdateSupplyLimit,
285
+ OptionExercise,
286
+ OptionMint,
287
+ OptionValidate,
288
+ RepayPoolLoan,
289
+ RepayPoolLoanFromCollateral,
290
+ RepayPoolLoanFromWallet,
291
+ SettleMakerCollateral,
292
+ SyncWriterPosition,
293
+ TransferAdmin,
294
+ UnwindWriterUnsold,
295
+ UpdateImpliedVolatility,
296
+ UpdateMarketData,
297
+ WithdrawFromPosition,
298
+ WriteToPool,
299
+ }
300
+
301
+ export function identifyOptionProgramInstruction(
302
+ instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
303
+ ): OptionProgramInstruction {
304
+ const data = "data" in instruction ? instruction.data : instruction;
305
+ if (
306
+ containsBytes(
307
+ data,
308
+ fixEncoderSize(getBytesEncoder(), 8).encode(
309
+ new Uint8Array([112, 42, 45, 90, 116, 181, 13, 170]),
310
+ ),
311
+ 0,
312
+ )
313
+ ) {
314
+ return OptionProgramInstruction.AcceptAdmin;
315
+ }
316
+ if (
317
+ containsBytes(
318
+ data,
319
+ fixEncoderSize(getBytesEncoder(), 8).encode(
320
+ new Uint8Array([114, 241, 93, 137, 214, 147, 43, 57]),
321
+ ),
322
+ 0,
323
+ )
324
+ ) {
325
+ return OptionProgramInstruction.AutoExerciseAllExpired;
326
+ }
327
+ if (
328
+ containsBytes(
329
+ data,
330
+ fixEncoderSize(getBytesEncoder(), 8).encode(
331
+ new Uint8Array([93, 222, 81, 8, 181, 25, 68, 25]),
332
+ ),
333
+ 0,
334
+ )
335
+ ) {
336
+ return OptionProgramInstruction.AutoExerciseExpired;
337
+ }
338
+ if (
339
+ containsBytes(
340
+ data,
341
+ fixEncoderSize(getBytesEncoder(), 8).encode(
342
+ new Uint8Array([186, 246, 186, 247, 84, 17, 148, 182]),
343
+ ),
344
+ 0,
345
+ )
346
+ ) {
347
+ return OptionProgramInstruction.BorrowFromPool;
348
+ }
349
+ if (
350
+ containsBytes(
351
+ data,
352
+ fixEncoderSize(getBytesEncoder(), 8).encode(
353
+ new Uint8Array([118, 108, 243, 198, 19, 184, 41, 246]),
354
+ ),
355
+ 0,
356
+ )
357
+ ) {
358
+ return OptionProgramInstruction.BuyFromPool;
359
+ }
360
+ if (
361
+ containsBytes(
362
+ data,
363
+ fixEncoderSize(getBytesEncoder(), 8).encode(
364
+ new Uint8Array([72, 117, 94, 238, 111, 113, 243, 91]),
365
+ ),
366
+ 0,
367
+ )
368
+ ) {
369
+ return OptionProgramInstruction.CloseLongToPool;
370
+ }
371
+ if (
372
+ containsBytes(
373
+ data,
374
+ fixEncoderSize(getBytesEncoder(), 8).encode(
375
+ new Uint8Array([138, 79, 53, 54, 221, 16, 109, 141]),
376
+ ),
377
+ 0,
378
+ )
379
+ ) {
380
+ return OptionProgramInstruction.CloseOption;
381
+ }
382
+ if (
383
+ containsBytes(
384
+ data,
385
+ fixEncoderSize(getBytesEncoder(), 8).encode(
386
+ new Uint8Array([235, 71, 10, 36, 206, 55, 150, 187]),
387
+ ),
388
+ 0,
389
+ )
390
+ ) {
391
+ return OptionProgramInstruction.CreateEscrowV2;
392
+ }
393
+ if (
394
+ containsBytes(
395
+ data,
396
+ fixEncoderSize(getBytesEncoder(), 8).encode(
397
+ new Uint8Array([156, 131, 142, 116, 146, 247, 162, 120]),
398
+ ),
399
+ 0,
400
+ )
401
+ ) {
402
+ return OptionProgramInstruction.DepositCollateral;
403
+ }
404
+ if (
405
+ containsBytes(
406
+ data,
407
+ fixEncoderSize(getBytesEncoder(), 8).encode(
408
+ new Uint8Array([4, 236, 119, 21, 20, 228, 104, 139]),
409
+ ),
410
+ 0,
411
+ )
412
+ ) {
413
+ return OptionProgramInstruction.DepositToPosition;
414
+ }
415
+ if (
416
+ containsBytes(
417
+ data,
418
+ fixEncoderSize(getBytesEncoder(), 8).encode(
419
+ new Uint8Array([76, 233, 1, 25, 52, 227, 208, 101]),
420
+ ),
421
+ 0,
422
+ )
423
+ ) {
424
+ return OptionProgramInstruction.InitCollateralPool;
425
+ }
426
+ if (
427
+ containsBytes(
428
+ data,
429
+ fixEncoderSize(getBytesEncoder(), 8).encode(
430
+ new Uint8Array([23, 235, 115, 232, 168, 96, 1, 231]),
431
+ ),
432
+ 0,
433
+ )
434
+ ) {
435
+ return OptionProgramInstruction.InitConfig;
436
+ }
437
+ if (
438
+ containsBytes(
439
+ data,
440
+ fixEncoderSize(getBytesEncoder(), 8).encode(
441
+ new Uint8Array([204, 113, 12, 141, 240, 219, 74, 220]),
442
+ ),
443
+ 0,
444
+ )
445
+ ) {
446
+ return OptionProgramInstruction.InitOptionPool;
447
+ }
448
+ if (
449
+ containsBytes(
450
+ data,
451
+ fixEncoderSize(getBytesEncoder(), 8).encode(
452
+ new Uint8Array([250, 21, 97, 28, 194, 42, 173, 236]),
453
+ ),
454
+ 0,
455
+ )
456
+ ) {
457
+ return OptionProgramInstruction.InitializeMarketData;
458
+ }
459
+ if (
460
+ containsBytes(
461
+ data,
462
+ fixEncoderSize(getBytesEncoder(), 8).encode(
463
+ new Uint8Array([184, 117, 16, 217, 120, 32, 16, 63]),
464
+ ),
465
+ 0,
466
+ )
467
+ ) {
468
+ return OptionProgramInstruction.LiquidateWriterPosition;
469
+ }
470
+ if (
471
+ containsBytes(
472
+ data,
473
+ fixEncoderSize(getBytesEncoder(), 8).encode(
474
+ new Uint8Array([210, 74, 45, 13, 187, 151, 90, 190]),
475
+ ),
476
+ 0,
477
+ )
478
+ ) {
479
+ return OptionProgramInstruction.LiquidateWriterPositionRescue;
480
+ }
481
+ if (
482
+ containsBytes(
483
+ data,
484
+ fixEncoderSize(getBytesEncoder(), 8).encode(
485
+ new Uint8Array([129, 63, 75, 202, 228, 221, 137, 221]),
486
+ ),
487
+ 0,
488
+ )
489
+ ) {
490
+ return OptionProgramInstruction.OmlpCreateVault;
491
+ }
492
+ if (
493
+ containsBytes(
494
+ data,
495
+ fixEncoderSize(getBytesEncoder(), 8).encode(
496
+ new Uint8Array([94, 66, 39, 241, 66, 246, 217, 92]),
497
+ ),
498
+ 0,
499
+ )
500
+ ) {
501
+ return OptionProgramInstruction.OmlpUpdateFeeWallet;
502
+ }
503
+ if (
504
+ containsBytes(
505
+ data,
506
+ fixEncoderSize(getBytesEncoder(), 8).encode(
507
+ new Uint8Array([193, 229, 132, 59, 147, 33, 181, 14]),
508
+ ),
509
+ 0,
510
+ )
511
+ ) {
512
+ return OptionProgramInstruction.OmlpUpdateInterestModel;
513
+ }
514
+ if (
515
+ containsBytes(
516
+ data,
517
+ fixEncoderSize(getBytesEncoder(), 8).encode(
518
+ new Uint8Array([196, 59, 136, 47, 38, 158, 76, 232]),
519
+ ),
520
+ 0,
521
+ )
522
+ ) {
523
+ return OptionProgramInstruction.OmlpUpdateLiquidationThreshold;
524
+ }
525
+ if (
526
+ containsBytes(
527
+ data,
528
+ fixEncoderSize(getBytesEncoder(), 8).encode(
529
+ new Uint8Array([101, 100, 162, 212, 169, 40, 40, 101]),
530
+ ),
531
+ 0,
532
+ )
533
+ ) {
534
+ return OptionProgramInstruction.OmlpUpdateMaintenanceBuffer;
535
+ }
536
+ if (
537
+ containsBytes(
538
+ data,
539
+ fixEncoderSize(getBytesEncoder(), 8).encode(
540
+ new Uint8Array([156, 196, 135, 28, 127, 162, 101, 52]),
541
+ ),
542
+ 0,
543
+ )
544
+ ) {
545
+ return OptionProgramInstruction.OmlpUpdateMaxBorrowCap;
546
+ }
547
+ if (
548
+ containsBytes(
549
+ data,
550
+ fixEncoderSize(getBytesEncoder(), 8).encode(
551
+ new Uint8Array([108, 142, 71, 44, 21, 120, 202, 28]),
552
+ ),
553
+ 0,
554
+ )
555
+ ) {
556
+ return OptionProgramInstruction.OmlpUpdateMaxLeverage;
557
+ }
558
+ if (
559
+ containsBytes(
560
+ data,
561
+ fixEncoderSize(getBytesEncoder(), 8).encode(
562
+ new Uint8Array([41, 17, 189, 37, 78, 53, 240, 52]),
563
+ ),
564
+ 0,
565
+ )
566
+ ) {
567
+ return OptionProgramInstruction.OmlpUpdateProtocolFee;
568
+ }
569
+ if (
570
+ containsBytes(
571
+ data,
572
+ fixEncoderSize(getBytesEncoder(), 8).encode(
573
+ new Uint8Array([38, 178, 193, 188, 127, 170, 122, 42]),
574
+ ),
575
+ 0,
576
+ )
577
+ ) {
578
+ return OptionProgramInstruction.OmlpUpdateSupplyLimit;
579
+ }
580
+ if (
581
+ containsBytes(
582
+ data,
583
+ fixEncoderSize(getBytesEncoder(), 8).encode(
584
+ new Uint8Array([43, 86, 237, 78, 235, 74, 131, 206]),
585
+ ),
586
+ 0,
587
+ )
588
+ ) {
589
+ return OptionProgramInstruction.OptionExercise;
590
+ }
591
+ if (
592
+ containsBytes(
593
+ data,
594
+ fixEncoderSize(getBytesEncoder(), 8).encode(
595
+ new Uint8Array([210, 192, 217, 89, 138, 0, 94, 90]),
596
+ ),
597
+ 0,
598
+ )
599
+ ) {
600
+ return OptionProgramInstruction.OptionMint;
601
+ }
602
+ if (
603
+ containsBytes(
604
+ data,
605
+ fixEncoderSize(getBytesEncoder(), 8).encode(
606
+ new Uint8Array([67, 10, 20, 254, 66, 53, 251, 6]),
607
+ ),
608
+ 0,
609
+ )
610
+ ) {
611
+ return OptionProgramInstruction.OptionValidate;
612
+ }
613
+ if (
614
+ containsBytes(
615
+ data,
616
+ fixEncoderSize(getBytesEncoder(), 8).encode(
617
+ new Uint8Array([166, 161, 84, 231, 244, 103, 63, 224]),
618
+ ),
619
+ 0,
620
+ )
621
+ ) {
622
+ return OptionProgramInstruction.RepayPoolLoan;
623
+ }
624
+ if (
625
+ containsBytes(
626
+ data,
627
+ fixEncoderSize(getBytesEncoder(), 8).encode(
628
+ new Uint8Array([213, 59, 182, 125, 195, 39, 67, 33]),
629
+ ),
630
+ 0,
631
+ )
632
+ ) {
633
+ return OptionProgramInstruction.RepayPoolLoanFromCollateral;
634
+ }
635
+ if (
636
+ containsBytes(
637
+ data,
638
+ fixEncoderSize(getBytesEncoder(), 8).encode(
639
+ new Uint8Array([78, 130, 135, 90, 211, 21, 247, 247]),
640
+ ),
641
+ 0,
642
+ )
643
+ ) {
644
+ return OptionProgramInstruction.RepayPoolLoanFromWallet;
645
+ }
646
+ if (
647
+ containsBytes(
648
+ data,
649
+ fixEncoderSize(getBytesEncoder(), 8).encode(
650
+ new Uint8Array([47, 169, 97, 199, 29, 197, 115, 148]),
651
+ ),
652
+ 0,
653
+ )
654
+ ) {
655
+ return OptionProgramInstruction.SettleMakerCollateral;
656
+ }
657
+ if (
658
+ containsBytes(
659
+ data,
660
+ fixEncoderSize(getBytesEncoder(), 8).encode(
661
+ new Uint8Array([57, 19, 103, 217, 187, 66, 3, 4]),
662
+ ),
663
+ 0,
664
+ )
665
+ ) {
666
+ return OptionProgramInstruction.SyncWriterPosition;
667
+ }
668
+ if (
669
+ containsBytes(
670
+ data,
671
+ fixEncoderSize(getBytesEncoder(), 8).encode(
672
+ new Uint8Array([42, 242, 66, 106, 228, 10, 111, 156]),
673
+ ),
674
+ 0,
675
+ )
676
+ ) {
677
+ return OptionProgramInstruction.TransferAdmin;
678
+ }
679
+ if (
680
+ containsBytes(
681
+ data,
682
+ fixEncoderSize(getBytesEncoder(), 8).encode(
683
+ new Uint8Array([48, 116, 34, 53, 22, 225, 22, 79]),
684
+ ),
685
+ 0,
686
+ )
687
+ ) {
688
+ return OptionProgramInstruction.UnwindWriterUnsold;
689
+ }
690
+ if (
691
+ containsBytes(
692
+ data,
693
+ fixEncoderSize(getBytesEncoder(), 8).encode(
694
+ new Uint8Array([73, 16, 245, 77, 198, 16, 17, 11]),
695
+ ),
696
+ 0,
697
+ )
698
+ ) {
699
+ return OptionProgramInstruction.UpdateImpliedVolatility;
700
+ }
701
+ if (
702
+ containsBytes(
703
+ data,
704
+ fixEncoderSize(getBytesEncoder(), 8).encode(
705
+ new Uint8Array([38, 27, 206, 55, 6, 151, 187, 10]),
706
+ ),
707
+ 0,
708
+ )
709
+ ) {
710
+ return OptionProgramInstruction.UpdateMarketData;
711
+ }
712
+ if (
713
+ containsBytes(
714
+ data,
715
+ fixEncoderSize(getBytesEncoder(), 8).encode(
716
+ new Uint8Array([39, 178, 255, 108, 24, 150, 180, 238]),
717
+ ),
718
+ 0,
719
+ )
720
+ ) {
721
+ return OptionProgramInstruction.WithdrawFromPosition;
722
+ }
723
+ if (
724
+ containsBytes(
725
+ data,
726
+ fixEncoderSize(getBytesEncoder(), 8).encode(
727
+ new Uint8Array([169, 94, 104, 228, 81, 205, 147, 71]),
728
+ ),
729
+ 0,
730
+ )
731
+ ) {
732
+ return OptionProgramInstruction.WriteToPool;
733
+ }
734
+ throw new Error(
735
+ "The provided instruction could not be identified as a optionProgram instruction.",
736
+ );
737
+ }
738
+
739
+ export type ParsedOptionProgramInstruction<
740
+ TProgram extends string = "AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg",
741
+ > =
742
+ | ({
743
+ instructionType: OptionProgramInstruction.AcceptAdmin;
744
+ } & ParsedAcceptAdminInstruction<TProgram>)
745
+ | ({
746
+ instructionType: OptionProgramInstruction.AutoExerciseAllExpired;
747
+ } & ParsedAutoExerciseAllExpiredInstruction<TProgram>)
748
+ | ({
749
+ instructionType: OptionProgramInstruction.AutoExerciseExpired;
750
+ } & ParsedAutoExerciseExpiredInstruction<TProgram>)
751
+ | ({
752
+ instructionType: OptionProgramInstruction.BorrowFromPool;
753
+ } & ParsedBorrowFromPoolInstruction<TProgram>)
754
+ | ({
755
+ instructionType: OptionProgramInstruction.BuyFromPool;
756
+ } & ParsedBuyFromPoolInstruction<TProgram>)
757
+ | ({
758
+ instructionType: OptionProgramInstruction.CloseLongToPool;
759
+ } & ParsedCloseLongToPoolInstruction<TProgram>)
760
+ | ({
761
+ instructionType: OptionProgramInstruction.CloseOption;
762
+ } & ParsedCloseOptionInstruction<TProgram>)
763
+ | ({
764
+ instructionType: OptionProgramInstruction.CreateEscrowV2;
765
+ } & ParsedCreateEscrowV2Instruction<TProgram>)
766
+ | ({
767
+ instructionType: OptionProgramInstruction.DepositCollateral;
768
+ } & ParsedDepositCollateralInstruction<TProgram>)
769
+ | ({
770
+ instructionType: OptionProgramInstruction.DepositToPosition;
771
+ } & ParsedDepositToPositionInstruction<TProgram>)
772
+ | ({
773
+ instructionType: OptionProgramInstruction.InitCollateralPool;
774
+ } & ParsedInitCollateralPoolInstruction<TProgram>)
775
+ | ({
776
+ instructionType: OptionProgramInstruction.InitConfig;
777
+ } & ParsedInitConfigInstruction<TProgram>)
778
+ | ({
779
+ instructionType: OptionProgramInstruction.InitOptionPool;
780
+ } & ParsedInitOptionPoolInstruction<TProgram>)
781
+ | ({
782
+ instructionType: OptionProgramInstruction.InitializeMarketData;
783
+ } & ParsedInitializeMarketDataInstruction<TProgram>)
784
+ | ({
785
+ instructionType: OptionProgramInstruction.LiquidateWriterPosition;
786
+ } & ParsedLiquidateWriterPositionInstruction<TProgram>)
787
+ | ({
788
+ instructionType: OptionProgramInstruction.LiquidateWriterPositionRescue;
789
+ } & ParsedLiquidateWriterPositionRescueInstruction<TProgram>)
790
+ | ({
791
+ instructionType: OptionProgramInstruction.OmlpCreateVault;
792
+ } & ParsedOmlpCreateVaultInstruction<TProgram>)
793
+ | ({
794
+ instructionType: OptionProgramInstruction.OmlpUpdateFeeWallet;
795
+ } & ParsedOmlpUpdateFeeWalletInstruction<TProgram>)
796
+ | ({
797
+ instructionType: OptionProgramInstruction.OmlpUpdateInterestModel;
798
+ } & ParsedOmlpUpdateInterestModelInstruction<TProgram>)
799
+ | ({
800
+ instructionType: OptionProgramInstruction.OmlpUpdateLiquidationThreshold;
801
+ } & ParsedOmlpUpdateLiquidationThresholdInstruction<TProgram>)
802
+ | ({
803
+ instructionType: OptionProgramInstruction.OmlpUpdateMaintenanceBuffer;
804
+ } & ParsedOmlpUpdateMaintenanceBufferInstruction<TProgram>)
805
+ | ({
806
+ instructionType: OptionProgramInstruction.OmlpUpdateMaxBorrowCap;
807
+ } & ParsedOmlpUpdateMaxBorrowCapInstruction<TProgram>)
808
+ | ({
809
+ instructionType: OptionProgramInstruction.OmlpUpdateMaxLeverage;
810
+ } & ParsedOmlpUpdateMaxLeverageInstruction<TProgram>)
811
+ | ({
812
+ instructionType: OptionProgramInstruction.OmlpUpdateProtocolFee;
813
+ } & ParsedOmlpUpdateProtocolFeeInstruction<TProgram>)
814
+ | ({
815
+ instructionType: OptionProgramInstruction.OmlpUpdateSupplyLimit;
816
+ } & ParsedOmlpUpdateSupplyLimitInstruction<TProgram>)
817
+ | ({
818
+ instructionType: OptionProgramInstruction.OptionExercise;
819
+ } & ParsedOptionExerciseInstruction<TProgram>)
820
+ | ({
821
+ instructionType: OptionProgramInstruction.OptionMint;
822
+ } & ParsedOptionMintInstruction<TProgram>)
823
+ | ({
824
+ instructionType: OptionProgramInstruction.OptionValidate;
825
+ } & ParsedOptionValidateInstruction<TProgram>)
826
+ | ({
827
+ instructionType: OptionProgramInstruction.RepayPoolLoan;
828
+ } & ParsedRepayPoolLoanInstruction<TProgram>)
829
+ | ({
830
+ instructionType: OptionProgramInstruction.RepayPoolLoanFromCollateral;
831
+ } & ParsedRepayPoolLoanFromCollateralInstruction<TProgram>)
832
+ | ({
833
+ instructionType: OptionProgramInstruction.RepayPoolLoanFromWallet;
834
+ } & ParsedRepayPoolLoanFromWalletInstruction<TProgram>)
835
+ | ({
836
+ instructionType: OptionProgramInstruction.SettleMakerCollateral;
837
+ } & ParsedSettleMakerCollateralInstruction<TProgram>)
838
+ | ({
839
+ instructionType: OptionProgramInstruction.SyncWriterPosition;
840
+ } & ParsedSyncWriterPositionInstruction<TProgram>)
841
+ | ({
842
+ instructionType: OptionProgramInstruction.TransferAdmin;
843
+ } & ParsedTransferAdminInstruction<TProgram>)
844
+ | ({
845
+ instructionType: OptionProgramInstruction.UnwindWriterUnsold;
846
+ } & ParsedUnwindWriterUnsoldInstruction<TProgram>)
847
+ | ({
848
+ instructionType: OptionProgramInstruction.UpdateImpliedVolatility;
849
+ } & ParsedUpdateImpliedVolatilityInstruction<TProgram>)
850
+ | ({
851
+ instructionType: OptionProgramInstruction.UpdateMarketData;
852
+ } & ParsedUpdateMarketDataInstruction<TProgram>)
853
+ | ({
854
+ instructionType: OptionProgramInstruction.WithdrawFromPosition;
855
+ } & ParsedWithdrawFromPositionInstruction<TProgram>)
856
+ | ({
857
+ instructionType: OptionProgramInstruction.WriteToPool;
858
+ } & ParsedWriteToPoolInstruction<TProgram>);
859
+
860
+ export function parseOptionProgramInstruction<TProgram extends string>(
861
+ instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
862
+ ): ParsedOptionProgramInstruction<TProgram> {
863
+ const instructionType = identifyOptionProgramInstruction(instruction);
864
+ switch (instructionType) {
865
+ case OptionProgramInstruction.AcceptAdmin: {
866
+ assertIsInstructionWithAccounts(instruction);
867
+ return {
868
+ instructionType: OptionProgramInstruction.AcceptAdmin,
869
+ ...parseAcceptAdminInstruction(instruction),
870
+ };
871
+ }
872
+ case OptionProgramInstruction.AutoExerciseAllExpired: {
873
+ assertIsInstructionWithAccounts(instruction);
874
+ return {
875
+ instructionType: OptionProgramInstruction.AutoExerciseAllExpired,
876
+ ...parseAutoExerciseAllExpiredInstruction(instruction),
877
+ };
878
+ }
879
+ case OptionProgramInstruction.AutoExerciseExpired: {
880
+ assertIsInstructionWithAccounts(instruction);
881
+ return {
882
+ instructionType: OptionProgramInstruction.AutoExerciseExpired,
883
+ ...parseAutoExerciseExpiredInstruction(instruction),
884
+ };
885
+ }
886
+ case OptionProgramInstruction.BorrowFromPool: {
887
+ assertIsInstructionWithAccounts(instruction);
888
+ return {
889
+ instructionType: OptionProgramInstruction.BorrowFromPool,
890
+ ...parseBorrowFromPoolInstruction(instruction),
891
+ };
892
+ }
893
+ case OptionProgramInstruction.BuyFromPool: {
894
+ assertIsInstructionWithAccounts(instruction);
895
+ return {
896
+ instructionType: OptionProgramInstruction.BuyFromPool,
897
+ ...parseBuyFromPoolInstruction(instruction),
898
+ };
899
+ }
900
+ case OptionProgramInstruction.CloseLongToPool: {
901
+ assertIsInstructionWithAccounts(instruction);
902
+ return {
903
+ instructionType: OptionProgramInstruction.CloseLongToPool,
904
+ ...parseCloseLongToPoolInstruction(instruction),
905
+ };
906
+ }
907
+ case OptionProgramInstruction.CloseOption: {
908
+ assertIsInstructionWithAccounts(instruction);
909
+ return {
910
+ instructionType: OptionProgramInstruction.CloseOption,
911
+ ...parseCloseOptionInstruction(instruction),
912
+ };
913
+ }
914
+ case OptionProgramInstruction.CreateEscrowV2: {
915
+ assertIsInstructionWithAccounts(instruction);
916
+ return {
917
+ instructionType: OptionProgramInstruction.CreateEscrowV2,
918
+ ...parseCreateEscrowV2Instruction(instruction),
919
+ };
920
+ }
921
+ case OptionProgramInstruction.DepositCollateral: {
922
+ assertIsInstructionWithAccounts(instruction);
923
+ return {
924
+ instructionType: OptionProgramInstruction.DepositCollateral,
925
+ ...parseDepositCollateralInstruction(instruction),
926
+ };
927
+ }
928
+ case OptionProgramInstruction.DepositToPosition: {
929
+ assertIsInstructionWithAccounts(instruction);
930
+ return {
931
+ instructionType: OptionProgramInstruction.DepositToPosition,
932
+ ...parseDepositToPositionInstruction(instruction),
933
+ };
934
+ }
935
+ case OptionProgramInstruction.InitCollateralPool: {
936
+ assertIsInstructionWithAccounts(instruction);
937
+ return {
938
+ instructionType: OptionProgramInstruction.InitCollateralPool,
939
+ ...parseInitCollateralPoolInstruction(instruction),
940
+ };
941
+ }
942
+ case OptionProgramInstruction.InitConfig: {
943
+ assertIsInstructionWithAccounts(instruction);
944
+ return {
945
+ instructionType: OptionProgramInstruction.InitConfig,
946
+ ...parseInitConfigInstruction(instruction),
947
+ };
948
+ }
949
+ case OptionProgramInstruction.InitOptionPool: {
950
+ assertIsInstructionWithAccounts(instruction);
951
+ return {
952
+ instructionType: OptionProgramInstruction.InitOptionPool,
953
+ ...parseInitOptionPoolInstruction(instruction),
954
+ };
955
+ }
956
+ case OptionProgramInstruction.InitializeMarketData: {
957
+ assertIsInstructionWithAccounts(instruction);
958
+ return {
959
+ instructionType: OptionProgramInstruction.InitializeMarketData,
960
+ ...parseInitializeMarketDataInstruction(instruction),
961
+ };
962
+ }
963
+ case OptionProgramInstruction.LiquidateWriterPosition: {
964
+ assertIsInstructionWithAccounts(instruction);
965
+ return {
966
+ instructionType: OptionProgramInstruction.LiquidateWriterPosition,
967
+ ...parseLiquidateWriterPositionInstruction(instruction),
968
+ };
969
+ }
970
+ case OptionProgramInstruction.LiquidateWriterPositionRescue: {
971
+ assertIsInstructionWithAccounts(instruction);
972
+ return {
973
+ instructionType: OptionProgramInstruction.LiquidateWriterPositionRescue,
974
+ ...parseLiquidateWriterPositionRescueInstruction(instruction),
975
+ };
976
+ }
977
+ case OptionProgramInstruction.OmlpCreateVault: {
978
+ assertIsInstructionWithAccounts(instruction);
979
+ return {
980
+ instructionType: OptionProgramInstruction.OmlpCreateVault,
981
+ ...parseOmlpCreateVaultInstruction(instruction),
982
+ };
983
+ }
984
+ case OptionProgramInstruction.OmlpUpdateFeeWallet: {
985
+ assertIsInstructionWithAccounts(instruction);
986
+ return {
987
+ instructionType: OptionProgramInstruction.OmlpUpdateFeeWallet,
988
+ ...parseOmlpUpdateFeeWalletInstruction(instruction),
989
+ };
990
+ }
991
+ case OptionProgramInstruction.OmlpUpdateInterestModel: {
992
+ assertIsInstructionWithAccounts(instruction);
993
+ return {
994
+ instructionType: OptionProgramInstruction.OmlpUpdateInterestModel,
995
+ ...parseOmlpUpdateInterestModelInstruction(instruction),
996
+ };
997
+ }
998
+ case OptionProgramInstruction.OmlpUpdateLiquidationThreshold: {
999
+ assertIsInstructionWithAccounts(instruction);
1000
+ return {
1001
+ instructionType:
1002
+ OptionProgramInstruction.OmlpUpdateLiquidationThreshold,
1003
+ ...parseOmlpUpdateLiquidationThresholdInstruction(instruction),
1004
+ };
1005
+ }
1006
+ case OptionProgramInstruction.OmlpUpdateMaintenanceBuffer: {
1007
+ assertIsInstructionWithAccounts(instruction);
1008
+ return {
1009
+ instructionType: OptionProgramInstruction.OmlpUpdateMaintenanceBuffer,
1010
+ ...parseOmlpUpdateMaintenanceBufferInstruction(instruction),
1011
+ };
1012
+ }
1013
+ case OptionProgramInstruction.OmlpUpdateMaxBorrowCap: {
1014
+ assertIsInstructionWithAccounts(instruction);
1015
+ return {
1016
+ instructionType: OptionProgramInstruction.OmlpUpdateMaxBorrowCap,
1017
+ ...parseOmlpUpdateMaxBorrowCapInstruction(instruction),
1018
+ };
1019
+ }
1020
+ case OptionProgramInstruction.OmlpUpdateMaxLeverage: {
1021
+ assertIsInstructionWithAccounts(instruction);
1022
+ return {
1023
+ instructionType: OptionProgramInstruction.OmlpUpdateMaxLeverage,
1024
+ ...parseOmlpUpdateMaxLeverageInstruction(instruction),
1025
+ };
1026
+ }
1027
+ case OptionProgramInstruction.OmlpUpdateProtocolFee: {
1028
+ assertIsInstructionWithAccounts(instruction);
1029
+ return {
1030
+ instructionType: OptionProgramInstruction.OmlpUpdateProtocolFee,
1031
+ ...parseOmlpUpdateProtocolFeeInstruction(instruction),
1032
+ };
1033
+ }
1034
+ case OptionProgramInstruction.OmlpUpdateSupplyLimit: {
1035
+ assertIsInstructionWithAccounts(instruction);
1036
+ return {
1037
+ instructionType: OptionProgramInstruction.OmlpUpdateSupplyLimit,
1038
+ ...parseOmlpUpdateSupplyLimitInstruction(instruction),
1039
+ };
1040
+ }
1041
+ case OptionProgramInstruction.OptionExercise: {
1042
+ assertIsInstructionWithAccounts(instruction);
1043
+ return {
1044
+ instructionType: OptionProgramInstruction.OptionExercise,
1045
+ ...parseOptionExerciseInstruction(instruction),
1046
+ };
1047
+ }
1048
+ case OptionProgramInstruction.OptionMint: {
1049
+ assertIsInstructionWithAccounts(instruction);
1050
+ return {
1051
+ instructionType: OptionProgramInstruction.OptionMint,
1052
+ ...parseOptionMintInstruction(instruction),
1053
+ };
1054
+ }
1055
+ case OptionProgramInstruction.OptionValidate: {
1056
+ assertIsInstructionWithAccounts(instruction);
1057
+ return {
1058
+ instructionType: OptionProgramInstruction.OptionValidate,
1059
+ ...parseOptionValidateInstruction(instruction),
1060
+ };
1061
+ }
1062
+ case OptionProgramInstruction.RepayPoolLoan: {
1063
+ assertIsInstructionWithAccounts(instruction);
1064
+ return {
1065
+ instructionType: OptionProgramInstruction.RepayPoolLoan,
1066
+ ...parseRepayPoolLoanInstruction(instruction),
1067
+ };
1068
+ }
1069
+ case OptionProgramInstruction.RepayPoolLoanFromCollateral: {
1070
+ assertIsInstructionWithAccounts(instruction);
1071
+ return {
1072
+ instructionType: OptionProgramInstruction.RepayPoolLoanFromCollateral,
1073
+ ...parseRepayPoolLoanFromCollateralInstruction(instruction),
1074
+ };
1075
+ }
1076
+ case OptionProgramInstruction.RepayPoolLoanFromWallet: {
1077
+ assertIsInstructionWithAccounts(instruction);
1078
+ return {
1079
+ instructionType: OptionProgramInstruction.RepayPoolLoanFromWallet,
1080
+ ...parseRepayPoolLoanFromWalletInstruction(instruction),
1081
+ };
1082
+ }
1083
+ case OptionProgramInstruction.SettleMakerCollateral: {
1084
+ assertIsInstructionWithAccounts(instruction);
1085
+ return {
1086
+ instructionType: OptionProgramInstruction.SettleMakerCollateral,
1087
+ ...parseSettleMakerCollateralInstruction(instruction),
1088
+ };
1089
+ }
1090
+ case OptionProgramInstruction.SyncWriterPosition: {
1091
+ assertIsInstructionWithAccounts(instruction);
1092
+ return {
1093
+ instructionType: OptionProgramInstruction.SyncWriterPosition,
1094
+ ...parseSyncWriterPositionInstruction(instruction),
1095
+ };
1096
+ }
1097
+ case OptionProgramInstruction.TransferAdmin: {
1098
+ assertIsInstructionWithAccounts(instruction);
1099
+ return {
1100
+ instructionType: OptionProgramInstruction.TransferAdmin,
1101
+ ...parseTransferAdminInstruction(instruction),
1102
+ };
1103
+ }
1104
+ case OptionProgramInstruction.UnwindWriterUnsold: {
1105
+ assertIsInstructionWithAccounts(instruction);
1106
+ return {
1107
+ instructionType: OptionProgramInstruction.UnwindWriterUnsold,
1108
+ ...parseUnwindWriterUnsoldInstruction(instruction),
1109
+ };
1110
+ }
1111
+ case OptionProgramInstruction.UpdateImpliedVolatility: {
1112
+ assertIsInstructionWithAccounts(instruction);
1113
+ return {
1114
+ instructionType: OptionProgramInstruction.UpdateImpliedVolatility,
1115
+ ...parseUpdateImpliedVolatilityInstruction(instruction),
1116
+ };
1117
+ }
1118
+ case OptionProgramInstruction.UpdateMarketData: {
1119
+ assertIsInstructionWithAccounts(instruction);
1120
+ return {
1121
+ instructionType: OptionProgramInstruction.UpdateMarketData,
1122
+ ...parseUpdateMarketDataInstruction(instruction),
1123
+ };
1124
+ }
1125
+ case OptionProgramInstruction.WithdrawFromPosition: {
1126
+ assertIsInstructionWithAccounts(instruction);
1127
+ return {
1128
+ instructionType: OptionProgramInstruction.WithdrawFromPosition,
1129
+ ...parseWithdrawFromPositionInstruction(instruction),
1130
+ };
1131
+ }
1132
+ case OptionProgramInstruction.WriteToPool: {
1133
+ assertIsInstructionWithAccounts(instruction);
1134
+ return {
1135
+ instructionType: OptionProgramInstruction.WriteToPool,
1136
+ ...parseWriteToPoolInstruction(instruction),
1137
+ };
1138
+ }
1139
+ default:
1140
+ throw new Error(
1141
+ `Unrecognized instruction type: ${instructionType as string}`,
1142
+ );
1143
+ }
1144
+ }