@epicentral/sos-sdk 0.14.0-beta → 0.14.2-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 +1 -0
- package/accounts/list.ts +22 -0
- package/generated/errors/optionProgram.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -398,6 +398,7 @@ Error codes to watch (see `generated/errors/optionProgram.ts`):
|
|
|
398
398
|
- `RescueUnauthorized` (6102) — rescue ix caller is not the vault keeper.
|
|
399
399
|
- `InvalidLoanRepayment` (6103) — repayment exceeded synced balances (slot race).
|
|
400
400
|
- `RescuePreconditionsNotMet` (6104) — rescue called on a solvent position.
|
|
401
|
+
- `StaleCanonicalLoanRequiresCleanup` — `option_mint` (leveraged) found the canonical loan (`["pool_loan", writer_position]`) carrying untracked residual principal from an abandoned borrow setup (TX A landed, TX B never completed). Repay the open loan before re-minting; the OPX client auto-repays via `cleanupStaleCanonicalLoanBeforeMint` before the borrow.
|
|
401
402
|
|
|
402
403
|
## Usage Examples
|
|
403
404
|
|
package/accounts/list.ts
CHANGED
|
@@ -146,6 +146,28 @@ export async function fetchWriterPositionsForPool(
|
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Fetches every WriterPosition account for the program in a single getProgramAccounts call.
|
|
151
|
+
*
|
|
152
|
+
* Use this instead of calling {@link fetchWriterPositionsForPool} once per pool when you need
|
|
153
|
+
* writer positions across many pools (e.g. option-chain sync). The caller can group the result
|
|
154
|
+
* by `data.optionPool` in memory, turning N RPC round-trips into one.
|
|
155
|
+
*/
|
|
156
|
+
export async function fetchAllWriterPositions(
|
|
157
|
+
rpc: KitRpc,
|
|
158
|
+
programId?: AddressLike
|
|
159
|
+
): Promise<Array<ListedAccount<WriterPosition>>> {
|
|
160
|
+
return fetchAndDecodeProgramAccounts(
|
|
161
|
+
rpc,
|
|
162
|
+
getWriterPositionDecoder(),
|
|
163
|
+
[
|
|
164
|
+
discriminatorFilter(WRITER_POSITION_DISCRIMINATOR),
|
|
165
|
+
{ dataSize: BigInt(getWriterPositionSize()) },
|
|
166
|
+
],
|
|
167
|
+
programId ?? PROGRAM_ID
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
149
171
|
export async function fetchPositionAccountsByBuyer(
|
|
150
172
|
rpc: KitRpc,
|
|
151
173
|
buyer: AddressLike
|
|
@@ -240,6 +240,8 @@ export const OPTION_PROGRAM_ERROR__RESCUE_UNAUTHORIZED = 0x17de; // 6110
|
|
|
240
240
|
export const OPTION_PROGRAM_ERROR__INVALID_LOAN_REPAYMENT = 0x17df; // 6111
|
|
241
241
|
/** RescuePreconditionsNotMet: Rescue preconditions not met: collateral_vault must be short of the remaining debt after theta forfeiture */
|
|
242
242
|
export const OPTION_PROGRAM_ERROR__RESCUE_PRECONDITIONS_NOT_MET = 0x17e0; // 6112
|
|
243
|
+
/** StaleCanonicalLoanRequiresCleanup: Canonical pool loan carries untracked residual principal from an abandoned borrow setup; repay/clean up the open loan before minting */
|
|
244
|
+
export const OPTION_PROGRAM_ERROR__STALE_CANONICAL_LOAN_REQUIRES_CLEANUP = 0x17e1; // 6113
|
|
243
245
|
|
|
244
246
|
export type OptionProgramError =
|
|
245
247
|
| typeof OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN
|
|
@@ -343,6 +345,7 @@ export type OptionProgramError =
|
|
|
343
345
|
| typeof OPTION_PROGRAM_ERROR__SETTLEMENT_CLAIM_ALREADY_PREPARED
|
|
344
346
|
| typeof OPTION_PROGRAM_ERROR__SETTLEMENT_CLAIM_NOT_PREPARED
|
|
345
347
|
| typeof OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED
|
|
348
|
+
| typeof OPTION_PROGRAM_ERROR__STALE_CANONICAL_LOAN_REQUIRES_CLEANUP
|
|
346
349
|
| typeof OPTION_PROGRAM_ERROR__STALE_MARKET_DATA
|
|
347
350
|
| typeof OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE
|
|
348
351
|
| typeof OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED
|
|
@@ -460,6 +463,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
460
463
|
[OPTION_PROGRAM_ERROR__SETTLEMENT_CLAIM_ALREADY_PREPARED]: `Settlement claim has already been prepared`,
|
|
461
464
|
[OPTION_PROGRAM_ERROR__SETTLEMENT_CLAIM_NOT_PREPARED]: `Settlement claim has not been prepared`,
|
|
462
465
|
[OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED]: `Slippage tolerance exceeded`,
|
|
466
|
+
[OPTION_PROGRAM_ERROR__STALE_CANONICAL_LOAN_REQUIRES_CLEANUP]: `Canonical pool loan carries untracked residual principal from an abandoned borrow setup; repay/clean up the open loan before minting`,
|
|
463
467
|
[OPTION_PROGRAM_ERROR__STALE_MARKET_DATA]: `Market data is stale and needs to be updated`,
|
|
464
468
|
[OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE]: `Oracle price is too old`,
|
|
465
469
|
[OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED]: `Deposit would exceed vault supply limit`,
|
package/package.json
CHANGED