@epicentral/sos-sdk 0.9.1-beta → 0.10.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 +14 -2
- package/generated/accounts/collateralPool.ts +29 -1
- package/generated/accounts/makerCollateralShare.ts +9 -1
- package/generated/errors/optionProgram.ts +48 -36
- package/generated/instructions/autoExerciseAllExpired.ts +32 -86
- package/generated/instructions/autoExerciseExpired.ts +38 -95
- package/generated/instructions/claimMakerRemaining.ts +452 -0
- package/generated/instructions/depositCollateral.ts +6 -6
- package/generated/instructions/index.ts +1 -0
- package/generated/instructions/initCollateralPool.ts +3 -3
- package/generated/instructions/settleMakerCollateral.ts +50 -74
- package/generated/programs/optionProgram.ts +24 -0
- package/package.json +1 -1
- package/short/builders.ts +8 -8
|
@@ -0,0 +1,452 @@
|
|
|
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 CLAIM_MAKER_REMAINING_DISCRIMINATOR = new Uint8Array([
|
|
43
|
+
108, 194, 135, 237, 155, 192, 199, 57,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
export function getClaimMakerRemainingDiscriminatorBytes() {
|
|
47
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
48
|
+
CLAIM_MAKER_REMAINING_DISCRIMINATOR,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type ClaimMakerRemainingInstruction<
|
|
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
|
+
TAccountCollateralVault extends string | AccountMeta<string> = string,
|
|
59
|
+
TAccountMakerCollateralAccount extends string | AccountMeta<string> = string,
|
|
60
|
+
TAccountKeeper extends string | AccountMeta<string> = string,
|
|
61
|
+
TAccountTokenProgram extends string | AccountMeta<string> =
|
|
62
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
|
|
63
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
64
|
+
"11111111111111111111111111111111",
|
|
65
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
66
|
+
> = Instruction<TProgram> &
|
|
67
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
68
|
+
InstructionWithAccounts<
|
|
69
|
+
[
|
|
70
|
+
TAccountCollateralPool extends string
|
|
71
|
+
? WritableAccount<TAccountCollateralPool>
|
|
72
|
+
: TAccountCollateralPool,
|
|
73
|
+
TAccountOptionAccount extends string
|
|
74
|
+
? WritableAccount<TAccountOptionAccount>
|
|
75
|
+
: TAccountOptionAccount,
|
|
76
|
+
TAccountMakerCollateralShare extends string
|
|
77
|
+
? WritableAccount<TAccountMakerCollateralShare>
|
|
78
|
+
: TAccountMakerCollateralShare,
|
|
79
|
+
TAccountWriterPosition extends string
|
|
80
|
+
? WritableAccount<TAccountWriterPosition>
|
|
81
|
+
: TAccountWriterPosition,
|
|
82
|
+
TAccountCollateralVault extends string
|
|
83
|
+
? WritableAccount<TAccountCollateralVault>
|
|
84
|
+
: TAccountCollateralVault,
|
|
85
|
+
TAccountMakerCollateralAccount extends string
|
|
86
|
+
? WritableAccount<TAccountMakerCollateralAccount>
|
|
87
|
+
: TAccountMakerCollateralAccount,
|
|
88
|
+
TAccountKeeper extends string
|
|
89
|
+
? WritableSignerAccount<TAccountKeeper> &
|
|
90
|
+
AccountSignerMeta<TAccountKeeper>
|
|
91
|
+
: TAccountKeeper,
|
|
92
|
+
TAccountTokenProgram extends string
|
|
93
|
+
? ReadonlyAccount<TAccountTokenProgram>
|
|
94
|
+
: TAccountTokenProgram,
|
|
95
|
+
TAccountSystemProgram extends string
|
|
96
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
97
|
+
: TAccountSystemProgram,
|
|
98
|
+
...TRemainingAccounts,
|
|
99
|
+
]
|
|
100
|
+
>;
|
|
101
|
+
|
|
102
|
+
export type ClaimMakerRemainingInstructionData = {
|
|
103
|
+
discriminator: ReadonlyUint8Array;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export type ClaimMakerRemainingInstructionDataArgs = {};
|
|
107
|
+
|
|
108
|
+
export function getClaimMakerRemainingInstructionDataEncoder(): FixedSizeEncoder<ClaimMakerRemainingInstructionDataArgs> {
|
|
109
|
+
return transformEncoder(
|
|
110
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
111
|
+
(value) => ({
|
|
112
|
+
...value,
|
|
113
|
+
discriminator: CLAIM_MAKER_REMAINING_DISCRIMINATOR,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getClaimMakerRemainingInstructionDataDecoder(): FixedSizeDecoder<ClaimMakerRemainingInstructionData> {
|
|
119
|
+
return getStructDecoder([
|
|
120
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function getClaimMakerRemainingInstructionDataCodec(): FixedSizeCodec<
|
|
125
|
+
ClaimMakerRemainingInstructionDataArgs,
|
|
126
|
+
ClaimMakerRemainingInstructionData
|
|
127
|
+
> {
|
|
128
|
+
return combineCodec(
|
|
129
|
+
getClaimMakerRemainingInstructionDataEncoder(),
|
|
130
|
+
getClaimMakerRemainingInstructionDataDecoder(),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type ClaimMakerRemainingAsyncInput<
|
|
135
|
+
TAccountCollateralPool extends string = string,
|
|
136
|
+
TAccountOptionAccount extends string = string,
|
|
137
|
+
TAccountMakerCollateralShare extends string = string,
|
|
138
|
+
TAccountWriterPosition extends string = string,
|
|
139
|
+
TAccountCollateralVault extends string = string,
|
|
140
|
+
TAccountMakerCollateralAccount extends string = string,
|
|
141
|
+
TAccountKeeper extends string = string,
|
|
142
|
+
TAccountTokenProgram extends string = string,
|
|
143
|
+
TAccountSystemProgram extends string = string,
|
|
144
|
+
> = {
|
|
145
|
+
collateralPool?: Address<TAccountCollateralPool>;
|
|
146
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
147
|
+
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
148
|
+
writerPosition: Address<TAccountWriterPosition>;
|
|
149
|
+
collateralVault: Address<TAccountCollateralVault>;
|
|
150
|
+
makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
|
|
151
|
+
keeper: TransactionSigner<TAccountKeeper>;
|
|
152
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
153
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export async function getClaimMakerRemainingInstructionAsync<
|
|
157
|
+
TAccountCollateralPool extends string,
|
|
158
|
+
TAccountOptionAccount extends string,
|
|
159
|
+
TAccountMakerCollateralShare extends string,
|
|
160
|
+
TAccountWriterPosition extends string,
|
|
161
|
+
TAccountCollateralVault extends string,
|
|
162
|
+
TAccountMakerCollateralAccount extends string,
|
|
163
|
+
TAccountKeeper extends string,
|
|
164
|
+
TAccountTokenProgram extends string,
|
|
165
|
+
TAccountSystemProgram extends string,
|
|
166
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
167
|
+
>(
|
|
168
|
+
input: ClaimMakerRemainingAsyncInput<
|
|
169
|
+
TAccountCollateralPool,
|
|
170
|
+
TAccountOptionAccount,
|
|
171
|
+
TAccountMakerCollateralShare,
|
|
172
|
+
TAccountWriterPosition,
|
|
173
|
+
TAccountCollateralVault,
|
|
174
|
+
TAccountMakerCollateralAccount,
|
|
175
|
+
TAccountKeeper,
|
|
176
|
+
TAccountTokenProgram,
|
|
177
|
+
TAccountSystemProgram
|
|
178
|
+
>,
|
|
179
|
+
config?: { programAddress?: TProgramAddress },
|
|
180
|
+
): Promise<
|
|
181
|
+
ClaimMakerRemainingInstruction<
|
|
182
|
+
TProgramAddress,
|
|
183
|
+
TAccountCollateralPool,
|
|
184
|
+
TAccountOptionAccount,
|
|
185
|
+
TAccountMakerCollateralShare,
|
|
186
|
+
TAccountWriterPosition,
|
|
187
|
+
TAccountCollateralVault,
|
|
188
|
+
TAccountMakerCollateralAccount,
|
|
189
|
+
TAccountKeeper,
|
|
190
|
+
TAccountTokenProgram,
|
|
191
|
+
TAccountSystemProgram
|
|
192
|
+
>
|
|
193
|
+
> {
|
|
194
|
+
// Program address.
|
|
195
|
+
const programAddress =
|
|
196
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
197
|
+
|
|
198
|
+
// Original accounts.
|
|
199
|
+
const originalAccounts = {
|
|
200
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
201
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
202
|
+
makerCollateralShare: {
|
|
203
|
+
value: input.makerCollateralShare ?? null,
|
|
204
|
+
isWritable: true,
|
|
205
|
+
},
|
|
206
|
+
writerPosition: { value: input.writerPosition ?? null, isWritable: true },
|
|
207
|
+
collateralVault: { value: input.collateralVault ?? null, isWritable: true },
|
|
208
|
+
makerCollateralAccount: {
|
|
209
|
+
value: input.makerCollateralAccount ?? null,
|
|
210
|
+
isWritable: true,
|
|
211
|
+
},
|
|
212
|
+
keeper: { value: input.keeper ?? null, isWritable: true },
|
|
213
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
214
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
215
|
+
};
|
|
216
|
+
const accounts = originalAccounts as Record<
|
|
217
|
+
keyof typeof originalAccounts,
|
|
218
|
+
ResolvedAccount
|
|
219
|
+
>;
|
|
220
|
+
|
|
221
|
+
// Resolve default values.
|
|
222
|
+
if (!accounts.collateralPool.value) {
|
|
223
|
+
accounts.collateralPool.value = await getProgramDerivedAddress({
|
|
224
|
+
programAddress,
|
|
225
|
+
seeds: [
|
|
226
|
+
getBytesEncoder().encode(
|
|
227
|
+
new Uint8Array([
|
|
228
|
+
99, 111, 108, 108, 97, 116, 101, 114, 97, 108, 95, 112, 111, 111,
|
|
229
|
+
108,
|
|
230
|
+
]),
|
|
231
|
+
),
|
|
232
|
+
getAddressEncoder().encode(expectAddress(accounts.optionAccount.value)),
|
|
233
|
+
],
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
if (!accounts.tokenProgram.value) {
|
|
237
|
+
accounts.tokenProgram.value =
|
|
238
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
|
|
239
|
+
}
|
|
240
|
+
if (!accounts.systemProgram.value) {
|
|
241
|
+
accounts.systemProgram.value =
|
|
242
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
246
|
+
return Object.freeze({
|
|
247
|
+
accounts: [
|
|
248
|
+
getAccountMeta(accounts.collateralPool),
|
|
249
|
+
getAccountMeta(accounts.optionAccount),
|
|
250
|
+
getAccountMeta(accounts.makerCollateralShare),
|
|
251
|
+
getAccountMeta(accounts.writerPosition),
|
|
252
|
+
getAccountMeta(accounts.collateralVault),
|
|
253
|
+
getAccountMeta(accounts.makerCollateralAccount),
|
|
254
|
+
getAccountMeta(accounts.keeper),
|
|
255
|
+
getAccountMeta(accounts.tokenProgram),
|
|
256
|
+
getAccountMeta(accounts.systemProgram),
|
|
257
|
+
],
|
|
258
|
+
data: getClaimMakerRemainingInstructionDataEncoder().encode({}),
|
|
259
|
+
programAddress,
|
|
260
|
+
} as ClaimMakerRemainingInstruction<
|
|
261
|
+
TProgramAddress,
|
|
262
|
+
TAccountCollateralPool,
|
|
263
|
+
TAccountOptionAccount,
|
|
264
|
+
TAccountMakerCollateralShare,
|
|
265
|
+
TAccountWriterPosition,
|
|
266
|
+
TAccountCollateralVault,
|
|
267
|
+
TAccountMakerCollateralAccount,
|
|
268
|
+
TAccountKeeper,
|
|
269
|
+
TAccountTokenProgram,
|
|
270
|
+
TAccountSystemProgram
|
|
271
|
+
>);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export type ClaimMakerRemainingInput<
|
|
275
|
+
TAccountCollateralPool extends string = string,
|
|
276
|
+
TAccountOptionAccount extends string = string,
|
|
277
|
+
TAccountMakerCollateralShare extends string = string,
|
|
278
|
+
TAccountWriterPosition extends string = string,
|
|
279
|
+
TAccountCollateralVault extends string = string,
|
|
280
|
+
TAccountMakerCollateralAccount extends string = string,
|
|
281
|
+
TAccountKeeper extends string = string,
|
|
282
|
+
TAccountTokenProgram extends string = string,
|
|
283
|
+
TAccountSystemProgram extends string = string,
|
|
284
|
+
> = {
|
|
285
|
+
collateralPool: Address<TAccountCollateralPool>;
|
|
286
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
287
|
+
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
288
|
+
writerPosition: Address<TAccountWriterPosition>;
|
|
289
|
+
collateralVault: Address<TAccountCollateralVault>;
|
|
290
|
+
makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
|
|
291
|
+
keeper: TransactionSigner<TAccountKeeper>;
|
|
292
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
293
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export function getClaimMakerRemainingInstruction<
|
|
297
|
+
TAccountCollateralPool extends string,
|
|
298
|
+
TAccountOptionAccount extends string,
|
|
299
|
+
TAccountMakerCollateralShare extends string,
|
|
300
|
+
TAccountWriterPosition extends string,
|
|
301
|
+
TAccountCollateralVault extends string,
|
|
302
|
+
TAccountMakerCollateralAccount extends string,
|
|
303
|
+
TAccountKeeper extends string,
|
|
304
|
+
TAccountTokenProgram extends string,
|
|
305
|
+
TAccountSystemProgram extends string,
|
|
306
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
307
|
+
>(
|
|
308
|
+
input: ClaimMakerRemainingInput<
|
|
309
|
+
TAccountCollateralPool,
|
|
310
|
+
TAccountOptionAccount,
|
|
311
|
+
TAccountMakerCollateralShare,
|
|
312
|
+
TAccountWriterPosition,
|
|
313
|
+
TAccountCollateralVault,
|
|
314
|
+
TAccountMakerCollateralAccount,
|
|
315
|
+
TAccountKeeper,
|
|
316
|
+
TAccountTokenProgram,
|
|
317
|
+
TAccountSystemProgram
|
|
318
|
+
>,
|
|
319
|
+
config?: { programAddress?: TProgramAddress },
|
|
320
|
+
): ClaimMakerRemainingInstruction<
|
|
321
|
+
TProgramAddress,
|
|
322
|
+
TAccountCollateralPool,
|
|
323
|
+
TAccountOptionAccount,
|
|
324
|
+
TAccountMakerCollateralShare,
|
|
325
|
+
TAccountWriterPosition,
|
|
326
|
+
TAccountCollateralVault,
|
|
327
|
+
TAccountMakerCollateralAccount,
|
|
328
|
+
TAccountKeeper,
|
|
329
|
+
TAccountTokenProgram,
|
|
330
|
+
TAccountSystemProgram
|
|
331
|
+
> {
|
|
332
|
+
// Program address.
|
|
333
|
+
const programAddress =
|
|
334
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
335
|
+
|
|
336
|
+
// Original accounts.
|
|
337
|
+
const originalAccounts = {
|
|
338
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
339
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
340
|
+
makerCollateralShare: {
|
|
341
|
+
value: input.makerCollateralShare ?? null,
|
|
342
|
+
isWritable: true,
|
|
343
|
+
},
|
|
344
|
+
writerPosition: { value: input.writerPosition ?? null, isWritable: true },
|
|
345
|
+
collateralVault: { value: input.collateralVault ?? null, isWritable: true },
|
|
346
|
+
makerCollateralAccount: {
|
|
347
|
+
value: input.makerCollateralAccount ?? null,
|
|
348
|
+
isWritable: true,
|
|
349
|
+
},
|
|
350
|
+
keeper: { value: input.keeper ?? null, isWritable: true },
|
|
351
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
352
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
353
|
+
};
|
|
354
|
+
const accounts = originalAccounts as Record<
|
|
355
|
+
keyof typeof originalAccounts,
|
|
356
|
+
ResolvedAccount
|
|
357
|
+
>;
|
|
358
|
+
|
|
359
|
+
// Resolve default values.
|
|
360
|
+
if (!accounts.tokenProgram.value) {
|
|
361
|
+
accounts.tokenProgram.value =
|
|
362
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
|
|
363
|
+
}
|
|
364
|
+
if (!accounts.systemProgram.value) {
|
|
365
|
+
accounts.systemProgram.value =
|
|
366
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
370
|
+
return Object.freeze({
|
|
371
|
+
accounts: [
|
|
372
|
+
getAccountMeta(accounts.collateralPool),
|
|
373
|
+
getAccountMeta(accounts.optionAccount),
|
|
374
|
+
getAccountMeta(accounts.makerCollateralShare),
|
|
375
|
+
getAccountMeta(accounts.writerPosition),
|
|
376
|
+
getAccountMeta(accounts.collateralVault),
|
|
377
|
+
getAccountMeta(accounts.makerCollateralAccount),
|
|
378
|
+
getAccountMeta(accounts.keeper),
|
|
379
|
+
getAccountMeta(accounts.tokenProgram),
|
|
380
|
+
getAccountMeta(accounts.systemProgram),
|
|
381
|
+
],
|
|
382
|
+
data: getClaimMakerRemainingInstructionDataEncoder().encode({}),
|
|
383
|
+
programAddress,
|
|
384
|
+
} as ClaimMakerRemainingInstruction<
|
|
385
|
+
TProgramAddress,
|
|
386
|
+
TAccountCollateralPool,
|
|
387
|
+
TAccountOptionAccount,
|
|
388
|
+
TAccountMakerCollateralShare,
|
|
389
|
+
TAccountWriterPosition,
|
|
390
|
+
TAccountCollateralVault,
|
|
391
|
+
TAccountMakerCollateralAccount,
|
|
392
|
+
TAccountKeeper,
|
|
393
|
+
TAccountTokenProgram,
|
|
394
|
+
TAccountSystemProgram
|
|
395
|
+
>);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
export type ParsedClaimMakerRemainingInstruction<
|
|
399
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
400
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
401
|
+
> = {
|
|
402
|
+
programAddress: Address<TProgram>;
|
|
403
|
+
accounts: {
|
|
404
|
+
collateralPool: TAccountMetas[0];
|
|
405
|
+
optionAccount: TAccountMetas[1];
|
|
406
|
+
makerCollateralShare: TAccountMetas[2];
|
|
407
|
+
writerPosition: TAccountMetas[3];
|
|
408
|
+
collateralVault: TAccountMetas[4];
|
|
409
|
+
makerCollateralAccount: TAccountMetas[5];
|
|
410
|
+
keeper: TAccountMetas[6];
|
|
411
|
+
tokenProgram: TAccountMetas[7];
|
|
412
|
+
systemProgram: TAccountMetas[8];
|
|
413
|
+
};
|
|
414
|
+
data: ClaimMakerRemainingInstructionData;
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
export function parseClaimMakerRemainingInstruction<
|
|
418
|
+
TProgram extends string,
|
|
419
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
420
|
+
>(
|
|
421
|
+
instruction: Instruction<TProgram> &
|
|
422
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
423
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
424
|
+
): ParsedClaimMakerRemainingInstruction<TProgram, TAccountMetas> {
|
|
425
|
+
if (instruction.accounts.length < 9) {
|
|
426
|
+
// TODO: Coded error.
|
|
427
|
+
throw new Error("Not enough accounts");
|
|
428
|
+
}
|
|
429
|
+
let accountIndex = 0;
|
|
430
|
+
const getNextAccount = () => {
|
|
431
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
432
|
+
accountIndex += 1;
|
|
433
|
+
return accountMeta;
|
|
434
|
+
};
|
|
435
|
+
return {
|
|
436
|
+
programAddress: instruction.programAddress,
|
|
437
|
+
accounts: {
|
|
438
|
+
collateralPool: getNextAccount(),
|
|
439
|
+
optionAccount: getNextAccount(),
|
|
440
|
+
makerCollateralShare: getNextAccount(),
|
|
441
|
+
writerPosition: getNextAccount(),
|
|
442
|
+
collateralVault: getNextAccount(),
|
|
443
|
+
makerCollateralAccount: getNextAccount(),
|
|
444
|
+
keeper: getNextAccount(),
|
|
445
|
+
tokenProgram: getNextAccount(),
|
|
446
|
+
systemProgram: getNextAccount(),
|
|
447
|
+
},
|
|
448
|
+
data: getClaimMakerRemainingInstructionDataDecoder().decode(
|
|
449
|
+
instruction.data,
|
|
450
|
+
),
|
|
451
|
+
};
|
|
452
|
+
}
|
|
@@ -77,7 +77,7 @@ export type DepositCollateralInstruction<
|
|
|
77
77
|
? WritableAccount<TAccountCollateralPool>
|
|
78
78
|
: TAccountCollateralPool,
|
|
79
79
|
TAccountOptionAccount extends string
|
|
80
|
-
?
|
|
80
|
+
? WritableAccount<TAccountOptionAccount>
|
|
81
81
|
: TAccountOptionAccount,
|
|
82
82
|
TAccountMakerCollateralShare extends string
|
|
83
83
|
? WritableAccount<TAccountMakerCollateralShare>
|
|
@@ -175,7 +175,7 @@ export type DepositCollateralAsyncInput<
|
|
|
175
175
|
collateralPool: Address<TAccountCollateralPool>;
|
|
176
176
|
optionAccount: Address<TAccountOptionAccount>;
|
|
177
177
|
makerCollateralShare?: Address<TAccountMakerCollateralShare>;
|
|
178
|
-
/** Maker's
|
|
178
|
+
/** Maker's collateral token account (source of maker's own collateral) */
|
|
179
179
|
makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
|
|
180
180
|
/** Pool's collateral vault (destination for both maker and borrowed funds) */
|
|
181
181
|
collateralVault: Address<TAccountCollateralVault>;
|
|
@@ -257,7 +257,7 @@ export async function getDepositCollateralInstructionAsync<
|
|
|
257
257
|
// Original accounts.
|
|
258
258
|
const originalAccounts = {
|
|
259
259
|
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
260
|
-
optionAccount: { value: input.optionAccount ?? null, isWritable:
|
|
260
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
261
261
|
makerCollateralShare: {
|
|
262
262
|
value: input.makerCollateralShare ?? null,
|
|
263
263
|
isWritable: true,
|
|
@@ -377,7 +377,7 @@ export type DepositCollateralInput<
|
|
|
377
377
|
collateralPool: Address<TAccountCollateralPool>;
|
|
378
378
|
optionAccount: Address<TAccountOptionAccount>;
|
|
379
379
|
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
380
|
-
/** Maker's
|
|
380
|
+
/** Maker's collateral token account (source of maker's own collateral) */
|
|
381
381
|
makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
|
|
382
382
|
/** Pool's collateral vault (destination for both maker and borrowed funds) */
|
|
383
383
|
collateralVault: Address<TAccountCollateralVault>;
|
|
@@ -457,7 +457,7 @@ export function getDepositCollateralInstruction<
|
|
|
457
457
|
// Original accounts.
|
|
458
458
|
const originalAccounts = {
|
|
459
459
|
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
460
|
-
optionAccount: { value: input.optionAccount ?? null, isWritable:
|
|
460
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
461
461
|
makerCollateralShare: {
|
|
462
462
|
value: input.makerCollateralShare ?? null,
|
|
463
463
|
isWritable: true,
|
|
@@ -552,7 +552,7 @@ export type ParsedDepositCollateralInstruction<
|
|
|
552
552
|
collateralPool: TAccountMetas[0];
|
|
553
553
|
optionAccount: TAccountMetas[1];
|
|
554
554
|
makerCollateralShare: TAccountMetas[2];
|
|
555
|
-
/** Maker's
|
|
555
|
+
/** Maker's collateral token account (source of maker's own collateral) */
|
|
556
556
|
makerCollateralAccount: TAccountMetas[3];
|
|
557
557
|
/** Pool's collateral vault (destination for both maker and borrowed funds) */
|
|
558
558
|
collateralVault: TAccountMetas[4];
|
|
@@ -11,6 +11,7 @@ export * from "./autoExerciseAllExpired";
|
|
|
11
11
|
export * from "./autoExerciseExpired";
|
|
12
12
|
export * from "./borrowFromPool";
|
|
13
13
|
export * from "./buyFromPool";
|
|
14
|
+
export * from "./claimMakerRemaining";
|
|
14
15
|
export * from "./closeLongToPool";
|
|
15
16
|
export * from "./closeOption";
|
|
16
17
|
export * from "./createEscrowV2";
|
|
@@ -152,7 +152,7 @@ export type InitCollateralPoolAsyncInput<
|
|
|
152
152
|
optionAccount: Address<TAccountOptionAccount>;
|
|
153
153
|
optionPool: Address<TAccountOptionPool>;
|
|
154
154
|
collateralPool?: Address<TAccountCollateralPool>;
|
|
155
|
-
/**
|
|
155
|
+
/** Settlement/collateral mint for this pool. */
|
|
156
156
|
collateralMint: Address<TAccountCollateralMint>;
|
|
157
157
|
/** Pool's collateral vault (ATA) */
|
|
158
158
|
collateralVault?: Address<TAccountCollateralVault>;
|
|
@@ -328,7 +328,7 @@ export type InitCollateralPoolInput<
|
|
|
328
328
|
optionAccount: Address<TAccountOptionAccount>;
|
|
329
329
|
optionPool: Address<TAccountOptionPool>;
|
|
330
330
|
collateralPool: Address<TAccountCollateralPool>;
|
|
331
|
-
/**
|
|
331
|
+
/** Settlement/collateral mint for this pool. */
|
|
332
332
|
collateralMint: Address<TAccountCollateralMint>;
|
|
333
333
|
/** Pool's collateral vault (ATA) */
|
|
334
334
|
collateralVault: Address<TAccountCollateralVault>;
|
|
@@ -461,7 +461,7 @@ export type ParsedInitCollateralPoolInstruction<
|
|
|
461
461
|
optionAccount: TAccountMetas[0];
|
|
462
462
|
optionPool: TAccountMetas[1];
|
|
463
463
|
collateralPool: TAccountMetas[2];
|
|
464
|
-
/**
|
|
464
|
+
/** Settlement/collateral mint for this pool. */
|
|
465
465
|
collateralMint: TAccountMetas[3];
|
|
466
466
|
/** Pool's collateral vault (ATA) */
|
|
467
467
|
collateralVault: TAccountMetas[4];
|