@epicentral/sos-sdk 0.10.5-beta → 0.11.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.
package/README.md CHANGED
@@ -63,8 +63,12 @@ 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: 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
- | `getClaimMakerRemainingInstructionAsync` | Expiry Phase C generated instruction: returns remaining maker collateral after Phase B buyer payouts complete. |
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 prepared/claimed separately. |
67
+ | `buildPrepareBuyerSettlementInstruction` | Expiry Phase B (prepare): keeper snapshots a buyer’s capped expiry claim into `BuyerSettlementClaim` PDAs; **does not** transfer to the buyer’s wallet (non-custodial OPX path). |
68
+ | `buildClaimBuyerSettlementInstruction` | Expiry Phase B (claim): **buyer-signed** instruction that transfers the prepared payout from the collateral vault to the buyer’s ATA and closes the position. |
69
+ | `buildPrepareMakerSettlementInstruction` | Expiry Phase C (prepare): keeper snapshots maker residual into `MakerSettlementClaim` after Phase B completes. |
70
+ | `buildClaimMakerSettlementInstruction` | Expiry Phase C (claim): **maker-signed** instruction that transfers prepared residual collateral to the maker. |
71
+ | `getClaimMakerRemainingInstructionAsync` | **Legacy** Phase C: direct vault → maker transfer in one keeper call (still on-chain). Prefer prepare/claim for user-controlled settlement. |
68
72
  | `buildCloseOptionTransaction` | Closes option token account. |
69
73
  | `buildClaimThetaTransaction` | Claims theta (time-decay share) for writer. |
70
74
  | `buildRepayPoolLoanFromCollateralInstruction` | Repays pool loan from collateral (short/pool). |
@@ -81,17 +85,17 @@ Additional modules:
81
85
  - No maker transaction signer is required by this instruction format.
82
86
  - On-chain repayment (`collateral_vault` -> `omlp_vault`) is signed by the `collateral_pool` PDA.
83
87
  - Lender repayment is sourced from collateral vault funds, not maker wallet funds.
84
- - Expiry residual maker collateral is returned later by `claim_maker_remaining` after buyer payout Phase B.
88
+ - After Phase B, maker residual is returned via **prepare/claim** (`prepare_maker_settlement` `claim_maker_settlement`) or the legacy **`claim_maker_remaining`** instruction.
85
89
 
86
90
  ### Expiry Settlement
87
91
 
88
- Expiry settlement is lender-first and split across three instructions:
92
+ Expiry settlement is **lender-first**, then buyer phase, then maker phase. **OPX uses a non-custodial prepare/claim path:** keepers only **prepare** snapshots and phase progress; **users sign** claim transactions to receive tokens.
89
93
 
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.
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.
92
- 3. `claim_maker_remaining` (Phase C) for makers after `phase_b_complete`, returning residual collateral in the pool collateral mint.
94
+ 1. **`settle_maker_collateral` (Phase A)** For every non-liquidated maker: repay OMLP principal + interest from the collateral vault; snapshot `eligible_maker_pot` / `post_debt_collateral`. One transaction per active `PoolLoan` when a writer has multiple loans.
95
+ 2. **Phase B (buyers)** — **Recommended:** `prepare_buyer_settlement` (keeper, per position) records capped payouts on `BuyerSettlementClaim` and advances `phase_b_complete` when all buyer rows are processed; then **`claim_buyer_settlement` (buyer signer)** performs the vault buyer ATA transfer. Payouts are capped by `eligible_maker_pot` with the same pro-rata scaling as before. **Legacy:** `auto_exercise_expired` / `auto_exercise_all_expired` still exist and can transfer directly from the vault to buyer ATAs in the same instruction when invoked (custodial keeper pattern).
96
+ 3. **Phase C (makers)** — **Recommended:** `prepare_maker_settlement` (keeper) then **`claim_maker_settlement` (maker signer)**. **Legacy:** `claim_maker_remaining` still performs a direct residual transfer when called.
93
97
 
94
- New program errors exposed in the IDL: `LenderRepaymentNotComplete`, `BuyerPayoutNotComplete`, and `MakerLiquidated`.
98
+ New / related program errors include `LenderRepaymentNotComplete`, `BuyerPayoutNotComplete`, `MakerLiquidated`, and claim-state errors such as `SettlementClaimNotPrepared` / `SettlementClaimAlreadyClaimed` (see IDL).
95
99
 
96
100
  ### OMLP (Lending)
97
101
 
@@ -14,10 +14,6 @@ import {
14
14
  type ReadonlyUint8Array,
15
15
  } from "@solana/kit";
16
16
  import {
17
- parseBuyFromPoolInstruction,
18
- parseCloseLongToPoolInstruction,
19
- parseOptionMintInstruction,
20
- parseUnwindWriterUnsoldInstruction,
21
17
  type ParsedAcceptAdminInstruction,
22
18
  type ParsedAutoExerciseAllExpiredInstruction,
23
19
  type ParsedAutoExerciseExpiredInstruction,
@@ -938,36 +934,3 @@ export type ParsedOptionProgramInstruction<
938
934
  | ({
939
935
  instructionType: OptionProgramInstruction.WriteToPool;
940
936
  } & ParsedWriteToPoolInstruction<TProgram>);
941
-
942
-
943
- export function parseOptionProgramInstruction<
944
- TProgram extends string = "AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg",
945
- >(
946
- instruction: Parameters<typeof parseBuyFromPoolInstruction>[0],
947
- ): ParsedOptionProgramInstruction<TProgram> {
948
- const instructionType = identifyOptionProgramInstruction(instruction);
949
- switch (instructionType) {
950
- case OptionProgramInstruction.BuyFromPool:
951
- return {
952
- instructionType,
953
- ...parseBuyFromPoolInstruction(instruction),
954
- } as ParsedOptionProgramInstruction<TProgram>;
955
- case OptionProgramInstruction.CloseLongToPool:
956
- return {
957
- instructionType,
958
- ...parseCloseLongToPoolInstruction(instruction),
959
- } as ParsedOptionProgramInstruction<TProgram>;
960
- case OptionProgramInstruction.OptionMint:
961
- return {
962
- instructionType,
963
- ...parseOptionMintInstruction(instruction),
964
- } as ParsedOptionProgramInstruction<TProgram>;
965
- case OptionProgramInstruction.UnwindWriterUnsold:
966
- return {
967
- instructionType,
968
- ...parseUnwindWriterUnsoldInstruction(instruction),
969
- } as ParsedOptionProgramInstruction<TProgram>;
970
- default:
971
- throw new Error("Unsupported optionProgram instruction parser.");
972
- }
973
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epicentral/sos-sdk",
3
- "version": "0.10.5-beta",
3
+ "version": "0.11.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",