@epicentral/sos-sdk 0.1.0
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/LICENSE +21 -0
- package/README.md +239 -0
- package/accounts/fetchers.ts +140 -0
- package/accounts/list.ts +152 -0
- package/accounts/pdas.ts +308 -0
- package/client/lookup-table.ts +32 -0
- package/client/program.ts +13 -0
- package/client/types.ts +8 -0
- package/generated/accounts/collateralPool.ts +217 -0
- package/generated/accounts/config.ts +156 -0
- package/generated/accounts/dualSourceContract.ts +235 -0
- package/generated/accounts/escrowState.ts +183 -0
- package/generated/accounts/index.ts +24 -0
- package/generated/accounts/lenderPosition.ts +211 -0
- package/generated/accounts/liquidityRouter.ts +223 -0
- package/generated/accounts/makerCollateralShare.ts +229 -0
- package/generated/accounts/makerPoolShare.ts +203 -0
- package/generated/accounts/marketDataAccount.ts +176 -0
- package/generated/accounts/optionAccount.ts +247 -0
- package/generated/accounts/optionPool.ts +253 -0
- package/generated/accounts/poolLoan.ts +220 -0
- package/generated/accounts/positionAccount.ts +187 -0
- package/generated/accounts/priceUpdateV2.ts +163 -0
- package/generated/accounts/vault.ts +304 -0
- package/generated/accounts/writerPosition.ts +297 -0
- package/generated/errors/index.ts +9 -0
- package/generated/errors/optionProgram.ts +392 -0
- package/generated/index.ts +13 -0
- package/generated/instructions/acceptAdmin.ts +230 -0
- package/generated/instructions/autoExerciseAllExpired.ts +523 -0
- package/generated/instructions/autoExerciseExpired.ts +623 -0
- package/generated/instructions/borrowFromPool.ts +554 -0
- package/generated/instructions/buyFromPool.ts +684 -0
- package/generated/instructions/claimPremium.ts +377 -0
- package/generated/instructions/closeLongToPool.ts +716 -0
- package/generated/instructions/closeOption.ts +235 -0
- package/generated/instructions/createEscrowV2.ts +518 -0
- package/generated/instructions/createLiquidityRouter.ts +361 -0
- package/generated/instructions/depositCollateral.ts +624 -0
- package/generated/instructions/depositToPool.ts +497 -0
- package/generated/instructions/depositToPosition.ts +429 -0
- package/generated/instructions/index.ts +45 -0
- package/generated/instructions/initCollateralPool.ts +513 -0
- package/generated/instructions/initConfig.ts +279 -0
- package/generated/instructions/initOptionPool.ts +587 -0
- package/generated/instructions/initializeMarketData.ts +359 -0
- package/generated/instructions/liquidateWriterPosition.ts +592 -0
- package/generated/instructions/omlpCreateVault.ts +547 -0
- package/generated/instructions/omlpTakeOfferWithFailover.ts +606 -0
- package/generated/instructions/omlpUpdateMaxLeverage.ts +304 -0
- package/generated/instructions/omlpUpdateProtocolFee.ts +304 -0
- package/generated/instructions/omlpUpdateSupplyLimit.ts +304 -0
- package/generated/instructions/optionExercise.ts +540 -0
- package/generated/instructions/optionMint.ts +1349 -0
- package/generated/instructions/optionValidate.ts +255 -0
- package/generated/instructions/repayPoolLoan.ts +499 -0
- package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
- package/generated/instructions/settleMakerCollateral.ts +472 -0
- package/generated/instructions/syncWriterPosition.ts +206 -0
- package/generated/instructions/transferAdmin.ts +245 -0
- package/generated/instructions/unwindWriterUnsold.ts +668 -0
- package/generated/instructions/updateImpliedVolatility.ts +226 -0
- package/generated/instructions/updateMarketData.ts +315 -0
- package/generated/instructions/withdrawFromPool.ts +429 -0
- package/generated/instructions/withdrawFromPosition.ts +405 -0
- package/generated/instructions/writeToPool.ts +594 -0
- package/generated/programs/index.ts +9 -0
- package/generated/programs/optionProgram.ts +832 -0
- package/generated/shared/index.ts +164 -0
- package/generated/types/borrowedFromSAP1.ts +75 -0
- package/generated/types/borrowedFromSAP2.ts +83 -0
- package/generated/types/failoverTriggered.ts +85 -0
- package/generated/types/impliedVolatilityUpdated.ts +73 -0
- package/generated/types/index.ts +32 -0
- package/generated/types/liquidationExecuted.ts +73 -0
- package/generated/types/liquidityMetrics.ts +69 -0
- package/generated/types/liquidityRouterCreated.ts +79 -0
- package/generated/types/marketDataInitialized.ts +61 -0
- package/generated/types/marketDataUpdated.ts +69 -0
- package/generated/types/optionClosed.ts +56 -0
- package/generated/types/optionExercised.ts +62 -0
- package/generated/types/optionExpired.ts +49 -0
- package/generated/types/optionMinted.ts +78 -0
- package/generated/types/optionType.ts +38 -0
- package/generated/types/optionValidated.ts +82 -0
- package/generated/types/poolLoanCreated.ts +74 -0
- package/generated/types/poolLoanRepaid.ts +74 -0
- package/generated/types/positionDeposited.ts +73 -0
- package/generated/types/positionWithdrawn.ts +81 -0
- package/generated/types/priceFeedMessage.ts +117 -0
- package/generated/types/protocolFeeUpdated.ts +69 -0
- package/generated/types/sap2Provider.ts +38 -0
- package/generated/types/vaultCreated.ts +60 -0
- package/generated/types/verificationLevel.ts +95 -0
- package/index.ts +25 -0
- package/long/builders.ts +126 -0
- package/long/exercise.ts +49 -0
- package/long/quotes.ts +48 -0
- package/omlp/builders.ts +74 -0
- package/omlp/service.ts +94 -0
- package/package.json +22 -0
- package/shared/amounts.ts +32 -0
- package/shared/errors.ts +12 -0
- package/shared/remaining-accounts.ts +41 -0
- package/shared/transactions.ts +49 -0
- package/short/builders.ts +268 -0
- package/short/claim-premium.ts +37 -0
- package/short/close-option.ts +34 -0
- package/short/pool.ts +224 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,361 @@
|
|
|
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
|
+
getAddressDecoder,
|
|
14
|
+
getAddressEncoder,
|
|
15
|
+
getBytesDecoder,
|
|
16
|
+
getBytesEncoder,
|
|
17
|
+
getProgramDerivedAddress,
|
|
18
|
+
getStructDecoder,
|
|
19
|
+
getStructEncoder,
|
|
20
|
+
getU16Decoder,
|
|
21
|
+
getU16Encoder,
|
|
22
|
+
transformEncoder,
|
|
23
|
+
type AccountMeta,
|
|
24
|
+
type AccountSignerMeta,
|
|
25
|
+
type Address,
|
|
26
|
+
type FixedSizeCodec,
|
|
27
|
+
type FixedSizeDecoder,
|
|
28
|
+
type FixedSizeEncoder,
|
|
29
|
+
type Instruction,
|
|
30
|
+
type InstructionWithAccounts,
|
|
31
|
+
type InstructionWithData,
|
|
32
|
+
type ReadonlyAccount,
|
|
33
|
+
type ReadonlyUint8Array,
|
|
34
|
+
type TransactionSigner,
|
|
35
|
+
type WritableAccount,
|
|
36
|
+
type WritableSignerAccount,
|
|
37
|
+
} from "@solana/kit";
|
|
38
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
39
|
+
import {
|
|
40
|
+
expectAddress,
|
|
41
|
+
getAccountMetaFactory,
|
|
42
|
+
type ResolvedAccount,
|
|
43
|
+
} from "../shared";
|
|
44
|
+
import {
|
|
45
|
+
getSap2ProviderDecoder,
|
|
46
|
+
getSap2ProviderEncoder,
|
|
47
|
+
type Sap2Provider,
|
|
48
|
+
type Sap2ProviderArgs,
|
|
49
|
+
} from "../types";
|
|
50
|
+
|
|
51
|
+
export const CREATE_LIQUIDITY_ROUTER_DISCRIMINATOR = new Uint8Array([
|
|
52
|
+
226, 122, 201, 80, 25, 49, 83, 84,
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
export function getCreateLiquidityRouterDiscriminatorBytes() {
|
|
56
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
57
|
+
CREATE_LIQUIDITY_ROUTER_DISCRIMINATOR,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type CreateLiquidityRouterInstruction<
|
|
62
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
63
|
+
TAccountRouter extends string | AccountMeta<string> = string,
|
|
64
|
+
TAccountVault extends string | AccountMeta<string> = string,
|
|
65
|
+
TAccountAuthority extends string | AccountMeta<string> = string,
|
|
66
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
67
|
+
"11111111111111111111111111111111",
|
|
68
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
69
|
+
> = Instruction<TProgram> &
|
|
70
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
71
|
+
InstructionWithAccounts<
|
|
72
|
+
[
|
|
73
|
+
TAccountRouter extends string
|
|
74
|
+
? WritableAccount<TAccountRouter>
|
|
75
|
+
: TAccountRouter,
|
|
76
|
+
TAccountVault extends string
|
|
77
|
+
? ReadonlyAccount<TAccountVault>
|
|
78
|
+
: TAccountVault,
|
|
79
|
+
TAccountAuthority extends string
|
|
80
|
+
? WritableSignerAccount<TAccountAuthority> &
|
|
81
|
+
AccountSignerMeta<TAccountAuthority>
|
|
82
|
+
: TAccountAuthority,
|
|
83
|
+
TAccountSystemProgram extends string
|
|
84
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
85
|
+
: TAccountSystemProgram,
|
|
86
|
+
...TRemainingAccounts,
|
|
87
|
+
]
|
|
88
|
+
>;
|
|
89
|
+
|
|
90
|
+
export type CreateLiquidityRouterInstructionData = {
|
|
91
|
+
discriminator: ReadonlyUint8Array;
|
|
92
|
+
sap2Program: Address;
|
|
93
|
+
sap2Provider: Sap2Provider;
|
|
94
|
+
utilizationThreshold: number;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type CreateLiquidityRouterInstructionDataArgs = {
|
|
98
|
+
sap2Program: Address;
|
|
99
|
+
sap2Provider: Sap2ProviderArgs;
|
|
100
|
+
utilizationThreshold: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export function getCreateLiquidityRouterInstructionDataEncoder(): FixedSizeEncoder<CreateLiquidityRouterInstructionDataArgs> {
|
|
104
|
+
return transformEncoder(
|
|
105
|
+
getStructEncoder([
|
|
106
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
107
|
+
["sap2Program", getAddressEncoder()],
|
|
108
|
+
["sap2Provider", getSap2ProviderEncoder()],
|
|
109
|
+
["utilizationThreshold", getU16Encoder()],
|
|
110
|
+
]),
|
|
111
|
+
(value) => ({
|
|
112
|
+
...value,
|
|
113
|
+
discriminator: CREATE_LIQUIDITY_ROUTER_DISCRIMINATOR,
|
|
114
|
+
}),
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export function getCreateLiquidityRouterInstructionDataDecoder(): FixedSizeDecoder<CreateLiquidityRouterInstructionData> {
|
|
119
|
+
return getStructDecoder([
|
|
120
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
121
|
+
["sap2Program", getAddressDecoder()],
|
|
122
|
+
["sap2Provider", getSap2ProviderDecoder()],
|
|
123
|
+
["utilizationThreshold", getU16Decoder()],
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function getCreateLiquidityRouterInstructionDataCodec(): FixedSizeCodec<
|
|
128
|
+
CreateLiquidityRouterInstructionDataArgs,
|
|
129
|
+
CreateLiquidityRouterInstructionData
|
|
130
|
+
> {
|
|
131
|
+
return combineCodec(
|
|
132
|
+
getCreateLiquidityRouterInstructionDataEncoder(),
|
|
133
|
+
getCreateLiquidityRouterInstructionDataDecoder(),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type CreateLiquidityRouterAsyncInput<
|
|
138
|
+
TAccountRouter extends string = string,
|
|
139
|
+
TAccountVault extends string = string,
|
|
140
|
+
TAccountAuthority extends string = string,
|
|
141
|
+
TAccountSystemProgram extends string = string,
|
|
142
|
+
> = {
|
|
143
|
+
router?: Address<TAccountRouter>;
|
|
144
|
+
vault: Address<TAccountVault>;
|
|
145
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
146
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
147
|
+
sap2Program: CreateLiquidityRouterInstructionDataArgs["sap2Program"];
|
|
148
|
+
sap2Provider: CreateLiquidityRouterInstructionDataArgs["sap2Provider"];
|
|
149
|
+
utilizationThreshold: CreateLiquidityRouterInstructionDataArgs["utilizationThreshold"];
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export async function getCreateLiquidityRouterInstructionAsync<
|
|
153
|
+
TAccountRouter extends string,
|
|
154
|
+
TAccountVault extends string,
|
|
155
|
+
TAccountAuthority extends string,
|
|
156
|
+
TAccountSystemProgram extends string,
|
|
157
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
158
|
+
>(
|
|
159
|
+
input: CreateLiquidityRouterAsyncInput<
|
|
160
|
+
TAccountRouter,
|
|
161
|
+
TAccountVault,
|
|
162
|
+
TAccountAuthority,
|
|
163
|
+
TAccountSystemProgram
|
|
164
|
+
>,
|
|
165
|
+
config?: { programAddress?: TProgramAddress },
|
|
166
|
+
): Promise<
|
|
167
|
+
CreateLiquidityRouterInstruction<
|
|
168
|
+
TProgramAddress,
|
|
169
|
+
TAccountRouter,
|
|
170
|
+
TAccountVault,
|
|
171
|
+
TAccountAuthority,
|
|
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
|
+
router: { value: input.router ?? null, isWritable: true },
|
|
182
|
+
vault: { value: input.vault ?? null, isWritable: false },
|
|
183
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
184
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
185
|
+
};
|
|
186
|
+
const accounts = originalAccounts as Record<
|
|
187
|
+
keyof typeof originalAccounts,
|
|
188
|
+
ResolvedAccount
|
|
189
|
+
>;
|
|
190
|
+
|
|
191
|
+
// Original args.
|
|
192
|
+
const args = { ...input };
|
|
193
|
+
|
|
194
|
+
// Resolve default values.
|
|
195
|
+
if (!accounts.router.value) {
|
|
196
|
+
accounts.router.value = await getProgramDerivedAddress({
|
|
197
|
+
programAddress,
|
|
198
|
+
seeds: [
|
|
199
|
+
getBytesEncoder().encode(
|
|
200
|
+
new Uint8Array([
|
|
201
|
+
108, 105, 113, 117, 105, 100, 105, 116, 121, 95, 114, 111, 117, 116,
|
|
202
|
+
101, 114,
|
|
203
|
+
]),
|
|
204
|
+
),
|
|
205
|
+
getAddressEncoder().encode(expectAddress(accounts.vault.value)),
|
|
206
|
+
],
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
if (!accounts.systemProgram.value) {
|
|
210
|
+
accounts.systemProgram.value =
|
|
211
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
215
|
+
return Object.freeze({
|
|
216
|
+
accounts: [
|
|
217
|
+
getAccountMeta(accounts.router),
|
|
218
|
+
getAccountMeta(accounts.vault),
|
|
219
|
+
getAccountMeta(accounts.authority),
|
|
220
|
+
getAccountMeta(accounts.systemProgram),
|
|
221
|
+
],
|
|
222
|
+
data: getCreateLiquidityRouterInstructionDataEncoder().encode(
|
|
223
|
+
args as CreateLiquidityRouterInstructionDataArgs,
|
|
224
|
+
),
|
|
225
|
+
programAddress,
|
|
226
|
+
} as CreateLiquidityRouterInstruction<
|
|
227
|
+
TProgramAddress,
|
|
228
|
+
TAccountRouter,
|
|
229
|
+
TAccountVault,
|
|
230
|
+
TAccountAuthority,
|
|
231
|
+
TAccountSystemProgram
|
|
232
|
+
>);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export type CreateLiquidityRouterInput<
|
|
236
|
+
TAccountRouter extends string = string,
|
|
237
|
+
TAccountVault extends string = string,
|
|
238
|
+
TAccountAuthority extends string = string,
|
|
239
|
+
TAccountSystemProgram extends string = string,
|
|
240
|
+
> = {
|
|
241
|
+
router: Address<TAccountRouter>;
|
|
242
|
+
vault: Address<TAccountVault>;
|
|
243
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
244
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
245
|
+
sap2Program: CreateLiquidityRouterInstructionDataArgs["sap2Program"];
|
|
246
|
+
sap2Provider: CreateLiquidityRouterInstructionDataArgs["sap2Provider"];
|
|
247
|
+
utilizationThreshold: CreateLiquidityRouterInstructionDataArgs["utilizationThreshold"];
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export function getCreateLiquidityRouterInstruction<
|
|
251
|
+
TAccountRouter extends string,
|
|
252
|
+
TAccountVault extends string,
|
|
253
|
+
TAccountAuthority extends string,
|
|
254
|
+
TAccountSystemProgram extends string,
|
|
255
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
256
|
+
>(
|
|
257
|
+
input: CreateLiquidityRouterInput<
|
|
258
|
+
TAccountRouter,
|
|
259
|
+
TAccountVault,
|
|
260
|
+
TAccountAuthority,
|
|
261
|
+
TAccountSystemProgram
|
|
262
|
+
>,
|
|
263
|
+
config?: { programAddress?: TProgramAddress },
|
|
264
|
+
): CreateLiquidityRouterInstruction<
|
|
265
|
+
TProgramAddress,
|
|
266
|
+
TAccountRouter,
|
|
267
|
+
TAccountVault,
|
|
268
|
+
TAccountAuthority,
|
|
269
|
+
TAccountSystemProgram
|
|
270
|
+
> {
|
|
271
|
+
// Program address.
|
|
272
|
+
const programAddress =
|
|
273
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
274
|
+
|
|
275
|
+
// Original accounts.
|
|
276
|
+
const originalAccounts = {
|
|
277
|
+
router: { value: input.router ?? null, isWritable: true },
|
|
278
|
+
vault: { value: input.vault ?? null, isWritable: false },
|
|
279
|
+
authority: { value: input.authority ?? null, isWritable: true },
|
|
280
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
281
|
+
};
|
|
282
|
+
const accounts = originalAccounts as Record<
|
|
283
|
+
keyof typeof originalAccounts,
|
|
284
|
+
ResolvedAccount
|
|
285
|
+
>;
|
|
286
|
+
|
|
287
|
+
// Original args.
|
|
288
|
+
const args = { ...input };
|
|
289
|
+
|
|
290
|
+
// Resolve default values.
|
|
291
|
+
if (!accounts.systemProgram.value) {
|
|
292
|
+
accounts.systemProgram.value =
|
|
293
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
297
|
+
return Object.freeze({
|
|
298
|
+
accounts: [
|
|
299
|
+
getAccountMeta(accounts.router),
|
|
300
|
+
getAccountMeta(accounts.vault),
|
|
301
|
+
getAccountMeta(accounts.authority),
|
|
302
|
+
getAccountMeta(accounts.systemProgram),
|
|
303
|
+
],
|
|
304
|
+
data: getCreateLiquidityRouterInstructionDataEncoder().encode(
|
|
305
|
+
args as CreateLiquidityRouterInstructionDataArgs,
|
|
306
|
+
),
|
|
307
|
+
programAddress,
|
|
308
|
+
} as CreateLiquidityRouterInstruction<
|
|
309
|
+
TProgramAddress,
|
|
310
|
+
TAccountRouter,
|
|
311
|
+
TAccountVault,
|
|
312
|
+
TAccountAuthority,
|
|
313
|
+
TAccountSystemProgram
|
|
314
|
+
>);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
export type ParsedCreateLiquidityRouterInstruction<
|
|
318
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
319
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
320
|
+
> = {
|
|
321
|
+
programAddress: Address<TProgram>;
|
|
322
|
+
accounts: {
|
|
323
|
+
router: TAccountMetas[0];
|
|
324
|
+
vault: TAccountMetas[1];
|
|
325
|
+
authority: TAccountMetas[2];
|
|
326
|
+
systemProgram: TAccountMetas[3];
|
|
327
|
+
};
|
|
328
|
+
data: CreateLiquidityRouterInstructionData;
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
export function parseCreateLiquidityRouterInstruction<
|
|
332
|
+
TProgram extends string,
|
|
333
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
334
|
+
>(
|
|
335
|
+
instruction: Instruction<TProgram> &
|
|
336
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
337
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
338
|
+
): ParsedCreateLiquidityRouterInstruction<TProgram, TAccountMetas> {
|
|
339
|
+
if (instruction.accounts.length < 4) {
|
|
340
|
+
// TODO: Coded error.
|
|
341
|
+
throw new Error("Not enough accounts");
|
|
342
|
+
}
|
|
343
|
+
let accountIndex = 0;
|
|
344
|
+
const getNextAccount = () => {
|
|
345
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
346
|
+
accountIndex += 1;
|
|
347
|
+
return accountMeta;
|
|
348
|
+
};
|
|
349
|
+
return {
|
|
350
|
+
programAddress: instruction.programAddress,
|
|
351
|
+
accounts: {
|
|
352
|
+
router: getNextAccount(),
|
|
353
|
+
vault: getNextAccount(),
|
|
354
|
+
authority: getNextAccount(),
|
|
355
|
+
systemProgram: getNextAccount(),
|
|
356
|
+
},
|
|
357
|
+
data: getCreateLiquidityRouterInstructionDataDecoder().decode(
|
|
358
|
+
instruction.data,
|
|
359
|
+
),
|
|
360
|
+
};
|
|
361
|
+
}
|