@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,476 @@
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
+ isProgramError,
11
+ type Address,
12
+ type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
13
+ type SolanaError,
14
+ } from "@solana/kit";
15
+ import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
16
+
17
+ /** OptionExpired: Option has already expired */
18
+ export const OPTION_PROGRAM_ERROR__OPTION_EXPIRED = 0x1770; // 6000
19
+ /** InvalidExpirationDate: Invalid expiration date - must be in the future */
20
+ export const OPTION_PROGRAM_ERROR__INVALID_EXPIRATION_DATE = 0x1771; // 6001
21
+ /** InvalidPricingParameters: Invalid pricing parameters */
22
+ export const OPTION_PROGRAM_ERROR__INVALID_PRICING_PARAMETERS = 0x1772; // 6002
23
+ /** PositionAlreadyClosed: Position is already closed */
24
+ export const OPTION_PROGRAM_ERROR__POSITION_ALREADY_CLOSED = 0x1773; // 6003
25
+ /** UnauthorizedExercise: Unauthorized to exercise this option */
26
+ export const OPTION_PROGRAM_ERROR__UNAUTHORIZED_EXERCISE = 0x1774; // 6004
27
+ /** OptionOutOfMoney: Option is out of the money and cannot be exercised */
28
+ export const OPTION_PROGRAM_ERROR__OPTION_OUT_OF_MONEY = 0x1775; // 6005
29
+ /** InsufficientCollateral: Insufficient collateral provided */
30
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL = 0x1776; // 6006
31
+ /** InvalidOptionType: Invalid option type */
32
+ export const OPTION_PROGRAM_ERROR__INVALID_OPTION_TYPE = 0x1777; // 6007
33
+ /** InvalidStrikePrice: Strike price must be greater than zero */
34
+ export const OPTION_PROGRAM_ERROR__INVALID_STRIKE_PRICE = 0x1778; // 6008
35
+ /** InvalidQuantity: Quantity must be greater than zero */
36
+ export const OPTION_PROGRAM_ERROR__INVALID_QUANTITY = 0x1779; // 6009
37
+ /** OptionAlreadyExercised: Option has already been exercised */
38
+ export const OPTION_PROGRAM_ERROR__OPTION_ALREADY_EXERCISED = 0x177a; // 6010
39
+ /** StaleMarketData: Market data is stale and needs to be updated */
40
+ export const OPTION_PROGRAM_ERROR__STALE_MARKET_DATA = 0x177b; // 6011
41
+ /** InvalidVolatility: Volatility must be greater than zero */
42
+ export const OPTION_PROGRAM_ERROR__INVALID_VOLATILITY = 0x177c; // 6012
43
+ /** InvalidRiskFreeRate: Risk-free rate must be non-negative */
44
+ export const OPTION_PROGRAM_ERROR__INVALID_RISK_FREE_RATE = 0x177d; // 6013
45
+ /** InvalidUnderlyingPrice: Underlying price is invalid */
46
+ export const OPTION_PROGRAM_ERROR__INVALID_UNDERLYING_PRICE = 0x177e; // 6014
47
+ /** InvalidTimeToExpiration: Time to expiration must be positive */
48
+ export const OPTION_PROGRAM_ERROR__INVALID_TIME_TO_EXPIRATION = 0x177f; // 6015
49
+ /** StaleOraclePrice: Oracle price is too old */
50
+ export const OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE = 0x1780; // 6016
51
+ /** LowOraclePriceConfidence: Oracle price confidence is too low */
52
+ export const OPTION_PROGRAM_ERROR__LOW_ORACLE_PRICE_CONFIDENCE = 0x1781; // 6017
53
+ /** InvalidOracleAccount: Invalid oracle account - cannot parse price feed */
54
+ export const OPTION_PROGRAM_ERROR__INVALID_ORACLE_ACCOUNT = 0x1782; // 6018
55
+ /** InvalidSwitchboardQuoteAccount: Invalid Switchboard quote account */
56
+ export const OPTION_PROGRAM_ERROR__INVALID_SWITCHBOARD_QUOTE_ACCOUNT = 0x1783; // 6019
57
+ /** InvalidSwitchboardUpdateProof: Switchboard quote update proof missing or invalid */
58
+ export const OPTION_PROGRAM_ERROR__INVALID_SWITCHBOARD_UPDATE_PROOF = 0x1784; // 6020
59
+ /** OraclePriceUnavailable: Oracle price is unavailable */
60
+ export const OPTION_PROGRAM_ERROR__ORACLE_PRICE_UNAVAILABLE = 0x1785; // 6021
61
+ /** InvalidOraclePrice: Invalid oracle price - must be positive */
62
+ export const OPTION_PROGRAM_ERROR__INVALID_ORACLE_PRICE = 0x1786; // 6022
63
+ /** InsufficientBalance: Insufficient balance for premium payment */
64
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_BALANCE = 0x1787; // 6023
65
+ /** PositionNotFound: Position not found */
66
+ export const OPTION_PROGRAM_ERROR__POSITION_NOT_FOUND = 0x1788; // 6024
67
+ /** OptionAccountMismatch: Option account mismatch */
68
+ export const OPTION_PROGRAM_ERROR__OPTION_ACCOUNT_MISMATCH = 0x1789; // 6025
69
+ /** ArithmeticOverflow: Arithmetic overflow occurred */
70
+ export const OPTION_PROGRAM_ERROR__ARITHMETIC_OVERFLOW = 0x178a; // 6026
71
+ /** ArithmeticUnderflow: Arithmetic underflow occurred */
72
+ export const OPTION_PROGRAM_ERROR__ARITHMETIC_UNDERFLOW = 0x178b; // 6027
73
+ /** DivisionByZero: Division by zero */
74
+ export const OPTION_PROGRAM_ERROR__DIVISION_BY_ZERO = 0x178c; // 6028
75
+ /** PremiumCalculationFailed: Premium calculation failed */
76
+ export const OPTION_PROGRAM_ERROR__PREMIUM_CALCULATION_FAILED = 0x178d; // 6029
77
+ /** GreeksCalculationFailed: Greeks calculation failed */
78
+ export const OPTION_PROGRAM_ERROR__GREEKS_CALCULATION_FAILED = 0x178e; // 6030
79
+ /** InvalidEscrowAuthority: Invalid escrow authority */
80
+ export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_AUTHORITY = 0x178f; // 6031
81
+ /** EscrowAccountFrozen: Escrow account is frozen */
82
+ export const OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_FROZEN = 0x1790; // 6032
83
+ /** MarketClosed: Market is closed */
84
+ export const OPTION_PROGRAM_ERROR__MARKET_CLOSED = 0x1791; // 6033
85
+ /** MaxPositionsReached: Maximum positions limit reached */
86
+ export const OPTION_PROGRAM_ERROR__MAX_POSITIONS_REACHED = 0x1792; // 6034
87
+ /** MinimumPositionSizeNotMet: Minimum position size not met */
88
+ export const OPTION_PROGRAM_ERROR__MINIMUM_POSITION_SIZE_NOT_MET = 0x1793; // 6035
89
+ /** MaximumPositionSizeExceeded: Maximum position size exceeded */
90
+ export const OPTION_PROGRAM_ERROR__MAXIMUM_POSITION_SIZE_EXCEEDED = 0x1794; // 6036
91
+ /** InvalidMakerAuthority: Invalid maker authority */
92
+ export const OPTION_PROGRAM_ERROR__INVALID_MAKER_AUTHORITY = 0x1795; // 6037
93
+ /** InvalidBuyerAuthority: Invalid buyer authority */
94
+ export const OPTION_PROGRAM_ERROR__INVALID_BUYER_AUTHORITY = 0x1796; // 6038
95
+ /** OptionChainFull: Option chain is full */
96
+ export const OPTION_PROGRAM_ERROR__OPTION_CHAIN_FULL = 0x1797; // 6039
97
+ /** DuplicateOption: Duplicate option exists */
98
+ export const OPTION_PROGRAM_ERROR__DUPLICATE_OPTION = 0x1798; // 6040
99
+ /** PriceImpactTooHigh: Price impact too high */
100
+ export const OPTION_PROGRAM_ERROR__PRICE_IMPACT_TOO_HIGH = 0x1799; // 6041
101
+ /** SlippageToleranceExceeded: Slippage tolerance exceeded */
102
+ export const OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED = 0x179a; // 6042
103
+ /** InsufficientPoolLiquidity: Insufficient pool liquidity available */
104
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_LIQUIDITY = 0x179b; // 6043
105
+ /** InsufficientPoolAggregateLiquidity: Insufficient aggregate pool liquidity for requested quantity */
106
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_AGGREGATE_LIQUIDITY = 0x179c; // 6044
107
+ /** InsufficientWriterPositionLiquidity: Insufficient active writer liquidity to fill requested quantity */
108
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_WRITER_POSITION_LIQUIDITY = 0x179d; // 6045
109
+ /** InsufficientUserBalance: Insufficient user balance for withdrawal */
110
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_USER_BALANCE = 0x179e; // 6046
111
+ /** UnhealthyPosition: Health ratio below liquidation threshold */
112
+ export const OPTION_PROGRAM_ERROR__UNHEALTHY_POSITION = 0x179f; // 6047
113
+ /** UnauthorizedOmlp: Unauthorized to perform this OMLP action */
114
+ export const OPTION_PROGRAM_ERROR__UNAUTHORIZED_OMLP = 0x17a0; // 6048
115
+ /** InvalidTenor: Invalid loan tenor */
116
+ export const OPTION_PROGRAM_ERROR__INVALID_TENOR = 0x17a1; // 6049
117
+ /** InvalidRate: Invalid interest rate */
118
+ export const OPTION_PROGRAM_ERROR__INVALID_RATE = 0x17a2; // 6050
119
+ /** NotForeclosable: Loan is not eligible for foreclosure */
120
+ export const OPTION_PROGRAM_ERROR__NOT_FORECLOSABLE = 0x17a3; // 6051
121
+ /** InsufficientVaultLiquidity: Vault has insufficient liquidity */
122
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_VAULT_LIQUIDITY = 0x17a4; // 6052
123
+ /** InsufficientLoanCollateral: Collateral insufficient for loan */
124
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_LOAN_COLLATERAL = 0x17a5; // 6053
125
+ /** OracleTooStale: Oracle price is stale - cannot validate */
126
+ export const OPTION_PROGRAM_ERROR__ORACLE_TOO_STALE = 0x17a6; // 6054
127
+ /** ValidationRequired: Must call option_validate before borrow/settlement */
128
+ export const OPTION_PROGRAM_ERROR__VALIDATION_REQUIRED = 0x17a7; // 6055
129
+ /** HealthCalculationFailed: Health ratio calculation failed */
130
+ export const OPTION_PROGRAM_ERROR__HEALTH_CALCULATION_FAILED = 0x17a8; // 6056
131
+ /** ContractAlreadySettled: Contract already settled */
132
+ export const OPTION_PROGRAM_ERROR__CONTRACT_ALREADY_SETTLED = 0x17a9; // 6057
133
+ /** NoYieldAvailable: No yield available to claim */
134
+ export const OPTION_PROGRAM_ERROR__NO_YIELD_AVAILABLE = 0x17aa; // 6058
135
+ /** UnauthorizedAccess: Unauthorized access - you don't own this resource */
136
+ export const OPTION_PROGRAM_ERROR__UNAUTHORIZED_ACCESS = 0x17ab; // 6059
137
+ /** InsufficientQuantity: Insufficient quantity available in ask position */
138
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_QUANTITY = 0x17ac; // 6060
139
+ /** NothingToClaim: Nothing to claim - no unclaimed premium */
140
+ export const OPTION_PROGRAM_ERROR__NOTHING_TO_CLAIM = 0x17ad; // 6061
141
+ /** PoolNotActive: Pool is not active */
142
+ export const OPTION_PROGRAM_ERROR__POOL_NOT_ACTIVE = 0x17ae; // 6062
143
+ /** PoolAlreadyExists: Pool already exists for this option */
144
+ export const OPTION_PROGRAM_ERROR__POOL_ALREADY_EXISTS = 0x17af; // 6063
145
+ /** PoolNotExercised: Pool has not been exercised yet */
146
+ export const OPTION_PROGRAM_ERROR__POOL_NOT_EXERCISED = 0x17b0; // 6064
147
+ /** AlreadySettled: Maker's collateral share has already been settled */
148
+ export const OPTION_PROGRAM_ERROR__ALREADY_SETTLED = 0x17b1; // 6065
149
+ /** InsufficientPoolCollateral: Insufficient collateral in pool for exercise */
150
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_COLLATERAL = 0x17b2; // 6066
151
+ /** CollateralPoolNotFound: Collateral pool does not exist */
152
+ export const OPTION_PROGRAM_ERROR__COLLATERAL_POOL_NOT_FOUND = 0x17b3; // 6067
153
+ /** NoCollateralToWithdraw: No collateral to withdraw */
154
+ export const OPTION_PROGRAM_ERROR__NO_COLLATERAL_TO_WITHDRAW = 0x17b4; // 6068
155
+ /** OptionNotExpired: Option has not expired yet - cannot settle */
156
+ export const OPTION_PROGRAM_ERROR__OPTION_NOT_EXPIRED = 0x17b5; // 6069
157
+ /** SupplyLimitExceeded: Deposit would exceed vault supply limit */
158
+ export const OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED = 0x17b6; // 6070
159
+ /** InvalidFeeWallet: Invalid fee wallet - must match protocol constant */
160
+ export const OPTION_PROGRAM_ERROR__INVALID_FEE_WALLET = 0x17b7; // 6071
161
+ /** InvalidProtocolFee: Invalid protocol fee rate */
162
+ export const OPTION_PROGRAM_ERROR__INVALID_PROTOCOL_FEE = 0x17b8; // 6072
163
+ /** UnderlyingAssetMismatch: Underlying asset mismatch - market data or mint does not match option */
164
+ export const OPTION_PROGRAM_ERROR__UNDERLYING_ASSET_MISMATCH = 0x17b9; // 6073
165
+ /** InvalidMint: Invalid token mint - does not match expected underlying asset */
166
+ export const OPTION_PROGRAM_ERROR__INVALID_MINT = 0x17ba; // 6074
167
+ /** BatchSizeExceeded: Batch size exceeds maximum allowed (10 positions) */
168
+ export const OPTION_PROGRAM_ERROR__BATCH_SIZE_EXCEEDED = 0x17bb; // 6075
169
+ /** NoPositionsProvided: No positions provided in batch */
170
+ export const OPTION_PROGRAM_ERROR__NO_POSITIONS_PROVIDED = 0x17bc; // 6076
171
+ /** PositionOptionMismatch: Position account does not belong to this option */
172
+ export const OPTION_PROGRAM_ERROR__POSITION_OPTION_MISMATCH = 0x17bd; // 6077
173
+ /** OptionPoolMismatch: Option account does not match the option pool's option account */
174
+ export const OPTION_PROGRAM_ERROR__OPTION_POOL_MISMATCH = 0x17be; // 6078
175
+ /** InvalidSeed: Invalid seed - must be exactly 32 bytes */
176
+ export const OPTION_PROGRAM_ERROR__INVALID_SEED = 0x17bf; // 6079
177
+ /** InvalidAuthority: Invalid authority - does not match escrow authority */
178
+ export const OPTION_PROGRAM_ERROR__INVALID_AUTHORITY = 0x17c0; // 6080
179
+ /** EscrowAccountRequired: Escrow accounts required when borrowed_amount > 0 */
180
+ export const OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_REQUIRED = 0x17c1; // 6081
181
+ /** InvalidEscrowMaker: Escrow state maker does not match instruction maker */
182
+ export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_MAKER = 0x17c2; // 6082
183
+ /** EscrowMintMismatch: Escrow collateral mint does not match collateral pool mint */
184
+ export const OPTION_PROGRAM_ERROR__ESCROW_MINT_MISMATCH = 0x17c3; // 6083
185
+ /** InsufficientEscrowBalance: Insufficient balance in escrow token account */
186
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_ESCROW_BALANCE = 0x17c4; // 6084
187
+ /** InvalidEscrowOwner: Escrow token account owner mismatch */
188
+ export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_OWNER = 0x17c5; // 6085
189
+ /** InvalidEscrowMint: Escrow token account mint mismatch */
190
+ export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_MINT = 0x17c6; // 6086
191
+ /** AccountFrozen: Token account is frozen and cannot be burned */
192
+ export const OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN = 0x17c7; // 6087
193
+ /** InvalidAccount: Invalid account - does not match expected account */
194
+ export const OPTION_PROGRAM_ERROR__INVALID_ACCOUNT = 0x17c8; // 6088
195
+ /** UnwindRepayAccountsMissing: Unwind repayment accounts are required when active pool loans exist */
196
+ export const OPTION_PROGRAM_ERROR__UNWIND_REPAY_ACCOUNTS_MISSING = 0x17c9; // 6089
197
+ /** InsufficientCollateralVault: Collateral vault has insufficient funds for unwind collateral return */
198
+ export const OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL_VAULT = 0x17ca; // 6090
199
+ /** InvalidVaultMint: Invalid vault mint - does not match expected collateral mint */
200
+ export const OPTION_PROGRAM_ERROR__INVALID_VAULT_MINT = 0x17cb; // 6091
201
+ /** InvalidCollateralMint: Invalid collateral mint - not supported or no vault exists */
202
+ export const OPTION_PROGRAM_ERROR__INVALID_COLLATERAL_MINT = 0x17cc; // 6092
203
+ /** CollateralMismatch: Collateral mint mismatch - position uses different collateral type */
204
+ export const OPTION_PROGRAM_ERROR__COLLATERAL_MISMATCH = 0x17cd; // 6093
205
+ /** BuyRemainingAccountsUnsorted: buy_from_pool remaining_accounts are not sorted by (created_at asc, pubkey asc) */
206
+ export const OPTION_PROGRAM_ERROR__BUY_REMAINING_ACCOUNTS_UNSORTED = 0x17ce; // 6094
207
+ /** CloseLongWritersIncomplete: close_long_to_pool requires a complete set of active WriterPositions: sum(sold_qty) must equal pool.total_sold_qty */
208
+ export const OPTION_PROGRAM_ERROR__CLOSE_LONG_WRITERS_INCOMPLETE = 0x17cf; // 6095
209
+ /** CloseLongNoSoldInventory: close_long_to_pool cannot run because no writer has sold inventory for this pool */
210
+ export const OPTION_PROGRAM_ERROR__CLOSE_LONG_NO_SOLD_INVENTORY = 0x17d0; // 6096
211
+ /** CloseLongDuplicateWriter: close_long_to_pool remaining_accounts contain duplicate WriterPosition entries */
212
+ export const OPTION_PROGRAM_ERROR__CLOSE_LONG_DUPLICATE_WRITER = 0x17d1; // 6097
213
+ /** MaintenanceBufferBreached: Writer position breaches maintenance buffer: free_collateral + claimable_theta < accrued_interest + fees + buffer */
214
+ export const OPTION_PROGRAM_ERROR__MAINTENANCE_BUFFER_BREACHED = 0x17d2; // 6098
215
+ /** LiquidationInsufficientCollateralForDebt: Liquidation cannot cover full debt (principal + interest + fees) from writer's collateral + theta; call rescue path instead */
216
+ export const OPTION_PROGRAM_ERROR__LIQUIDATION_INSUFFICIENT_COLLATERAL_FOR_DEBT = 0x17d3; // 6099
217
+ /** ThetaClaimDisabled: claim_theta instruction has been removed; theta is now auto-realized on unwind or forfeited on liquidation */
218
+ export const OPTION_PROGRAM_ERROR__THETA_CLAIM_DISABLED = 0x17d4; // 6100
219
+ /** PoolLoanWriterMismatch: PoolLoan.writer_position does not match the WriterPosition in this instruction */
220
+ export const OPTION_PROGRAM_ERROR__POOL_LOAN_WRITER_MISMATCH = 0x17d5; // 6101
221
+ /** MaintenanceLoansIncomplete: Maintenance debt sync remaining_accounts must contain every active PoolLoan for this writer */
222
+ export const OPTION_PROGRAM_ERROR__MAINTENANCE_LOANS_INCOMPLETE = 0x17d6; // 6102
223
+ /** RescueUnauthorized: Rescue liquidation is gated to the vault keeper */
224
+ export const OPTION_PROGRAM_ERROR__RESCUE_UNAUTHORIZED = 0x17d7; // 6103
225
+ /** InvalidLoanRepayment: Loan repayment amount exceeds synced balances (principal/interest/fees) */
226
+ export const OPTION_PROGRAM_ERROR__INVALID_LOAN_REPAYMENT = 0x17d8; // 6104
227
+ /** RescuePreconditionsNotMet: Rescue preconditions not met: collateral_vault must be short of the remaining debt after theta forfeiture */
228
+ export const OPTION_PROGRAM_ERROR__RESCUE_PRECONDITIONS_NOT_MET = 0x17d9; // 6105
229
+
230
+ export type OptionProgramError =
231
+ | typeof OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN
232
+ | typeof OPTION_PROGRAM_ERROR__ALREADY_SETTLED
233
+ | typeof OPTION_PROGRAM_ERROR__ARITHMETIC_OVERFLOW
234
+ | typeof OPTION_PROGRAM_ERROR__ARITHMETIC_UNDERFLOW
235
+ | typeof OPTION_PROGRAM_ERROR__BATCH_SIZE_EXCEEDED
236
+ | typeof OPTION_PROGRAM_ERROR__BUY_REMAINING_ACCOUNTS_UNSORTED
237
+ | typeof OPTION_PROGRAM_ERROR__CLOSE_LONG_DUPLICATE_WRITER
238
+ | typeof OPTION_PROGRAM_ERROR__CLOSE_LONG_NO_SOLD_INVENTORY
239
+ | typeof OPTION_PROGRAM_ERROR__CLOSE_LONG_WRITERS_INCOMPLETE
240
+ | typeof OPTION_PROGRAM_ERROR__COLLATERAL_MISMATCH
241
+ | typeof OPTION_PROGRAM_ERROR__COLLATERAL_POOL_NOT_FOUND
242
+ | typeof OPTION_PROGRAM_ERROR__CONTRACT_ALREADY_SETTLED
243
+ | typeof OPTION_PROGRAM_ERROR__DIVISION_BY_ZERO
244
+ | typeof OPTION_PROGRAM_ERROR__DUPLICATE_OPTION
245
+ | typeof OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_FROZEN
246
+ | typeof OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_REQUIRED
247
+ | typeof OPTION_PROGRAM_ERROR__ESCROW_MINT_MISMATCH
248
+ | typeof OPTION_PROGRAM_ERROR__GREEKS_CALCULATION_FAILED
249
+ | typeof OPTION_PROGRAM_ERROR__HEALTH_CALCULATION_FAILED
250
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_BALANCE
251
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL
252
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL_VAULT
253
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_ESCROW_BALANCE
254
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_LOAN_COLLATERAL
255
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_AGGREGATE_LIQUIDITY
256
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_COLLATERAL
257
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_LIQUIDITY
258
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_QUANTITY
259
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_USER_BALANCE
260
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_VAULT_LIQUIDITY
261
+ | typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_WRITER_POSITION_LIQUIDITY
262
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ACCOUNT
263
+ | typeof OPTION_PROGRAM_ERROR__INVALID_AUTHORITY
264
+ | typeof OPTION_PROGRAM_ERROR__INVALID_BUYER_AUTHORITY
265
+ | typeof OPTION_PROGRAM_ERROR__INVALID_COLLATERAL_MINT
266
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_AUTHORITY
267
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_MAKER
268
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_MINT
269
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_OWNER
270
+ | typeof OPTION_PROGRAM_ERROR__INVALID_EXPIRATION_DATE
271
+ | typeof OPTION_PROGRAM_ERROR__INVALID_FEE_WALLET
272
+ | typeof OPTION_PROGRAM_ERROR__INVALID_LOAN_REPAYMENT
273
+ | typeof OPTION_PROGRAM_ERROR__INVALID_MAKER_AUTHORITY
274
+ | typeof OPTION_PROGRAM_ERROR__INVALID_MINT
275
+ | typeof OPTION_PROGRAM_ERROR__INVALID_OPTION_TYPE
276
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ORACLE_ACCOUNT
277
+ | typeof OPTION_PROGRAM_ERROR__INVALID_ORACLE_PRICE
278
+ | typeof OPTION_PROGRAM_ERROR__INVALID_PRICING_PARAMETERS
279
+ | typeof OPTION_PROGRAM_ERROR__INVALID_PROTOCOL_FEE
280
+ | typeof OPTION_PROGRAM_ERROR__INVALID_QUANTITY
281
+ | typeof OPTION_PROGRAM_ERROR__INVALID_RATE
282
+ | typeof OPTION_PROGRAM_ERROR__INVALID_RISK_FREE_RATE
283
+ | typeof OPTION_PROGRAM_ERROR__INVALID_SEED
284
+ | typeof OPTION_PROGRAM_ERROR__INVALID_STRIKE_PRICE
285
+ | typeof OPTION_PROGRAM_ERROR__INVALID_SWITCHBOARD_QUOTE_ACCOUNT
286
+ | typeof OPTION_PROGRAM_ERROR__INVALID_SWITCHBOARD_UPDATE_PROOF
287
+ | typeof OPTION_PROGRAM_ERROR__INVALID_TENOR
288
+ | typeof OPTION_PROGRAM_ERROR__INVALID_TIME_TO_EXPIRATION
289
+ | typeof OPTION_PROGRAM_ERROR__INVALID_UNDERLYING_PRICE
290
+ | typeof OPTION_PROGRAM_ERROR__INVALID_VAULT_MINT
291
+ | typeof OPTION_PROGRAM_ERROR__INVALID_VOLATILITY
292
+ | typeof OPTION_PROGRAM_ERROR__LIQUIDATION_INSUFFICIENT_COLLATERAL_FOR_DEBT
293
+ | typeof OPTION_PROGRAM_ERROR__LOW_ORACLE_PRICE_CONFIDENCE
294
+ | typeof OPTION_PROGRAM_ERROR__MAINTENANCE_BUFFER_BREACHED
295
+ | typeof OPTION_PROGRAM_ERROR__MAINTENANCE_LOANS_INCOMPLETE
296
+ | typeof OPTION_PROGRAM_ERROR__MARKET_CLOSED
297
+ | typeof OPTION_PROGRAM_ERROR__MAXIMUM_POSITION_SIZE_EXCEEDED
298
+ | typeof OPTION_PROGRAM_ERROR__MAX_POSITIONS_REACHED
299
+ | typeof OPTION_PROGRAM_ERROR__MINIMUM_POSITION_SIZE_NOT_MET
300
+ | typeof OPTION_PROGRAM_ERROR__NO_COLLATERAL_TO_WITHDRAW
301
+ | typeof OPTION_PROGRAM_ERROR__NO_POSITIONS_PROVIDED
302
+ | typeof OPTION_PROGRAM_ERROR__NOT_FORECLOSABLE
303
+ | typeof OPTION_PROGRAM_ERROR__NOTHING_TO_CLAIM
304
+ | typeof OPTION_PROGRAM_ERROR__NO_YIELD_AVAILABLE
305
+ | typeof OPTION_PROGRAM_ERROR__OPTION_ACCOUNT_MISMATCH
306
+ | typeof OPTION_PROGRAM_ERROR__OPTION_ALREADY_EXERCISED
307
+ | typeof OPTION_PROGRAM_ERROR__OPTION_CHAIN_FULL
308
+ | typeof OPTION_PROGRAM_ERROR__OPTION_EXPIRED
309
+ | typeof OPTION_PROGRAM_ERROR__OPTION_NOT_EXPIRED
310
+ | typeof OPTION_PROGRAM_ERROR__OPTION_OUT_OF_MONEY
311
+ | typeof OPTION_PROGRAM_ERROR__OPTION_POOL_MISMATCH
312
+ | typeof OPTION_PROGRAM_ERROR__ORACLE_PRICE_UNAVAILABLE
313
+ | typeof OPTION_PROGRAM_ERROR__ORACLE_TOO_STALE
314
+ | typeof OPTION_PROGRAM_ERROR__POOL_ALREADY_EXISTS
315
+ | typeof OPTION_PROGRAM_ERROR__POOL_LOAN_WRITER_MISMATCH
316
+ | typeof OPTION_PROGRAM_ERROR__POOL_NOT_ACTIVE
317
+ | typeof OPTION_PROGRAM_ERROR__POOL_NOT_EXERCISED
318
+ | typeof OPTION_PROGRAM_ERROR__POSITION_ALREADY_CLOSED
319
+ | typeof OPTION_PROGRAM_ERROR__POSITION_NOT_FOUND
320
+ | typeof OPTION_PROGRAM_ERROR__POSITION_OPTION_MISMATCH
321
+ | typeof OPTION_PROGRAM_ERROR__PREMIUM_CALCULATION_FAILED
322
+ | typeof OPTION_PROGRAM_ERROR__PRICE_IMPACT_TOO_HIGH
323
+ | typeof OPTION_PROGRAM_ERROR__RESCUE_PRECONDITIONS_NOT_MET
324
+ | typeof OPTION_PROGRAM_ERROR__RESCUE_UNAUTHORIZED
325
+ | typeof OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED
326
+ | typeof OPTION_PROGRAM_ERROR__STALE_MARKET_DATA
327
+ | typeof OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE
328
+ | typeof OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED
329
+ | typeof OPTION_PROGRAM_ERROR__THETA_CLAIM_DISABLED
330
+ | typeof OPTION_PROGRAM_ERROR__UNAUTHORIZED_ACCESS
331
+ | typeof OPTION_PROGRAM_ERROR__UNAUTHORIZED_EXERCISE
332
+ | typeof OPTION_PROGRAM_ERROR__UNAUTHORIZED_OMLP
333
+ | typeof OPTION_PROGRAM_ERROR__UNDERLYING_ASSET_MISMATCH
334
+ | typeof OPTION_PROGRAM_ERROR__UNHEALTHY_POSITION
335
+ | typeof OPTION_PROGRAM_ERROR__UNWIND_REPAY_ACCOUNTS_MISSING
336
+ | typeof OPTION_PROGRAM_ERROR__VALIDATION_REQUIRED;
337
+
338
+ let optionProgramErrorMessages: Record<OptionProgramError, string> | undefined;
339
+ if (process.env.NODE_ENV !== "production") {
340
+ optionProgramErrorMessages = {
341
+ [OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN]: `Token account is frozen and cannot be burned`,
342
+ [OPTION_PROGRAM_ERROR__ALREADY_SETTLED]: `Maker's collateral share has already been settled`,
343
+ [OPTION_PROGRAM_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow occurred`,
344
+ [OPTION_PROGRAM_ERROR__ARITHMETIC_UNDERFLOW]: `Arithmetic underflow occurred`,
345
+ [OPTION_PROGRAM_ERROR__BATCH_SIZE_EXCEEDED]: `Batch size exceeds maximum allowed (10 positions)`,
346
+ [OPTION_PROGRAM_ERROR__BUY_REMAINING_ACCOUNTS_UNSORTED]: `buy_from_pool remaining_accounts are not sorted by (created_at asc, pubkey asc)`,
347
+ [OPTION_PROGRAM_ERROR__CLOSE_LONG_DUPLICATE_WRITER]: `close_long_to_pool remaining_accounts contain duplicate WriterPosition entries`,
348
+ [OPTION_PROGRAM_ERROR__CLOSE_LONG_NO_SOLD_INVENTORY]: `close_long_to_pool cannot run because no writer has sold inventory for this pool`,
349
+ [OPTION_PROGRAM_ERROR__CLOSE_LONG_WRITERS_INCOMPLETE]: `close_long_to_pool requires a complete set of active WriterPositions: sum(sold_qty) must equal pool.total_sold_qty`,
350
+ [OPTION_PROGRAM_ERROR__COLLATERAL_MISMATCH]: `Collateral mint mismatch - position uses different collateral type`,
351
+ [OPTION_PROGRAM_ERROR__COLLATERAL_POOL_NOT_FOUND]: `Collateral pool does not exist`,
352
+ [OPTION_PROGRAM_ERROR__CONTRACT_ALREADY_SETTLED]: `Contract already settled`,
353
+ [OPTION_PROGRAM_ERROR__DIVISION_BY_ZERO]: `Division by zero`,
354
+ [OPTION_PROGRAM_ERROR__DUPLICATE_OPTION]: `Duplicate option exists`,
355
+ [OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_FROZEN]: `Escrow account is frozen`,
356
+ [OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_REQUIRED]: `Escrow accounts required when borrowed_amount > 0`,
357
+ [OPTION_PROGRAM_ERROR__ESCROW_MINT_MISMATCH]: `Escrow collateral mint does not match collateral pool mint`,
358
+ [OPTION_PROGRAM_ERROR__GREEKS_CALCULATION_FAILED]: `Greeks calculation failed`,
359
+ [OPTION_PROGRAM_ERROR__HEALTH_CALCULATION_FAILED]: `Health ratio calculation failed`,
360
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance for premium payment`,
361
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL]: `Insufficient collateral provided`,
362
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL_VAULT]: `Collateral vault has insufficient funds for unwind collateral return`,
363
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_ESCROW_BALANCE]: `Insufficient balance in escrow token account`,
364
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_LOAN_COLLATERAL]: `Collateral insufficient for loan`,
365
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_AGGREGATE_LIQUIDITY]: `Insufficient aggregate pool liquidity for requested quantity`,
366
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_COLLATERAL]: `Insufficient collateral in pool for exercise`,
367
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_LIQUIDITY]: `Insufficient pool liquidity available`,
368
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_QUANTITY]: `Insufficient quantity available in ask position`,
369
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_USER_BALANCE]: `Insufficient user balance for withdrawal`,
370
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_VAULT_LIQUIDITY]: `Vault has insufficient liquidity`,
371
+ [OPTION_PROGRAM_ERROR__INSUFFICIENT_WRITER_POSITION_LIQUIDITY]: `Insufficient active writer liquidity to fill requested quantity`,
372
+ [OPTION_PROGRAM_ERROR__INVALID_ACCOUNT]: `Invalid account - does not match expected account`,
373
+ [OPTION_PROGRAM_ERROR__INVALID_AUTHORITY]: `Invalid authority - does not match escrow authority`,
374
+ [OPTION_PROGRAM_ERROR__INVALID_BUYER_AUTHORITY]: `Invalid buyer authority`,
375
+ [OPTION_PROGRAM_ERROR__INVALID_COLLATERAL_MINT]: `Invalid collateral mint - not supported or no vault exists`,
376
+ [OPTION_PROGRAM_ERROR__INVALID_ESCROW_AUTHORITY]: `Invalid escrow authority`,
377
+ [OPTION_PROGRAM_ERROR__INVALID_ESCROW_MAKER]: `Escrow state maker does not match instruction maker`,
378
+ [OPTION_PROGRAM_ERROR__INVALID_ESCROW_MINT]: `Escrow token account mint mismatch`,
379
+ [OPTION_PROGRAM_ERROR__INVALID_ESCROW_OWNER]: `Escrow token account owner mismatch`,
380
+ [OPTION_PROGRAM_ERROR__INVALID_EXPIRATION_DATE]: `Invalid expiration date - must be in the future`,
381
+ [OPTION_PROGRAM_ERROR__INVALID_FEE_WALLET]: `Invalid fee wallet - must match protocol constant`,
382
+ [OPTION_PROGRAM_ERROR__INVALID_LOAN_REPAYMENT]: `Loan repayment amount exceeds synced balances (principal/interest/fees)`,
383
+ [OPTION_PROGRAM_ERROR__INVALID_MAKER_AUTHORITY]: `Invalid maker authority`,
384
+ [OPTION_PROGRAM_ERROR__INVALID_MINT]: `Invalid token mint - does not match expected underlying asset`,
385
+ [OPTION_PROGRAM_ERROR__INVALID_OPTION_TYPE]: `Invalid option type`,
386
+ [OPTION_PROGRAM_ERROR__INVALID_ORACLE_ACCOUNT]: `Invalid oracle account - cannot parse price feed`,
387
+ [OPTION_PROGRAM_ERROR__INVALID_ORACLE_PRICE]: `Invalid oracle price - must be positive`,
388
+ [OPTION_PROGRAM_ERROR__INVALID_PRICING_PARAMETERS]: `Invalid pricing parameters`,
389
+ [OPTION_PROGRAM_ERROR__INVALID_PROTOCOL_FEE]: `Invalid protocol fee rate`,
390
+ [OPTION_PROGRAM_ERROR__INVALID_QUANTITY]: `Quantity must be greater than zero`,
391
+ [OPTION_PROGRAM_ERROR__INVALID_RATE]: `Invalid interest rate`,
392
+ [OPTION_PROGRAM_ERROR__INVALID_RISK_FREE_RATE]: `Risk-free rate must be non-negative`,
393
+ [OPTION_PROGRAM_ERROR__INVALID_SEED]: `Invalid seed - must be exactly 32 bytes`,
394
+ [OPTION_PROGRAM_ERROR__INVALID_STRIKE_PRICE]: `Strike price must be greater than zero`,
395
+ [OPTION_PROGRAM_ERROR__INVALID_SWITCHBOARD_QUOTE_ACCOUNT]: `Invalid Switchboard quote account`,
396
+ [OPTION_PROGRAM_ERROR__INVALID_SWITCHBOARD_UPDATE_PROOF]: `Switchboard quote update proof missing or invalid`,
397
+ [OPTION_PROGRAM_ERROR__INVALID_TENOR]: `Invalid loan tenor`,
398
+ [OPTION_PROGRAM_ERROR__INVALID_TIME_TO_EXPIRATION]: `Time to expiration must be positive`,
399
+ [OPTION_PROGRAM_ERROR__INVALID_UNDERLYING_PRICE]: `Underlying price is invalid`,
400
+ [OPTION_PROGRAM_ERROR__INVALID_VAULT_MINT]: `Invalid vault mint - does not match expected collateral mint`,
401
+ [OPTION_PROGRAM_ERROR__INVALID_VOLATILITY]: `Volatility must be greater than zero`,
402
+ [OPTION_PROGRAM_ERROR__LIQUIDATION_INSUFFICIENT_COLLATERAL_FOR_DEBT]: `Liquidation cannot cover full debt (principal + interest + fees) from writer's collateral + theta; call rescue path instead`,
403
+ [OPTION_PROGRAM_ERROR__LOW_ORACLE_PRICE_CONFIDENCE]: `Oracle price confidence is too low`,
404
+ [OPTION_PROGRAM_ERROR__MAINTENANCE_BUFFER_BREACHED]: `Writer position breaches maintenance buffer: free_collateral + claimable_theta < accrued_interest + fees + buffer`,
405
+ [OPTION_PROGRAM_ERROR__MAINTENANCE_LOANS_INCOMPLETE]: `Maintenance debt sync remaining_accounts must contain every active PoolLoan for this writer`,
406
+ [OPTION_PROGRAM_ERROR__MARKET_CLOSED]: `Market is closed`,
407
+ [OPTION_PROGRAM_ERROR__MAXIMUM_POSITION_SIZE_EXCEEDED]: `Maximum position size exceeded`,
408
+ [OPTION_PROGRAM_ERROR__MAX_POSITIONS_REACHED]: `Maximum positions limit reached`,
409
+ [OPTION_PROGRAM_ERROR__MINIMUM_POSITION_SIZE_NOT_MET]: `Minimum position size not met`,
410
+ [OPTION_PROGRAM_ERROR__NO_COLLATERAL_TO_WITHDRAW]: `No collateral to withdraw`,
411
+ [OPTION_PROGRAM_ERROR__NO_POSITIONS_PROVIDED]: `No positions provided in batch`,
412
+ [OPTION_PROGRAM_ERROR__NOT_FORECLOSABLE]: `Loan is not eligible for foreclosure`,
413
+ [OPTION_PROGRAM_ERROR__NOTHING_TO_CLAIM]: `Nothing to claim - no unclaimed premium`,
414
+ [OPTION_PROGRAM_ERROR__NO_YIELD_AVAILABLE]: `No yield available to claim`,
415
+ [OPTION_PROGRAM_ERROR__OPTION_ACCOUNT_MISMATCH]: `Option account mismatch`,
416
+ [OPTION_PROGRAM_ERROR__OPTION_ALREADY_EXERCISED]: `Option has already been exercised`,
417
+ [OPTION_PROGRAM_ERROR__OPTION_CHAIN_FULL]: `Option chain is full`,
418
+ [OPTION_PROGRAM_ERROR__OPTION_EXPIRED]: `Option has already expired`,
419
+ [OPTION_PROGRAM_ERROR__OPTION_NOT_EXPIRED]: `Option has not expired yet - cannot settle`,
420
+ [OPTION_PROGRAM_ERROR__OPTION_OUT_OF_MONEY]: `Option is out of the money and cannot be exercised`,
421
+ [OPTION_PROGRAM_ERROR__OPTION_POOL_MISMATCH]: `Option account does not match the option pool's option account`,
422
+ [OPTION_PROGRAM_ERROR__ORACLE_PRICE_UNAVAILABLE]: `Oracle price is unavailable`,
423
+ [OPTION_PROGRAM_ERROR__ORACLE_TOO_STALE]: `Oracle price is stale - cannot validate`,
424
+ [OPTION_PROGRAM_ERROR__POOL_ALREADY_EXISTS]: `Pool already exists for this option`,
425
+ [OPTION_PROGRAM_ERROR__POOL_LOAN_WRITER_MISMATCH]: `PoolLoan.writer_position does not match the WriterPosition in this instruction`,
426
+ [OPTION_PROGRAM_ERROR__POOL_NOT_ACTIVE]: `Pool is not active`,
427
+ [OPTION_PROGRAM_ERROR__POOL_NOT_EXERCISED]: `Pool has not been exercised yet`,
428
+ [OPTION_PROGRAM_ERROR__POSITION_ALREADY_CLOSED]: `Position is already closed`,
429
+ [OPTION_PROGRAM_ERROR__POSITION_NOT_FOUND]: `Position not found`,
430
+ [OPTION_PROGRAM_ERROR__POSITION_OPTION_MISMATCH]: `Position account does not belong to this option`,
431
+ [OPTION_PROGRAM_ERROR__PREMIUM_CALCULATION_FAILED]: `Premium calculation failed`,
432
+ [OPTION_PROGRAM_ERROR__PRICE_IMPACT_TOO_HIGH]: `Price impact too high`,
433
+ [OPTION_PROGRAM_ERROR__RESCUE_PRECONDITIONS_NOT_MET]: `Rescue preconditions not met: collateral_vault must be short of the remaining debt after theta forfeiture`,
434
+ [OPTION_PROGRAM_ERROR__RESCUE_UNAUTHORIZED]: `Rescue liquidation is gated to the vault keeper`,
435
+ [OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED]: `Slippage tolerance exceeded`,
436
+ [OPTION_PROGRAM_ERROR__STALE_MARKET_DATA]: `Market data is stale and needs to be updated`,
437
+ [OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE]: `Oracle price is too old`,
438
+ [OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED]: `Deposit would exceed vault supply limit`,
439
+ [OPTION_PROGRAM_ERROR__THETA_CLAIM_DISABLED]: `claim_theta instruction has been removed; theta is now auto-realized on unwind or forfeited on liquidation`,
440
+ [OPTION_PROGRAM_ERROR__UNAUTHORIZED_ACCESS]: `Unauthorized access - you don't own this resource`,
441
+ [OPTION_PROGRAM_ERROR__UNAUTHORIZED_EXERCISE]: `Unauthorized to exercise this option`,
442
+ [OPTION_PROGRAM_ERROR__UNAUTHORIZED_OMLP]: `Unauthorized to perform this OMLP action`,
443
+ [OPTION_PROGRAM_ERROR__UNDERLYING_ASSET_MISMATCH]: `Underlying asset mismatch - market data or mint does not match option`,
444
+ [OPTION_PROGRAM_ERROR__UNHEALTHY_POSITION]: `Health ratio below liquidation threshold`,
445
+ [OPTION_PROGRAM_ERROR__UNWIND_REPAY_ACCOUNTS_MISSING]: `Unwind repayment accounts are required when active pool loans exist`,
446
+ [OPTION_PROGRAM_ERROR__VALIDATION_REQUIRED]: `Must call option_validate before borrow/settlement`,
447
+ };
448
+ }
449
+
450
+ export function getOptionProgramErrorMessage(code: OptionProgramError): string {
451
+ if (process.env.NODE_ENV !== "production") {
452
+ return (optionProgramErrorMessages as Record<OptionProgramError, string>)[
453
+ code
454
+ ];
455
+ }
456
+
457
+ return "Error message not available in production bundles.";
458
+ }
459
+
460
+ export function isOptionProgramError<
461
+ TProgramErrorCode extends OptionProgramError,
462
+ >(
463
+ error: unknown,
464
+ transactionMessage: {
465
+ instructions: Record<number, { programAddress: Address }>;
466
+ },
467
+ code?: TProgramErrorCode,
468
+ ): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &
469
+ Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
470
+ return isProgramError<TProgramErrorCode>(
471
+ error,
472
+ transactionMessage,
473
+ OPTION_PROGRAM_PROGRAM_ADDRESS,
474
+ code,
475
+ );
476
+ }
@@ -0,0 +1,13 @@
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
+ export * from "./accounts";
10
+ export * from "./errors";
11
+ export * from "./instructions";
12
+ export * from "./programs";
13
+ export * from "./types";