@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,574 @@
|
|
|
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_SETTLEMENT_DISCRIMINATOR = new Uint8Array([
|
|
43
|
+
16, 218, 114, 253, 132, 17, 125, 37,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
export function getClaimMakerSettlementDiscriminatorBytes() {
|
|
47
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
48
|
+
CLAIM_MAKER_SETTLEMENT_DISCRIMINATOR,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type ClaimMakerSettlementInstruction<
|
|
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
|
+
TAccountCollateralVault extends string | AccountMeta<string> = string,
|
|
60
|
+
TAccountMakerCollateralAccount extends string | AccountMeta<string> = string,
|
|
61
|
+
TAccountCollateralMint extends string | AccountMeta<string> = string,
|
|
62
|
+
TAccountMaker extends string | AccountMeta<string> = string,
|
|
63
|
+
TAccountTokenProgram extends string | AccountMeta<string> =
|
|
64
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
|
|
65
|
+
TAccountAssociatedTokenProgram extends string | AccountMeta<string> =
|
|
66
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
67
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
68
|
+
"11111111111111111111111111111111",
|
|
69
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
70
|
+
> = Instruction<TProgram> &
|
|
71
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
72
|
+
InstructionWithAccounts<
|
|
73
|
+
[
|
|
74
|
+
TAccountCollateralPool extends string
|
|
75
|
+
? WritableAccount<TAccountCollateralPool>
|
|
76
|
+
: TAccountCollateralPool,
|
|
77
|
+
TAccountOptionAccount extends string
|
|
78
|
+
? WritableAccount<TAccountOptionAccount>
|
|
79
|
+
: TAccountOptionAccount,
|
|
80
|
+
TAccountMakerCollateralShare extends string
|
|
81
|
+
? WritableAccount<TAccountMakerCollateralShare>
|
|
82
|
+
: TAccountMakerCollateralShare,
|
|
83
|
+
TAccountWriterPosition extends string
|
|
84
|
+
? WritableAccount<TAccountWriterPosition>
|
|
85
|
+
: TAccountWriterPosition,
|
|
86
|
+
TAccountMakerSettlementClaim extends string
|
|
87
|
+
? WritableAccount<TAccountMakerSettlementClaim>
|
|
88
|
+
: TAccountMakerSettlementClaim,
|
|
89
|
+
TAccountCollateralVault extends string
|
|
90
|
+
? WritableAccount<TAccountCollateralVault>
|
|
91
|
+
: TAccountCollateralVault,
|
|
92
|
+
TAccountMakerCollateralAccount extends string
|
|
93
|
+
? WritableAccount<TAccountMakerCollateralAccount>
|
|
94
|
+
: TAccountMakerCollateralAccount,
|
|
95
|
+
TAccountCollateralMint extends string
|
|
96
|
+
? ReadonlyAccount<TAccountCollateralMint>
|
|
97
|
+
: TAccountCollateralMint,
|
|
98
|
+
TAccountMaker extends string
|
|
99
|
+
? WritableSignerAccount<TAccountMaker> &
|
|
100
|
+
AccountSignerMeta<TAccountMaker>
|
|
101
|
+
: TAccountMaker,
|
|
102
|
+
TAccountTokenProgram extends string
|
|
103
|
+
? ReadonlyAccount<TAccountTokenProgram>
|
|
104
|
+
: TAccountTokenProgram,
|
|
105
|
+
TAccountAssociatedTokenProgram extends string
|
|
106
|
+
? ReadonlyAccount<TAccountAssociatedTokenProgram>
|
|
107
|
+
: TAccountAssociatedTokenProgram,
|
|
108
|
+
TAccountSystemProgram extends string
|
|
109
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
110
|
+
: TAccountSystemProgram,
|
|
111
|
+
...TRemainingAccounts,
|
|
112
|
+
]
|
|
113
|
+
>;
|
|
114
|
+
|
|
115
|
+
export type ClaimMakerSettlementInstructionData = {
|
|
116
|
+
discriminator: ReadonlyUint8Array;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export type ClaimMakerSettlementInstructionDataArgs = {};
|
|
120
|
+
|
|
121
|
+
export function getClaimMakerSettlementInstructionDataEncoder(): FixedSizeEncoder<ClaimMakerSettlementInstructionDataArgs> {
|
|
122
|
+
return transformEncoder(
|
|
123
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
124
|
+
(value) => ({
|
|
125
|
+
...value,
|
|
126
|
+
discriminator: CLAIM_MAKER_SETTLEMENT_DISCRIMINATOR,
|
|
127
|
+
}),
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function getClaimMakerSettlementInstructionDataDecoder(): FixedSizeDecoder<ClaimMakerSettlementInstructionData> {
|
|
132
|
+
return getStructDecoder([
|
|
133
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function getClaimMakerSettlementInstructionDataCodec(): FixedSizeCodec<
|
|
138
|
+
ClaimMakerSettlementInstructionDataArgs,
|
|
139
|
+
ClaimMakerSettlementInstructionData
|
|
140
|
+
> {
|
|
141
|
+
return combineCodec(
|
|
142
|
+
getClaimMakerSettlementInstructionDataEncoder(),
|
|
143
|
+
getClaimMakerSettlementInstructionDataDecoder(),
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export type ClaimMakerSettlementAsyncInput<
|
|
148
|
+
TAccountCollateralPool extends string = string,
|
|
149
|
+
TAccountOptionAccount extends string = string,
|
|
150
|
+
TAccountMakerCollateralShare extends string = string,
|
|
151
|
+
TAccountWriterPosition extends string = string,
|
|
152
|
+
TAccountMakerSettlementClaim extends string = string,
|
|
153
|
+
TAccountCollateralVault extends string = string,
|
|
154
|
+
TAccountMakerCollateralAccount extends string = string,
|
|
155
|
+
TAccountCollateralMint extends string = string,
|
|
156
|
+
TAccountMaker extends string = string,
|
|
157
|
+
TAccountTokenProgram extends string = string,
|
|
158
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
159
|
+
TAccountSystemProgram extends string = string,
|
|
160
|
+
> = {
|
|
161
|
+
collateralPool?: Address<TAccountCollateralPool>;
|
|
162
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
163
|
+
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
164
|
+
writerPosition: Address<TAccountWriterPosition>;
|
|
165
|
+
makerSettlementClaim?: Address<TAccountMakerSettlementClaim>;
|
|
166
|
+
collateralVault: Address<TAccountCollateralVault>;
|
|
167
|
+
makerCollateralAccount?: Address<TAccountMakerCollateralAccount>;
|
|
168
|
+
collateralMint: Address<TAccountCollateralMint>;
|
|
169
|
+
maker: TransactionSigner<TAccountMaker>;
|
|
170
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
171
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
172
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export async function getClaimMakerSettlementInstructionAsync<
|
|
176
|
+
TAccountCollateralPool extends string,
|
|
177
|
+
TAccountOptionAccount extends string,
|
|
178
|
+
TAccountMakerCollateralShare extends string,
|
|
179
|
+
TAccountWriterPosition extends string,
|
|
180
|
+
TAccountMakerSettlementClaim extends string,
|
|
181
|
+
TAccountCollateralVault extends string,
|
|
182
|
+
TAccountMakerCollateralAccount extends string,
|
|
183
|
+
TAccountCollateralMint extends string,
|
|
184
|
+
TAccountMaker extends string,
|
|
185
|
+
TAccountTokenProgram extends string,
|
|
186
|
+
TAccountAssociatedTokenProgram extends string,
|
|
187
|
+
TAccountSystemProgram extends string,
|
|
188
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
189
|
+
>(
|
|
190
|
+
input: ClaimMakerSettlementAsyncInput<
|
|
191
|
+
TAccountCollateralPool,
|
|
192
|
+
TAccountOptionAccount,
|
|
193
|
+
TAccountMakerCollateralShare,
|
|
194
|
+
TAccountWriterPosition,
|
|
195
|
+
TAccountMakerSettlementClaim,
|
|
196
|
+
TAccountCollateralVault,
|
|
197
|
+
TAccountMakerCollateralAccount,
|
|
198
|
+
TAccountCollateralMint,
|
|
199
|
+
TAccountMaker,
|
|
200
|
+
TAccountTokenProgram,
|
|
201
|
+
TAccountAssociatedTokenProgram,
|
|
202
|
+
TAccountSystemProgram
|
|
203
|
+
>,
|
|
204
|
+
config?: { programAddress?: TProgramAddress },
|
|
205
|
+
): Promise<
|
|
206
|
+
ClaimMakerSettlementInstruction<
|
|
207
|
+
TProgramAddress,
|
|
208
|
+
TAccountCollateralPool,
|
|
209
|
+
TAccountOptionAccount,
|
|
210
|
+
TAccountMakerCollateralShare,
|
|
211
|
+
TAccountWriterPosition,
|
|
212
|
+
TAccountMakerSettlementClaim,
|
|
213
|
+
TAccountCollateralVault,
|
|
214
|
+
TAccountMakerCollateralAccount,
|
|
215
|
+
TAccountCollateralMint,
|
|
216
|
+
TAccountMaker,
|
|
217
|
+
TAccountTokenProgram,
|
|
218
|
+
TAccountAssociatedTokenProgram,
|
|
219
|
+
TAccountSystemProgram
|
|
220
|
+
>
|
|
221
|
+
> {
|
|
222
|
+
// Program address.
|
|
223
|
+
const programAddress =
|
|
224
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
225
|
+
|
|
226
|
+
// Original accounts.
|
|
227
|
+
const originalAccounts = {
|
|
228
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
229
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
230
|
+
makerCollateralShare: {
|
|
231
|
+
value: input.makerCollateralShare ?? null,
|
|
232
|
+
isWritable: true,
|
|
233
|
+
},
|
|
234
|
+
writerPosition: { value: input.writerPosition ?? null, isWritable: true },
|
|
235
|
+
makerSettlementClaim: {
|
|
236
|
+
value: input.makerSettlementClaim ?? null,
|
|
237
|
+
isWritable: true,
|
|
238
|
+
},
|
|
239
|
+
collateralVault: { value: input.collateralVault ?? null, isWritable: true },
|
|
240
|
+
makerCollateralAccount: {
|
|
241
|
+
value: input.makerCollateralAccount ?? null,
|
|
242
|
+
isWritable: true,
|
|
243
|
+
},
|
|
244
|
+
collateralMint: { value: input.collateralMint ?? null, isWritable: false },
|
|
245
|
+
maker: { value: input.maker ?? null, isWritable: true },
|
|
246
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
247
|
+
associatedTokenProgram: {
|
|
248
|
+
value: input.associatedTokenProgram ?? null,
|
|
249
|
+
isWritable: false,
|
|
250
|
+
},
|
|
251
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
252
|
+
};
|
|
253
|
+
const accounts = originalAccounts as Record<
|
|
254
|
+
keyof typeof originalAccounts,
|
|
255
|
+
ResolvedAccount
|
|
256
|
+
>;
|
|
257
|
+
|
|
258
|
+
// Resolve default values.
|
|
259
|
+
if (!accounts.collateralPool.value) {
|
|
260
|
+
accounts.collateralPool.value = await getProgramDerivedAddress({
|
|
261
|
+
programAddress,
|
|
262
|
+
seeds: [
|
|
263
|
+
getBytesEncoder().encode(
|
|
264
|
+
new Uint8Array([
|
|
265
|
+
99, 111, 108, 108, 97, 116, 101, 114, 97, 108, 95, 112, 111, 111,
|
|
266
|
+
108,
|
|
267
|
+
]),
|
|
268
|
+
),
|
|
269
|
+
getAddressEncoder().encode(expectAddress(accounts.optionAccount.value)),
|
|
270
|
+
],
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (!accounts.makerSettlementClaim.value) {
|
|
274
|
+
accounts.makerSettlementClaim.value = await getProgramDerivedAddress({
|
|
275
|
+
programAddress,
|
|
276
|
+
seeds: [
|
|
277
|
+
getBytesEncoder().encode(
|
|
278
|
+
new Uint8Array([
|
|
279
|
+
109, 97, 107, 101, 114, 95, 115, 101, 116, 116, 108, 101, 109, 101,
|
|
280
|
+
110, 116, 95, 99, 108, 97, 105, 109,
|
|
281
|
+
]),
|
|
282
|
+
),
|
|
283
|
+
getAddressEncoder().encode(
|
|
284
|
+
expectAddress(accounts.makerCollateralShare.value),
|
|
285
|
+
),
|
|
286
|
+
],
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
if (!accounts.makerCollateralAccount.value) {
|
|
290
|
+
accounts.makerCollateralAccount.value = await getProgramDerivedAddress({
|
|
291
|
+
programAddress:
|
|
292
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">,
|
|
293
|
+
seeds: [
|
|
294
|
+
getAddressEncoder().encode(expectAddress(accounts.maker.value)),
|
|
295
|
+
getBytesEncoder().encode(
|
|
296
|
+
new Uint8Array([
|
|
297
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
298
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
299
|
+
126, 255, 0, 169,
|
|
300
|
+
]),
|
|
301
|
+
),
|
|
302
|
+
getAddressEncoder().encode(
|
|
303
|
+
expectAddress(accounts.collateralMint.value),
|
|
304
|
+
),
|
|
305
|
+
],
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (!accounts.tokenProgram.value) {
|
|
309
|
+
accounts.tokenProgram.value =
|
|
310
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
|
|
311
|
+
}
|
|
312
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
313
|
+
accounts.associatedTokenProgram.value =
|
|
314
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
315
|
+
}
|
|
316
|
+
if (!accounts.systemProgram.value) {
|
|
317
|
+
accounts.systemProgram.value =
|
|
318
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
322
|
+
return Object.freeze({
|
|
323
|
+
accounts: [
|
|
324
|
+
getAccountMeta(accounts.collateralPool),
|
|
325
|
+
getAccountMeta(accounts.optionAccount),
|
|
326
|
+
getAccountMeta(accounts.makerCollateralShare),
|
|
327
|
+
getAccountMeta(accounts.writerPosition),
|
|
328
|
+
getAccountMeta(accounts.makerSettlementClaim),
|
|
329
|
+
getAccountMeta(accounts.collateralVault),
|
|
330
|
+
getAccountMeta(accounts.makerCollateralAccount),
|
|
331
|
+
getAccountMeta(accounts.collateralMint),
|
|
332
|
+
getAccountMeta(accounts.maker),
|
|
333
|
+
getAccountMeta(accounts.tokenProgram),
|
|
334
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
335
|
+
getAccountMeta(accounts.systemProgram),
|
|
336
|
+
],
|
|
337
|
+
data: getClaimMakerSettlementInstructionDataEncoder().encode({}),
|
|
338
|
+
programAddress,
|
|
339
|
+
} as ClaimMakerSettlementInstruction<
|
|
340
|
+
TProgramAddress,
|
|
341
|
+
TAccountCollateralPool,
|
|
342
|
+
TAccountOptionAccount,
|
|
343
|
+
TAccountMakerCollateralShare,
|
|
344
|
+
TAccountWriterPosition,
|
|
345
|
+
TAccountMakerSettlementClaim,
|
|
346
|
+
TAccountCollateralVault,
|
|
347
|
+
TAccountMakerCollateralAccount,
|
|
348
|
+
TAccountCollateralMint,
|
|
349
|
+
TAccountMaker,
|
|
350
|
+
TAccountTokenProgram,
|
|
351
|
+
TAccountAssociatedTokenProgram,
|
|
352
|
+
TAccountSystemProgram
|
|
353
|
+
>);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export type ClaimMakerSettlementInput<
|
|
357
|
+
TAccountCollateralPool extends string = string,
|
|
358
|
+
TAccountOptionAccount extends string = string,
|
|
359
|
+
TAccountMakerCollateralShare extends string = string,
|
|
360
|
+
TAccountWriterPosition extends string = string,
|
|
361
|
+
TAccountMakerSettlementClaim extends string = string,
|
|
362
|
+
TAccountCollateralVault extends string = string,
|
|
363
|
+
TAccountMakerCollateralAccount extends string = string,
|
|
364
|
+
TAccountCollateralMint extends string = string,
|
|
365
|
+
TAccountMaker extends string = string,
|
|
366
|
+
TAccountTokenProgram extends string = string,
|
|
367
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
368
|
+
TAccountSystemProgram extends string = string,
|
|
369
|
+
> = {
|
|
370
|
+
collateralPool: Address<TAccountCollateralPool>;
|
|
371
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
372
|
+
makerCollateralShare: Address<TAccountMakerCollateralShare>;
|
|
373
|
+
writerPosition: Address<TAccountWriterPosition>;
|
|
374
|
+
makerSettlementClaim: Address<TAccountMakerSettlementClaim>;
|
|
375
|
+
collateralVault: Address<TAccountCollateralVault>;
|
|
376
|
+
makerCollateralAccount: Address<TAccountMakerCollateralAccount>;
|
|
377
|
+
collateralMint: Address<TAccountCollateralMint>;
|
|
378
|
+
maker: TransactionSigner<TAccountMaker>;
|
|
379
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
380
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
381
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
export function getClaimMakerSettlementInstruction<
|
|
385
|
+
TAccountCollateralPool extends string,
|
|
386
|
+
TAccountOptionAccount extends string,
|
|
387
|
+
TAccountMakerCollateralShare extends string,
|
|
388
|
+
TAccountWriterPosition extends string,
|
|
389
|
+
TAccountMakerSettlementClaim extends string,
|
|
390
|
+
TAccountCollateralVault extends string,
|
|
391
|
+
TAccountMakerCollateralAccount extends string,
|
|
392
|
+
TAccountCollateralMint extends string,
|
|
393
|
+
TAccountMaker extends string,
|
|
394
|
+
TAccountTokenProgram extends string,
|
|
395
|
+
TAccountAssociatedTokenProgram extends string,
|
|
396
|
+
TAccountSystemProgram extends string,
|
|
397
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
398
|
+
>(
|
|
399
|
+
input: ClaimMakerSettlementInput<
|
|
400
|
+
TAccountCollateralPool,
|
|
401
|
+
TAccountOptionAccount,
|
|
402
|
+
TAccountMakerCollateralShare,
|
|
403
|
+
TAccountWriterPosition,
|
|
404
|
+
TAccountMakerSettlementClaim,
|
|
405
|
+
TAccountCollateralVault,
|
|
406
|
+
TAccountMakerCollateralAccount,
|
|
407
|
+
TAccountCollateralMint,
|
|
408
|
+
TAccountMaker,
|
|
409
|
+
TAccountTokenProgram,
|
|
410
|
+
TAccountAssociatedTokenProgram,
|
|
411
|
+
TAccountSystemProgram
|
|
412
|
+
>,
|
|
413
|
+
config?: { programAddress?: TProgramAddress },
|
|
414
|
+
): ClaimMakerSettlementInstruction<
|
|
415
|
+
TProgramAddress,
|
|
416
|
+
TAccountCollateralPool,
|
|
417
|
+
TAccountOptionAccount,
|
|
418
|
+
TAccountMakerCollateralShare,
|
|
419
|
+
TAccountWriterPosition,
|
|
420
|
+
TAccountMakerSettlementClaim,
|
|
421
|
+
TAccountCollateralVault,
|
|
422
|
+
TAccountMakerCollateralAccount,
|
|
423
|
+
TAccountCollateralMint,
|
|
424
|
+
TAccountMaker,
|
|
425
|
+
TAccountTokenProgram,
|
|
426
|
+
TAccountAssociatedTokenProgram,
|
|
427
|
+
TAccountSystemProgram
|
|
428
|
+
> {
|
|
429
|
+
// Program address.
|
|
430
|
+
const programAddress =
|
|
431
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
432
|
+
|
|
433
|
+
// Original accounts.
|
|
434
|
+
const originalAccounts = {
|
|
435
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
436
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: true },
|
|
437
|
+
makerCollateralShare: {
|
|
438
|
+
value: input.makerCollateralShare ?? null,
|
|
439
|
+
isWritable: true,
|
|
440
|
+
},
|
|
441
|
+
writerPosition: { value: input.writerPosition ?? null, isWritable: true },
|
|
442
|
+
makerSettlementClaim: {
|
|
443
|
+
value: input.makerSettlementClaim ?? null,
|
|
444
|
+
isWritable: true,
|
|
445
|
+
},
|
|
446
|
+
collateralVault: { value: input.collateralVault ?? null, isWritable: true },
|
|
447
|
+
makerCollateralAccount: {
|
|
448
|
+
value: input.makerCollateralAccount ?? null,
|
|
449
|
+
isWritable: true,
|
|
450
|
+
},
|
|
451
|
+
collateralMint: { value: input.collateralMint ?? null, isWritable: false },
|
|
452
|
+
maker: { value: input.maker ?? null, isWritable: true },
|
|
453
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
454
|
+
associatedTokenProgram: {
|
|
455
|
+
value: input.associatedTokenProgram ?? null,
|
|
456
|
+
isWritable: false,
|
|
457
|
+
},
|
|
458
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
459
|
+
};
|
|
460
|
+
const accounts = originalAccounts as Record<
|
|
461
|
+
keyof typeof originalAccounts,
|
|
462
|
+
ResolvedAccount
|
|
463
|
+
>;
|
|
464
|
+
|
|
465
|
+
// Resolve default values.
|
|
466
|
+
if (!accounts.tokenProgram.value) {
|
|
467
|
+
accounts.tokenProgram.value =
|
|
468
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
|
|
469
|
+
}
|
|
470
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
471
|
+
accounts.associatedTokenProgram.value =
|
|
472
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
473
|
+
}
|
|
474
|
+
if (!accounts.systemProgram.value) {
|
|
475
|
+
accounts.systemProgram.value =
|
|
476
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
480
|
+
return Object.freeze({
|
|
481
|
+
accounts: [
|
|
482
|
+
getAccountMeta(accounts.collateralPool),
|
|
483
|
+
getAccountMeta(accounts.optionAccount),
|
|
484
|
+
getAccountMeta(accounts.makerCollateralShare),
|
|
485
|
+
getAccountMeta(accounts.writerPosition),
|
|
486
|
+
getAccountMeta(accounts.makerSettlementClaim),
|
|
487
|
+
getAccountMeta(accounts.collateralVault),
|
|
488
|
+
getAccountMeta(accounts.makerCollateralAccount),
|
|
489
|
+
getAccountMeta(accounts.collateralMint),
|
|
490
|
+
getAccountMeta(accounts.maker),
|
|
491
|
+
getAccountMeta(accounts.tokenProgram),
|
|
492
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
493
|
+
getAccountMeta(accounts.systemProgram),
|
|
494
|
+
],
|
|
495
|
+
data: getClaimMakerSettlementInstructionDataEncoder().encode({}),
|
|
496
|
+
programAddress,
|
|
497
|
+
} as ClaimMakerSettlementInstruction<
|
|
498
|
+
TProgramAddress,
|
|
499
|
+
TAccountCollateralPool,
|
|
500
|
+
TAccountOptionAccount,
|
|
501
|
+
TAccountMakerCollateralShare,
|
|
502
|
+
TAccountWriterPosition,
|
|
503
|
+
TAccountMakerSettlementClaim,
|
|
504
|
+
TAccountCollateralVault,
|
|
505
|
+
TAccountMakerCollateralAccount,
|
|
506
|
+
TAccountCollateralMint,
|
|
507
|
+
TAccountMaker,
|
|
508
|
+
TAccountTokenProgram,
|
|
509
|
+
TAccountAssociatedTokenProgram,
|
|
510
|
+
TAccountSystemProgram
|
|
511
|
+
>);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export type ParsedClaimMakerSettlementInstruction<
|
|
515
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
516
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
517
|
+
> = {
|
|
518
|
+
programAddress: Address<TProgram>;
|
|
519
|
+
accounts: {
|
|
520
|
+
collateralPool: TAccountMetas[0];
|
|
521
|
+
optionAccount: TAccountMetas[1];
|
|
522
|
+
makerCollateralShare: TAccountMetas[2];
|
|
523
|
+
writerPosition: TAccountMetas[3];
|
|
524
|
+
makerSettlementClaim: TAccountMetas[4];
|
|
525
|
+
collateralVault: TAccountMetas[5];
|
|
526
|
+
makerCollateralAccount: TAccountMetas[6];
|
|
527
|
+
collateralMint: TAccountMetas[7];
|
|
528
|
+
maker: TAccountMetas[8];
|
|
529
|
+
tokenProgram: TAccountMetas[9];
|
|
530
|
+
associatedTokenProgram: TAccountMetas[10];
|
|
531
|
+
systemProgram: TAccountMetas[11];
|
|
532
|
+
};
|
|
533
|
+
data: ClaimMakerSettlementInstructionData;
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
export function parseClaimMakerSettlementInstruction<
|
|
537
|
+
TProgram extends string,
|
|
538
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
539
|
+
>(
|
|
540
|
+
instruction: Instruction<TProgram> &
|
|
541
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
542
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
543
|
+
): ParsedClaimMakerSettlementInstruction<TProgram, TAccountMetas> {
|
|
544
|
+
if (instruction.accounts.length < 12) {
|
|
545
|
+
// TODO: Coded error.
|
|
546
|
+
throw new Error("Not enough accounts");
|
|
547
|
+
}
|
|
548
|
+
let accountIndex = 0;
|
|
549
|
+
const getNextAccount = () => {
|
|
550
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
551
|
+
accountIndex += 1;
|
|
552
|
+
return accountMeta;
|
|
553
|
+
};
|
|
554
|
+
return {
|
|
555
|
+
programAddress: instruction.programAddress,
|
|
556
|
+
accounts: {
|
|
557
|
+
collateralPool: getNextAccount(),
|
|
558
|
+
optionAccount: getNextAccount(),
|
|
559
|
+
makerCollateralShare: getNextAccount(),
|
|
560
|
+
writerPosition: getNextAccount(),
|
|
561
|
+
makerSettlementClaim: getNextAccount(),
|
|
562
|
+
collateralVault: getNextAccount(),
|
|
563
|
+
makerCollateralAccount: getNextAccount(),
|
|
564
|
+
collateralMint: getNextAccount(),
|
|
565
|
+
maker: getNextAccount(),
|
|
566
|
+
tokenProgram: getNextAccount(),
|
|
567
|
+
associatedTokenProgram: getNextAccount(),
|
|
568
|
+
systemProgram: getNextAccount(),
|
|
569
|
+
},
|
|
570
|
+
data: getClaimMakerSettlementInstructionDataDecoder().decode(
|
|
571
|
+
instruction.data,
|
|
572
|
+
),
|
|
573
|
+
};
|
|
574
|
+
}
|
|
@@ -11,7 +11,9 @@ export * from "./autoExerciseAllExpired";
|
|
|
11
11
|
export * from "./autoExerciseExpired";
|
|
12
12
|
export * from "./borrowFromPool";
|
|
13
13
|
export * from "./buyFromPool";
|
|
14
|
+
export * from "./claimBuyerSettlement";
|
|
14
15
|
export * from "./claimMakerRemaining";
|
|
16
|
+
export * from "./claimMakerSettlement";
|
|
15
17
|
export * from "./closeLongToPool";
|
|
16
18
|
export * from "./closeOption";
|
|
17
19
|
export * from "./createEscrowV2";
|
|
@@ -36,6 +38,8 @@ export * from "./omlpUpdateSupplyLimit";
|
|
|
36
38
|
export * from "./optionExercise";
|
|
37
39
|
export * from "./optionMint";
|
|
38
40
|
export * from "./optionValidate";
|
|
41
|
+
export * from "./prepareBuyerSettlement";
|
|
42
|
+
export * from "./prepareMakerSettlement";
|
|
39
43
|
export * from "./repayPoolLoan";
|
|
40
44
|
export * from "./repayPoolLoanFromCollateral";
|
|
41
45
|
export * from "./repayPoolLoanFromWallet";
|