@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.
- package/.env.example +1 -0
- package/AGENTS.md +7 -0
- package/LICENSE +21 -0
- package/README.md +568 -0
- package/accounts/fetchers.ts +196 -0
- package/accounts/list.ts +184 -0
- package/accounts/pdas.ts +325 -0
- package/accounts/resolve-option.ts +104 -0
- package/client/lookup-table.ts +114 -0
- package/client/program.ts +13 -0
- package/client/types.ts +9 -0
- package/generated/accounts/collateralPool.ts +217 -0
- package/generated/accounts/config.ts +156 -0
- package/generated/accounts/escrowState.ts +183 -0
- package/generated/accounts/index.ts +20 -0
- package/generated/accounts/lenderPosition.ts +211 -0
- package/generated/accounts/makerCollateralShare.ts +229 -0
- package/generated/accounts/marketDataAccount.ts +176 -0
- package/generated/accounts/optionAccount.ts +247 -0
- package/generated/accounts/optionPool.ts +285 -0
- package/generated/accounts/poolLoan.ts +232 -0
- package/generated/accounts/positionAccount.ts +201 -0
- package/generated/accounts/vault.ts +366 -0
- package/generated/accounts/writerPosition.ts +327 -0
- package/generated/errors/index.ts +9 -0
- package/generated/errors/optionProgram.ts +476 -0
- package/generated/index.ts +13 -0
- package/generated/instructions/acceptAdmin.ts +230 -0
- package/generated/instructions/autoExerciseAllExpired.ts +685 -0
- package/generated/instructions/autoExerciseExpired.ts +754 -0
- package/generated/instructions/borrowFromPool.ts +619 -0
- package/generated/instructions/buyFromPool.ts +761 -0
- package/generated/instructions/closeLongToPool.ts +762 -0
- package/generated/instructions/closeOption.ts +235 -0
- package/generated/instructions/createEscrowV2.ts +518 -0
- package/generated/instructions/depositCollateral.ts +624 -0
- package/generated/instructions/depositToPosition.ts +429 -0
- package/generated/instructions/index.ts +47 -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 +750 -0
- package/generated/instructions/liquidateWriterPositionRescue.ts +623 -0
- package/generated/instructions/omlpCreateVault.ts +553 -0
- package/generated/instructions/omlpUpdateFeeWallet.ts +473 -0
- package/generated/instructions/omlpUpdateInterestModel.ts +322 -0
- package/generated/instructions/omlpUpdateLiquidationThreshold.ts +304 -0
- package/generated/instructions/omlpUpdateMaintenanceBuffer.ts +304 -0
- package/generated/instructions/omlpUpdateMaxBorrowCap.ts +304 -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 +617 -0
- package/generated/instructions/optionMint.ts +1373 -0
- package/generated/instructions/optionValidate.ts +302 -0
- package/generated/instructions/repayPoolLoan.ts +558 -0
- package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
- package/generated/instructions/repayPoolLoanFromWallet.ts +542 -0
- package/generated/instructions/settleMakerCollateral.ts +509 -0
- package/generated/instructions/syncWriterPosition.ts +206 -0
- package/generated/instructions/transferAdmin.ts +245 -0
- package/generated/instructions/unwindWriterUnsold.ts +764 -0
- package/generated/instructions/updateImpliedVolatility.ts +226 -0
- package/generated/instructions/updateMarketData.ts +315 -0
- package/generated/instructions/withdrawFromPosition.ts +405 -0
- package/generated/instructions/writeToPool.ts +619 -0
- package/generated/programs/index.ts +9 -0
- package/generated/programs/optionProgram.ts +1144 -0
- package/generated/shared/index.ts +164 -0
- package/generated/types/impliedVolatilityUpdated.ts +73 -0
- package/generated/types/index.ts +28 -0
- package/generated/types/liquidationExecuted.ts +73 -0
- package/generated/types/liquidationRescueEvent.ts +82 -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/protocolFeeUpdated.ts +69 -0
- package/generated/types/vaultCreated.ts +60 -0
- package/generated/types/vaultFeeWalletUpdated.ts +67 -0
- package/generated/types/vaultInterestModelUpdated.ts +77 -0
- package/generated/types/vaultLiquidationThresholdUpdated.ts +69 -0
- package/index.ts +68 -0
- package/long/builders.ts +690 -0
- package/long/exercise.ts +123 -0
- package/long/preflight.ts +214 -0
- package/long/quotes.ts +48 -0
- package/long/remaining-accounts.ts +111 -0
- package/omlp/builders.ts +94 -0
- package/omlp/service.ts +136 -0
- package/oracle/switchboard.ts +315 -0
- package/package.json +34 -0
- package/shared/amounts.ts +53 -0
- package/shared/balances.ts +57 -0
- package/shared/errors.ts +12 -0
- package/shared/remaining-accounts.ts +41 -0
- package/shared/trade-config.ts +27 -0
- package/shared/transactions.ts +121 -0
- package/short/builders.ts +874 -0
- package/short/close-option.ts +34 -0
- package/short/pool.ts +189 -0
- package/short/preflight.ts +619 -0
- package/tsconfig.json +13 -0
- package/wsol/instructions.ts +247 -0
|
@@ -0,0 +1,322 @@
|
|
|
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
|
+
getU16Decoder,
|
|
19
|
+
getU16Encoder,
|
|
20
|
+
transformEncoder,
|
|
21
|
+
type AccountMeta,
|
|
22
|
+
type AccountSignerMeta,
|
|
23
|
+
type Address,
|
|
24
|
+
type FixedSizeCodec,
|
|
25
|
+
type FixedSizeDecoder,
|
|
26
|
+
type FixedSizeEncoder,
|
|
27
|
+
type Instruction,
|
|
28
|
+
type InstructionWithAccounts,
|
|
29
|
+
type InstructionWithData,
|
|
30
|
+
type ReadonlyAccount,
|
|
31
|
+
type ReadonlySignerAccount,
|
|
32
|
+
type ReadonlyUint8Array,
|
|
33
|
+
type TransactionSigner,
|
|
34
|
+
type WritableAccount,
|
|
35
|
+
} from "@solana/kit";
|
|
36
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
37
|
+
import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
|
|
38
|
+
|
|
39
|
+
export const OMLP_UPDATE_INTEREST_MODEL_DISCRIMINATOR = new Uint8Array([
|
|
40
|
+
193, 229, 132, 59, 147, 33, 181, 14,
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
export function getOmlpUpdateInterestModelDiscriminatorBytes() {
|
|
44
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
45
|
+
OMLP_UPDATE_INTEREST_MODEL_DISCRIMINATOR,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type OmlpUpdateInterestModelInstruction<
|
|
50
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
51
|
+
TAccountConfig extends string | AccountMeta<string> = string,
|
|
52
|
+
TAccountVault extends string | AccountMeta<string> = string,
|
|
53
|
+
TAccountAdmin extends string | AccountMeta<string> = string,
|
|
54
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
55
|
+
> = Instruction<TProgram> &
|
|
56
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
57
|
+
InstructionWithAccounts<
|
|
58
|
+
[
|
|
59
|
+
TAccountConfig extends string
|
|
60
|
+
? ReadonlyAccount<TAccountConfig>
|
|
61
|
+
: TAccountConfig,
|
|
62
|
+
TAccountVault extends string
|
|
63
|
+
? WritableAccount<TAccountVault>
|
|
64
|
+
: TAccountVault,
|
|
65
|
+
TAccountAdmin extends string
|
|
66
|
+
? ReadonlySignerAccount<TAccountAdmin> &
|
|
67
|
+
AccountSignerMeta<TAccountAdmin>
|
|
68
|
+
: TAccountAdmin,
|
|
69
|
+
...TRemainingAccounts,
|
|
70
|
+
]
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
export type OmlpUpdateInterestModelInstructionData = {
|
|
74
|
+
discriminator: ReadonlyUint8Array;
|
|
75
|
+
baseRateBps: number;
|
|
76
|
+
optimalUtilizationBps: number;
|
|
77
|
+
rateSlope1Bps: number;
|
|
78
|
+
rateSlope2Bps: number;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type OmlpUpdateInterestModelInstructionDataArgs = {
|
|
82
|
+
baseRateBps: number;
|
|
83
|
+
optimalUtilizationBps: number;
|
|
84
|
+
rateSlope1Bps: number;
|
|
85
|
+
rateSlope2Bps: number;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export function getOmlpUpdateInterestModelInstructionDataEncoder(): FixedSizeEncoder<OmlpUpdateInterestModelInstructionDataArgs> {
|
|
89
|
+
return transformEncoder(
|
|
90
|
+
getStructEncoder([
|
|
91
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
92
|
+
["baseRateBps", getU16Encoder()],
|
|
93
|
+
["optimalUtilizationBps", getU16Encoder()],
|
|
94
|
+
["rateSlope1Bps", getU16Encoder()],
|
|
95
|
+
["rateSlope2Bps", getU16Encoder()],
|
|
96
|
+
]),
|
|
97
|
+
(value) => ({
|
|
98
|
+
...value,
|
|
99
|
+
discriminator: OMLP_UPDATE_INTEREST_MODEL_DISCRIMINATOR,
|
|
100
|
+
}),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function getOmlpUpdateInterestModelInstructionDataDecoder(): FixedSizeDecoder<OmlpUpdateInterestModelInstructionData> {
|
|
105
|
+
return getStructDecoder([
|
|
106
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
107
|
+
["baseRateBps", getU16Decoder()],
|
|
108
|
+
["optimalUtilizationBps", getU16Decoder()],
|
|
109
|
+
["rateSlope1Bps", getU16Decoder()],
|
|
110
|
+
["rateSlope2Bps", getU16Decoder()],
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function getOmlpUpdateInterestModelInstructionDataCodec(): FixedSizeCodec<
|
|
115
|
+
OmlpUpdateInterestModelInstructionDataArgs,
|
|
116
|
+
OmlpUpdateInterestModelInstructionData
|
|
117
|
+
> {
|
|
118
|
+
return combineCodec(
|
|
119
|
+
getOmlpUpdateInterestModelInstructionDataEncoder(),
|
|
120
|
+
getOmlpUpdateInterestModelInstructionDataDecoder(),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export type OmlpUpdateInterestModelAsyncInput<
|
|
125
|
+
TAccountConfig extends string = string,
|
|
126
|
+
TAccountVault extends string = string,
|
|
127
|
+
TAccountAdmin extends string = string,
|
|
128
|
+
> = {
|
|
129
|
+
/** Protocol config - stores admin authority */
|
|
130
|
+
config?: Address<TAccountConfig>;
|
|
131
|
+
vault: Address<TAccountVault>;
|
|
132
|
+
/** Admin signer - must match config.admin */
|
|
133
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
134
|
+
baseRateBps: OmlpUpdateInterestModelInstructionDataArgs["baseRateBps"];
|
|
135
|
+
optimalUtilizationBps: OmlpUpdateInterestModelInstructionDataArgs["optimalUtilizationBps"];
|
|
136
|
+
rateSlope1Bps: OmlpUpdateInterestModelInstructionDataArgs["rateSlope1Bps"];
|
|
137
|
+
rateSlope2Bps: OmlpUpdateInterestModelInstructionDataArgs["rateSlope2Bps"];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export async function getOmlpUpdateInterestModelInstructionAsync<
|
|
141
|
+
TAccountConfig extends string,
|
|
142
|
+
TAccountVault extends string,
|
|
143
|
+
TAccountAdmin extends string,
|
|
144
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
145
|
+
>(
|
|
146
|
+
input: OmlpUpdateInterestModelAsyncInput<
|
|
147
|
+
TAccountConfig,
|
|
148
|
+
TAccountVault,
|
|
149
|
+
TAccountAdmin
|
|
150
|
+
>,
|
|
151
|
+
config?: { programAddress?: TProgramAddress },
|
|
152
|
+
): Promise<
|
|
153
|
+
OmlpUpdateInterestModelInstruction<
|
|
154
|
+
TProgramAddress,
|
|
155
|
+
TAccountConfig,
|
|
156
|
+
TAccountVault,
|
|
157
|
+
TAccountAdmin
|
|
158
|
+
>
|
|
159
|
+
> {
|
|
160
|
+
// Program address.
|
|
161
|
+
const programAddress =
|
|
162
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
163
|
+
|
|
164
|
+
// Original accounts.
|
|
165
|
+
const originalAccounts = {
|
|
166
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
167
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
168
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
169
|
+
};
|
|
170
|
+
const accounts = originalAccounts as Record<
|
|
171
|
+
keyof typeof originalAccounts,
|
|
172
|
+
ResolvedAccount
|
|
173
|
+
>;
|
|
174
|
+
|
|
175
|
+
// Original args.
|
|
176
|
+
const args = { ...input };
|
|
177
|
+
|
|
178
|
+
// Resolve default values.
|
|
179
|
+
if (!accounts.config.value) {
|
|
180
|
+
accounts.config.value = await getProgramDerivedAddress({
|
|
181
|
+
programAddress,
|
|
182
|
+
seeds: [
|
|
183
|
+
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
189
|
+
return Object.freeze({
|
|
190
|
+
accounts: [
|
|
191
|
+
getAccountMeta(accounts.config),
|
|
192
|
+
getAccountMeta(accounts.vault),
|
|
193
|
+
getAccountMeta(accounts.admin),
|
|
194
|
+
],
|
|
195
|
+
data: getOmlpUpdateInterestModelInstructionDataEncoder().encode(
|
|
196
|
+
args as OmlpUpdateInterestModelInstructionDataArgs,
|
|
197
|
+
),
|
|
198
|
+
programAddress,
|
|
199
|
+
} as OmlpUpdateInterestModelInstruction<
|
|
200
|
+
TProgramAddress,
|
|
201
|
+
TAccountConfig,
|
|
202
|
+
TAccountVault,
|
|
203
|
+
TAccountAdmin
|
|
204
|
+
>);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export type OmlpUpdateInterestModelInput<
|
|
208
|
+
TAccountConfig extends string = string,
|
|
209
|
+
TAccountVault extends string = string,
|
|
210
|
+
TAccountAdmin extends string = string,
|
|
211
|
+
> = {
|
|
212
|
+
/** Protocol config - stores admin authority */
|
|
213
|
+
config: Address<TAccountConfig>;
|
|
214
|
+
vault: Address<TAccountVault>;
|
|
215
|
+
/** Admin signer - must match config.admin */
|
|
216
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
217
|
+
baseRateBps: OmlpUpdateInterestModelInstructionDataArgs["baseRateBps"];
|
|
218
|
+
optimalUtilizationBps: OmlpUpdateInterestModelInstructionDataArgs["optimalUtilizationBps"];
|
|
219
|
+
rateSlope1Bps: OmlpUpdateInterestModelInstructionDataArgs["rateSlope1Bps"];
|
|
220
|
+
rateSlope2Bps: OmlpUpdateInterestModelInstructionDataArgs["rateSlope2Bps"];
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export function getOmlpUpdateInterestModelInstruction<
|
|
224
|
+
TAccountConfig extends string,
|
|
225
|
+
TAccountVault extends string,
|
|
226
|
+
TAccountAdmin extends string,
|
|
227
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
228
|
+
>(
|
|
229
|
+
input: OmlpUpdateInterestModelInput<
|
|
230
|
+
TAccountConfig,
|
|
231
|
+
TAccountVault,
|
|
232
|
+
TAccountAdmin
|
|
233
|
+
>,
|
|
234
|
+
config?: { programAddress?: TProgramAddress },
|
|
235
|
+
): OmlpUpdateInterestModelInstruction<
|
|
236
|
+
TProgramAddress,
|
|
237
|
+
TAccountConfig,
|
|
238
|
+
TAccountVault,
|
|
239
|
+
TAccountAdmin
|
|
240
|
+
> {
|
|
241
|
+
// Program address.
|
|
242
|
+
const programAddress =
|
|
243
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
244
|
+
|
|
245
|
+
// Original accounts.
|
|
246
|
+
const originalAccounts = {
|
|
247
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
248
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
249
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
250
|
+
};
|
|
251
|
+
const accounts = originalAccounts as Record<
|
|
252
|
+
keyof typeof originalAccounts,
|
|
253
|
+
ResolvedAccount
|
|
254
|
+
>;
|
|
255
|
+
|
|
256
|
+
// Original args.
|
|
257
|
+
const args = { ...input };
|
|
258
|
+
|
|
259
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
260
|
+
return Object.freeze({
|
|
261
|
+
accounts: [
|
|
262
|
+
getAccountMeta(accounts.config),
|
|
263
|
+
getAccountMeta(accounts.vault),
|
|
264
|
+
getAccountMeta(accounts.admin),
|
|
265
|
+
],
|
|
266
|
+
data: getOmlpUpdateInterestModelInstructionDataEncoder().encode(
|
|
267
|
+
args as OmlpUpdateInterestModelInstructionDataArgs,
|
|
268
|
+
),
|
|
269
|
+
programAddress,
|
|
270
|
+
} as OmlpUpdateInterestModelInstruction<
|
|
271
|
+
TProgramAddress,
|
|
272
|
+
TAccountConfig,
|
|
273
|
+
TAccountVault,
|
|
274
|
+
TAccountAdmin
|
|
275
|
+
>);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export type ParsedOmlpUpdateInterestModelInstruction<
|
|
279
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
280
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
281
|
+
> = {
|
|
282
|
+
programAddress: Address<TProgram>;
|
|
283
|
+
accounts: {
|
|
284
|
+
/** Protocol config - stores admin authority */
|
|
285
|
+
config: TAccountMetas[0];
|
|
286
|
+
vault: TAccountMetas[1];
|
|
287
|
+
/** Admin signer - must match config.admin */
|
|
288
|
+
admin: TAccountMetas[2];
|
|
289
|
+
};
|
|
290
|
+
data: OmlpUpdateInterestModelInstructionData;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
export function parseOmlpUpdateInterestModelInstruction<
|
|
294
|
+
TProgram extends string,
|
|
295
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
296
|
+
>(
|
|
297
|
+
instruction: Instruction<TProgram> &
|
|
298
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
299
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
300
|
+
): ParsedOmlpUpdateInterestModelInstruction<TProgram, TAccountMetas> {
|
|
301
|
+
if (instruction.accounts.length < 3) {
|
|
302
|
+
// TODO: Coded error.
|
|
303
|
+
throw new Error("Not enough accounts");
|
|
304
|
+
}
|
|
305
|
+
let accountIndex = 0;
|
|
306
|
+
const getNextAccount = () => {
|
|
307
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
308
|
+
accountIndex += 1;
|
|
309
|
+
return accountMeta;
|
|
310
|
+
};
|
|
311
|
+
return {
|
|
312
|
+
programAddress: instruction.programAddress,
|
|
313
|
+
accounts: {
|
|
314
|
+
config: getNextAccount(),
|
|
315
|
+
vault: getNextAccount(),
|
|
316
|
+
admin: getNextAccount(),
|
|
317
|
+
},
|
|
318
|
+
data: getOmlpUpdateInterestModelInstructionDataDecoder().decode(
|
|
319
|
+
instruction.data,
|
|
320
|
+
),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
@@ -0,0 +1,304 @@
|
|
|
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
|
+
getU16Decoder,
|
|
19
|
+
getU16Encoder,
|
|
20
|
+
transformEncoder,
|
|
21
|
+
type AccountMeta,
|
|
22
|
+
type AccountSignerMeta,
|
|
23
|
+
type Address,
|
|
24
|
+
type FixedSizeCodec,
|
|
25
|
+
type FixedSizeDecoder,
|
|
26
|
+
type FixedSizeEncoder,
|
|
27
|
+
type Instruction,
|
|
28
|
+
type InstructionWithAccounts,
|
|
29
|
+
type InstructionWithData,
|
|
30
|
+
type ReadonlyAccount,
|
|
31
|
+
type ReadonlySignerAccount,
|
|
32
|
+
type ReadonlyUint8Array,
|
|
33
|
+
type TransactionSigner,
|
|
34
|
+
type WritableAccount,
|
|
35
|
+
} from "@solana/kit";
|
|
36
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
37
|
+
import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
|
|
38
|
+
|
|
39
|
+
export const OMLP_UPDATE_LIQUIDATION_THRESHOLD_DISCRIMINATOR = new Uint8Array([
|
|
40
|
+
196, 59, 136, 47, 38, 158, 76, 232,
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
export function getOmlpUpdateLiquidationThresholdDiscriminatorBytes() {
|
|
44
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
45
|
+
OMLP_UPDATE_LIQUIDATION_THRESHOLD_DISCRIMINATOR,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type OmlpUpdateLiquidationThresholdInstruction<
|
|
50
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
51
|
+
TAccountConfig extends string | AccountMeta<string> = string,
|
|
52
|
+
TAccountVault extends string | AccountMeta<string> = string,
|
|
53
|
+
TAccountAdmin extends string | AccountMeta<string> = string,
|
|
54
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
55
|
+
> = Instruction<TProgram> &
|
|
56
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
57
|
+
InstructionWithAccounts<
|
|
58
|
+
[
|
|
59
|
+
TAccountConfig extends string
|
|
60
|
+
? ReadonlyAccount<TAccountConfig>
|
|
61
|
+
: TAccountConfig,
|
|
62
|
+
TAccountVault extends string
|
|
63
|
+
? WritableAccount<TAccountVault>
|
|
64
|
+
: TAccountVault,
|
|
65
|
+
TAccountAdmin extends string
|
|
66
|
+
? ReadonlySignerAccount<TAccountAdmin> &
|
|
67
|
+
AccountSignerMeta<TAccountAdmin>
|
|
68
|
+
: TAccountAdmin,
|
|
69
|
+
...TRemainingAccounts,
|
|
70
|
+
]
|
|
71
|
+
>;
|
|
72
|
+
|
|
73
|
+
export type OmlpUpdateLiquidationThresholdInstructionData = {
|
|
74
|
+
discriminator: ReadonlyUint8Array;
|
|
75
|
+
newLiqThresholdBps: number;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type OmlpUpdateLiquidationThresholdInstructionDataArgs = {
|
|
79
|
+
newLiqThresholdBps: number;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export function getOmlpUpdateLiquidationThresholdInstructionDataEncoder(): FixedSizeEncoder<OmlpUpdateLiquidationThresholdInstructionDataArgs> {
|
|
83
|
+
return transformEncoder(
|
|
84
|
+
getStructEncoder([
|
|
85
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
86
|
+
["newLiqThresholdBps", getU16Encoder()],
|
|
87
|
+
]),
|
|
88
|
+
(value) => ({
|
|
89
|
+
...value,
|
|
90
|
+
discriminator: OMLP_UPDATE_LIQUIDATION_THRESHOLD_DISCRIMINATOR,
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getOmlpUpdateLiquidationThresholdInstructionDataDecoder(): FixedSizeDecoder<OmlpUpdateLiquidationThresholdInstructionData> {
|
|
96
|
+
return getStructDecoder([
|
|
97
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
98
|
+
["newLiqThresholdBps", getU16Decoder()],
|
|
99
|
+
]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function getOmlpUpdateLiquidationThresholdInstructionDataCodec(): FixedSizeCodec<
|
|
103
|
+
OmlpUpdateLiquidationThresholdInstructionDataArgs,
|
|
104
|
+
OmlpUpdateLiquidationThresholdInstructionData
|
|
105
|
+
> {
|
|
106
|
+
return combineCodec(
|
|
107
|
+
getOmlpUpdateLiquidationThresholdInstructionDataEncoder(),
|
|
108
|
+
getOmlpUpdateLiquidationThresholdInstructionDataDecoder(),
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type OmlpUpdateLiquidationThresholdAsyncInput<
|
|
113
|
+
TAccountConfig extends string = string,
|
|
114
|
+
TAccountVault extends string = string,
|
|
115
|
+
TAccountAdmin extends string = string,
|
|
116
|
+
> = {
|
|
117
|
+
/** Protocol config - stores admin authority */
|
|
118
|
+
config?: Address<TAccountConfig>;
|
|
119
|
+
vault: Address<TAccountVault>;
|
|
120
|
+
/** Admin signer - must match config.admin */
|
|
121
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
122
|
+
newLiqThresholdBps: OmlpUpdateLiquidationThresholdInstructionDataArgs["newLiqThresholdBps"];
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export async function getOmlpUpdateLiquidationThresholdInstructionAsync<
|
|
126
|
+
TAccountConfig extends string,
|
|
127
|
+
TAccountVault extends string,
|
|
128
|
+
TAccountAdmin extends string,
|
|
129
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
130
|
+
>(
|
|
131
|
+
input: OmlpUpdateLiquidationThresholdAsyncInput<
|
|
132
|
+
TAccountConfig,
|
|
133
|
+
TAccountVault,
|
|
134
|
+
TAccountAdmin
|
|
135
|
+
>,
|
|
136
|
+
config?: { programAddress?: TProgramAddress },
|
|
137
|
+
): Promise<
|
|
138
|
+
OmlpUpdateLiquidationThresholdInstruction<
|
|
139
|
+
TProgramAddress,
|
|
140
|
+
TAccountConfig,
|
|
141
|
+
TAccountVault,
|
|
142
|
+
TAccountAdmin
|
|
143
|
+
>
|
|
144
|
+
> {
|
|
145
|
+
// Program address.
|
|
146
|
+
const programAddress =
|
|
147
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
148
|
+
|
|
149
|
+
// Original accounts.
|
|
150
|
+
const originalAccounts = {
|
|
151
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
152
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
153
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
154
|
+
};
|
|
155
|
+
const accounts = originalAccounts as Record<
|
|
156
|
+
keyof typeof originalAccounts,
|
|
157
|
+
ResolvedAccount
|
|
158
|
+
>;
|
|
159
|
+
|
|
160
|
+
// Original args.
|
|
161
|
+
const args = { ...input };
|
|
162
|
+
|
|
163
|
+
// Resolve default values.
|
|
164
|
+
if (!accounts.config.value) {
|
|
165
|
+
accounts.config.value = await getProgramDerivedAddress({
|
|
166
|
+
programAddress,
|
|
167
|
+
seeds: [
|
|
168
|
+
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
169
|
+
],
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
174
|
+
return Object.freeze({
|
|
175
|
+
accounts: [
|
|
176
|
+
getAccountMeta(accounts.config),
|
|
177
|
+
getAccountMeta(accounts.vault),
|
|
178
|
+
getAccountMeta(accounts.admin),
|
|
179
|
+
],
|
|
180
|
+
data: getOmlpUpdateLiquidationThresholdInstructionDataEncoder().encode(
|
|
181
|
+
args as OmlpUpdateLiquidationThresholdInstructionDataArgs,
|
|
182
|
+
),
|
|
183
|
+
programAddress,
|
|
184
|
+
} as OmlpUpdateLiquidationThresholdInstruction<
|
|
185
|
+
TProgramAddress,
|
|
186
|
+
TAccountConfig,
|
|
187
|
+
TAccountVault,
|
|
188
|
+
TAccountAdmin
|
|
189
|
+
>);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type OmlpUpdateLiquidationThresholdInput<
|
|
193
|
+
TAccountConfig extends string = string,
|
|
194
|
+
TAccountVault extends string = string,
|
|
195
|
+
TAccountAdmin extends string = string,
|
|
196
|
+
> = {
|
|
197
|
+
/** Protocol config - stores admin authority */
|
|
198
|
+
config: Address<TAccountConfig>;
|
|
199
|
+
vault: Address<TAccountVault>;
|
|
200
|
+
/** Admin signer - must match config.admin */
|
|
201
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
202
|
+
newLiqThresholdBps: OmlpUpdateLiquidationThresholdInstructionDataArgs["newLiqThresholdBps"];
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export function getOmlpUpdateLiquidationThresholdInstruction<
|
|
206
|
+
TAccountConfig extends string,
|
|
207
|
+
TAccountVault extends string,
|
|
208
|
+
TAccountAdmin extends string,
|
|
209
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
210
|
+
>(
|
|
211
|
+
input: OmlpUpdateLiquidationThresholdInput<
|
|
212
|
+
TAccountConfig,
|
|
213
|
+
TAccountVault,
|
|
214
|
+
TAccountAdmin
|
|
215
|
+
>,
|
|
216
|
+
config?: { programAddress?: TProgramAddress },
|
|
217
|
+
): OmlpUpdateLiquidationThresholdInstruction<
|
|
218
|
+
TProgramAddress,
|
|
219
|
+
TAccountConfig,
|
|
220
|
+
TAccountVault,
|
|
221
|
+
TAccountAdmin
|
|
222
|
+
> {
|
|
223
|
+
// Program address.
|
|
224
|
+
const programAddress =
|
|
225
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
226
|
+
|
|
227
|
+
// Original accounts.
|
|
228
|
+
const originalAccounts = {
|
|
229
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
230
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
231
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
232
|
+
};
|
|
233
|
+
const accounts = originalAccounts as Record<
|
|
234
|
+
keyof typeof originalAccounts,
|
|
235
|
+
ResolvedAccount
|
|
236
|
+
>;
|
|
237
|
+
|
|
238
|
+
// Original args.
|
|
239
|
+
const args = { ...input };
|
|
240
|
+
|
|
241
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
242
|
+
return Object.freeze({
|
|
243
|
+
accounts: [
|
|
244
|
+
getAccountMeta(accounts.config),
|
|
245
|
+
getAccountMeta(accounts.vault),
|
|
246
|
+
getAccountMeta(accounts.admin),
|
|
247
|
+
],
|
|
248
|
+
data: getOmlpUpdateLiquidationThresholdInstructionDataEncoder().encode(
|
|
249
|
+
args as OmlpUpdateLiquidationThresholdInstructionDataArgs,
|
|
250
|
+
),
|
|
251
|
+
programAddress,
|
|
252
|
+
} as OmlpUpdateLiquidationThresholdInstruction<
|
|
253
|
+
TProgramAddress,
|
|
254
|
+
TAccountConfig,
|
|
255
|
+
TAccountVault,
|
|
256
|
+
TAccountAdmin
|
|
257
|
+
>);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export type ParsedOmlpUpdateLiquidationThresholdInstruction<
|
|
261
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
262
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
263
|
+
> = {
|
|
264
|
+
programAddress: Address<TProgram>;
|
|
265
|
+
accounts: {
|
|
266
|
+
/** Protocol config - stores admin authority */
|
|
267
|
+
config: TAccountMetas[0];
|
|
268
|
+
vault: TAccountMetas[1];
|
|
269
|
+
/** Admin signer - must match config.admin */
|
|
270
|
+
admin: TAccountMetas[2];
|
|
271
|
+
};
|
|
272
|
+
data: OmlpUpdateLiquidationThresholdInstructionData;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export function parseOmlpUpdateLiquidationThresholdInstruction<
|
|
276
|
+
TProgram extends string,
|
|
277
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
278
|
+
>(
|
|
279
|
+
instruction: Instruction<TProgram> &
|
|
280
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
281
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
282
|
+
): ParsedOmlpUpdateLiquidationThresholdInstruction<TProgram, TAccountMetas> {
|
|
283
|
+
if (instruction.accounts.length < 3) {
|
|
284
|
+
// TODO: Coded error.
|
|
285
|
+
throw new Error("Not enough accounts");
|
|
286
|
+
}
|
|
287
|
+
let accountIndex = 0;
|
|
288
|
+
const getNextAccount = () => {
|
|
289
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
290
|
+
accountIndex += 1;
|
|
291
|
+
return accountMeta;
|
|
292
|
+
};
|
|
293
|
+
return {
|
|
294
|
+
programAddress: instruction.programAddress,
|
|
295
|
+
accounts: {
|
|
296
|
+
config: getNextAccount(),
|
|
297
|
+
vault: getNextAccount(),
|
|
298
|
+
admin: getNextAccount(),
|
|
299
|
+
},
|
|
300
|
+
data: getOmlpUpdateLiquidationThresholdInstructionDataDecoder().decode(
|
|
301
|
+
instruction.data,
|
|
302
|
+
),
|
|
303
|
+
};
|
|
304
|
+
}
|