@epicentral/sos-sdk 0.10.1-beta → 0.10.3-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/README.md CHANGED
@@ -63,7 +63,7 @@ Additional modules:
63
63
  | `buildUnwindWriterUnsoldTransactionWithDerivation` | Builds unwind unsold transaction. |
64
64
  | `buildUnwindWriterUnsoldWithLoanRepayment` | **Unwind + repay pool loans in one tx.** Use when closing unsold shorts that borrowed from OMLP. |
65
65
  | `buildSyncWriterPositionTransaction` | Syncs writer position with pool accumulators. |
66
- | `buildSettleMakerCollateralTransaction` | Expiry Phase A: repays one active loan's principal + accrued interest to OMLP from collateral vault. Writers with multiple loans for the expired option call it once per loan; maker residual is claimed separately. |
66
+ | `buildSettleMakerCollateralTransaction` | Expiry Phase A: keeper-signed lender repayment and maker-share snapshot. Repays one active loan's principal + accrued interest to OMLP from collateral vault, and initializes the maker settlement share from `WriterPosition` when older mints do not yet have one. Writers with multiple loans for the expired option call it once per loan; maker residual is claimed separately. |
67
67
  | `getClaimMakerRemainingInstructionAsync` | Expiry Phase C generated instruction: returns remaining maker collateral after Phase B buyer payouts complete. |
68
68
  | `buildCloseOptionTransaction` | Closes option token account. |
69
69
  | `buildClaimThetaTransaction` | Claims theta (time-decay share) for writer. |
@@ -77,6 +77,7 @@ Additional modules:
77
77
  - Requires `writer` transaction signer.
78
78
  - On-chain transfers for lender repayment and collateral return are authorized by program PDAs (`collateral_pool` / `option_pool`) where applicable.
79
79
  - `buildSettleMakerCollateralTransaction`
80
+ - Requires a keeper transaction signer as payer for any missing `MakerCollateralShare` account.
80
81
  - No maker transaction signer is required by this instruction format.
81
82
  - On-chain repayment (`collateral_vault` -> `omlp_vault`) is signed by the `collateral_pool` PDA.
82
83
  - Lender repayment is sourced from collateral vault funds, not maker wallet funds.
@@ -86,7 +87,7 @@ Additional modules:
86
87
 
87
88
  Expiry settlement is lender-first and split across three instructions:
88
89
 
89
- 1. `settle_maker_collateral` (Phase A) for every non-liquidated maker. Lender repayment is paid to the loan vault's ATA for the pool collateral mint, so devnet fake SOL/USDC pools and mainnet WSOL pools use the same mint-safe path. If a writer has multiple active `PoolLoan` accounts for that expired option, keepers submit one Phase A transaction per loan; the maker share is not marked Phase A settled until all are repaid.
90
+ 1. `settle_maker_collateral` (Phase A) for every non-liquidated maker. Lender repayment is paid to the loan vault's ATA for the pool collateral mint, so devnet fake SOL/USDC pools and mainnet WSOL pools use the same mint-safe path. The keeper pays rent to create the maker settlement share if the writer was opened through `option_mint` before that share existed. If a writer has multiple active `PoolLoan` accounts for that expired option, keepers submit one Phase A transaction per loan; the maker share is not marked Phase A settled until all are repaid.
90
91
  2. `auto_exercise_expired` / `auto_exercise_all_expired` (Phase B) for buyers, capped by `eligible_maker_pot`; options with zero buyer positions are considered buyer-settled so maker claims do not stall. The single and batch paths take the collateral/settlement mint so cash-settled payouts use the correct token decimals; batch remaining accounts must pair each position with that buyer's token account for the same mint.
91
92
  3. `claim_maker_remaining` (Phase C) for makers after `phase_b_complete`, returning residual collateral in the pool collateral mint.
92
93
 
@@ -23,6 +23,7 @@ export * from "./initializeMarketData";
23
23
  export * from "./initOptionPool";
24
24
  export * from "./liquidateWriterPosition";
25
25
  export * from "./liquidateWriterPositionRescue";
26
+ export * from "./migrateCollateralPoolV1ToV2";
26
27
  export * from "./omlpCreateVault";
27
28
  export * from "./omlpUpdateFeeWallet";
28
29
  export * from "./omlpUpdateInterestModel";
@@ -0,0 +1,239 @@
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
+ getBytesDecoder,
14
+ getBytesEncoder,
15
+ getStructDecoder,
16
+ getStructEncoder,
17
+ transformEncoder,
18
+ type AccountMeta,
19
+ type AccountSignerMeta,
20
+ type Address,
21
+ type FixedSizeCodec,
22
+ type FixedSizeDecoder,
23
+ type FixedSizeEncoder,
24
+ type Instruction,
25
+ type InstructionWithAccounts,
26
+ type InstructionWithData,
27
+ type ReadonlyAccount,
28
+ type ReadonlyUint8Array,
29
+ type TransactionSigner,
30
+ type WritableAccount,
31
+ type WritableSignerAccount,
32
+ } from "@solana/kit";
33
+ import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
34
+ import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
35
+
36
+ export const MIGRATE_COLLATERAL_POOL_V1_TO_V2_DISCRIMINATOR = new Uint8Array([
37
+ 7, 151, 240, 114, 7, 75, 88, 10,
38
+ ]);
39
+
40
+ export function getMigrateCollateralPoolV1ToV2DiscriminatorBytes() {
41
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
42
+ MIGRATE_COLLATERAL_POOL_V1_TO_V2_DISCRIMINATOR,
43
+ );
44
+ }
45
+
46
+ export type MigrateCollateralPoolV1ToV2Instruction<
47
+ TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
48
+ TAccountCollateralPool extends string | AccountMeta<string> = string,
49
+ TAccountOptionAccount extends string | AccountMeta<string> = string,
50
+ TAccountVault extends string | AccountMeta<string> = string,
51
+ TAccountKeeper extends string | AccountMeta<string> = string,
52
+ TAccountSystemProgram extends string | AccountMeta<string> =
53
+ "11111111111111111111111111111111",
54
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
55
+ > = Instruction<TProgram> &
56
+ InstructionWithData<ReadonlyUint8Array> &
57
+ InstructionWithAccounts<
58
+ [
59
+ TAccountCollateralPool extends string
60
+ ? WritableAccount<TAccountCollateralPool>
61
+ : TAccountCollateralPool,
62
+ TAccountOptionAccount extends string
63
+ ? ReadonlyAccount<TAccountOptionAccount>
64
+ : TAccountOptionAccount,
65
+ TAccountVault extends string
66
+ ? ReadonlyAccount<TAccountVault>
67
+ : TAccountVault,
68
+ TAccountKeeper extends string
69
+ ? WritableSignerAccount<TAccountKeeper> &
70
+ AccountSignerMeta<TAccountKeeper>
71
+ : TAccountKeeper,
72
+ TAccountSystemProgram extends string
73
+ ? ReadonlyAccount<TAccountSystemProgram>
74
+ : TAccountSystemProgram,
75
+ ...TRemainingAccounts,
76
+ ]
77
+ >;
78
+
79
+ export type MigrateCollateralPoolV1ToV2InstructionData = {
80
+ discriminator: ReadonlyUint8Array;
81
+ };
82
+
83
+ export type MigrateCollateralPoolV1ToV2InstructionDataArgs = {};
84
+
85
+ export function getMigrateCollateralPoolV1ToV2InstructionDataEncoder(): FixedSizeEncoder<MigrateCollateralPoolV1ToV2InstructionDataArgs> {
86
+ return transformEncoder(
87
+ getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
88
+ (value) => ({
89
+ ...value,
90
+ discriminator: MIGRATE_COLLATERAL_POOL_V1_TO_V2_DISCRIMINATOR,
91
+ }),
92
+ );
93
+ }
94
+
95
+ export function getMigrateCollateralPoolV1ToV2InstructionDataDecoder(): FixedSizeDecoder<MigrateCollateralPoolV1ToV2InstructionData> {
96
+ return getStructDecoder([
97
+ ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
98
+ ]);
99
+ }
100
+
101
+ export function getMigrateCollateralPoolV1ToV2InstructionDataCodec(): FixedSizeCodec<
102
+ MigrateCollateralPoolV1ToV2InstructionDataArgs,
103
+ MigrateCollateralPoolV1ToV2InstructionData
104
+ > {
105
+ return combineCodec(
106
+ getMigrateCollateralPoolV1ToV2InstructionDataEncoder(),
107
+ getMigrateCollateralPoolV1ToV2InstructionDataDecoder(),
108
+ );
109
+ }
110
+
111
+ export type MigrateCollateralPoolV1ToV2Input<
112
+ TAccountCollateralPool extends string = string,
113
+ TAccountOptionAccount extends string = string,
114
+ TAccountVault extends string = string,
115
+ TAccountKeeper extends string = string,
116
+ TAccountSystemProgram extends string = string,
117
+ > = {
118
+ collateralPool: Address<TAccountCollateralPool>;
119
+ optionAccount: Address<TAccountOptionAccount>;
120
+ vault: Address<TAccountVault>;
121
+ keeper: TransactionSigner<TAccountKeeper>;
122
+ systemProgram?: Address<TAccountSystemProgram>;
123
+ };
124
+
125
+ export function getMigrateCollateralPoolV1ToV2Instruction<
126
+ TAccountCollateralPool extends string,
127
+ TAccountOptionAccount extends string,
128
+ TAccountVault extends string,
129
+ TAccountKeeper extends string,
130
+ TAccountSystemProgram extends string,
131
+ TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
132
+ >(
133
+ input: MigrateCollateralPoolV1ToV2Input<
134
+ TAccountCollateralPool,
135
+ TAccountOptionAccount,
136
+ TAccountVault,
137
+ TAccountKeeper,
138
+ TAccountSystemProgram
139
+ >,
140
+ config?: { programAddress?: TProgramAddress },
141
+ ): MigrateCollateralPoolV1ToV2Instruction<
142
+ TProgramAddress,
143
+ TAccountCollateralPool,
144
+ TAccountOptionAccount,
145
+ TAccountVault,
146
+ TAccountKeeper,
147
+ TAccountSystemProgram
148
+ > {
149
+ // Program address.
150
+ const programAddress =
151
+ config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
152
+
153
+ // Original accounts.
154
+ const originalAccounts = {
155
+ collateralPool: { value: input.collateralPool ?? null, isWritable: true },
156
+ optionAccount: { value: input.optionAccount ?? null, isWritable: false },
157
+ vault: { value: input.vault ?? null, isWritable: false },
158
+ keeper: { value: input.keeper ?? null, isWritable: true },
159
+ systemProgram: { value: input.systemProgram ?? null, isWritable: false },
160
+ };
161
+ const accounts = originalAccounts as Record<
162
+ keyof typeof originalAccounts,
163
+ ResolvedAccount
164
+ >;
165
+
166
+ // Resolve default values.
167
+ if (!accounts.systemProgram.value) {
168
+ accounts.systemProgram.value =
169
+ "11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
170
+ }
171
+
172
+ const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
173
+ return Object.freeze({
174
+ accounts: [
175
+ getAccountMeta(accounts.collateralPool),
176
+ getAccountMeta(accounts.optionAccount),
177
+ getAccountMeta(accounts.vault),
178
+ getAccountMeta(accounts.keeper),
179
+ getAccountMeta(accounts.systemProgram),
180
+ ],
181
+ data: getMigrateCollateralPoolV1ToV2InstructionDataEncoder().encode({}),
182
+ programAddress,
183
+ } as MigrateCollateralPoolV1ToV2Instruction<
184
+ TProgramAddress,
185
+ TAccountCollateralPool,
186
+ TAccountOptionAccount,
187
+ TAccountVault,
188
+ TAccountKeeper,
189
+ TAccountSystemProgram
190
+ >);
191
+ }
192
+
193
+ export type ParsedMigrateCollateralPoolV1ToV2Instruction<
194
+ TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
195
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
196
+ > = {
197
+ programAddress: Address<TProgram>;
198
+ accounts: {
199
+ collateralPool: TAccountMetas[0];
200
+ optionAccount: TAccountMetas[1];
201
+ vault: TAccountMetas[2];
202
+ keeper: TAccountMetas[3];
203
+ systemProgram: TAccountMetas[4];
204
+ };
205
+ data: MigrateCollateralPoolV1ToV2InstructionData;
206
+ };
207
+
208
+ export function parseMigrateCollateralPoolV1ToV2Instruction<
209
+ TProgram extends string,
210
+ TAccountMetas extends readonly AccountMeta[],
211
+ >(
212
+ instruction: Instruction<TProgram> &
213
+ InstructionWithAccounts<TAccountMetas> &
214
+ InstructionWithData<ReadonlyUint8Array>,
215
+ ): ParsedMigrateCollateralPoolV1ToV2Instruction<TProgram, TAccountMetas> {
216
+ if (instruction.accounts.length < 5) {
217
+ // TODO: Coded error.
218
+ throw new Error("Not enough accounts");
219
+ }
220
+ let accountIndex = 0;
221
+ const getNextAccount = () => {
222
+ const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
223
+ accountIndex += 1;
224
+ return accountMeta;
225
+ };
226
+ return {
227
+ programAddress: instruction.programAddress,
228
+ accounts: {
229
+ collateralPool: getNextAccount(),
230
+ optionAccount: getNextAccount(),
231
+ vault: getNextAccount(),
232
+ keeper: getNextAccount(),
233
+ systemProgram: getNextAccount(),
234
+ },
235
+ data: getMigrateCollateralPoolV1ToV2InstructionDataDecoder().decode(
236
+ instruction.data,
237
+ ),
238
+ };
239
+ }
@@ -18,6 +18,7 @@ import {
18
18
  getStructEncoder,
19
19
  transformEncoder,
20
20
  type AccountMeta,
21
+ type AccountSignerMeta,
21
22
  type Address,
22
23
  type FixedSizeCodec,
23
24
  type FixedSizeDecoder,
@@ -27,7 +28,9 @@ import {
27
28
  type InstructionWithData,
28
29
  type ReadonlyAccount,
29
30
  type ReadonlyUint8Array,
31
+ type TransactionSigner,
30
32
  type WritableAccount,
33
+ type WritableSignerAccount,
31
34
  } from "@solana/kit";
32
35
  import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
33
36
  import {
@@ -50,12 +53,13 @@ export type SettleMakerCollateralInstruction<
50
53
  TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
51
54
  TAccountCollateralPool extends string | AccountMeta<string> = string,
52
55
  TAccountOptionAccount extends string | AccountMeta<string> = string,
53
- TAccountMakerCollateralShare extends string | AccountMeta<string> = string,
54
56
  TAccountWriterPosition extends string | AccountMeta<string> = string,
57
+ TAccountMakerCollateralShare extends string | AccountMeta<string> = string,
55
58
  TAccountCollateralVault extends string | AccountMeta<string> = string,
56
59
  TAccountOmlpVault extends string | AccountMeta<string> = string,
57
60
  TAccountOmlpVaultState extends string | AccountMeta<string> = string,
58
61
  TAccountPoolLoan extends string | AccountMeta<string> = string,
62
+ TAccountKeeper extends string | AccountMeta<string> = string,
59
63
  TAccountTokenProgram extends string | AccountMeta<string> =
60
64
  "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
61
65
  TAccountSystemProgram extends string | AccountMeta<string> =
@@ -71,12 +75,12 @@ export type SettleMakerCollateralInstruction<
71
75
  TAccountOptionAccount extends string
72
76
  ? ReadonlyAccount<TAccountOptionAccount>
73
77
  : TAccountOptionAccount,
74
- TAccountMakerCollateralShare extends string
75
- ? WritableAccount<TAccountMakerCollateralShare>
76
- : TAccountMakerCollateralShare,
77
78
  TAccountWriterPosition extends string
78
79
  ? WritableAccount<TAccountWriterPosition>
79
80
  : TAccountWriterPosition,
81
+ TAccountMakerCollateralShare extends string
82
+ ? WritableAccount<TAccountMakerCollateralShare>
83
+ : TAccountMakerCollateralShare,
80
84
  TAccountCollateralVault extends string
81
85
  ? WritableAccount<TAccountCollateralVault>
82
86
  : TAccountCollateralVault,
@@ -89,6 +93,10 @@ export type SettleMakerCollateralInstruction<
89
93
  TAccountPoolLoan extends string
90
94
  ? WritableAccount<TAccountPoolLoan>
91
95
  : TAccountPoolLoan,
96
+ TAccountKeeper extends string
97
+ ? WritableSignerAccount<TAccountKeeper> &
98
+ AccountSignerMeta<TAccountKeeper>
99
+ : TAccountKeeper,
92
100
  TAccountTokenProgram extends string
93
101
  ? ReadonlyAccount<TAccountTokenProgram>
94
102
  : TAccountTokenProgram,
@@ -134,20 +142,21 @@ export function getSettleMakerCollateralInstructionDataCodec(): FixedSizeCodec<
134
142
  export type SettleMakerCollateralAsyncInput<
135
143
  TAccountCollateralPool extends string = string,
136
144
  TAccountOptionAccount extends string = string,
137
- TAccountMakerCollateralShare extends string = string,
138
145
  TAccountWriterPosition extends string = string,
146
+ TAccountMakerCollateralShare extends string = string,
139
147
  TAccountCollateralVault extends string = string,
140
148
  TAccountOmlpVault extends string = string,
141
149
  TAccountOmlpVaultState extends string = string,
142
150
  TAccountPoolLoan extends string = string,
151
+ TAccountKeeper extends string = string,
143
152
  TAccountTokenProgram extends string = string,
144
153
  TAccountSystemProgram extends string = string,
145
154
  > = {
146
155
  collateralPool?: Address<TAccountCollateralPool>;
147
156
  /** The option account (needed for PDA derivation) */
148
157
  optionAccount: Address<TAccountOptionAccount>;
149
- makerCollateralShare: Address<TAccountMakerCollateralShare>;
150
158
  writerPosition: Address<TAccountWriterPosition>;
159
+ makerCollateralShare: Address<TAccountMakerCollateralShare>;
151
160
  /** Pool's collateral vault */
152
161
  collateralVault: Address<TAccountCollateralVault>;
153
162
  /** OMLP Vault token account (receives loan repayments when the maker borrowed) */
@@ -156,6 +165,7 @@ export type SettleMakerCollateralAsyncInput<
156
165
  omlpVaultState?: Address<TAccountOmlpVaultState>;
157
166
  /** Optional OMLP Pool Loan for leveraged makers; unleveraged makers omit it. */
158
167
  poolLoan?: Address<TAccountPoolLoan>;
168
+ keeper: TransactionSigner<TAccountKeeper>;
159
169
  tokenProgram?: Address<TAccountTokenProgram>;
160
170
  systemProgram?: Address<TAccountSystemProgram>;
161
171
  };
@@ -163,12 +173,13 @@ export type SettleMakerCollateralAsyncInput<
163
173
  export async function getSettleMakerCollateralInstructionAsync<
164
174
  TAccountCollateralPool extends string,
165
175
  TAccountOptionAccount extends string,
166
- TAccountMakerCollateralShare extends string,
167
176
  TAccountWriterPosition extends string,
177
+ TAccountMakerCollateralShare extends string,
168
178
  TAccountCollateralVault extends string,
169
179
  TAccountOmlpVault extends string,
170
180
  TAccountOmlpVaultState extends string,
171
181
  TAccountPoolLoan extends string,
182
+ TAccountKeeper extends string,
172
183
  TAccountTokenProgram extends string,
173
184
  TAccountSystemProgram extends string,
174
185
  TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
@@ -176,12 +187,13 @@ export async function getSettleMakerCollateralInstructionAsync<
176
187
  input: SettleMakerCollateralAsyncInput<
177
188
  TAccountCollateralPool,
178
189
  TAccountOptionAccount,
179
- TAccountMakerCollateralShare,
180
190
  TAccountWriterPosition,
191
+ TAccountMakerCollateralShare,
181
192
  TAccountCollateralVault,
182
193
  TAccountOmlpVault,
183
194
  TAccountOmlpVaultState,
184
195
  TAccountPoolLoan,
196
+ TAccountKeeper,
185
197
  TAccountTokenProgram,
186
198
  TAccountSystemProgram
187
199
  >,
@@ -191,12 +203,13 @@ export async function getSettleMakerCollateralInstructionAsync<
191
203
  TProgramAddress,
192
204
  TAccountCollateralPool,
193
205
  TAccountOptionAccount,
194
- TAccountMakerCollateralShare,
195
206
  TAccountWriterPosition,
207
+ TAccountMakerCollateralShare,
196
208
  TAccountCollateralVault,
197
209
  TAccountOmlpVault,
198
210
  TAccountOmlpVaultState,
199
211
  TAccountPoolLoan,
212
+ TAccountKeeper,
200
213
  TAccountTokenProgram,
201
214
  TAccountSystemProgram
202
215
  >
@@ -209,15 +222,16 @@ export async function getSettleMakerCollateralInstructionAsync<
209
222
  const originalAccounts = {
210
223
  collateralPool: { value: input.collateralPool ?? null, isWritable: true },
211
224
  optionAccount: { value: input.optionAccount ?? null, isWritable: false },
225
+ writerPosition: { value: input.writerPosition ?? null, isWritable: true },
212
226
  makerCollateralShare: {
213
227
  value: input.makerCollateralShare ?? null,
214
228
  isWritable: true,
215
229
  },
216
- writerPosition: { value: input.writerPosition ?? null, isWritable: true },
217
230
  collateralVault: { value: input.collateralVault ?? null, isWritable: true },
218
231
  omlpVault: { value: input.omlpVault ?? null, isWritable: true },
219
232
  omlpVaultState: { value: input.omlpVaultState ?? null, isWritable: true },
220
233
  poolLoan: { value: input.poolLoan ?? null, isWritable: true },
234
+ keeper: { value: input.keeper ?? null, isWritable: true },
221
235
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
222
236
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
223
237
  };
@@ -255,12 +269,13 @@ export async function getSettleMakerCollateralInstructionAsync<
255
269
  accounts: [
256
270
  getAccountMeta(accounts.collateralPool),
257
271
  getAccountMeta(accounts.optionAccount),
258
- getAccountMeta(accounts.makerCollateralShare),
259
272
  getAccountMeta(accounts.writerPosition),
273
+ getAccountMeta(accounts.makerCollateralShare),
260
274
  getAccountMeta(accounts.collateralVault),
261
275
  getAccountMeta(accounts.omlpVault),
262
276
  getAccountMeta(accounts.omlpVaultState),
263
277
  getAccountMeta(accounts.poolLoan),
278
+ getAccountMeta(accounts.keeper),
264
279
  getAccountMeta(accounts.tokenProgram),
265
280
  getAccountMeta(accounts.systemProgram),
266
281
  ],
@@ -270,12 +285,13 @@ export async function getSettleMakerCollateralInstructionAsync<
270
285
  TProgramAddress,
271
286
  TAccountCollateralPool,
272
287
  TAccountOptionAccount,
273
- TAccountMakerCollateralShare,
274
288
  TAccountWriterPosition,
289
+ TAccountMakerCollateralShare,
275
290
  TAccountCollateralVault,
276
291
  TAccountOmlpVault,
277
292
  TAccountOmlpVaultState,
278
293
  TAccountPoolLoan,
294
+ TAccountKeeper,
279
295
  TAccountTokenProgram,
280
296
  TAccountSystemProgram
281
297
  >);
@@ -284,20 +300,21 @@ export async function getSettleMakerCollateralInstructionAsync<
284
300
  export type SettleMakerCollateralInput<
285
301
  TAccountCollateralPool extends string = string,
286
302
  TAccountOptionAccount extends string = string,
287
- TAccountMakerCollateralShare extends string = string,
288
303
  TAccountWriterPosition extends string = string,
304
+ TAccountMakerCollateralShare extends string = string,
289
305
  TAccountCollateralVault extends string = string,
290
306
  TAccountOmlpVault extends string = string,
291
307
  TAccountOmlpVaultState extends string = string,
292
308
  TAccountPoolLoan extends string = string,
309
+ TAccountKeeper extends string = string,
293
310
  TAccountTokenProgram extends string = string,
294
311
  TAccountSystemProgram extends string = string,
295
312
  > = {
296
313
  collateralPool: Address<TAccountCollateralPool>;
297
314
  /** The option account (needed for PDA derivation) */
298
315
  optionAccount: Address<TAccountOptionAccount>;
299
- makerCollateralShare: Address<TAccountMakerCollateralShare>;
300
316
  writerPosition: Address<TAccountWriterPosition>;
317
+ makerCollateralShare: Address<TAccountMakerCollateralShare>;
301
318
  /** Pool's collateral vault */
302
319
  collateralVault: Address<TAccountCollateralVault>;
303
320
  /** OMLP Vault token account (receives loan repayments when the maker borrowed) */
@@ -306,6 +323,7 @@ export type SettleMakerCollateralInput<
306
323
  omlpVaultState?: Address<TAccountOmlpVaultState>;
307
324
  /** Optional OMLP Pool Loan for leveraged makers; unleveraged makers omit it. */
308
325
  poolLoan?: Address<TAccountPoolLoan>;
326
+ keeper: TransactionSigner<TAccountKeeper>;
309
327
  tokenProgram?: Address<TAccountTokenProgram>;
310
328
  systemProgram?: Address<TAccountSystemProgram>;
311
329
  };
@@ -313,12 +331,13 @@ export type SettleMakerCollateralInput<
313
331
  export function getSettleMakerCollateralInstruction<
314
332
  TAccountCollateralPool extends string,
315
333
  TAccountOptionAccount extends string,
316
- TAccountMakerCollateralShare extends string,
317
334
  TAccountWriterPosition extends string,
335
+ TAccountMakerCollateralShare extends string,
318
336
  TAccountCollateralVault extends string,
319
337
  TAccountOmlpVault extends string,
320
338
  TAccountOmlpVaultState extends string,
321
339
  TAccountPoolLoan extends string,
340
+ TAccountKeeper extends string,
322
341
  TAccountTokenProgram extends string,
323
342
  TAccountSystemProgram extends string,
324
343
  TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
@@ -326,12 +345,13 @@ export function getSettleMakerCollateralInstruction<
326
345
  input: SettleMakerCollateralInput<
327
346
  TAccountCollateralPool,
328
347
  TAccountOptionAccount,
329
- TAccountMakerCollateralShare,
330
348
  TAccountWriterPosition,
349
+ TAccountMakerCollateralShare,
331
350
  TAccountCollateralVault,
332
351
  TAccountOmlpVault,
333
352
  TAccountOmlpVaultState,
334
353
  TAccountPoolLoan,
354
+ TAccountKeeper,
335
355
  TAccountTokenProgram,
336
356
  TAccountSystemProgram
337
357
  >,
@@ -340,12 +360,13 @@ export function getSettleMakerCollateralInstruction<
340
360
  TProgramAddress,
341
361
  TAccountCollateralPool,
342
362
  TAccountOptionAccount,
343
- TAccountMakerCollateralShare,
344
363
  TAccountWriterPosition,
364
+ TAccountMakerCollateralShare,
345
365
  TAccountCollateralVault,
346
366
  TAccountOmlpVault,
347
367
  TAccountOmlpVaultState,
348
368
  TAccountPoolLoan,
369
+ TAccountKeeper,
349
370
  TAccountTokenProgram,
350
371
  TAccountSystemProgram
351
372
  > {
@@ -357,15 +378,16 @@ export function getSettleMakerCollateralInstruction<
357
378
  const originalAccounts = {
358
379
  collateralPool: { value: input.collateralPool ?? null, isWritable: true },
359
380
  optionAccount: { value: input.optionAccount ?? null, isWritable: false },
381
+ writerPosition: { value: input.writerPosition ?? null, isWritable: true },
360
382
  makerCollateralShare: {
361
383
  value: input.makerCollateralShare ?? null,
362
384
  isWritable: true,
363
385
  },
364
- writerPosition: { value: input.writerPosition ?? null, isWritable: true },
365
386
  collateralVault: { value: input.collateralVault ?? null, isWritable: true },
366
387
  omlpVault: { value: input.omlpVault ?? null, isWritable: true },
367
388
  omlpVaultState: { value: input.omlpVaultState ?? null, isWritable: true },
368
389
  poolLoan: { value: input.poolLoan ?? null, isWritable: true },
390
+ keeper: { value: input.keeper ?? null, isWritable: true },
369
391
  tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
370
392
  systemProgram: { value: input.systemProgram ?? null, isWritable: false },
371
393
  };
@@ -389,12 +411,13 @@ export function getSettleMakerCollateralInstruction<
389
411
  accounts: [
390
412
  getAccountMeta(accounts.collateralPool),
391
413
  getAccountMeta(accounts.optionAccount),
392
- getAccountMeta(accounts.makerCollateralShare),
393
414
  getAccountMeta(accounts.writerPosition),
415
+ getAccountMeta(accounts.makerCollateralShare),
394
416
  getAccountMeta(accounts.collateralVault),
395
417
  getAccountMeta(accounts.omlpVault),
396
418
  getAccountMeta(accounts.omlpVaultState),
397
419
  getAccountMeta(accounts.poolLoan),
420
+ getAccountMeta(accounts.keeper),
398
421
  getAccountMeta(accounts.tokenProgram),
399
422
  getAccountMeta(accounts.systemProgram),
400
423
  ],
@@ -404,12 +427,13 @@ export function getSettleMakerCollateralInstruction<
404
427
  TProgramAddress,
405
428
  TAccountCollateralPool,
406
429
  TAccountOptionAccount,
407
- TAccountMakerCollateralShare,
408
430
  TAccountWriterPosition,
431
+ TAccountMakerCollateralShare,
409
432
  TAccountCollateralVault,
410
433
  TAccountOmlpVault,
411
434
  TAccountOmlpVaultState,
412
435
  TAccountPoolLoan,
436
+ TAccountKeeper,
413
437
  TAccountTokenProgram,
414
438
  TAccountSystemProgram
415
439
  >);
@@ -424,8 +448,8 @@ export type ParsedSettleMakerCollateralInstruction<
424
448
  collateralPool: TAccountMetas[0];
425
449
  /** The option account (needed for PDA derivation) */
426
450
  optionAccount: TAccountMetas[1];
427
- makerCollateralShare: TAccountMetas[2];
428
- writerPosition: TAccountMetas[3];
451
+ writerPosition: TAccountMetas[2];
452
+ makerCollateralShare: TAccountMetas[3];
429
453
  /** Pool's collateral vault */
430
454
  collateralVault: TAccountMetas[4];
431
455
  /** OMLP Vault token account (receives loan repayments when the maker borrowed) */
@@ -434,8 +458,9 @@ export type ParsedSettleMakerCollateralInstruction<
434
458
  omlpVaultState?: TAccountMetas[6] | undefined;
435
459
  /** Optional OMLP Pool Loan for leveraged makers; unleveraged makers omit it. */
436
460
  poolLoan?: TAccountMetas[7] | undefined;
437
- tokenProgram: TAccountMetas[8];
438
- systemProgram: TAccountMetas[9];
461
+ keeper: TAccountMetas[8];
462
+ tokenProgram: TAccountMetas[9];
463
+ systemProgram: TAccountMetas[10];
439
464
  };
440
465
  data: SettleMakerCollateralInstructionData;
441
466
  };
@@ -448,7 +473,7 @@ export function parseSettleMakerCollateralInstruction<
448
473
  InstructionWithAccounts<TAccountMetas> &
449
474
  InstructionWithData<ReadonlyUint8Array>,
450
475
  ): ParsedSettleMakerCollateralInstruction<TProgram, TAccountMetas> {
451
- if (instruction.accounts.length < 10) {
476
+ if (instruction.accounts.length < 11) {
452
477
  // TODO: Coded error.
453
478
  throw new Error("Not enough accounts");
454
479
  }
@@ -469,12 +494,13 @@ export function parseSettleMakerCollateralInstruction<
469
494
  accounts: {
470
495
  collateralPool: getNextAccount(),
471
496
  optionAccount: getNextAccount(),
472
- makerCollateralShare: getNextAccount(),
473
497
  writerPosition: getNextAccount(),
498
+ makerCollateralShare: getNextAccount(),
474
499
  collateralVault: getNextAccount(),
475
500
  omlpVault: getNextOptionalAccount(),
476
501
  omlpVaultState: getNextOptionalAccount(),
477
502
  poolLoan: getNextOptionalAccount(),
503
+ keeper: getNextAccount(),
478
504
  tokenProgram: getNextAccount(),
479
505
  systemProgram: getNextAccount(),
480
506
  },
@@ -7,56 +7,21 @@
7
7
  */
8
8
 
9
9
  import {
10
- assertIsInstructionWithAccounts,
11
10
  containsBytes,
12
11
  fixEncoderSize,
13
12
  getBytesEncoder,
14
13
  type Address,
15
14
  type Instruction,
15
+ type InstructionWithAccounts,
16
16
  type InstructionWithData,
17
+ type AccountMeta,
17
18
  type ReadonlyUint8Array,
18
19
  } from "@solana/kit";
19
20
  import {
20
- parseAcceptAdminInstruction,
21
- parseAutoExerciseAllExpiredInstruction,
22
- parseAutoExerciseExpiredInstruction,
23
- parseBorrowFromPoolInstruction,
24
21
  parseBuyFromPoolInstruction,
25
- parseClaimMakerRemainingInstruction,
26
22
  parseCloseLongToPoolInstruction,
27
- parseCloseOptionInstruction,
28
- parseCreateEscrowV2Instruction,
29
- parseDepositCollateralInstruction,
30
- parseDepositToPositionInstruction,
31
- parseInitCollateralPoolInstruction,
32
- parseInitConfigInstruction,
33
- parseInitializeMarketDataInstruction,
34
- parseInitOptionPoolInstruction,
35
- parseLiquidateWriterPositionInstruction,
36
- parseLiquidateWriterPositionRescueInstruction,
37
- parseOmlpCreateVaultInstruction,
38
- parseOmlpUpdateFeeWalletInstruction,
39
- parseOmlpUpdateInterestModelInstruction,
40
- parseOmlpUpdateLiquidationThresholdInstruction,
41
- parseOmlpUpdateMaintenanceBufferInstruction,
42
- parseOmlpUpdateMaxBorrowCapInstruction,
43
- parseOmlpUpdateMaxLeverageInstruction,
44
- parseOmlpUpdateProtocolFeeInstruction,
45
- parseOmlpUpdateSupplyLimitInstruction,
46
- parseOptionExerciseInstruction,
47
23
  parseOptionMintInstruction,
48
- parseOptionValidateInstruction,
49
- parseRepayPoolLoanFromCollateralInstruction,
50
- parseRepayPoolLoanFromWalletInstruction,
51
- parseRepayPoolLoanInstruction,
52
- parseSettleMakerCollateralInstruction,
53
- parseSyncWriterPositionInstruction,
54
- parseTransferAdminInstruction,
55
24
  parseUnwindWriterUnsoldInstruction,
56
- parseUpdateImpliedVolatilityInstruction,
57
- parseUpdateMarketDataInstruction,
58
- parseWithdrawFromPositionInstruction,
59
- parseWriteToPoolInstruction,
60
25
  type ParsedAcceptAdminInstruction,
61
26
  type ParsedAutoExerciseAllExpiredInstruction,
62
27
  type ParsedAutoExerciseExpiredInstruction,
@@ -74,6 +39,7 @@ import {
74
39
  type ParsedInitOptionPoolInstruction,
75
40
  type ParsedLiquidateWriterPositionInstruction,
76
41
  type ParsedLiquidateWriterPositionRescueInstruction,
42
+ type ParsedMigrateCollateralPoolV1ToV2Instruction,
77
43
  type ParsedOmlpCreateVaultInstruction,
78
44
  type ParsedOmlpUpdateFeeWalletInstruction,
79
45
  type ParsedOmlpUpdateInterestModelInstruction,
@@ -276,6 +242,7 @@ export enum OptionProgramInstruction {
276
242
  InitializeMarketData,
277
243
  LiquidateWriterPosition,
278
244
  LiquidateWriterPositionRescue,
245
+ MigrateCollateralPoolV1ToV2,
279
246
  OmlpCreateVault,
280
247
  OmlpUpdateFeeWallet,
281
248
  OmlpUpdateInterestModel,
@@ -492,6 +459,17 @@ export function identifyOptionProgramInstruction(
492
459
  ) {
493
460
  return OptionProgramInstruction.LiquidateWriterPositionRescue;
494
461
  }
462
+ if (
463
+ containsBytes(
464
+ data,
465
+ fixEncoderSize(getBytesEncoder(), 8).encode(
466
+ new Uint8Array([7, 151, 240, 114, 7, 75, 88, 10]),
467
+ ),
468
+ 0,
469
+ )
470
+ ) {
471
+ return OptionProgramInstruction.MigrateCollateralPoolV1ToV2;
472
+ }
495
473
  if (
496
474
  containsBytes(
497
475
  data,
@@ -804,6 +782,9 @@ export type ParsedOptionProgramInstruction<
804
782
  | ({
805
783
  instructionType: OptionProgramInstruction.LiquidateWriterPositionRescue;
806
784
  } & ParsedLiquidateWriterPositionRescueInstruction<TProgram>)
785
+ | ({
786
+ instructionType: OptionProgramInstruction.MigrateCollateralPoolV1ToV2;
787
+ } & ParsedMigrateCollateralPoolV1ToV2Instruction<TProgram>)
807
788
  | ({
808
789
  instructionType: OptionProgramInstruction.OmlpCreateVault;
809
790
  } & ParsedOmlpCreateVaultInstruction<TProgram>)
@@ -874,295 +855,40 @@ export type ParsedOptionProgramInstruction<
874
855
  instructionType: OptionProgramInstruction.WriteToPool;
875
856
  } & ParsedWriteToPoolInstruction<TProgram>);
876
857
 
877
- export function parseOptionProgramInstruction<TProgram extends string>(
878
- instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
858
+ export function parseOptionProgramInstruction<
859
+ TProgram extends string,
860
+ TAccountMetas extends readonly AccountMeta[],
861
+ >(
862
+ instruction: Instruction<TProgram> &
863
+ InstructionWithAccounts<TAccountMetas> &
864
+ InstructionWithData<ReadonlyUint8Array>,
879
865
  ): ParsedOptionProgramInstruction<TProgram> {
880
866
  const instructionType = identifyOptionProgramInstruction(instruction);
867
+
881
868
  switch (instructionType) {
882
- case OptionProgramInstruction.AcceptAdmin: {
883
- assertIsInstructionWithAccounts(instruction);
884
- return {
885
- instructionType: OptionProgramInstruction.AcceptAdmin,
886
- ...parseAcceptAdminInstruction(instruction),
887
- };
888
- }
889
- case OptionProgramInstruction.AutoExerciseAllExpired: {
890
- assertIsInstructionWithAccounts(instruction);
869
+ case OptionProgramInstruction.BuyFromPool:
891
870
  return {
892
- instructionType: OptionProgramInstruction.AutoExerciseAllExpired,
893
- ...parseAutoExerciseAllExpiredInstruction(instruction),
894
- };
895
- }
896
- case OptionProgramInstruction.AutoExerciseExpired: {
897
- assertIsInstructionWithAccounts(instruction);
898
- return {
899
- instructionType: OptionProgramInstruction.AutoExerciseExpired,
900
- ...parseAutoExerciseExpiredInstruction(instruction),
901
- };
902
- }
903
- case OptionProgramInstruction.BorrowFromPool: {
904
- assertIsInstructionWithAccounts(instruction);
905
- return {
906
- instructionType: OptionProgramInstruction.BorrowFromPool,
907
- ...parseBorrowFromPoolInstruction(instruction),
908
- };
909
- }
910
- case OptionProgramInstruction.BuyFromPool: {
911
- assertIsInstructionWithAccounts(instruction);
912
- return {
913
- instructionType: OptionProgramInstruction.BuyFromPool,
871
+ instructionType,
914
872
  ...parseBuyFromPoolInstruction(instruction),
915
- };
916
- }
917
- case OptionProgramInstruction.ClaimMakerRemaining: {
918
- assertIsInstructionWithAccounts(instruction);
873
+ } as ParsedOptionProgramInstruction<TProgram>;
874
+ case OptionProgramInstruction.CloseLongToPool:
919
875
  return {
920
- instructionType: OptionProgramInstruction.ClaimMakerRemaining,
921
- ...parseClaimMakerRemainingInstruction(instruction),
922
- };
923
- }
924
- case OptionProgramInstruction.CloseLongToPool: {
925
- assertIsInstructionWithAccounts(instruction);
926
- return {
927
- instructionType: OptionProgramInstruction.CloseLongToPool,
876
+ instructionType,
928
877
  ...parseCloseLongToPoolInstruction(instruction),
929
- };
930
- }
931
- case OptionProgramInstruction.CloseOption: {
932
- assertIsInstructionWithAccounts(instruction);
933
- return {
934
- instructionType: OptionProgramInstruction.CloseOption,
935
- ...parseCloseOptionInstruction(instruction),
936
- };
937
- }
938
- case OptionProgramInstruction.CreateEscrowV2: {
939
- assertIsInstructionWithAccounts(instruction);
940
- return {
941
- instructionType: OptionProgramInstruction.CreateEscrowV2,
942
- ...parseCreateEscrowV2Instruction(instruction),
943
- };
944
- }
945
- case OptionProgramInstruction.DepositCollateral: {
946
- assertIsInstructionWithAccounts(instruction);
947
- return {
948
- instructionType: OptionProgramInstruction.DepositCollateral,
949
- ...parseDepositCollateralInstruction(instruction),
950
- };
951
- }
952
- case OptionProgramInstruction.DepositToPosition: {
953
- assertIsInstructionWithAccounts(instruction);
954
- return {
955
- instructionType: OptionProgramInstruction.DepositToPosition,
956
- ...parseDepositToPositionInstruction(instruction),
957
- };
958
- }
959
- case OptionProgramInstruction.InitCollateralPool: {
960
- assertIsInstructionWithAccounts(instruction);
961
- return {
962
- instructionType: OptionProgramInstruction.InitCollateralPool,
963
- ...parseInitCollateralPoolInstruction(instruction),
964
- };
965
- }
966
- case OptionProgramInstruction.InitConfig: {
967
- assertIsInstructionWithAccounts(instruction);
968
- return {
969
- instructionType: OptionProgramInstruction.InitConfig,
970
- ...parseInitConfigInstruction(instruction),
971
- };
972
- }
973
- case OptionProgramInstruction.InitOptionPool: {
974
- assertIsInstructionWithAccounts(instruction);
975
- return {
976
- instructionType: OptionProgramInstruction.InitOptionPool,
977
- ...parseInitOptionPoolInstruction(instruction),
978
- };
979
- }
980
- case OptionProgramInstruction.InitializeMarketData: {
981
- assertIsInstructionWithAccounts(instruction);
982
- return {
983
- instructionType: OptionProgramInstruction.InitializeMarketData,
984
- ...parseInitializeMarketDataInstruction(instruction),
985
- };
986
- }
987
- case OptionProgramInstruction.LiquidateWriterPosition: {
988
- assertIsInstructionWithAccounts(instruction);
878
+ } as ParsedOptionProgramInstruction<TProgram>;
879
+ case OptionProgramInstruction.OptionMint:
989
880
  return {
990
- instructionType: OptionProgramInstruction.LiquidateWriterPosition,
991
- ...parseLiquidateWriterPositionInstruction(instruction),
992
- };
993
- }
994
- case OptionProgramInstruction.LiquidateWriterPositionRescue: {
995
- assertIsInstructionWithAccounts(instruction);
996
- return {
997
- instructionType: OptionProgramInstruction.LiquidateWriterPositionRescue,
998
- ...parseLiquidateWriterPositionRescueInstruction(instruction),
999
- };
1000
- }
1001
- case OptionProgramInstruction.OmlpCreateVault: {
1002
- assertIsInstructionWithAccounts(instruction);
1003
- return {
1004
- instructionType: OptionProgramInstruction.OmlpCreateVault,
1005
- ...parseOmlpCreateVaultInstruction(instruction),
1006
- };
1007
- }
1008
- case OptionProgramInstruction.OmlpUpdateFeeWallet: {
1009
- assertIsInstructionWithAccounts(instruction);
1010
- return {
1011
- instructionType: OptionProgramInstruction.OmlpUpdateFeeWallet,
1012
- ...parseOmlpUpdateFeeWalletInstruction(instruction),
1013
- };
1014
- }
1015
- case OptionProgramInstruction.OmlpUpdateInterestModel: {
1016
- assertIsInstructionWithAccounts(instruction);
1017
- return {
1018
- instructionType: OptionProgramInstruction.OmlpUpdateInterestModel,
1019
- ...parseOmlpUpdateInterestModelInstruction(instruction),
1020
- };
1021
- }
1022
- case OptionProgramInstruction.OmlpUpdateLiquidationThreshold: {
1023
- assertIsInstructionWithAccounts(instruction);
1024
- return {
1025
- instructionType:
1026
- OptionProgramInstruction.OmlpUpdateLiquidationThreshold,
1027
- ...parseOmlpUpdateLiquidationThresholdInstruction(instruction),
1028
- };
1029
- }
1030
- case OptionProgramInstruction.OmlpUpdateMaintenanceBuffer: {
1031
- assertIsInstructionWithAccounts(instruction);
1032
- return {
1033
- instructionType: OptionProgramInstruction.OmlpUpdateMaintenanceBuffer,
1034
- ...parseOmlpUpdateMaintenanceBufferInstruction(instruction),
1035
- };
1036
- }
1037
- case OptionProgramInstruction.OmlpUpdateMaxBorrowCap: {
1038
- assertIsInstructionWithAccounts(instruction);
1039
- return {
1040
- instructionType: OptionProgramInstruction.OmlpUpdateMaxBorrowCap,
1041
- ...parseOmlpUpdateMaxBorrowCapInstruction(instruction),
1042
- };
1043
- }
1044
- case OptionProgramInstruction.OmlpUpdateMaxLeverage: {
1045
- assertIsInstructionWithAccounts(instruction);
1046
- return {
1047
- instructionType: OptionProgramInstruction.OmlpUpdateMaxLeverage,
1048
- ...parseOmlpUpdateMaxLeverageInstruction(instruction),
1049
- };
1050
- }
1051
- case OptionProgramInstruction.OmlpUpdateProtocolFee: {
1052
- assertIsInstructionWithAccounts(instruction);
1053
- return {
1054
- instructionType: OptionProgramInstruction.OmlpUpdateProtocolFee,
1055
- ...parseOmlpUpdateProtocolFeeInstruction(instruction),
1056
- };
1057
- }
1058
- case OptionProgramInstruction.OmlpUpdateSupplyLimit: {
1059
- assertIsInstructionWithAccounts(instruction);
1060
- return {
1061
- instructionType: OptionProgramInstruction.OmlpUpdateSupplyLimit,
1062
- ...parseOmlpUpdateSupplyLimitInstruction(instruction),
1063
- };
1064
- }
1065
- case OptionProgramInstruction.OptionExercise: {
1066
- assertIsInstructionWithAccounts(instruction);
1067
- return {
1068
- instructionType: OptionProgramInstruction.OptionExercise,
1069
- ...parseOptionExerciseInstruction(instruction),
1070
- };
1071
- }
1072
- case OptionProgramInstruction.OptionMint: {
1073
- assertIsInstructionWithAccounts(instruction);
1074
- return {
1075
- instructionType: OptionProgramInstruction.OptionMint,
881
+ instructionType,
1076
882
  ...parseOptionMintInstruction(instruction),
1077
- };
1078
- }
1079
- case OptionProgramInstruction.OptionValidate: {
1080
- assertIsInstructionWithAccounts(instruction);
883
+ } as ParsedOptionProgramInstruction<TProgram>;
884
+ case OptionProgramInstruction.UnwindWriterUnsold:
1081
885
  return {
1082
- instructionType: OptionProgramInstruction.OptionValidate,
1083
- ...parseOptionValidateInstruction(instruction),
1084
- };
1085
- }
1086
- case OptionProgramInstruction.RepayPoolLoan: {
1087
- assertIsInstructionWithAccounts(instruction);
1088
- return {
1089
- instructionType: OptionProgramInstruction.RepayPoolLoan,
1090
- ...parseRepayPoolLoanInstruction(instruction),
1091
- };
1092
- }
1093
- case OptionProgramInstruction.RepayPoolLoanFromCollateral: {
1094
- assertIsInstructionWithAccounts(instruction);
1095
- return {
1096
- instructionType: OptionProgramInstruction.RepayPoolLoanFromCollateral,
1097
- ...parseRepayPoolLoanFromCollateralInstruction(instruction),
1098
- };
1099
- }
1100
- case OptionProgramInstruction.RepayPoolLoanFromWallet: {
1101
- assertIsInstructionWithAccounts(instruction);
1102
- return {
1103
- instructionType: OptionProgramInstruction.RepayPoolLoanFromWallet,
1104
- ...parseRepayPoolLoanFromWalletInstruction(instruction),
1105
- };
1106
- }
1107
- case OptionProgramInstruction.SettleMakerCollateral: {
1108
- assertIsInstructionWithAccounts(instruction);
1109
- return {
1110
- instructionType: OptionProgramInstruction.SettleMakerCollateral,
1111
- ...parseSettleMakerCollateralInstruction(instruction),
1112
- };
1113
- }
1114
- case OptionProgramInstruction.SyncWriterPosition: {
1115
- assertIsInstructionWithAccounts(instruction);
1116
- return {
1117
- instructionType: OptionProgramInstruction.SyncWriterPosition,
1118
- ...parseSyncWriterPositionInstruction(instruction),
1119
- };
1120
- }
1121
- case OptionProgramInstruction.TransferAdmin: {
1122
- assertIsInstructionWithAccounts(instruction);
1123
- return {
1124
- instructionType: OptionProgramInstruction.TransferAdmin,
1125
- ...parseTransferAdminInstruction(instruction),
1126
- };
1127
- }
1128
- case OptionProgramInstruction.UnwindWriterUnsold: {
1129
- assertIsInstructionWithAccounts(instruction);
1130
- return {
1131
- instructionType: OptionProgramInstruction.UnwindWriterUnsold,
886
+ instructionType,
1132
887
  ...parseUnwindWriterUnsoldInstruction(instruction),
1133
- };
1134
- }
1135
- case OptionProgramInstruction.UpdateImpliedVolatility: {
1136
- assertIsInstructionWithAccounts(instruction);
1137
- return {
1138
- instructionType: OptionProgramInstruction.UpdateImpliedVolatility,
1139
- ...parseUpdateImpliedVolatilityInstruction(instruction),
1140
- };
1141
- }
1142
- case OptionProgramInstruction.UpdateMarketData: {
1143
- assertIsInstructionWithAccounts(instruction);
1144
- return {
1145
- instructionType: OptionProgramInstruction.UpdateMarketData,
1146
- ...parseUpdateMarketDataInstruction(instruction),
1147
- };
1148
- }
1149
- case OptionProgramInstruction.WithdrawFromPosition: {
1150
- assertIsInstructionWithAccounts(instruction);
1151
- return {
1152
- instructionType: OptionProgramInstruction.WithdrawFromPosition,
1153
- ...parseWithdrawFromPositionInstruction(instruction),
1154
- };
1155
- }
1156
- case OptionProgramInstruction.WriteToPool: {
1157
- assertIsInstructionWithAccounts(instruction);
1158
- return {
1159
- instructionType: OptionProgramInstruction.WriteToPool,
1160
- ...parseWriteToPoolInstruction(instruction),
1161
- };
1162
- }
888
+ } as ParsedOptionProgramInstruction<TProgram>;
1163
889
  default:
1164
890
  throw new Error(
1165
- `Unrecognized instruction type: ${instructionType as string}`,
891
+ "No parser is registered for this optionProgram instruction.",
1166
892
  );
1167
893
  }
1168
894
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.10.1-beta",
3
+ "version": "0.10.3-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",
package/short/builders.ts CHANGED
@@ -128,6 +128,7 @@ export interface BuildSettleMakerCollateralParams {
128
128
  optionAccount: AddressLike;
129
129
  collateralVault: AddressLike;
130
130
  writerPosition: AddressLike;
131
+ keeper: TransactionSigner;
131
132
  /** OMLP Vault token account (destination for principal+interest). */
132
133
  omlpVault?: AddressLike;
133
134
  /** OMLP Vault state PDA (mut: updates `total_loans`, `total_liquidity`, `acc_interest_per_share_fp`). */
@@ -807,6 +808,7 @@ export async function buildSettleMakerCollateralInstruction(
807
808
  omlpVault: params.omlpVault ? toAddress(params.omlpVault) : undefined,
808
809
  omlpVaultState: params.omlpVaultState ? toAddress(params.omlpVaultState) : undefined,
809
810
  poolLoan: params.poolLoan ? toAddress(params.poolLoan) : undefined,
811
+ keeper: params.keeper,
810
812
  });
811
813
  return kitInstruction;
812
814
  }