@epicentral/sos-sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +239 -0
- package/accounts/fetchers.ts +140 -0
- package/accounts/list.ts +152 -0
- package/accounts/pdas.ts +308 -0
- package/client/lookup-table.ts +32 -0
- package/client/program.ts +13 -0
- package/client/types.ts +8 -0
- package/generated/accounts/collateralPool.ts +217 -0
- package/generated/accounts/config.ts +156 -0
- package/generated/accounts/dualSourceContract.ts +235 -0
- package/generated/accounts/escrowState.ts +183 -0
- package/generated/accounts/index.ts +24 -0
- package/generated/accounts/lenderPosition.ts +211 -0
- package/generated/accounts/liquidityRouter.ts +223 -0
- package/generated/accounts/makerCollateralShare.ts +229 -0
- package/generated/accounts/makerPoolShare.ts +203 -0
- package/generated/accounts/marketDataAccount.ts +176 -0
- package/generated/accounts/optionAccount.ts +247 -0
- package/generated/accounts/optionPool.ts +253 -0
- package/generated/accounts/poolLoan.ts +220 -0
- package/generated/accounts/positionAccount.ts +187 -0
- package/generated/accounts/priceUpdateV2.ts +163 -0
- package/generated/accounts/vault.ts +304 -0
- package/generated/accounts/writerPosition.ts +297 -0
- package/generated/errors/index.ts +9 -0
- package/generated/errors/optionProgram.ts +392 -0
- package/generated/index.ts +13 -0
- package/generated/instructions/acceptAdmin.ts +230 -0
- package/generated/instructions/autoExerciseAllExpired.ts +523 -0
- package/generated/instructions/autoExerciseExpired.ts +623 -0
- package/generated/instructions/borrowFromPool.ts +554 -0
- package/generated/instructions/buyFromPool.ts +684 -0
- package/generated/instructions/claimPremium.ts +377 -0
- package/generated/instructions/closeLongToPool.ts +716 -0
- package/generated/instructions/closeOption.ts +235 -0
- package/generated/instructions/createEscrowV2.ts +518 -0
- package/generated/instructions/createLiquidityRouter.ts +361 -0
- package/generated/instructions/depositCollateral.ts +624 -0
- package/generated/instructions/depositToPool.ts +497 -0
- package/generated/instructions/depositToPosition.ts +429 -0
- package/generated/instructions/index.ts +45 -0
- package/generated/instructions/initCollateralPool.ts +513 -0
- package/generated/instructions/initConfig.ts +279 -0
- package/generated/instructions/initOptionPool.ts +587 -0
- package/generated/instructions/initializeMarketData.ts +359 -0
- package/generated/instructions/liquidateWriterPosition.ts +592 -0
- package/generated/instructions/omlpCreateVault.ts +547 -0
- package/generated/instructions/omlpTakeOfferWithFailover.ts +606 -0
- package/generated/instructions/omlpUpdateMaxLeverage.ts +304 -0
- package/generated/instructions/omlpUpdateProtocolFee.ts +304 -0
- package/generated/instructions/omlpUpdateSupplyLimit.ts +304 -0
- package/generated/instructions/optionExercise.ts +540 -0
- package/generated/instructions/optionMint.ts +1349 -0
- package/generated/instructions/optionValidate.ts +255 -0
- package/generated/instructions/repayPoolLoan.ts +499 -0
- package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
- package/generated/instructions/settleMakerCollateral.ts +472 -0
- package/generated/instructions/syncWriterPosition.ts +206 -0
- package/generated/instructions/transferAdmin.ts +245 -0
- package/generated/instructions/unwindWriterUnsold.ts +668 -0
- package/generated/instructions/updateImpliedVolatility.ts +226 -0
- package/generated/instructions/updateMarketData.ts +315 -0
- package/generated/instructions/withdrawFromPool.ts +429 -0
- package/generated/instructions/withdrawFromPosition.ts +405 -0
- package/generated/instructions/writeToPool.ts +594 -0
- package/generated/programs/index.ts +9 -0
- package/generated/programs/optionProgram.ts +832 -0
- package/generated/shared/index.ts +164 -0
- package/generated/types/borrowedFromSAP1.ts +75 -0
- package/generated/types/borrowedFromSAP2.ts +83 -0
- package/generated/types/failoverTriggered.ts +85 -0
- package/generated/types/impliedVolatilityUpdated.ts +73 -0
- package/generated/types/index.ts +32 -0
- package/generated/types/liquidationExecuted.ts +73 -0
- package/generated/types/liquidityMetrics.ts +69 -0
- package/generated/types/liquidityRouterCreated.ts +79 -0
- package/generated/types/marketDataInitialized.ts +61 -0
- package/generated/types/marketDataUpdated.ts +69 -0
- package/generated/types/optionClosed.ts +56 -0
- package/generated/types/optionExercised.ts +62 -0
- package/generated/types/optionExpired.ts +49 -0
- package/generated/types/optionMinted.ts +78 -0
- package/generated/types/optionType.ts +38 -0
- package/generated/types/optionValidated.ts +82 -0
- package/generated/types/poolLoanCreated.ts +74 -0
- package/generated/types/poolLoanRepaid.ts +74 -0
- package/generated/types/positionDeposited.ts +73 -0
- package/generated/types/positionWithdrawn.ts +81 -0
- package/generated/types/priceFeedMessage.ts +117 -0
- package/generated/types/protocolFeeUpdated.ts +69 -0
- package/generated/types/sap2Provider.ts +38 -0
- package/generated/types/vaultCreated.ts +60 -0
- package/generated/types/verificationLevel.ts +95 -0
- package/index.ts +25 -0
- package/long/builders.ts +126 -0
- package/long/exercise.ts +49 -0
- package/long/quotes.ts +48 -0
- package/omlp/builders.ts +74 -0
- package/omlp/service.ts +94 -0
- package/package.json +22 -0
- package/shared/amounts.ts +32 -0
- package/shared/errors.ts +12 -0
- package/shared/remaining-accounts.ts +41 -0
- package/shared/transactions.ts +49 -0
- package/short/builders.ts +268 -0
- package/short/claim-premium.ts +37 -0
- package/short/close-option.ts +34 -0
- package/short/pool.ts +224 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,392 @@
|
|
|
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
|
+
/** OraclePriceUnavailable: Oracle price is unavailable */
|
|
56
|
+
export const OPTION_PROGRAM_ERROR__ORACLE_PRICE_UNAVAILABLE = 0x1783; // 6019
|
|
57
|
+
/** InvalidOraclePrice: Invalid oracle price - must be positive */
|
|
58
|
+
export const OPTION_PROGRAM_ERROR__INVALID_ORACLE_PRICE = 0x1784; // 6020
|
|
59
|
+
/** InsufficientBalance: Insufficient balance for premium payment */
|
|
60
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_BALANCE = 0x1785; // 6021
|
|
61
|
+
/** PositionNotFound: Position not found */
|
|
62
|
+
export const OPTION_PROGRAM_ERROR__POSITION_NOT_FOUND = 0x1786; // 6022
|
|
63
|
+
/** OptionAccountMismatch: Option account mismatch */
|
|
64
|
+
export const OPTION_PROGRAM_ERROR__OPTION_ACCOUNT_MISMATCH = 0x1787; // 6023
|
|
65
|
+
/** ArithmeticOverflow: Arithmetic overflow occurred */
|
|
66
|
+
export const OPTION_PROGRAM_ERROR__ARITHMETIC_OVERFLOW = 0x1788; // 6024
|
|
67
|
+
/** ArithmeticUnderflow: Arithmetic underflow occurred */
|
|
68
|
+
export const OPTION_PROGRAM_ERROR__ARITHMETIC_UNDERFLOW = 0x1789; // 6025
|
|
69
|
+
/** DivisionByZero: Division by zero */
|
|
70
|
+
export const OPTION_PROGRAM_ERROR__DIVISION_BY_ZERO = 0x178a; // 6026
|
|
71
|
+
/** PremiumCalculationFailed: Premium calculation failed */
|
|
72
|
+
export const OPTION_PROGRAM_ERROR__PREMIUM_CALCULATION_FAILED = 0x178b; // 6027
|
|
73
|
+
/** GreeksCalculationFailed: Greeks calculation failed */
|
|
74
|
+
export const OPTION_PROGRAM_ERROR__GREEKS_CALCULATION_FAILED = 0x178c; // 6028
|
|
75
|
+
/** InvalidEscrowAuthority: Invalid escrow authority */
|
|
76
|
+
export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_AUTHORITY = 0x178d; // 6029
|
|
77
|
+
/** EscrowAccountFrozen: Escrow account is frozen */
|
|
78
|
+
export const OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_FROZEN = 0x178e; // 6030
|
|
79
|
+
/** MarketClosed: Market is closed */
|
|
80
|
+
export const OPTION_PROGRAM_ERROR__MARKET_CLOSED = 0x178f; // 6031
|
|
81
|
+
/** MaxPositionsReached: Maximum positions limit reached */
|
|
82
|
+
export const OPTION_PROGRAM_ERROR__MAX_POSITIONS_REACHED = 0x1790; // 6032
|
|
83
|
+
/** MinimumPositionSizeNotMet: Minimum position size not met */
|
|
84
|
+
export const OPTION_PROGRAM_ERROR__MINIMUM_POSITION_SIZE_NOT_MET = 0x1791; // 6033
|
|
85
|
+
/** MaximumPositionSizeExceeded: Maximum position size exceeded */
|
|
86
|
+
export const OPTION_PROGRAM_ERROR__MAXIMUM_POSITION_SIZE_EXCEEDED = 0x1792; // 6034
|
|
87
|
+
/** InvalidMakerAuthority: Invalid maker authority */
|
|
88
|
+
export const OPTION_PROGRAM_ERROR__INVALID_MAKER_AUTHORITY = 0x1793; // 6035
|
|
89
|
+
/** InvalidBuyerAuthority: Invalid buyer authority */
|
|
90
|
+
export const OPTION_PROGRAM_ERROR__INVALID_BUYER_AUTHORITY = 0x1794; // 6036
|
|
91
|
+
/** OptionChainFull: Option chain is full */
|
|
92
|
+
export const OPTION_PROGRAM_ERROR__OPTION_CHAIN_FULL = 0x1795; // 6037
|
|
93
|
+
/** DuplicateOption: Duplicate option exists */
|
|
94
|
+
export const OPTION_PROGRAM_ERROR__DUPLICATE_OPTION = 0x1796; // 6038
|
|
95
|
+
/** PriceImpactTooHigh: Price impact too high */
|
|
96
|
+
export const OPTION_PROGRAM_ERROR__PRICE_IMPACT_TOO_HIGH = 0x1797; // 6039
|
|
97
|
+
/** SlippageToleranceExceeded: Slippage tolerance exceeded */
|
|
98
|
+
export const OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED = 0x1798; // 6040
|
|
99
|
+
/** InsufficientPoolLiquidity: Insufficient pool liquidity available */
|
|
100
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_LIQUIDITY = 0x1799; // 6041
|
|
101
|
+
/** InsufficientUserBalance: Insufficient user balance for withdrawal */
|
|
102
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_USER_BALANCE = 0x179a; // 6042
|
|
103
|
+
/** UnhealthyPosition: Health ratio below liquidation threshold */
|
|
104
|
+
export const OPTION_PROGRAM_ERROR__UNHEALTHY_POSITION = 0x179b; // 6043
|
|
105
|
+
/** UnauthorizedOmlp: Unauthorized to perform this OMLP action */
|
|
106
|
+
export const OPTION_PROGRAM_ERROR__UNAUTHORIZED_OMLP = 0x179c; // 6044
|
|
107
|
+
/** InvalidTenor: Invalid loan tenor */
|
|
108
|
+
export const OPTION_PROGRAM_ERROR__INVALID_TENOR = 0x179d; // 6045
|
|
109
|
+
/** InvalidRate: Invalid interest rate */
|
|
110
|
+
export const OPTION_PROGRAM_ERROR__INVALID_RATE = 0x179e; // 6046
|
|
111
|
+
/** NotForeclosable: Loan is not eligible for foreclosure */
|
|
112
|
+
export const OPTION_PROGRAM_ERROR__NOT_FORECLOSABLE = 0x179f; // 6047
|
|
113
|
+
/** InsufficientVaultLiquidity: Vault has insufficient liquidity */
|
|
114
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_VAULT_LIQUIDITY = 0x17a0; // 6048
|
|
115
|
+
/** InsufficientLoanCollateral: Collateral insufficient for loan */
|
|
116
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_LOAN_COLLATERAL = 0x17a1; // 6049
|
|
117
|
+
/** OracleTooStale: Oracle price is stale - cannot validate */
|
|
118
|
+
export const OPTION_PROGRAM_ERROR__ORACLE_TOO_STALE = 0x17a2; // 6050
|
|
119
|
+
/** ValidationRequired: Must call option_validate before borrow/settlement */
|
|
120
|
+
export const OPTION_PROGRAM_ERROR__VALIDATION_REQUIRED = 0x17a3; // 6051
|
|
121
|
+
/** HealthCalculationFailed: Health ratio calculation failed */
|
|
122
|
+
export const OPTION_PROGRAM_ERROR__HEALTH_CALCULATION_FAILED = 0x17a4; // 6052
|
|
123
|
+
/** ContractAlreadySettled: Contract already settled */
|
|
124
|
+
export const OPTION_PROGRAM_ERROR__CONTRACT_ALREADY_SETTLED = 0x17a5; // 6053
|
|
125
|
+
/** NoYieldAvailable: No yield available to claim */
|
|
126
|
+
export const OPTION_PROGRAM_ERROR__NO_YIELD_AVAILABLE = 0x17a6; // 6054
|
|
127
|
+
/** UnauthorizedAccess: Unauthorized access - you don't own this resource */
|
|
128
|
+
export const OPTION_PROGRAM_ERROR__UNAUTHORIZED_ACCESS = 0x17a7; // 6055
|
|
129
|
+
/** InsufficientQuantity: Insufficient quantity available in ask position */
|
|
130
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_QUANTITY = 0x17a8; // 6056
|
|
131
|
+
/** NothingToClaim: Nothing to claim - no unclaimed premium */
|
|
132
|
+
export const OPTION_PROGRAM_ERROR__NOTHING_TO_CLAIM = 0x17a9; // 6057
|
|
133
|
+
/** PoolNotActive: Pool is not active */
|
|
134
|
+
export const OPTION_PROGRAM_ERROR__POOL_NOT_ACTIVE = 0x17aa; // 6058
|
|
135
|
+
/** PoolAlreadyExists: Pool already exists for this option */
|
|
136
|
+
export const OPTION_PROGRAM_ERROR__POOL_ALREADY_EXISTS = 0x17ab; // 6059
|
|
137
|
+
/** PoolNotExercised: Pool has not been exercised yet */
|
|
138
|
+
export const OPTION_PROGRAM_ERROR__POOL_NOT_EXERCISED = 0x17ac; // 6060
|
|
139
|
+
/** AlreadySettled: Maker's collateral share has already been settled */
|
|
140
|
+
export const OPTION_PROGRAM_ERROR__ALREADY_SETTLED = 0x17ad; // 6061
|
|
141
|
+
/** InsufficientPoolCollateral: Insufficient collateral in pool for exercise */
|
|
142
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_COLLATERAL = 0x17ae; // 6062
|
|
143
|
+
/** CollateralPoolNotFound: Collateral pool does not exist */
|
|
144
|
+
export const OPTION_PROGRAM_ERROR__COLLATERAL_POOL_NOT_FOUND = 0x17af; // 6063
|
|
145
|
+
/** NoCollateralToWithdraw: No collateral to withdraw */
|
|
146
|
+
export const OPTION_PROGRAM_ERROR__NO_COLLATERAL_TO_WITHDRAW = 0x17b0; // 6064
|
|
147
|
+
/** OptionNotExpired: Option has not expired yet - cannot settle */
|
|
148
|
+
export const OPTION_PROGRAM_ERROR__OPTION_NOT_EXPIRED = 0x17b1; // 6065
|
|
149
|
+
/** SupplyLimitExceeded: Deposit would exceed vault supply limit */
|
|
150
|
+
export const OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED = 0x17b2; // 6066
|
|
151
|
+
/** InvalidFeeWallet: Invalid fee wallet - must match protocol constant */
|
|
152
|
+
export const OPTION_PROGRAM_ERROR__INVALID_FEE_WALLET = 0x17b3; // 6067
|
|
153
|
+
/** InvalidProtocolFee: Invalid protocol fee rate */
|
|
154
|
+
export const OPTION_PROGRAM_ERROR__INVALID_PROTOCOL_FEE = 0x17b4; // 6068
|
|
155
|
+
/** UnderlyingAssetMismatch: Underlying asset mismatch - market data or mint does not match option */
|
|
156
|
+
export const OPTION_PROGRAM_ERROR__UNDERLYING_ASSET_MISMATCH = 0x17b5; // 6069
|
|
157
|
+
/** InvalidMint: Invalid token mint - does not match expected underlying asset */
|
|
158
|
+
export const OPTION_PROGRAM_ERROR__INVALID_MINT = 0x17b6; // 6070
|
|
159
|
+
/** BatchSizeExceeded: Batch size exceeds maximum allowed (10 positions) */
|
|
160
|
+
export const OPTION_PROGRAM_ERROR__BATCH_SIZE_EXCEEDED = 0x17b7; // 6071
|
|
161
|
+
/** NoPositionsProvided: No positions provided in batch */
|
|
162
|
+
export const OPTION_PROGRAM_ERROR__NO_POSITIONS_PROVIDED = 0x17b8; // 6072
|
|
163
|
+
/** PositionOptionMismatch: Position account does not belong to this option */
|
|
164
|
+
export const OPTION_PROGRAM_ERROR__POSITION_OPTION_MISMATCH = 0x17b9; // 6073
|
|
165
|
+
/** OptionPoolMismatch: Option account does not match the option pool's option account */
|
|
166
|
+
export const OPTION_PROGRAM_ERROR__OPTION_POOL_MISMATCH = 0x17ba; // 6074
|
|
167
|
+
/** InvalidSeed: Invalid seed - must be exactly 32 bytes */
|
|
168
|
+
export const OPTION_PROGRAM_ERROR__INVALID_SEED = 0x17bb; // 6075
|
|
169
|
+
/** InvalidAuthority: Invalid authority - does not match escrow authority */
|
|
170
|
+
export const OPTION_PROGRAM_ERROR__INVALID_AUTHORITY = 0x17bc; // 6076
|
|
171
|
+
/** EscrowAccountRequired: Escrow accounts required when borrowed_amount > 0 */
|
|
172
|
+
export const OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_REQUIRED = 0x17bd; // 6077
|
|
173
|
+
/** InvalidEscrowMaker: Escrow state maker does not match instruction maker */
|
|
174
|
+
export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_MAKER = 0x17be; // 6078
|
|
175
|
+
/** EscrowMintMismatch: Escrow collateral mint does not match collateral pool mint */
|
|
176
|
+
export const OPTION_PROGRAM_ERROR__ESCROW_MINT_MISMATCH = 0x17bf; // 6079
|
|
177
|
+
/** InsufficientEscrowBalance: Insufficient balance in escrow token account */
|
|
178
|
+
export const OPTION_PROGRAM_ERROR__INSUFFICIENT_ESCROW_BALANCE = 0x17c0; // 6080
|
|
179
|
+
/** InvalidEscrowOwner: Escrow token account owner mismatch */
|
|
180
|
+
export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_OWNER = 0x17c1; // 6081
|
|
181
|
+
/** InvalidEscrowMint: Escrow token account mint mismatch */
|
|
182
|
+
export const OPTION_PROGRAM_ERROR__INVALID_ESCROW_MINT = 0x17c2; // 6082
|
|
183
|
+
/** AccountFrozen: Token account is frozen and cannot be burned */
|
|
184
|
+
export const OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN = 0x17c3; // 6083
|
|
185
|
+
/** InvalidAccount: Invalid account - does not match expected account */
|
|
186
|
+
export const OPTION_PROGRAM_ERROR__INVALID_ACCOUNT = 0x17c4; // 6084
|
|
187
|
+
|
|
188
|
+
export type OptionProgramError =
|
|
189
|
+
| typeof OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN
|
|
190
|
+
| typeof OPTION_PROGRAM_ERROR__ALREADY_SETTLED
|
|
191
|
+
| typeof OPTION_PROGRAM_ERROR__ARITHMETIC_OVERFLOW
|
|
192
|
+
| typeof OPTION_PROGRAM_ERROR__ARITHMETIC_UNDERFLOW
|
|
193
|
+
| typeof OPTION_PROGRAM_ERROR__BATCH_SIZE_EXCEEDED
|
|
194
|
+
| typeof OPTION_PROGRAM_ERROR__COLLATERAL_POOL_NOT_FOUND
|
|
195
|
+
| typeof OPTION_PROGRAM_ERROR__CONTRACT_ALREADY_SETTLED
|
|
196
|
+
| typeof OPTION_PROGRAM_ERROR__DIVISION_BY_ZERO
|
|
197
|
+
| typeof OPTION_PROGRAM_ERROR__DUPLICATE_OPTION
|
|
198
|
+
| typeof OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_FROZEN
|
|
199
|
+
| typeof OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_REQUIRED
|
|
200
|
+
| typeof OPTION_PROGRAM_ERROR__ESCROW_MINT_MISMATCH
|
|
201
|
+
| typeof OPTION_PROGRAM_ERROR__GREEKS_CALCULATION_FAILED
|
|
202
|
+
| typeof OPTION_PROGRAM_ERROR__HEALTH_CALCULATION_FAILED
|
|
203
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_BALANCE
|
|
204
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL
|
|
205
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_ESCROW_BALANCE
|
|
206
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_LOAN_COLLATERAL
|
|
207
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_COLLATERAL
|
|
208
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_LIQUIDITY
|
|
209
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_QUANTITY
|
|
210
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_USER_BALANCE
|
|
211
|
+
| typeof OPTION_PROGRAM_ERROR__INSUFFICIENT_VAULT_LIQUIDITY
|
|
212
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ACCOUNT
|
|
213
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_AUTHORITY
|
|
214
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_BUYER_AUTHORITY
|
|
215
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_AUTHORITY
|
|
216
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_MAKER
|
|
217
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_MINT
|
|
218
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ESCROW_OWNER
|
|
219
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_EXPIRATION_DATE
|
|
220
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_FEE_WALLET
|
|
221
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_MAKER_AUTHORITY
|
|
222
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_MINT
|
|
223
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_OPTION_TYPE
|
|
224
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ORACLE_ACCOUNT
|
|
225
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_ORACLE_PRICE
|
|
226
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_PRICING_PARAMETERS
|
|
227
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_PROTOCOL_FEE
|
|
228
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_QUANTITY
|
|
229
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_RATE
|
|
230
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_RISK_FREE_RATE
|
|
231
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_SEED
|
|
232
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_STRIKE_PRICE
|
|
233
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_TENOR
|
|
234
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_TIME_TO_EXPIRATION
|
|
235
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_UNDERLYING_PRICE
|
|
236
|
+
| typeof OPTION_PROGRAM_ERROR__INVALID_VOLATILITY
|
|
237
|
+
| typeof OPTION_PROGRAM_ERROR__LOW_ORACLE_PRICE_CONFIDENCE
|
|
238
|
+
| typeof OPTION_PROGRAM_ERROR__MARKET_CLOSED
|
|
239
|
+
| typeof OPTION_PROGRAM_ERROR__MAXIMUM_POSITION_SIZE_EXCEEDED
|
|
240
|
+
| typeof OPTION_PROGRAM_ERROR__MAX_POSITIONS_REACHED
|
|
241
|
+
| typeof OPTION_PROGRAM_ERROR__MINIMUM_POSITION_SIZE_NOT_MET
|
|
242
|
+
| typeof OPTION_PROGRAM_ERROR__NO_COLLATERAL_TO_WITHDRAW
|
|
243
|
+
| typeof OPTION_PROGRAM_ERROR__NO_POSITIONS_PROVIDED
|
|
244
|
+
| typeof OPTION_PROGRAM_ERROR__NOT_FORECLOSABLE
|
|
245
|
+
| typeof OPTION_PROGRAM_ERROR__NOTHING_TO_CLAIM
|
|
246
|
+
| typeof OPTION_PROGRAM_ERROR__NO_YIELD_AVAILABLE
|
|
247
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_ACCOUNT_MISMATCH
|
|
248
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_ALREADY_EXERCISED
|
|
249
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_CHAIN_FULL
|
|
250
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_EXPIRED
|
|
251
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_NOT_EXPIRED
|
|
252
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_OUT_OF_MONEY
|
|
253
|
+
| typeof OPTION_PROGRAM_ERROR__OPTION_POOL_MISMATCH
|
|
254
|
+
| typeof OPTION_PROGRAM_ERROR__ORACLE_PRICE_UNAVAILABLE
|
|
255
|
+
| typeof OPTION_PROGRAM_ERROR__ORACLE_TOO_STALE
|
|
256
|
+
| typeof OPTION_PROGRAM_ERROR__POOL_ALREADY_EXISTS
|
|
257
|
+
| typeof OPTION_PROGRAM_ERROR__POOL_NOT_ACTIVE
|
|
258
|
+
| typeof OPTION_PROGRAM_ERROR__POOL_NOT_EXERCISED
|
|
259
|
+
| typeof OPTION_PROGRAM_ERROR__POSITION_ALREADY_CLOSED
|
|
260
|
+
| typeof OPTION_PROGRAM_ERROR__POSITION_NOT_FOUND
|
|
261
|
+
| typeof OPTION_PROGRAM_ERROR__POSITION_OPTION_MISMATCH
|
|
262
|
+
| typeof OPTION_PROGRAM_ERROR__PREMIUM_CALCULATION_FAILED
|
|
263
|
+
| typeof OPTION_PROGRAM_ERROR__PRICE_IMPACT_TOO_HIGH
|
|
264
|
+
| typeof OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED
|
|
265
|
+
| typeof OPTION_PROGRAM_ERROR__STALE_MARKET_DATA
|
|
266
|
+
| typeof OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE
|
|
267
|
+
| typeof OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED
|
|
268
|
+
| typeof OPTION_PROGRAM_ERROR__UNAUTHORIZED_ACCESS
|
|
269
|
+
| typeof OPTION_PROGRAM_ERROR__UNAUTHORIZED_EXERCISE
|
|
270
|
+
| typeof OPTION_PROGRAM_ERROR__UNAUTHORIZED_OMLP
|
|
271
|
+
| typeof OPTION_PROGRAM_ERROR__UNDERLYING_ASSET_MISMATCH
|
|
272
|
+
| typeof OPTION_PROGRAM_ERROR__UNHEALTHY_POSITION
|
|
273
|
+
| typeof OPTION_PROGRAM_ERROR__VALIDATION_REQUIRED;
|
|
274
|
+
|
|
275
|
+
let optionProgramErrorMessages: Record<OptionProgramError, string> | undefined;
|
|
276
|
+
if (process.env.NODE_ENV !== "production") {
|
|
277
|
+
optionProgramErrorMessages = {
|
|
278
|
+
[OPTION_PROGRAM_ERROR__ACCOUNT_FROZEN]: `Token account is frozen and cannot be burned`,
|
|
279
|
+
[OPTION_PROGRAM_ERROR__ALREADY_SETTLED]: `Maker's collateral share has already been settled`,
|
|
280
|
+
[OPTION_PROGRAM_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow occurred`,
|
|
281
|
+
[OPTION_PROGRAM_ERROR__ARITHMETIC_UNDERFLOW]: `Arithmetic underflow occurred`,
|
|
282
|
+
[OPTION_PROGRAM_ERROR__BATCH_SIZE_EXCEEDED]: `Batch size exceeds maximum allowed (10 positions)`,
|
|
283
|
+
[OPTION_PROGRAM_ERROR__COLLATERAL_POOL_NOT_FOUND]: `Collateral pool does not exist`,
|
|
284
|
+
[OPTION_PROGRAM_ERROR__CONTRACT_ALREADY_SETTLED]: `Contract already settled`,
|
|
285
|
+
[OPTION_PROGRAM_ERROR__DIVISION_BY_ZERO]: `Division by zero`,
|
|
286
|
+
[OPTION_PROGRAM_ERROR__DUPLICATE_OPTION]: `Duplicate option exists`,
|
|
287
|
+
[OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_FROZEN]: `Escrow account is frozen`,
|
|
288
|
+
[OPTION_PROGRAM_ERROR__ESCROW_ACCOUNT_REQUIRED]: `Escrow accounts required when borrowed_amount > 0`,
|
|
289
|
+
[OPTION_PROGRAM_ERROR__ESCROW_MINT_MISMATCH]: `Escrow collateral mint does not match collateral pool mint`,
|
|
290
|
+
[OPTION_PROGRAM_ERROR__GREEKS_CALCULATION_FAILED]: `Greeks calculation failed`,
|
|
291
|
+
[OPTION_PROGRAM_ERROR__HEALTH_CALCULATION_FAILED]: `Health ratio calculation failed`,
|
|
292
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance for premium payment`,
|
|
293
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_COLLATERAL]: `Insufficient collateral provided`,
|
|
294
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_ESCROW_BALANCE]: `Insufficient balance in escrow token account`,
|
|
295
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_LOAN_COLLATERAL]: `Collateral insufficient for loan`,
|
|
296
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_COLLATERAL]: `Insufficient collateral in pool for exercise`,
|
|
297
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_POOL_LIQUIDITY]: `Insufficient pool liquidity available`,
|
|
298
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_QUANTITY]: `Insufficient quantity available in ask position`,
|
|
299
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_USER_BALANCE]: `Insufficient user balance for withdrawal`,
|
|
300
|
+
[OPTION_PROGRAM_ERROR__INSUFFICIENT_VAULT_LIQUIDITY]: `Vault has insufficient liquidity`,
|
|
301
|
+
[OPTION_PROGRAM_ERROR__INVALID_ACCOUNT]: `Invalid account - does not match expected account`,
|
|
302
|
+
[OPTION_PROGRAM_ERROR__INVALID_AUTHORITY]: `Invalid authority - does not match escrow authority`,
|
|
303
|
+
[OPTION_PROGRAM_ERROR__INVALID_BUYER_AUTHORITY]: `Invalid buyer authority`,
|
|
304
|
+
[OPTION_PROGRAM_ERROR__INVALID_ESCROW_AUTHORITY]: `Invalid escrow authority`,
|
|
305
|
+
[OPTION_PROGRAM_ERROR__INVALID_ESCROW_MAKER]: `Escrow state maker does not match instruction maker`,
|
|
306
|
+
[OPTION_PROGRAM_ERROR__INVALID_ESCROW_MINT]: `Escrow token account mint mismatch`,
|
|
307
|
+
[OPTION_PROGRAM_ERROR__INVALID_ESCROW_OWNER]: `Escrow token account owner mismatch`,
|
|
308
|
+
[OPTION_PROGRAM_ERROR__INVALID_EXPIRATION_DATE]: `Invalid expiration date - must be in the future`,
|
|
309
|
+
[OPTION_PROGRAM_ERROR__INVALID_FEE_WALLET]: `Invalid fee wallet - must match protocol constant`,
|
|
310
|
+
[OPTION_PROGRAM_ERROR__INVALID_MAKER_AUTHORITY]: `Invalid maker authority`,
|
|
311
|
+
[OPTION_PROGRAM_ERROR__INVALID_MINT]: `Invalid token mint - does not match expected underlying asset`,
|
|
312
|
+
[OPTION_PROGRAM_ERROR__INVALID_OPTION_TYPE]: `Invalid option type`,
|
|
313
|
+
[OPTION_PROGRAM_ERROR__INVALID_ORACLE_ACCOUNT]: `Invalid oracle account - cannot parse price feed`,
|
|
314
|
+
[OPTION_PROGRAM_ERROR__INVALID_ORACLE_PRICE]: `Invalid oracle price - must be positive`,
|
|
315
|
+
[OPTION_PROGRAM_ERROR__INVALID_PRICING_PARAMETERS]: `Invalid pricing parameters`,
|
|
316
|
+
[OPTION_PROGRAM_ERROR__INVALID_PROTOCOL_FEE]: `Invalid protocol fee rate`,
|
|
317
|
+
[OPTION_PROGRAM_ERROR__INVALID_QUANTITY]: `Quantity must be greater than zero`,
|
|
318
|
+
[OPTION_PROGRAM_ERROR__INVALID_RATE]: `Invalid interest rate`,
|
|
319
|
+
[OPTION_PROGRAM_ERROR__INVALID_RISK_FREE_RATE]: `Risk-free rate must be non-negative`,
|
|
320
|
+
[OPTION_PROGRAM_ERROR__INVALID_SEED]: `Invalid seed - must be exactly 32 bytes`,
|
|
321
|
+
[OPTION_PROGRAM_ERROR__INVALID_STRIKE_PRICE]: `Strike price must be greater than zero`,
|
|
322
|
+
[OPTION_PROGRAM_ERROR__INVALID_TENOR]: `Invalid loan tenor`,
|
|
323
|
+
[OPTION_PROGRAM_ERROR__INVALID_TIME_TO_EXPIRATION]: `Time to expiration must be positive`,
|
|
324
|
+
[OPTION_PROGRAM_ERROR__INVALID_UNDERLYING_PRICE]: `Underlying price is invalid`,
|
|
325
|
+
[OPTION_PROGRAM_ERROR__INVALID_VOLATILITY]: `Volatility must be greater than zero`,
|
|
326
|
+
[OPTION_PROGRAM_ERROR__LOW_ORACLE_PRICE_CONFIDENCE]: `Oracle price confidence is too low`,
|
|
327
|
+
[OPTION_PROGRAM_ERROR__MARKET_CLOSED]: `Market is closed`,
|
|
328
|
+
[OPTION_PROGRAM_ERROR__MAXIMUM_POSITION_SIZE_EXCEEDED]: `Maximum position size exceeded`,
|
|
329
|
+
[OPTION_PROGRAM_ERROR__MAX_POSITIONS_REACHED]: `Maximum positions limit reached`,
|
|
330
|
+
[OPTION_PROGRAM_ERROR__MINIMUM_POSITION_SIZE_NOT_MET]: `Minimum position size not met`,
|
|
331
|
+
[OPTION_PROGRAM_ERROR__NO_COLLATERAL_TO_WITHDRAW]: `No collateral to withdraw`,
|
|
332
|
+
[OPTION_PROGRAM_ERROR__NO_POSITIONS_PROVIDED]: `No positions provided in batch`,
|
|
333
|
+
[OPTION_PROGRAM_ERROR__NOT_FORECLOSABLE]: `Loan is not eligible for foreclosure`,
|
|
334
|
+
[OPTION_PROGRAM_ERROR__NOTHING_TO_CLAIM]: `Nothing to claim - no unclaimed premium`,
|
|
335
|
+
[OPTION_PROGRAM_ERROR__NO_YIELD_AVAILABLE]: `No yield available to claim`,
|
|
336
|
+
[OPTION_PROGRAM_ERROR__OPTION_ACCOUNT_MISMATCH]: `Option account mismatch`,
|
|
337
|
+
[OPTION_PROGRAM_ERROR__OPTION_ALREADY_EXERCISED]: `Option has already been exercised`,
|
|
338
|
+
[OPTION_PROGRAM_ERROR__OPTION_CHAIN_FULL]: `Option chain is full`,
|
|
339
|
+
[OPTION_PROGRAM_ERROR__OPTION_EXPIRED]: `Option has already expired`,
|
|
340
|
+
[OPTION_PROGRAM_ERROR__OPTION_NOT_EXPIRED]: `Option has not expired yet - cannot settle`,
|
|
341
|
+
[OPTION_PROGRAM_ERROR__OPTION_OUT_OF_MONEY]: `Option is out of the money and cannot be exercised`,
|
|
342
|
+
[OPTION_PROGRAM_ERROR__OPTION_POOL_MISMATCH]: `Option account does not match the option pool's option account`,
|
|
343
|
+
[OPTION_PROGRAM_ERROR__ORACLE_PRICE_UNAVAILABLE]: `Oracle price is unavailable`,
|
|
344
|
+
[OPTION_PROGRAM_ERROR__ORACLE_TOO_STALE]: `Oracle price is stale - cannot validate`,
|
|
345
|
+
[OPTION_PROGRAM_ERROR__POOL_ALREADY_EXISTS]: `Pool already exists for this option`,
|
|
346
|
+
[OPTION_PROGRAM_ERROR__POOL_NOT_ACTIVE]: `Pool is not active`,
|
|
347
|
+
[OPTION_PROGRAM_ERROR__POOL_NOT_EXERCISED]: `Pool has not been exercised yet`,
|
|
348
|
+
[OPTION_PROGRAM_ERROR__POSITION_ALREADY_CLOSED]: `Position is already closed`,
|
|
349
|
+
[OPTION_PROGRAM_ERROR__POSITION_NOT_FOUND]: `Position not found`,
|
|
350
|
+
[OPTION_PROGRAM_ERROR__POSITION_OPTION_MISMATCH]: `Position account does not belong to this option`,
|
|
351
|
+
[OPTION_PROGRAM_ERROR__PREMIUM_CALCULATION_FAILED]: `Premium calculation failed`,
|
|
352
|
+
[OPTION_PROGRAM_ERROR__PRICE_IMPACT_TOO_HIGH]: `Price impact too high`,
|
|
353
|
+
[OPTION_PROGRAM_ERROR__SLIPPAGE_TOLERANCE_EXCEEDED]: `Slippage tolerance exceeded`,
|
|
354
|
+
[OPTION_PROGRAM_ERROR__STALE_MARKET_DATA]: `Market data is stale and needs to be updated`,
|
|
355
|
+
[OPTION_PROGRAM_ERROR__STALE_ORACLE_PRICE]: `Oracle price is too old`,
|
|
356
|
+
[OPTION_PROGRAM_ERROR__SUPPLY_LIMIT_EXCEEDED]: `Deposit would exceed vault supply limit`,
|
|
357
|
+
[OPTION_PROGRAM_ERROR__UNAUTHORIZED_ACCESS]: `Unauthorized access - you don't own this resource`,
|
|
358
|
+
[OPTION_PROGRAM_ERROR__UNAUTHORIZED_EXERCISE]: `Unauthorized to exercise this option`,
|
|
359
|
+
[OPTION_PROGRAM_ERROR__UNAUTHORIZED_OMLP]: `Unauthorized to perform this OMLP action`,
|
|
360
|
+
[OPTION_PROGRAM_ERROR__UNDERLYING_ASSET_MISMATCH]: `Underlying asset mismatch - market data or mint does not match option`,
|
|
361
|
+
[OPTION_PROGRAM_ERROR__UNHEALTHY_POSITION]: `Health ratio below liquidation threshold`,
|
|
362
|
+
[OPTION_PROGRAM_ERROR__VALIDATION_REQUIRED]: `Must call option_validate before borrow/settlement`,
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export function getOptionProgramErrorMessage(code: OptionProgramError): string {
|
|
367
|
+
if (process.env.NODE_ENV !== "production") {
|
|
368
|
+
return (optionProgramErrorMessages as Record<OptionProgramError, string>)[
|
|
369
|
+
code
|
|
370
|
+
];
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
return "Error message not available in production bundles.";
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export function isOptionProgramError<
|
|
377
|
+
TProgramErrorCode extends OptionProgramError,
|
|
378
|
+
>(
|
|
379
|
+
error: unknown,
|
|
380
|
+
transactionMessage: {
|
|
381
|
+
instructions: Record<number, { programAddress: Address }>;
|
|
382
|
+
},
|
|
383
|
+
code?: TProgramErrorCode,
|
|
384
|
+
): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &
|
|
385
|
+
Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
|
|
386
|
+
return isProgramError<TProgramErrorCode>(
|
|
387
|
+
error,
|
|
388
|
+
transactionMessage,
|
|
389
|
+
OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
390
|
+
code,
|
|
391
|
+
);
|
|
392
|
+
}
|
|
@@ -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";
|
|
@@ -0,0 +1,230 @@
|
|
|
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
|
+
getProgramDerivedAddress,
|
|
16
|
+
getStructDecoder,
|
|
17
|
+
getStructEncoder,
|
|
18
|
+
transformEncoder,
|
|
19
|
+
type AccountMeta,
|
|
20
|
+
type AccountSignerMeta,
|
|
21
|
+
type Address,
|
|
22
|
+
type FixedSizeCodec,
|
|
23
|
+
type FixedSizeDecoder,
|
|
24
|
+
type FixedSizeEncoder,
|
|
25
|
+
type Instruction,
|
|
26
|
+
type InstructionWithAccounts,
|
|
27
|
+
type InstructionWithData,
|
|
28
|
+
type ReadonlySignerAccount,
|
|
29
|
+
type ReadonlyUint8Array,
|
|
30
|
+
type TransactionSigner,
|
|
31
|
+
type WritableAccount,
|
|
32
|
+
} from "@solana/kit";
|
|
33
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
34
|
+
import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
|
|
35
|
+
|
|
36
|
+
export const ACCEPT_ADMIN_DISCRIMINATOR = new Uint8Array([
|
|
37
|
+
112, 42, 45, 90, 116, 181, 13, 170,
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export function getAcceptAdminDiscriminatorBytes() {
|
|
41
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
42
|
+
ACCEPT_ADMIN_DISCRIMINATOR,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type AcceptAdminInstruction<
|
|
47
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
48
|
+
TAccountConfig extends string | AccountMeta<string> = string,
|
|
49
|
+
TAccountNewAdmin extends string | AccountMeta<string> = string,
|
|
50
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
51
|
+
> = Instruction<TProgram> &
|
|
52
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
53
|
+
InstructionWithAccounts<
|
|
54
|
+
[
|
|
55
|
+
TAccountConfig extends string
|
|
56
|
+
? WritableAccount<TAccountConfig>
|
|
57
|
+
: TAccountConfig,
|
|
58
|
+
TAccountNewAdmin extends string
|
|
59
|
+
? ReadonlySignerAccount<TAccountNewAdmin> &
|
|
60
|
+
AccountSignerMeta<TAccountNewAdmin>
|
|
61
|
+
: TAccountNewAdmin,
|
|
62
|
+
...TRemainingAccounts,
|
|
63
|
+
]
|
|
64
|
+
>;
|
|
65
|
+
|
|
66
|
+
export type AcceptAdminInstructionData = { discriminator: ReadonlyUint8Array };
|
|
67
|
+
|
|
68
|
+
export type AcceptAdminInstructionDataArgs = {};
|
|
69
|
+
|
|
70
|
+
export function getAcceptAdminInstructionDataEncoder(): FixedSizeEncoder<AcceptAdminInstructionDataArgs> {
|
|
71
|
+
return transformEncoder(
|
|
72
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
73
|
+
(value) => ({ ...value, discriminator: ACCEPT_ADMIN_DISCRIMINATOR }),
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function getAcceptAdminInstructionDataDecoder(): FixedSizeDecoder<AcceptAdminInstructionData> {
|
|
78
|
+
return getStructDecoder([
|
|
79
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function getAcceptAdminInstructionDataCodec(): FixedSizeCodec<
|
|
84
|
+
AcceptAdminInstructionDataArgs,
|
|
85
|
+
AcceptAdminInstructionData
|
|
86
|
+
> {
|
|
87
|
+
return combineCodec(
|
|
88
|
+
getAcceptAdminInstructionDataEncoder(),
|
|
89
|
+
getAcceptAdminInstructionDataDecoder(),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type AcceptAdminAsyncInput<
|
|
94
|
+
TAccountConfig extends string = string,
|
|
95
|
+
TAccountNewAdmin extends string = string,
|
|
96
|
+
> = {
|
|
97
|
+
config?: Address<TAccountConfig>;
|
|
98
|
+
newAdmin: TransactionSigner<TAccountNewAdmin>;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export async function getAcceptAdminInstructionAsync<
|
|
102
|
+
TAccountConfig extends string,
|
|
103
|
+
TAccountNewAdmin extends string,
|
|
104
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
105
|
+
>(
|
|
106
|
+
input: AcceptAdminAsyncInput<TAccountConfig, TAccountNewAdmin>,
|
|
107
|
+
config?: { programAddress?: TProgramAddress },
|
|
108
|
+
): Promise<
|
|
109
|
+
AcceptAdminInstruction<TProgramAddress, TAccountConfig, TAccountNewAdmin>
|
|
110
|
+
> {
|
|
111
|
+
// Program address.
|
|
112
|
+
const programAddress =
|
|
113
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
114
|
+
|
|
115
|
+
// Original accounts.
|
|
116
|
+
const originalAccounts = {
|
|
117
|
+
config: { value: input.config ?? null, isWritable: true },
|
|
118
|
+
newAdmin: { value: input.newAdmin ?? null, isWritable: false },
|
|
119
|
+
};
|
|
120
|
+
const accounts = originalAccounts as Record<
|
|
121
|
+
keyof typeof originalAccounts,
|
|
122
|
+
ResolvedAccount
|
|
123
|
+
>;
|
|
124
|
+
|
|
125
|
+
// Resolve default values.
|
|
126
|
+
if (!accounts.config.value) {
|
|
127
|
+
accounts.config.value = await getProgramDerivedAddress({
|
|
128
|
+
programAddress,
|
|
129
|
+
seeds: [
|
|
130
|
+
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
131
|
+
],
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
136
|
+
return Object.freeze({
|
|
137
|
+
accounts: [
|
|
138
|
+
getAccountMeta(accounts.config),
|
|
139
|
+
getAccountMeta(accounts.newAdmin),
|
|
140
|
+
],
|
|
141
|
+
data: getAcceptAdminInstructionDataEncoder().encode({}),
|
|
142
|
+
programAddress,
|
|
143
|
+
} as AcceptAdminInstruction<
|
|
144
|
+
TProgramAddress,
|
|
145
|
+
TAccountConfig,
|
|
146
|
+
TAccountNewAdmin
|
|
147
|
+
>);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export type AcceptAdminInput<
|
|
151
|
+
TAccountConfig extends string = string,
|
|
152
|
+
TAccountNewAdmin extends string = string,
|
|
153
|
+
> = {
|
|
154
|
+
config: Address<TAccountConfig>;
|
|
155
|
+
newAdmin: TransactionSigner<TAccountNewAdmin>;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export function getAcceptAdminInstruction<
|
|
159
|
+
TAccountConfig extends string,
|
|
160
|
+
TAccountNewAdmin extends string,
|
|
161
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
162
|
+
>(
|
|
163
|
+
input: AcceptAdminInput<TAccountConfig, TAccountNewAdmin>,
|
|
164
|
+
config?: { programAddress?: TProgramAddress },
|
|
165
|
+
): AcceptAdminInstruction<TProgramAddress, TAccountConfig, TAccountNewAdmin> {
|
|
166
|
+
// Program address.
|
|
167
|
+
const programAddress =
|
|
168
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
169
|
+
|
|
170
|
+
// Original accounts.
|
|
171
|
+
const originalAccounts = {
|
|
172
|
+
config: { value: input.config ?? null, isWritable: true },
|
|
173
|
+
newAdmin: { value: input.newAdmin ?? null, isWritable: false },
|
|
174
|
+
};
|
|
175
|
+
const accounts = originalAccounts as Record<
|
|
176
|
+
keyof typeof originalAccounts,
|
|
177
|
+
ResolvedAccount
|
|
178
|
+
>;
|
|
179
|
+
|
|
180
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
181
|
+
return Object.freeze({
|
|
182
|
+
accounts: [
|
|
183
|
+
getAccountMeta(accounts.config),
|
|
184
|
+
getAccountMeta(accounts.newAdmin),
|
|
185
|
+
],
|
|
186
|
+
data: getAcceptAdminInstructionDataEncoder().encode({}),
|
|
187
|
+
programAddress,
|
|
188
|
+
} as AcceptAdminInstruction<
|
|
189
|
+
TProgramAddress,
|
|
190
|
+
TAccountConfig,
|
|
191
|
+
TAccountNewAdmin
|
|
192
|
+
>);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type ParsedAcceptAdminInstruction<
|
|
196
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
197
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
198
|
+
> = {
|
|
199
|
+
programAddress: Address<TProgram>;
|
|
200
|
+
accounts: {
|
|
201
|
+
config: TAccountMetas[0];
|
|
202
|
+
newAdmin: TAccountMetas[1];
|
|
203
|
+
};
|
|
204
|
+
data: AcceptAdminInstructionData;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
export function parseAcceptAdminInstruction<
|
|
208
|
+
TProgram extends string,
|
|
209
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
210
|
+
>(
|
|
211
|
+
instruction: Instruction<TProgram> &
|
|
212
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
213
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
214
|
+
): ParsedAcceptAdminInstruction<TProgram, TAccountMetas> {
|
|
215
|
+
if (instruction.accounts.length < 2) {
|
|
216
|
+
// TODO: Coded error.
|
|
217
|
+
throw new Error("Not enough accounts");
|
|
218
|
+
}
|
|
219
|
+
let accountIndex = 0;
|
|
220
|
+
const getNextAccount = () => {
|
|
221
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
222
|
+
accountIndex += 1;
|
|
223
|
+
return accountMeta;
|
|
224
|
+
};
|
|
225
|
+
return {
|
|
226
|
+
programAddress: instruction.programAddress,
|
|
227
|
+
accounts: { config: getNextAccount(), newAdmin: getNextAccount() },
|
|
228
|
+
data: getAcceptAdminInstructionDataDecoder().decode(instruction.data),
|
|
229
|
+
};
|
|
230
|
+
}
|