@epicentral/sos-sdk 0.10.4-beta → 0.11.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/README.md +12 -8
- 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 +88 -0
- 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
|
+
}
|
|
@@ -19,7 +19,9 @@ import {
|
|
|
19
19
|
type ParsedAutoExerciseExpiredInstruction,
|
|
20
20
|
type ParsedBorrowFromPoolInstruction,
|
|
21
21
|
type ParsedBuyFromPoolInstruction,
|
|
22
|
+
type ParsedClaimBuyerSettlementInstruction,
|
|
22
23
|
type ParsedClaimMakerRemainingInstruction,
|
|
24
|
+
type ParsedClaimMakerSettlementInstruction,
|
|
23
25
|
type ParsedCloseLongToPoolInstruction,
|
|
24
26
|
type ParsedCloseOptionInstruction,
|
|
25
27
|
type ParsedCreateEscrowV2Instruction,
|
|
@@ -44,6 +46,8 @@ import {
|
|
|
44
46
|
type ParsedOptionExerciseInstruction,
|
|
45
47
|
type ParsedOptionMintInstruction,
|
|
46
48
|
type ParsedOptionValidateInstruction,
|
|
49
|
+
type ParsedPrepareBuyerSettlementInstruction,
|
|
50
|
+
type ParsedPrepareMakerSettlementInstruction,
|
|
47
51
|
type ParsedRepayPoolLoanFromCollateralInstruction,
|
|
48
52
|
type ParsedRepayPoolLoanFromWalletInstruction,
|
|
49
53
|
type ParsedRepayPoolLoanInstruction,
|
|
@@ -61,11 +65,13 @@ export const OPTION_PROGRAM_PROGRAM_ADDRESS =
|
|
|
61
65
|
"AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg" as Address<"AVJa9h5aEZ5F4nwJGeoy4kmmiPy1pijrapEspZC5pRYg">;
|
|
62
66
|
|
|
63
67
|
export enum OptionProgramAccount {
|
|
68
|
+
BuyerSettlementClaim,
|
|
64
69
|
CollateralPool,
|
|
65
70
|
Config,
|
|
66
71
|
EscrowState,
|
|
67
72
|
LenderPosition,
|
|
68
73
|
MakerCollateralShare,
|
|
74
|
+
MakerSettlementClaim,
|
|
69
75
|
MarketDataAccount,
|
|
70
76
|
OptionAccount,
|
|
71
77
|
OptionPool,
|
|
@@ -79,6 +85,17 @@ export function identifyOptionProgramAccount(
|
|
|
79
85
|
account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
|
|
80
86
|
): OptionProgramAccount {
|
|
81
87
|
const data = "data" in account ? account.data : account;
|
|
88
|
+
if (
|
|
89
|
+
containsBytes(
|
|
90
|
+
data,
|
|
91
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
92
|
+
new Uint8Array([225, 103, 137, 75, 32, 42, 45, 106]),
|
|
93
|
+
),
|
|
94
|
+
0,
|
|
95
|
+
)
|
|
96
|
+
) {
|
|
97
|
+
return OptionProgramAccount.BuyerSettlementClaim;
|
|
98
|
+
}
|
|
82
99
|
if (
|
|
83
100
|
containsBytes(
|
|
84
101
|
data,
|
|
@@ -134,6 +151,17 @@ export function identifyOptionProgramAccount(
|
|
|
134
151
|
) {
|
|
135
152
|
return OptionProgramAccount.MakerCollateralShare;
|
|
136
153
|
}
|
|
154
|
+
if (
|
|
155
|
+
containsBytes(
|
|
156
|
+
data,
|
|
157
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
158
|
+
new Uint8Array([195, 112, 137, 189, 12, 182, 197, 194]),
|
|
159
|
+
),
|
|
160
|
+
0,
|
|
161
|
+
)
|
|
162
|
+
) {
|
|
163
|
+
return OptionProgramAccount.MakerSettlementClaim;
|
|
164
|
+
}
|
|
137
165
|
if (
|
|
138
166
|
containsBytes(
|
|
139
167
|
data,
|
|
@@ -222,7 +250,9 @@ export enum OptionProgramInstruction {
|
|
|
222
250
|
AutoExerciseExpired,
|
|
223
251
|
BorrowFromPool,
|
|
224
252
|
BuyFromPool,
|
|
253
|
+
ClaimBuyerSettlement,
|
|
225
254
|
ClaimMakerRemaining,
|
|
255
|
+
ClaimMakerSettlement,
|
|
226
256
|
CloseLongToPool,
|
|
227
257
|
CloseOption,
|
|
228
258
|
CreateEscrowV2,
|
|
@@ -247,6 +277,8 @@ export enum OptionProgramInstruction {
|
|
|
247
277
|
OptionExercise,
|
|
248
278
|
OptionMint,
|
|
249
279
|
OptionValidate,
|
|
280
|
+
PrepareBuyerSettlement,
|
|
281
|
+
PrepareMakerSettlement,
|
|
250
282
|
RepayPoolLoan,
|
|
251
283
|
RepayPoolLoanFromCollateral,
|
|
252
284
|
RepayPoolLoanFromWallet,
|
|
@@ -319,6 +351,17 @@ export function identifyOptionProgramInstruction(
|
|
|
319
351
|
) {
|
|
320
352
|
return OptionProgramInstruction.BuyFromPool;
|
|
321
353
|
}
|
|
354
|
+
if (
|
|
355
|
+
containsBytes(
|
|
356
|
+
data,
|
|
357
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
358
|
+
new Uint8Array([55, 220, 239, 89, 138, 112, 77, 246]),
|
|
359
|
+
),
|
|
360
|
+
0,
|
|
361
|
+
)
|
|
362
|
+
) {
|
|
363
|
+
return OptionProgramInstruction.ClaimBuyerSettlement;
|
|
364
|
+
}
|
|
322
365
|
if (
|
|
323
366
|
containsBytes(
|
|
324
367
|
data,
|
|
@@ -330,6 +373,17 @@ export function identifyOptionProgramInstruction(
|
|
|
330
373
|
) {
|
|
331
374
|
return OptionProgramInstruction.ClaimMakerRemaining;
|
|
332
375
|
}
|
|
376
|
+
if (
|
|
377
|
+
containsBytes(
|
|
378
|
+
data,
|
|
379
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
380
|
+
new Uint8Array([16, 218, 114, 253, 132, 17, 125, 37]),
|
|
381
|
+
),
|
|
382
|
+
0,
|
|
383
|
+
)
|
|
384
|
+
) {
|
|
385
|
+
return OptionProgramInstruction.ClaimMakerSettlement;
|
|
386
|
+
}
|
|
333
387
|
if (
|
|
334
388
|
containsBytes(
|
|
335
389
|
data,
|
|
@@ -594,6 +648,28 @@ export function identifyOptionProgramInstruction(
|
|
|
594
648
|
) {
|
|
595
649
|
return OptionProgramInstruction.OptionValidate;
|
|
596
650
|
}
|
|
651
|
+
if (
|
|
652
|
+
containsBytes(
|
|
653
|
+
data,
|
|
654
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
655
|
+
new Uint8Array([37, 99, 218, 43, 115, 142, 111, 119]),
|
|
656
|
+
),
|
|
657
|
+
0,
|
|
658
|
+
)
|
|
659
|
+
) {
|
|
660
|
+
return OptionProgramInstruction.PrepareBuyerSettlement;
|
|
661
|
+
}
|
|
662
|
+
if (
|
|
663
|
+
containsBytes(
|
|
664
|
+
data,
|
|
665
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
666
|
+
new Uint8Array([95, 202, 211, 28, 194, 177, 121, 39]),
|
|
667
|
+
),
|
|
668
|
+
0,
|
|
669
|
+
)
|
|
670
|
+
) {
|
|
671
|
+
return OptionProgramInstruction.PrepareMakerSettlement;
|
|
672
|
+
}
|
|
597
673
|
if (
|
|
598
674
|
containsBytes(
|
|
599
675
|
data,
|
|
@@ -738,9 +814,15 @@ export type ParsedOptionProgramInstruction<
|
|
|
738
814
|
| ({
|
|
739
815
|
instructionType: OptionProgramInstruction.BuyFromPool;
|
|
740
816
|
} & ParsedBuyFromPoolInstruction<TProgram>)
|
|
817
|
+
| ({
|
|
818
|
+
instructionType: OptionProgramInstruction.ClaimBuyerSettlement;
|
|
819
|
+
} & ParsedClaimBuyerSettlementInstruction<TProgram>)
|
|
741
820
|
| ({
|
|
742
821
|
instructionType: OptionProgramInstruction.ClaimMakerRemaining;
|
|
743
822
|
} & ParsedClaimMakerRemainingInstruction<TProgram>)
|
|
823
|
+
| ({
|
|
824
|
+
instructionType: OptionProgramInstruction.ClaimMakerSettlement;
|
|
825
|
+
} & ParsedClaimMakerSettlementInstruction<TProgram>)
|
|
744
826
|
| ({
|
|
745
827
|
instructionType: OptionProgramInstruction.CloseLongToPool;
|
|
746
828
|
} & ParsedCloseLongToPoolInstruction<TProgram>)
|
|
@@ -813,6 +895,12 @@ export type ParsedOptionProgramInstruction<
|
|
|
813
895
|
| ({
|
|
814
896
|
instructionType: OptionProgramInstruction.OptionValidate;
|
|
815
897
|
} & ParsedOptionValidateInstruction<TProgram>)
|
|
898
|
+
| ({
|
|
899
|
+
instructionType: OptionProgramInstruction.PrepareBuyerSettlement;
|
|
900
|
+
} & ParsedPrepareBuyerSettlementInstruction<TProgram>)
|
|
901
|
+
| ({
|
|
902
|
+
instructionType: OptionProgramInstruction.PrepareMakerSettlement;
|
|
903
|
+
} & ParsedPrepareMakerSettlementInstruction<TProgram>)
|
|
816
904
|
| ({
|
|
817
905
|
instructionType: OptionProgramInstruction.RepayPoolLoan;
|
|
818
906
|
} & ParsedRepayPoolLoanInstruction<TProgram>)
|
package/package.json
CHANGED