@epicentral/sos-sdk 0.9.1-beta → 0.10.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.
@@ -51,8 +51,8 @@ export type SettleMakerCollateralInstruction<
51
51
  TAccountCollateralPool extends string | AccountMeta<string> = string,
52
52
  TAccountOptionAccount extends string | AccountMeta<string> = string,
53
53
  TAccountMakerCollateralShare extends string | AccountMeta<string> = string,
54
+ TAccountWriterPosition extends string | AccountMeta<string> = string,
54
55
  TAccountCollateralVault extends string | AccountMeta<string> = string,
55
- TAccountMakerCollateralAccount extends string | AccountMeta<string> = string,
56
56
  TAccountOmlpVault extends string | AccountMeta<string> = string,
57
57
  TAccountOmlpVaultState extends string | AccountMeta<string> = string,
58
58
  TAccountPoolLoan extends string | AccountMeta<string> = string,
@@ -74,12 +74,12 @@ export type SettleMakerCollateralInstruction<
74
74
  TAccountMakerCollateralShare extends string
75
75
  ? WritableAccount<TAccountMakerCollateralShare>
76
76
  : TAccountMakerCollateralShare,
77
+ TAccountWriterPosition extends string
78
+ ? WritableAccount<TAccountWriterPosition>
79
+ : TAccountWriterPosition,
77
80
  TAccountCollateralVault extends string
78
81
  ? WritableAccount<TAccountCollateralVault>
79
82
  : TAccountCollateralVault,
80
- TAccountMakerCollateralAccount extends string
81
- ? WritableAccount<TAccountMakerCollateralAccount>
82
- : TAccountMakerCollateralAccount,
83
83
  TAccountOmlpVault extends string
84
84
  ? WritableAccount<TAccountOmlpVault>
85
85
  : TAccountOmlpVault,
@@ -135,8 +135,8 @@ export type SettleMakerCollateralAsyncInput<
135
135
  TAccountCollateralPool extends string = string,
136
136
  TAccountOptionAccount extends string = string,
137
137
  TAccountMakerCollateralShare extends string = string,
138
+ TAccountWriterPosition extends string = string,
138
139
  TAccountCollateralVault extends string = string,
139
- TAccountMakerCollateralAccount extends string = string,
140
140
  TAccountOmlpVault extends string = string,
141
141
  TAccountOmlpVaultState extends string = string,
142
142
  TAccountPoolLoan extends string = string,
@@ -147,23 +147,15 @@ export type SettleMakerCollateralAsyncInput<
147
147
  /** The option account (needed for PDA derivation) */
148
148
  optionAccount: Address<TAccountOptionAccount>;
149
149
  makerCollateralShare: Address<TAccountMakerCollateralShare>;
150
+ writerPosition: Address<TAccountWriterPosition>;
150
151
  /** Pool's collateral vault */
151
152
  collateralVault: Address<TAccountCollateralVault>;
152
- /** Maker's WSOL account (receives remaining collateral) */
153
- makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
154
- /** OMLP Vault token account (receives loan repayments) */
155
- omlpVault: Address<TAccountOmlpVault>;
156
- /**
157
- * OMLP Vault state PDA (mut: updates `total_loans`, `total_liquidity`,
158
- * and `acc_interest_per_share_fp` via `add_interest_to_index` so lenders
159
- * actually realize the interest this settlement just paid them).
160
- */
161
- omlpVaultState: Address<TAccountOmlpVaultState>;
162
- /**
163
- * The OMLP Pool Loan to mark as repaid (V2 pooled system)
164
- * Must belong to the same maker as the collateral share
165
- */
166
- poolLoan: Address<TAccountPoolLoan>;
153
+ /** OMLP Vault token account (receives loan repayments when the maker borrowed) */
154
+ omlpVault?: Address<TAccountOmlpVault>;
155
+ /** OMLP Vault state PDA when the maker borrowed. */
156
+ omlpVaultState?: Address<TAccountOmlpVaultState>;
157
+ /** Optional OMLP Pool Loan for leveraged makers; unleveraged makers omit it. */
158
+ poolLoan?: Address<TAccountPoolLoan>;
167
159
  tokenProgram?: Address<TAccountTokenProgram>;
168
160
  systemProgram?: Address<TAccountSystemProgram>;
169
161
  };
@@ -172,8 +164,8 @@ export async function getSettleMakerCollateralInstructionAsync<
172
164
  TAccountCollateralPool extends string,
173
165
  TAccountOptionAccount extends string,
174
166
  TAccountMakerCollateralShare extends string,
167
+ TAccountWriterPosition extends string,
175
168
  TAccountCollateralVault extends string,
176
- TAccountMakerCollateralAccount extends string,
177
169
  TAccountOmlpVault extends string,
178
170
  TAccountOmlpVaultState extends string,
179
171
  TAccountPoolLoan extends string,
@@ -185,8 +177,8 @@ export async function getSettleMakerCollateralInstructionAsync<
185
177
  TAccountCollateralPool,
186
178
  TAccountOptionAccount,
187
179
  TAccountMakerCollateralShare,
180
+ TAccountWriterPosition,
188
181
  TAccountCollateralVault,
189
- TAccountMakerCollateralAccount,
190
182
  TAccountOmlpVault,
191
183
  TAccountOmlpVaultState,
192
184
  TAccountPoolLoan,
@@ -200,8 +192,8 @@ export async function getSettleMakerCollateralInstructionAsync<
200
192
  TAccountCollateralPool,
201
193
  TAccountOptionAccount,
202
194
  TAccountMakerCollateralShare,
195
+ TAccountWriterPosition,
203
196
  TAccountCollateralVault,
204
- TAccountMakerCollateralAccount,
205
197
  TAccountOmlpVault,
206
198
  TAccountOmlpVaultState,
207
199
  TAccountPoolLoan,
@@ -221,11 +213,8 @@ export async function getSettleMakerCollateralInstructionAsync<
221
213
  value: input.makerCollateralShare ?? null,
222
214
  isWritable: true,
223
215
  },
216
+ writerPosition: { value: input.writerPosition ?? null, isWritable: true },
224
217
  collateralVault: { value: input.collateralVault ?? null, isWritable: true },
225
- makerCollateralAccount: {
226
- value: input.makerCollateralAccount ?? null,
227
- isWritable: true,
228
- },
229
218
  omlpVault: { value: input.omlpVault ?? null, isWritable: true },
230
219
  omlpVaultState: { value: input.omlpVaultState ?? null, isWritable: true },
231
220
  poolLoan: { value: input.poolLoan ?? null, isWritable: true },
@@ -267,8 +256,8 @@ export async function getSettleMakerCollateralInstructionAsync<
267
256
  getAccountMeta(accounts.collateralPool),
268
257
  getAccountMeta(accounts.optionAccount),
269
258
  getAccountMeta(accounts.makerCollateralShare),
259
+ getAccountMeta(accounts.writerPosition),
270
260
  getAccountMeta(accounts.collateralVault),
271
- getAccountMeta(accounts.makerCollateralAccount),
272
261
  getAccountMeta(accounts.omlpVault),
273
262
  getAccountMeta(accounts.omlpVaultState),
274
263
  getAccountMeta(accounts.poolLoan),
@@ -282,8 +271,8 @@ export async function getSettleMakerCollateralInstructionAsync<
282
271
  TAccountCollateralPool,
283
272
  TAccountOptionAccount,
284
273
  TAccountMakerCollateralShare,
274
+ TAccountWriterPosition,
285
275
  TAccountCollateralVault,
286
- TAccountMakerCollateralAccount,
287
276
  TAccountOmlpVault,
288
277
  TAccountOmlpVaultState,
289
278
  TAccountPoolLoan,
@@ -296,8 +285,8 @@ export type SettleMakerCollateralInput<
296
285
  TAccountCollateralPool extends string = string,
297
286
  TAccountOptionAccount extends string = string,
298
287
  TAccountMakerCollateralShare extends string = string,
288
+ TAccountWriterPosition extends string = string,
299
289
  TAccountCollateralVault extends string = string,
300
- TAccountMakerCollateralAccount extends string = string,
301
290
  TAccountOmlpVault extends string = string,
302
291
  TAccountOmlpVaultState extends string = string,
303
292
  TAccountPoolLoan extends string = string,
@@ -308,23 +297,15 @@ export type SettleMakerCollateralInput<
308
297
  /** The option account (needed for PDA derivation) */
309
298
  optionAccount: Address<TAccountOptionAccount>;
310
299
  makerCollateralShare: Address<TAccountMakerCollateralShare>;
300
+ writerPosition: Address<TAccountWriterPosition>;
311
301
  /** Pool's collateral vault */
312
302
  collateralVault: Address<TAccountCollateralVault>;
313
- /** Maker's WSOL account (receives remaining collateral) */
314
- makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
315
- /** OMLP Vault token account (receives loan repayments) */
316
- omlpVault: Address<TAccountOmlpVault>;
317
- /**
318
- * OMLP Vault state PDA (mut: updates `total_loans`, `total_liquidity`,
319
- * and `acc_interest_per_share_fp` via `add_interest_to_index` so lenders
320
- * actually realize the interest this settlement just paid them).
321
- */
322
- omlpVaultState: Address<TAccountOmlpVaultState>;
323
- /**
324
- * The OMLP Pool Loan to mark as repaid (V2 pooled system)
325
- * Must belong to the same maker as the collateral share
326
- */
327
- poolLoan: Address<TAccountPoolLoan>;
303
+ /** OMLP Vault token account (receives loan repayments when the maker borrowed) */
304
+ omlpVault?: Address<TAccountOmlpVault>;
305
+ /** OMLP Vault state PDA when the maker borrowed. */
306
+ omlpVaultState?: Address<TAccountOmlpVaultState>;
307
+ /** Optional OMLP Pool Loan for leveraged makers; unleveraged makers omit it. */
308
+ poolLoan?: Address<TAccountPoolLoan>;
328
309
  tokenProgram?: Address<TAccountTokenProgram>;
329
310
  systemProgram?: Address<TAccountSystemProgram>;
330
311
  };
@@ -333,8 +314,8 @@ export function getSettleMakerCollateralInstruction<
333
314
  TAccountCollateralPool extends string,
334
315
  TAccountOptionAccount extends string,
335
316
  TAccountMakerCollateralShare extends string,
317
+ TAccountWriterPosition extends string,
336
318
  TAccountCollateralVault extends string,
337
- TAccountMakerCollateralAccount extends string,
338
319
  TAccountOmlpVault extends string,
339
320
  TAccountOmlpVaultState extends string,
340
321
  TAccountPoolLoan extends string,
@@ -346,8 +327,8 @@ export function getSettleMakerCollateralInstruction<
346
327
  TAccountCollateralPool,
347
328
  TAccountOptionAccount,
348
329
  TAccountMakerCollateralShare,
330
+ TAccountWriterPosition,
349
331
  TAccountCollateralVault,
350
- TAccountMakerCollateralAccount,
351
332
  TAccountOmlpVault,
352
333
  TAccountOmlpVaultState,
353
334
  TAccountPoolLoan,
@@ -360,8 +341,8 @@ export function getSettleMakerCollateralInstruction<
360
341
  TAccountCollateralPool,
361
342
  TAccountOptionAccount,
362
343
  TAccountMakerCollateralShare,
344
+ TAccountWriterPosition,
363
345
  TAccountCollateralVault,
364
- TAccountMakerCollateralAccount,
365
346
  TAccountOmlpVault,
366
347
  TAccountOmlpVaultState,
367
348
  TAccountPoolLoan,
@@ -380,11 +361,8 @@ export function getSettleMakerCollateralInstruction<
380
361
  value: input.makerCollateralShare ?? null,
381
362
  isWritable: true,
382
363
  },
364
+ writerPosition: { value: input.writerPosition ?? null, isWritable: true },
383
365
  collateralVault: { value: input.collateralVault ?? null, isWritable: true },
384
- makerCollateralAccount: {
385
- value: input.makerCollateralAccount ?? null,
386
- isWritable: true,
387
- },
388
366
  omlpVault: { value: input.omlpVault ?? null, isWritable: true },
389
367
  omlpVaultState: { value: input.omlpVaultState ?? null, isWritable: true },
390
368
  poolLoan: { value: input.poolLoan ?? null, isWritable: true },
@@ -412,8 +390,8 @@ export function getSettleMakerCollateralInstruction<
412
390
  getAccountMeta(accounts.collateralPool),
413
391
  getAccountMeta(accounts.optionAccount),
414
392
  getAccountMeta(accounts.makerCollateralShare),
393
+ getAccountMeta(accounts.writerPosition),
415
394
  getAccountMeta(accounts.collateralVault),
416
- getAccountMeta(accounts.makerCollateralAccount),
417
395
  getAccountMeta(accounts.omlpVault),
418
396
  getAccountMeta(accounts.omlpVaultState),
419
397
  getAccountMeta(accounts.poolLoan),
@@ -427,8 +405,8 @@ export function getSettleMakerCollateralInstruction<
427
405
  TAccountCollateralPool,
428
406
  TAccountOptionAccount,
429
407
  TAccountMakerCollateralShare,
408
+ TAccountWriterPosition,
430
409
  TAccountCollateralVault,
431
- TAccountMakerCollateralAccount,
432
410
  TAccountOmlpVault,
433
411
  TAccountOmlpVaultState,
434
412
  TAccountPoolLoan,
@@ -447,23 +425,15 @@ export type ParsedSettleMakerCollateralInstruction<
447
425
  /** The option account (needed for PDA derivation) */
448
426
  optionAccount: TAccountMetas[1];
449
427
  makerCollateralShare: TAccountMetas[2];
428
+ writerPosition: TAccountMetas[3];
450
429
  /** Pool's collateral vault */
451
- collateralVault: TAccountMetas[3];
452
- /** Maker's WSOL account (receives remaining collateral) */
453
- makerCollateralAccount: TAccountMetas[4];
454
- /** OMLP Vault token account (receives loan repayments) */
455
- omlpVault: TAccountMetas[5];
456
- /**
457
- * OMLP Vault state PDA (mut: updates `total_loans`, `total_liquidity`,
458
- * and `acc_interest_per_share_fp` via `add_interest_to_index` so lenders
459
- * actually realize the interest this settlement just paid them).
460
- */
461
- omlpVaultState: TAccountMetas[6];
462
- /**
463
- * The OMLP Pool Loan to mark as repaid (V2 pooled system)
464
- * Must belong to the same maker as the collateral share
465
- */
466
- poolLoan: TAccountMetas[7];
430
+ collateralVault: TAccountMetas[4];
431
+ /** OMLP Vault token account (receives loan repayments when the maker borrowed) */
432
+ omlpVault?: TAccountMetas[5] | undefined;
433
+ /** OMLP Vault state PDA when the maker borrowed. */
434
+ omlpVaultState?: TAccountMetas[6] | undefined;
435
+ /** Optional OMLP Pool Loan for leveraged makers; unleveraged makers omit it. */
436
+ poolLoan?: TAccountMetas[7] | undefined;
467
437
  tokenProgram: TAccountMetas[8];
468
438
  systemProgram: TAccountMetas[9];
469
439
  };
@@ -488,17 +458,23 @@ export function parseSettleMakerCollateralInstruction<
488
458
  accountIndex += 1;
489
459
  return accountMeta;
490
460
  };
461
+ const getNextOptionalAccount = () => {
462
+ const accountMeta = getNextAccount();
463
+ return accountMeta.address === OPTION_PROGRAM_PROGRAM_ADDRESS
464
+ ? undefined
465
+ : accountMeta;
466
+ };
491
467
  return {
492
468
  programAddress: instruction.programAddress,
493
469
  accounts: {
494
470
  collateralPool: getNextAccount(),
495
471
  optionAccount: getNextAccount(),
496
472
  makerCollateralShare: getNextAccount(),
473
+ writerPosition: getNextAccount(),
497
474
  collateralVault: getNextAccount(),
498
- makerCollateralAccount: getNextAccount(),
499
- omlpVault: getNextAccount(),
500
- omlpVaultState: getNextAccount(),
501
- poolLoan: getNextAccount(),
475
+ omlpVault: getNextOptionalAccount(),
476
+ omlpVaultState: getNextOptionalAccount(),
477
+ poolLoan: getNextOptionalAccount(),
502
478
  tokenProgram: getNextAccount(),
503
479
  systemProgram: getNextAccount(),
504
480
  },
@@ -22,6 +22,7 @@ import {
22
22
  parseAutoExerciseExpiredInstruction,
23
23
  parseBorrowFromPoolInstruction,
24
24
  parseBuyFromPoolInstruction,
25
+ parseClaimMakerRemainingInstruction,
25
26
  parseCloseLongToPoolInstruction,
26
27
  parseCloseOptionInstruction,
27
28
  parseCreateEscrowV2Instruction,
@@ -61,6 +62,7 @@ import {
61
62
  type ParsedAutoExerciseExpiredInstruction,
62
63
  type ParsedBorrowFromPoolInstruction,
63
64
  type ParsedBuyFromPoolInstruction,
65
+ type ParsedClaimMakerRemainingInstruction,
64
66
  type ParsedCloseLongToPoolInstruction,
65
67
  type ParsedCloseOptionInstruction,
66
68
  type ParsedCreateEscrowV2Instruction,
@@ -262,6 +264,7 @@ export enum OptionProgramInstruction {
262
264
  AutoExerciseExpired,
263
265
  BorrowFromPool,
264
266
  BuyFromPool,
267
+ ClaimMakerRemaining,
265
268
  CloseLongToPool,
266
269
  CloseOption,
267
270
  CreateEscrowV2,
@@ -357,6 +360,17 @@ export function identifyOptionProgramInstruction(
357
360
  ) {
358
361
  return OptionProgramInstruction.BuyFromPool;
359
362
  }
363
+ if (
364
+ containsBytes(
365
+ data,
366
+ fixEncoderSize(getBytesEncoder(), 8).encode(
367
+ new Uint8Array([108, 194, 135, 237, 155, 192, 199, 57]),
368
+ ),
369
+ 0,
370
+ )
371
+ ) {
372
+ return OptionProgramInstruction.ClaimMakerRemaining;
373
+ }
360
374
  if (
361
375
  containsBytes(
362
376
  data,
@@ -754,6 +768,9 @@ export type ParsedOptionProgramInstruction<
754
768
  | ({
755
769
  instructionType: OptionProgramInstruction.BuyFromPool;
756
770
  } & ParsedBuyFromPoolInstruction<TProgram>)
771
+ | ({
772
+ instructionType: OptionProgramInstruction.ClaimMakerRemaining;
773
+ } & ParsedClaimMakerRemainingInstruction<TProgram>)
757
774
  | ({
758
775
  instructionType: OptionProgramInstruction.CloseLongToPool;
759
776
  } & ParsedCloseLongToPoolInstruction<TProgram>)
@@ -897,6 +914,13 @@ export function parseOptionProgramInstruction<TProgram extends string>(
897
914
  ...parseBuyFromPoolInstruction(instruction),
898
915
  };
899
916
  }
917
+ case OptionProgramInstruction.ClaimMakerRemaining: {
918
+ assertIsInstructionWithAccounts(instruction);
919
+ return {
920
+ instructionType: OptionProgramInstruction.ClaimMakerRemaining,
921
+ ...parseClaimMakerRemainingInstruction(instruction),
922
+ };
923
+ }
900
924
  case OptionProgramInstruction.CloseLongToPool: {
901
925
  assertIsInstructionWithAccounts(instruction);
902
926
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.9.1-beta",
3
+ "version": "0.10.0-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
@@ -127,12 +127,12 @@ export interface BuildSyncWriterPositionParams {
127
127
  export interface BuildSettleMakerCollateralParams {
128
128
  optionAccount: AddressLike;
129
129
  collateralVault: AddressLike;
130
- makerCollateralAccount: AddressLike;
130
+ writerPosition: AddressLike;
131
131
  /** OMLP Vault token account (destination for principal+interest). */
132
- omlpVault: AddressLike;
132
+ omlpVault?: AddressLike;
133
133
  /** OMLP Vault state PDA (mut: updates `total_loans`, `total_liquidity`, `acc_interest_per_share_fp`). */
134
- omlpVaultState: AddressLike;
135
- poolLoan: AddressLike;
134
+ omlpVaultState?: AddressLike;
135
+ poolLoan?: AddressLike;
136
136
  maker: AddressLike;
137
137
  makerCollateralShare?: AddressLike;
138
138
  collateralPool?: AddressLike;
@@ -802,11 +802,11 @@ export async function buildSettleMakerCollateralInstruction(
802
802
  optionAccount: toAddress(params.optionAccount),
803
803
  collateralPool: params.collateralPool ? toAddress(params.collateralPool) : undefined,
804
804
  makerCollateralShare: toAddress(makerCollateralShare),
805
+ writerPosition: toAddress(params.writerPosition),
805
806
  collateralVault: toAddress(params.collateralVault),
806
- makerCollateralAccount: toAddress(params.makerCollateralAccount),
807
- omlpVault: toAddress(params.omlpVault),
808
- omlpVaultState: toAddress(params.omlpVaultState),
809
- poolLoan: toAddress(params.poolLoan),
807
+ omlpVault: params.omlpVault ? toAddress(params.omlpVault) : undefined,
808
+ omlpVaultState: params.omlpVaultState ? toAddress(params.omlpVaultState) : undefined,
809
+ poolLoan: params.poolLoan ? toAddress(params.poolLoan) : undefined,
810
810
  });
811
811
  return kitInstruction;
812
812
  }