@epicentral/sos-sdk 0.10.3-beta → 0.10.5-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/accounts/fetchers.ts +18 -0
- package/accounts/pdas.ts +28 -0
- package/generated/accounts/buyerSettlementClaim.ts +227 -0
- package/generated/accounts/index.ts +2 -0
- package/generated/accounts/makerSettlementClaim.ts +233 -0
- package/generated/errors/optionProgram.ts +49 -37
- package/generated/instructions/claimBuyerSettlement.ts +568 -0
- package/generated/instructions/claimMakerSettlement.ts +574 -0
- package/generated/instructions/index.ts +4 -0
- package/generated/instructions/prepareBuyerSettlement.ts +577 -0
- package/generated/instructions/prepareMakerSettlement.ts +415 -0
- package/generated/programs/optionProgram.ts +92 -13
- package/package.json +1 -1
- package/short/builders.ts +124 -0
|
@@ -0,0 +1,415 @@
|
|
|
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
|
+
getAddressEncoder,
|
|
14
|
+
getBytesDecoder,
|
|
15
|
+
getBytesEncoder,
|
|
16
|
+
getProgramDerivedAddress,
|
|
17
|
+
getStructDecoder,
|
|
18
|
+
getStructEncoder,
|
|
19
|
+
transformEncoder,
|
|
20
|
+
type AccountMeta,
|
|
21
|
+
type AccountSignerMeta,
|
|
22
|
+
type Address,
|
|
23
|
+
type FixedSizeCodec,
|
|
24
|
+
type FixedSizeDecoder,
|
|
25
|
+
type FixedSizeEncoder,
|
|
26
|
+
type Instruction,
|
|
27
|
+
type InstructionWithAccounts,
|
|
28
|
+
type InstructionWithData,
|
|
29
|
+
type ReadonlyAccount,
|
|
30
|
+
type ReadonlyUint8Array,
|
|
31
|
+
type TransactionSigner,
|
|
32
|
+
type WritableAccount,
|
|
33
|
+
type WritableSignerAccount,
|
|
34
|
+
} from "@solana/kit";
|
|
35
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
36
|
+
import {
|
|
37
|
+
expectAddress,
|
|
38
|
+
getAccountMetaFactory,
|
|
39
|
+
type ResolvedAccount,
|
|
40
|
+
} from "../shared";
|
|
41
|
+
|
|
42
|
+
export const PREPARE_MAKER_SETTLEMENT_DISCRIMINATOR = new Uint8Array([
|
|
43
|
+
95, 202, 211, 28, 194, 177, 121, 39,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
export function getPrepareMakerSettlementDiscriminatorBytes() {
|
|
47
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
48
|
+
PREPARE_MAKER_SETTLEMENT_DISCRIMINATOR,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type PrepareMakerSettlementInstruction<
|
|
53
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
54
|
+
TAccountCollateralPool extends string | AccountMeta<string> = string,
|
|
55
|
+
TAccountOptionAccount extends string | AccountMeta<string> = string,
|
|
56
|
+
TAccountMakerCollateralShare extends string | AccountMeta<string> = string,
|
|
57
|
+
TAccountWriterPosition extends string | AccountMeta<string> = string,
|
|
58
|
+
TAccountMakerSettlementClaim extends string | AccountMeta<string> = string,
|
|
59
|
+
TAccountKeeper extends string | AccountMeta<string> = string,
|
|
60
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
61
|
+
"11111111111111111111111111111111",
|
|
62
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
63
|
+
> = Instruction<TProgram> &
|
|
64
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
65
|
+
InstructionWithAccounts<
|
|
66
|
+
[
|
|
67
|
+
TAccountCollateralPool extends string
|
|
68
|
+
? WritableAccount<TAccountCollateralPool>
|
|
69
|
+
: TAccountCollateralPool,
|
|
70
|
+
TAccountOptionAccount extends string
|
|
71
|
+
? WritableAccount<TAccountOptionAccount>
|
|
72
|
+
: TAccountOptionAccount,
|
|
73
|
+
TAccountMakerCollateralShare extends string
|
|
74
|
+
? WritableAccount<TAccountMakerCollateralShare>
|
|
75
|
+
: TAccountMakerCollateralShare,
|
|
76
|
+
TAccountWriterPosition extends string
|
|
77
|
+
? WritableAccount<TAccountWriterPosition>
|
|
78
|
+
: TAccountWriterPosition,
|
|
79
|
+
TAccountMakerSettlementClaim extends string
|
|
80
|
+
? WritableAccount<TAccountMakerSettlementClaim>
|
|
81
|
+
: TAccountMakerSettlementClaim,
|
|
82
|
+
TAccountKeeper extends string
|
|
83
|
+
? WritableSignerAccount<TAccountKeeper> &
|
|
84
|
+
AccountSignerMeta<TAccountKeeper>
|
|
85
|
+
: TAccountKeeper,
|
|
86
|
+
TAccountSystemProgram extends string
|
|
87
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
88
|
+
: TAccountSystemProgram,
|
|
89
|
+
...TRemainingAccounts,
|
|
90
|
+
]
|
|
91
|
+
>;
|
|
92
|
+
|
|
93
|
+
export type PrepareMakerSettlementInstructionData = {
|
|
94
|
+
discriminator: ReadonlyUint8Array;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type PrepareMakerSettlementInstructionDataArgs = {};
|
|
98
|
+
|
|
99
|
+
export function getPrepareMakerSettlementInstructionDataEncoder(): FixedSizeEncoder<PrepareMakerSettlementInstructionDataArgs> {
|
|
100
|
+
return transformEncoder(
|
|
101
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
102
|
+
(value) => ({
|
|
103
|
+
...value,
|
|
104
|
+
discriminator: PREPARE_MAKER_SETTLEMENT_DISCRIMINATOR,
|
|
105
|
+
}),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function getPrepareMakerSettlementInstructionDataDecoder(): FixedSizeDecoder<PrepareMakerSettlementInstructionData> {
|
|
110
|
+
return getStructDecoder([
|
|
111
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function getPrepareMakerSettlementInstructionDataCodec(): FixedSizeCodec<
|
|
116
|
+
PrepareMakerSettlementInstructionDataArgs,
|
|
117
|
+
PrepareMakerSettlementInstructionData
|
|
118
|
+
> {
|
|
119
|
+
return combineCodec(
|
|
120
|
+
getPrepareMakerSettlementInstructionDataEncoder(),
|
|
121
|
+
getPrepareMakerSettlementInstructionDataDecoder(),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export type PrepareMakerSettlementAsyncInput<
|
|
126
|
+
TAccountCollateralPool extends string = string,
|
|
127
|
+
TAccountOptionAccount extends string = string,
|
|
128
|
+
TAccountMakerCollateralShare extends string = string,
|
|
129
|
+
TAccountWriterPosition extends string = string,
|
|
130
|
+
TAccountMakerSettlementClaim extends string = string,
|
|
131
|
+
TAccountKeeper extends string = string,
|
|
132
|
+
TAccountSystemProgram extends string = string,
|
|
133
|
+
> = {
|
|
134
|
+
collateralPool?: Address<TAccountCollateralPool>;
|
|
135
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
136
|
+
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
137
|
+
writerPosition: Address<TAccountWriterPosition>;
|
|
138
|
+
makerSettlementClaim?: Address<TAccountMakerSettlementClaim>;
|
|
139
|
+
keeper: TransactionSigner<TAccountKeeper>;
|
|
140
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export async function getPrepareMakerSettlementInstructionAsync<
|
|
144
|
+
TAccountCollateralPool extends string,
|
|
145
|
+
TAccountOptionAccount extends string,
|
|
146
|
+
TAccountMakerCollateralShare extends string,
|
|
147
|
+
TAccountWriterPosition extends string,
|
|
148
|
+
TAccountMakerSettlementClaim extends string,
|
|
149
|
+
TAccountKeeper extends string,
|
|
150
|
+
TAccountSystemProgram extends string,
|
|
151
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
152
|
+
>(
|
|
153
|
+
input: PrepareMakerSettlementAsyncInput<
|
|
154
|
+
TAccountCollateralPool,
|
|
155
|
+
TAccountOptionAccount,
|
|
156
|
+
TAccountMakerCollateralShare,
|
|
157
|
+
TAccountWriterPosition,
|
|
158
|
+
TAccountMakerSettlementClaim,
|
|
159
|
+
TAccountKeeper,
|
|
160
|
+
TAccountSystemProgram
|
|
161
|
+
>,
|
|
162
|
+
config?: { programAddress?: TProgramAddress },
|
|
163
|
+
): Promise<
|
|
164
|
+
PrepareMakerSettlementInstruction<
|
|
165
|
+
TProgramAddress,
|
|
166
|
+
TAccountCollateralPool,
|
|
167
|
+
TAccountOptionAccount,
|
|
168
|
+
TAccountMakerCollateralShare,
|
|
169
|
+
TAccountWriterPosition,
|
|
170
|
+
TAccountMakerSettlementClaim,
|
|
171
|
+
TAccountKeeper,
|
|
172
|
+
TAccountSystemProgram
|
|
173
|
+
>
|
|
174
|
+
> {
|
|
175
|
+
// Program address.
|
|
176
|
+
const programAddress =
|
|
177
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
178
|
+
|
|
179
|
+
// Original accounts.
|
|
180
|
+
const originalAccounts = {
|
|
181
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
182
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
183
|
+
makerCollateralShare: {
|
|
184
|
+
value: input.makerCollateralShare ?? null,
|
|
185
|
+
isWritable: true,
|
|
186
|
+
},
|
|
187
|
+
writerPosition: { value: input.writerPosition ?? null, isWritable: true },
|
|
188
|
+
makerSettlementClaim: {
|
|
189
|
+
value: input.makerSettlementClaim ?? null,
|
|
190
|
+
isWritable: true,
|
|
191
|
+
},
|
|
192
|
+
keeper: { value: input.keeper ?? null, isWritable: true },
|
|
193
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
194
|
+
};
|
|
195
|
+
const accounts = originalAccounts as Record<
|
|
196
|
+
keyof typeof originalAccounts,
|
|
197
|
+
ResolvedAccount
|
|
198
|
+
>;
|
|
199
|
+
|
|
200
|
+
// Resolve default values.
|
|
201
|
+
if (!accounts.collateralPool.value) {
|
|
202
|
+
accounts.collateralPool.value = await getProgramDerivedAddress({
|
|
203
|
+
programAddress,
|
|
204
|
+
seeds: [
|
|
205
|
+
getBytesEncoder().encode(
|
|
206
|
+
new Uint8Array([
|
|
207
|
+
99, 111, 108, 108, 97, 116, 101, 114, 97, 108, 95, 112, 111, 111,
|
|
208
|
+
108,
|
|
209
|
+
]),
|
|
210
|
+
),
|
|
211
|
+
getAddressEncoder().encode(expectAddress(accounts.optionAccount.value)),
|
|
212
|
+
],
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
if (!accounts.makerSettlementClaim.value) {
|
|
216
|
+
accounts.makerSettlementClaim.value = await getProgramDerivedAddress({
|
|
217
|
+
programAddress,
|
|
218
|
+
seeds: [
|
|
219
|
+
getBytesEncoder().encode(
|
|
220
|
+
new Uint8Array([
|
|
221
|
+
109, 97, 107, 101, 114, 95, 115, 101, 116, 116, 108, 101, 109, 101,
|
|
222
|
+
110, 116, 95, 99, 108, 97, 105, 109,
|
|
223
|
+
]),
|
|
224
|
+
),
|
|
225
|
+
getAddressEncoder().encode(
|
|
226
|
+
expectAddress(accounts.makerCollateralShare.value),
|
|
227
|
+
),
|
|
228
|
+
],
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (!accounts.systemProgram.value) {
|
|
232
|
+
accounts.systemProgram.value =
|
|
233
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
237
|
+
return Object.freeze({
|
|
238
|
+
accounts: [
|
|
239
|
+
getAccountMeta(accounts.collateralPool),
|
|
240
|
+
getAccountMeta(accounts.optionAccount),
|
|
241
|
+
getAccountMeta(accounts.makerCollateralShare),
|
|
242
|
+
getAccountMeta(accounts.writerPosition),
|
|
243
|
+
getAccountMeta(accounts.makerSettlementClaim),
|
|
244
|
+
getAccountMeta(accounts.keeper),
|
|
245
|
+
getAccountMeta(accounts.systemProgram),
|
|
246
|
+
],
|
|
247
|
+
data: getPrepareMakerSettlementInstructionDataEncoder().encode({}),
|
|
248
|
+
programAddress,
|
|
249
|
+
} as PrepareMakerSettlementInstruction<
|
|
250
|
+
TProgramAddress,
|
|
251
|
+
TAccountCollateralPool,
|
|
252
|
+
TAccountOptionAccount,
|
|
253
|
+
TAccountMakerCollateralShare,
|
|
254
|
+
TAccountWriterPosition,
|
|
255
|
+
TAccountMakerSettlementClaim,
|
|
256
|
+
TAccountKeeper,
|
|
257
|
+
TAccountSystemProgram
|
|
258
|
+
>);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export type PrepareMakerSettlementInput<
|
|
262
|
+
TAccountCollateralPool extends string = string,
|
|
263
|
+
TAccountOptionAccount extends string = string,
|
|
264
|
+
TAccountMakerCollateralShare extends string = string,
|
|
265
|
+
TAccountWriterPosition extends string = string,
|
|
266
|
+
TAccountMakerSettlementClaim extends string = string,
|
|
267
|
+
TAccountKeeper extends string = string,
|
|
268
|
+
TAccountSystemProgram extends string = string,
|
|
269
|
+
> = {
|
|
270
|
+
collateralPool: Address<TAccountCollateralPool>;
|
|
271
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
272
|
+
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
273
|
+
writerPosition: Address<TAccountWriterPosition>;
|
|
274
|
+
makerSettlementClaim: Address<TAccountMakerSettlementClaim>;
|
|
275
|
+
keeper: TransactionSigner<TAccountKeeper>;
|
|
276
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
export function getPrepareMakerSettlementInstruction<
|
|
280
|
+
TAccountCollateralPool extends string,
|
|
281
|
+
TAccountOptionAccount extends string,
|
|
282
|
+
TAccountMakerCollateralShare extends string,
|
|
283
|
+
TAccountWriterPosition extends string,
|
|
284
|
+
TAccountMakerSettlementClaim extends string,
|
|
285
|
+
TAccountKeeper extends string,
|
|
286
|
+
TAccountSystemProgram extends string,
|
|
287
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
288
|
+
>(
|
|
289
|
+
input: PrepareMakerSettlementInput<
|
|
290
|
+
TAccountCollateralPool,
|
|
291
|
+
TAccountOptionAccount,
|
|
292
|
+
TAccountMakerCollateralShare,
|
|
293
|
+
TAccountWriterPosition,
|
|
294
|
+
TAccountMakerSettlementClaim,
|
|
295
|
+
TAccountKeeper,
|
|
296
|
+
TAccountSystemProgram
|
|
297
|
+
>,
|
|
298
|
+
config?: { programAddress?: TProgramAddress },
|
|
299
|
+
): PrepareMakerSettlementInstruction<
|
|
300
|
+
TProgramAddress,
|
|
301
|
+
TAccountCollateralPool,
|
|
302
|
+
TAccountOptionAccount,
|
|
303
|
+
TAccountMakerCollateralShare,
|
|
304
|
+
TAccountWriterPosition,
|
|
305
|
+
TAccountMakerSettlementClaim,
|
|
306
|
+
TAccountKeeper,
|
|
307
|
+
TAccountSystemProgram
|
|
308
|
+
> {
|
|
309
|
+
// Program address.
|
|
310
|
+
const programAddress =
|
|
311
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
312
|
+
|
|
313
|
+
// Original accounts.
|
|
314
|
+
const originalAccounts = {
|
|
315
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
316
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
317
|
+
makerCollateralShare: {
|
|
318
|
+
value: input.makerCollateralShare ?? null,
|
|
319
|
+
isWritable: true,
|
|
320
|
+
},
|
|
321
|
+
writerPosition: { value: input.writerPosition ?? null, isWritable: true },
|
|
322
|
+
makerSettlementClaim: {
|
|
323
|
+
value: input.makerSettlementClaim ?? null,
|
|
324
|
+
isWritable: true,
|
|
325
|
+
},
|
|
326
|
+
keeper: { value: input.keeper ?? null, isWritable: true },
|
|
327
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
328
|
+
};
|
|
329
|
+
const accounts = originalAccounts as Record<
|
|
330
|
+
keyof typeof originalAccounts,
|
|
331
|
+
ResolvedAccount
|
|
332
|
+
>;
|
|
333
|
+
|
|
334
|
+
// Resolve default values.
|
|
335
|
+
if (!accounts.systemProgram.value) {
|
|
336
|
+
accounts.systemProgram.value =
|
|
337
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
341
|
+
return Object.freeze({
|
|
342
|
+
accounts: [
|
|
343
|
+
getAccountMeta(accounts.collateralPool),
|
|
344
|
+
getAccountMeta(accounts.optionAccount),
|
|
345
|
+
getAccountMeta(accounts.makerCollateralShare),
|
|
346
|
+
getAccountMeta(accounts.writerPosition),
|
|
347
|
+
getAccountMeta(accounts.makerSettlementClaim),
|
|
348
|
+
getAccountMeta(accounts.keeper),
|
|
349
|
+
getAccountMeta(accounts.systemProgram),
|
|
350
|
+
],
|
|
351
|
+
data: getPrepareMakerSettlementInstructionDataEncoder().encode({}),
|
|
352
|
+
programAddress,
|
|
353
|
+
} as PrepareMakerSettlementInstruction<
|
|
354
|
+
TProgramAddress,
|
|
355
|
+
TAccountCollateralPool,
|
|
356
|
+
TAccountOptionAccount,
|
|
357
|
+
TAccountMakerCollateralShare,
|
|
358
|
+
TAccountWriterPosition,
|
|
359
|
+
TAccountMakerSettlementClaim,
|
|
360
|
+
TAccountKeeper,
|
|
361
|
+
TAccountSystemProgram
|
|
362
|
+
>);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export type ParsedPrepareMakerSettlementInstruction<
|
|
366
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
367
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
368
|
+
> = {
|
|
369
|
+
programAddress: Address<TProgram>;
|
|
370
|
+
accounts: {
|
|
371
|
+
collateralPool: TAccountMetas[0];
|
|
372
|
+
optionAccount: TAccountMetas[1];
|
|
373
|
+
makerCollateralShare: TAccountMetas[2];
|
|
374
|
+
writerPosition: TAccountMetas[3];
|
|
375
|
+
makerSettlementClaim: TAccountMetas[4];
|
|
376
|
+
keeper: TAccountMetas[5];
|
|
377
|
+
systemProgram: TAccountMetas[6];
|
|
378
|
+
};
|
|
379
|
+
data: PrepareMakerSettlementInstructionData;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
export function parsePrepareMakerSettlementInstruction<
|
|
383
|
+
TProgram extends string,
|
|
384
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
385
|
+
>(
|
|
386
|
+
instruction: Instruction<TProgram> &
|
|
387
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
388
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
389
|
+
): ParsedPrepareMakerSettlementInstruction<TProgram, TAccountMetas> {
|
|
390
|
+
if (instruction.accounts.length < 7) {
|
|
391
|
+
// TODO: Coded error.
|
|
392
|
+
throw new Error("Not enough accounts");
|
|
393
|
+
}
|
|
394
|
+
let accountIndex = 0;
|
|
395
|
+
const getNextAccount = () => {
|
|
396
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
397
|
+
accountIndex += 1;
|
|
398
|
+
return accountMeta;
|
|
399
|
+
};
|
|
400
|
+
return {
|
|
401
|
+
programAddress: instruction.programAddress,
|
|
402
|
+
accounts: {
|
|
403
|
+
collateralPool: getNextAccount(),
|
|
404
|
+
optionAccount: getNextAccount(),
|
|
405
|
+
makerCollateralShare: getNextAccount(),
|
|
406
|
+
writerPosition: getNextAccount(),
|
|
407
|
+
makerSettlementClaim: getNextAccount(),
|
|
408
|
+
keeper: getNextAccount(),
|
|
409
|
+
systemProgram: getNextAccount(),
|
|
410
|
+
},
|
|
411
|
+
data: getPrepareMakerSettlementInstructionDataDecoder().decode(
|
|
412
|
+
instruction.data,
|
|
413
|
+
),
|
|
414
|
+
};
|
|
415
|
+
}
|
|
@@ -11,10 +11,6 @@ import {
|
|
|
11
11
|
fixEncoderSize,
|
|
12
12
|
getBytesEncoder,
|
|
13
13
|
type Address,
|
|
14
|
-
type Instruction,
|
|
15
|
-
type InstructionWithAccounts,
|
|
16
|
-
type InstructionWithData,
|
|
17
|
-
type AccountMeta,
|
|
18
14
|
type ReadonlyUint8Array,
|
|
19
15
|
} from "@solana/kit";
|
|
20
16
|
import {
|
|
@@ -27,7 +23,9 @@ import {
|
|
|
27
23
|
type ParsedAutoExerciseExpiredInstruction,
|
|
28
24
|
type ParsedBorrowFromPoolInstruction,
|
|
29
25
|
type ParsedBuyFromPoolInstruction,
|
|
26
|
+
type ParsedClaimBuyerSettlementInstruction,
|
|
30
27
|
type ParsedClaimMakerRemainingInstruction,
|
|
28
|
+
type ParsedClaimMakerSettlementInstruction,
|
|
31
29
|
type ParsedCloseLongToPoolInstruction,
|
|
32
30
|
type ParsedCloseOptionInstruction,
|
|
33
31
|
type ParsedCreateEscrowV2Instruction,
|
|
@@ -52,6 +50,8 @@ import {
|
|
|
52
50
|
type ParsedOptionExerciseInstruction,
|
|
53
51
|
type ParsedOptionMintInstruction,
|
|
54
52
|
type ParsedOptionValidateInstruction,
|
|
53
|
+
type ParsedPrepareBuyerSettlementInstruction,
|
|
54
|
+
type ParsedPrepareMakerSettlementInstruction,
|
|
55
55
|
type ParsedRepayPoolLoanFromCollateralInstruction,
|
|
56
56
|
type ParsedRepayPoolLoanFromWalletInstruction,
|
|
57
57
|
type ParsedRepayPoolLoanInstruction,
|
|
@@ -69,11 +69,13 @@ export const OPTION_PROGRAM_PROGRAM_ADDRESS =
|
|
|
69
69
|
"AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg" as Address<"AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg">;
|
|
70
70
|
|
|
71
71
|
export enum OptionProgramAccount {
|
|
72
|
+
BuyerSettlementClaim,
|
|
72
73
|
CollateralPool,
|
|
73
74
|
Config,
|
|
74
75
|
EscrowState,
|
|
75
76
|
LenderPosition,
|
|
76
77
|
MakerCollateralShare,
|
|
78
|
+
MakerSettlementClaim,
|
|
77
79
|
MarketDataAccount,
|
|
78
80
|
OptionAccount,
|
|
79
81
|
OptionPool,
|
|
@@ -87,6 +89,17 @@ export function identifyOptionProgramAccount(
|
|
|
87
89
|
account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
|
|
88
90
|
): OptionProgramAccount {
|
|
89
91
|
const data = "data" in account ? account.data : account;
|
|
92
|
+
if (
|
|
93
|
+
containsBytes(
|
|
94
|
+
data,
|
|
95
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
96
|
+
new Uint8Array([225, 103, 137, 75, 32, 42, 45, 106]),
|
|
97
|
+
),
|
|
98
|
+
0,
|
|
99
|
+
)
|
|
100
|
+
) {
|
|
101
|
+
return OptionProgramAccount.BuyerSettlementClaim;
|
|
102
|
+
}
|
|
90
103
|
if (
|
|
91
104
|
containsBytes(
|
|
92
105
|
data,
|
|
@@ -142,6 +155,17 @@ export function identifyOptionProgramAccount(
|
|
|
142
155
|
) {
|
|
143
156
|
return OptionProgramAccount.MakerCollateralShare;
|
|
144
157
|
}
|
|
158
|
+
if (
|
|
159
|
+
containsBytes(
|
|
160
|
+
data,
|
|
161
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
162
|
+
new Uint8Array([195, 112, 137, 189, 12, 182, 197, 194]),
|
|
163
|
+
),
|
|
164
|
+
0,
|
|
165
|
+
)
|
|
166
|
+
) {
|
|
167
|
+
return OptionProgramAccount.MakerSettlementClaim;
|
|
168
|
+
}
|
|
145
169
|
if (
|
|
146
170
|
containsBytes(
|
|
147
171
|
data,
|
|
@@ -230,7 +254,9 @@ export enum OptionProgramInstruction {
|
|
|
230
254
|
AutoExerciseExpired,
|
|
231
255
|
BorrowFromPool,
|
|
232
256
|
BuyFromPool,
|
|
257
|
+
ClaimBuyerSettlement,
|
|
233
258
|
ClaimMakerRemaining,
|
|
259
|
+
ClaimMakerSettlement,
|
|
234
260
|
CloseLongToPool,
|
|
235
261
|
CloseOption,
|
|
236
262
|
CreateEscrowV2,
|
|
@@ -255,6 +281,8 @@ export enum OptionProgramInstruction {
|
|
|
255
281
|
OptionExercise,
|
|
256
282
|
OptionMint,
|
|
257
283
|
OptionValidate,
|
|
284
|
+
PrepareBuyerSettlement,
|
|
285
|
+
PrepareMakerSettlement,
|
|
258
286
|
RepayPoolLoan,
|
|
259
287
|
RepayPoolLoanFromCollateral,
|
|
260
288
|
RepayPoolLoanFromWallet,
|
|
@@ -327,6 +355,17 @@ export function identifyOptionProgramInstruction(
|
|
|
327
355
|
) {
|
|
328
356
|
return OptionProgramInstruction.BuyFromPool;
|
|
329
357
|
}
|
|
358
|
+
if (
|
|
359
|
+
containsBytes(
|
|
360
|
+
data,
|
|
361
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
362
|
+
new Uint8Array([55, 220, 239, 89, 138, 112, 77, 246]),
|
|
363
|
+
),
|
|
364
|
+
0,
|
|
365
|
+
)
|
|
366
|
+
) {
|
|
367
|
+
return OptionProgramInstruction.ClaimBuyerSettlement;
|
|
368
|
+
}
|
|
330
369
|
if (
|
|
331
370
|
containsBytes(
|
|
332
371
|
data,
|
|
@@ -338,6 +377,17 @@ export function identifyOptionProgramInstruction(
|
|
|
338
377
|
) {
|
|
339
378
|
return OptionProgramInstruction.ClaimMakerRemaining;
|
|
340
379
|
}
|
|
380
|
+
if (
|
|
381
|
+
containsBytes(
|
|
382
|
+
data,
|
|
383
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
384
|
+
new Uint8Array([16, 218, 114, 253, 132, 17, 125, 37]),
|
|
385
|
+
),
|
|
386
|
+
0,
|
|
387
|
+
)
|
|
388
|
+
) {
|
|
389
|
+
return OptionProgramInstruction.ClaimMakerSettlement;
|
|
390
|
+
}
|
|
341
391
|
if (
|
|
342
392
|
containsBytes(
|
|
343
393
|
data,
|
|
@@ -602,6 +652,28 @@ export function identifyOptionProgramInstruction(
|
|
|
602
652
|
) {
|
|
603
653
|
return OptionProgramInstruction.OptionValidate;
|
|
604
654
|
}
|
|
655
|
+
if (
|
|
656
|
+
containsBytes(
|
|
657
|
+
data,
|
|
658
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
659
|
+
new Uint8Array([37, 99, 218, 43, 115, 142, 111, 119]),
|
|
660
|
+
),
|
|
661
|
+
0,
|
|
662
|
+
)
|
|
663
|
+
) {
|
|
664
|
+
return OptionProgramInstruction.PrepareBuyerSettlement;
|
|
665
|
+
}
|
|
666
|
+
if (
|
|
667
|
+
containsBytes(
|
|
668
|
+
data,
|
|
669
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
670
|
+
new Uint8Array([95, 202, 211, 28, 194, 177, 121, 39]),
|
|
671
|
+
),
|
|
672
|
+
0,
|
|
673
|
+
)
|
|
674
|
+
) {
|
|
675
|
+
return OptionProgramInstruction.PrepareMakerSettlement;
|
|
676
|
+
}
|
|
605
677
|
if (
|
|
606
678
|
containsBytes(
|
|
607
679
|
data,
|
|
@@ -746,9 +818,15 @@ export type ParsedOptionProgramInstruction<
|
|
|
746
818
|
| ({
|
|
747
819
|
instructionType: OptionProgramInstruction.BuyFromPool;
|
|
748
820
|
} & ParsedBuyFromPoolInstruction<TProgram>)
|
|
821
|
+
| ({
|
|
822
|
+
instructionType: OptionProgramInstruction.ClaimBuyerSettlement;
|
|
823
|
+
} & ParsedClaimBuyerSettlementInstruction<TProgram>)
|
|
749
824
|
| ({
|
|
750
825
|
instructionType: OptionProgramInstruction.ClaimMakerRemaining;
|
|
751
826
|
} & ParsedClaimMakerRemainingInstruction<TProgram>)
|
|
827
|
+
| ({
|
|
828
|
+
instructionType: OptionProgramInstruction.ClaimMakerSettlement;
|
|
829
|
+
} & ParsedClaimMakerSettlementInstruction<TProgram>)
|
|
752
830
|
| ({
|
|
753
831
|
instructionType: OptionProgramInstruction.CloseLongToPool;
|
|
754
832
|
} & ParsedCloseLongToPoolInstruction<TProgram>)
|
|
@@ -821,6 +899,12 @@ export type ParsedOptionProgramInstruction<
|
|
|
821
899
|
| ({
|
|
822
900
|
instructionType: OptionProgramInstruction.OptionValidate;
|
|
823
901
|
} & ParsedOptionValidateInstruction<TProgram>)
|
|
902
|
+
| ({
|
|
903
|
+
instructionType: OptionProgramInstruction.PrepareBuyerSettlement;
|
|
904
|
+
} & ParsedPrepareBuyerSettlementInstruction<TProgram>)
|
|
905
|
+
| ({
|
|
906
|
+
instructionType: OptionProgramInstruction.PrepareMakerSettlement;
|
|
907
|
+
} & ParsedPrepareMakerSettlementInstruction<TProgram>)
|
|
824
908
|
| ({
|
|
825
909
|
instructionType: OptionProgramInstruction.RepayPoolLoan;
|
|
826
910
|
} & ParsedRepayPoolLoanInstruction<TProgram>)
|
|
@@ -855,16 +939,13 @@ export type ParsedOptionProgramInstruction<
|
|
|
855
939
|
instructionType: OptionProgramInstruction.WriteToPool;
|
|
856
940
|
} & ParsedWriteToPoolInstruction<TProgram>);
|
|
857
941
|
|
|
942
|
+
|
|
858
943
|
export function parseOptionProgramInstruction<
|
|
859
|
-
TProgram extends string,
|
|
860
|
-
TAccountMetas extends readonly AccountMeta[],
|
|
944
|
+
TProgram extends string = "AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg",
|
|
861
945
|
>(
|
|
862
|
-
instruction:
|
|
863
|
-
InstructionWithAccounts<TAccountMetas> &
|
|
864
|
-
InstructionWithData<ReadonlyUint8Array>,
|
|
946
|
+
instruction: Parameters<typeof parseBuyFromPoolInstruction>[0],
|
|
865
947
|
): ParsedOptionProgramInstruction<TProgram> {
|
|
866
948
|
const instructionType = identifyOptionProgramInstruction(instruction);
|
|
867
|
-
|
|
868
949
|
switch (instructionType) {
|
|
869
950
|
case OptionProgramInstruction.BuyFromPool:
|
|
870
951
|
return {
|
|
@@ -887,8 +968,6 @@ export function parseOptionProgramInstruction<
|
|
|
887
968
|
...parseUnwindWriterUnsoldInstruction(instruction),
|
|
888
969
|
} as ParsedOptionProgramInstruction<TProgram>;
|
|
889
970
|
default:
|
|
890
|
-
throw new Error(
|
|
891
|
-
"No parser is registered for this optionProgram instruction.",
|
|
892
|
-
);
|
|
971
|
+
throw new Error("Unsupported optionProgram instruction parser.");
|
|
893
972
|
}
|
|
894
973
|
}
|
package/package.json
CHANGED