@epicentral/sos-sdk 0.9.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/.env.example +1 -0
- package/AGENTS.md +7 -0
- package/LICENSE +21 -0
- package/README.md +568 -0
- package/accounts/fetchers.ts +196 -0
- package/accounts/list.ts +184 -0
- package/accounts/pdas.ts +325 -0
- package/accounts/resolve-option.ts +104 -0
- package/client/lookup-table.ts +114 -0
- package/client/program.ts +13 -0
- package/client/types.ts +9 -0
- package/generated/accounts/collateralPool.ts +217 -0
- package/generated/accounts/config.ts +156 -0
- package/generated/accounts/escrowState.ts +183 -0
- package/generated/accounts/index.ts +20 -0
- package/generated/accounts/lenderPosition.ts +211 -0
- package/generated/accounts/makerCollateralShare.ts +229 -0
- package/generated/accounts/marketDataAccount.ts +176 -0
- package/generated/accounts/optionAccount.ts +247 -0
- package/generated/accounts/optionPool.ts +285 -0
- package/generated/accounts/poolLoan.ts +232 -0
- package/generated/accounts/positionAccount.ts +201 -0
- package/generated/accounts/vault.ts +366 -0
- package/generated/accounts/writerPosition.ts +327 -0
- package/generated/errors/index.ts +9 -0
- package/generated/errors/optionProgram.ts +476 -0
- package/generated/index.ts +13 -0
- package/generated/instructions/acceptAdmin.ts +230 -0
- package/generated/instructions/autoExerciseAllExpired.ts +685 -0
- package/generated/instructions/autoExerciseExpired.ts +754 -0
- package/generated/instructions/borrowFromPool.ts +619 -0
- package/generated/instructions/buyFromPool.ts +761 -0
- package/generated/instructions/closeLongToPool.ts +762 -0
- package/generated/instructions/closeOption.ts +235 -0
- package/generated/instructions/createEscrowV2.ts +518 -0
- package/generated/instructions/depositCollateral.ts +624 -0
- package/generated/instructions/depositToPosition.ts +429 -0
- package/generated/instructions/index.ts +47 -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 +750 -0
- package/generated/instructions/liquidateWriterPositionRescue.ts +623 -0
- package/generated/instructions/omlpCreateVault.ts +553 -0
- package/generated/instructions/omlpUpdateFeeWallet.ts +473 -0
- package/generated/instructions/omlpUpdateInterestModel.ts +322 -0
- package/generated/instructions/omlpUpdateLiquidationThreshold.ts +304 -0
- package/generated/instructions/omlpUpdateMaintenanceBuffer.ts +304 -0
- package/generated/instructions/omlpUpdateMaxBorrowCap.ts +304 -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 +617 -0
- package/generated/instructions/optionMint.ts +1373 -0
- package/generated/instructions/optionValidate.ts +302 -0
- package/generated/instructions/repayPoolLoan.ts +558 -0
- package/generated/instructions/repayPoolLoanFromCollateral.ts +514 -0
- package/generated/instructions/repayPoolLoanFromWallet.ts +542 -0
- package/generated/instructions/settleMakerCollateral.ts +509 -0
- package/generated/instructions/syncWriterPosition.ts +206 -0
- package/generated/instructions/transferAdmin.ts +245 -0
- package/generated/instructions/unwindWriterUnsold.ts +764 -0
- package/generated/instructions/updateImpliedVolatility.ts +226 -0
- package/generated/instructions/updateMarketData.ts +315 -0
- package/generated/instructions/withdrawFromPosition.ts +405 -0
- package/generated/instructions/writeToPool.ts +619 -0
- package/generated/programs/index.ts +9 -0
- package/generated/programs/optionProgram.ts +1144 -0
- package/generated/shared/index.ts +164 -0
- package/generated/types/impliedVolatilityUpdated.ts +73 -0
- package/generated/types/index.ts +28 -0
- package/generated/types/liquidationExecuted.ts +73 -0
- package/generated/types/liquidationRescueEvent.ts +82 -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/protocolFeeUpdated.ts +69 -0
- package/generated/types/vaultCreated.ts +60 -0
- package/generated/types/vaultFeeWalletUpdated.ts +67 -0
- package/generated/types/vaultInterestModelUpdated.ts +77 -0
- package/generated/types/vaultLiquidationThresholdUpdated.ts +69 -0
- package/index.ts +68 -0
- package/long/builders.ts +690 -0
- package/long/exercise.ts +123 -0
- package/long/preflight.ts +214 -0
- package/long/quotes.ts +48 -0
- package/long/remaining-accounts.ts +111 -0
- package/omlp/builders.ts +94 -0
- package/omlp/service.ts +136 -0
- package/oracle/switchboard.ts +315 -0
- package/package.json +34 -0
- package/shared/amounts.ts +53 -0
- package/shared/balances.ts +57 -0
- package/shared/errors.ts +12 -0
- package/shared/remaining-accounts.ts +41 -0
- package/shared/trade-config.ts +27 -0
- package/shared/transactions.ts +121 -0
- package/short/builders.ts +874 -0
- package/short/close-option.ts +34 -0
- package/short/pool.ts +189 -0
- package/short/preflight.ts +619 -0
- package/tsconfig.json +13 -0
- package/wsol/instructions.ts +247 -0
|
@@ -0,0 +1,473 @@
|
|
|
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 OMLP_UPDATE_FEE_WALLET_DISCRIMINATOR = new Uint8Array([
|
|
43
|
+
94, 66, 39, 241, 66, 246, 217, 92,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
export function getOmlpUpdateFeeWalletDiscriminatorBytes() {
|
|
47
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
48
|
+
OMLP_UPDATE_FEE_WALLET_DISCRIMINATOR,
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type OmlpUpdateFeeWalletInstruction<
|
|
53
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
54
|
+
TAccountConfig extends string | AccountMeta<string> = string,
|
|
55
|
+
TAccountVault extends string | AccountMeta<string> = string,
|
|
56
|
+
TAccountMint extends string | AccountMeta<string> = string,
|
|
57
|
+
TAccountNewFeeWalletTokenAccount extends string | AccountMeta<string> =
|
|
58
|
+
string,
|
|
59
|
+
TAccountNewFeeWallet extends string | AccountMeta<string> = string,
|
|
60
|
+
TAccountAdmin extends string | AccountMeta<string> = string,
|
|
61
|
+
TAccountTokenProgram extends string | AccountMeta<string> =
|
|
62
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
|
|
63
|
+
TAccountAssociatedTokenProgram extends string | AccountMeta<string> =
|
|
64
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
|
|
65
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
66
|
+
"11111111111111111111111111111111",
|
|
67
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
68
|
+
> = Instruction<TProgram> &
|
|
69
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
70
|
+
InstructionWithAccounts<
|
|
71
|
+
[
|
|
72
|
+
TAccountConfig extends string
|
|
73
|
+
? ReadonlyAccount<TAccountConfig>
|
|
74
|
+
: TAccountConfig,
|
|
75
|
+
TAccountVault extends string
|
|
76
|
+
? WritableAccount<TAccountVault>
|
|
77
|
+
: TAccountVault,
|
|
78
|
+
TAccountMint extends string
|
|
79
|
+
? ReadonlyAccount<TAccountMint>
|
|
80
|
+
: TAccountMint,
|
|
81
|
+
TAccountNewFeeWalletTokenAccount extends string
|
|
82
|
+
? WritableAccount<TAccountNewFeeWalletTokenAccount>
|
|
83
|
+
: TAccountNewFeeWalletTokenAccount,
|
|
84
|
+
TAccountNewFeeWallet extends string
|
|
85
|
+
? ReadonlyAccount<TAccountNewFeeWallet>
|
|
86
|
+
: TAccountNewFeeWallet,
|
|
87
|
+
TAccountAdmin extends string
|
|
88
|
+
? WritableSignerAccount<TAccountAdmin> &
|
|
89
|
+
AccountSignerMeta<TAccountAdmin>
|
|
90
|
+
: TAccountAdmin,
|
|
91
|
+
TAccountTokenProgram extends string
|
|
92
|
+
? ReadonlyAccount<TAccountTokenProgram>
|
|
93
|
+
: TAccountTokenProgram,
|
|
94
|
+
TAccountAssociatedTokenProgram extends string
|
|
95
|
+
? ReadonlyAccount<TAccountAssociatedTokenProgram>
|
|
96
|
+
: TAccountAssociatedTokenProgram,
|
|
97
|
+
TAccountSystemProgram extends string
|
|
98
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
99
|
+
: TAccountSystemProgram,
|
|
100
|
+
...TRemainingAccounts,
|
|
101
|
+
]
|
|
102
|
+
>;
|
|
103
|
+
|
|
104
|
+
export type OmlpUpdateFeeWalletInstructionData = {
|
|
105
|
+
discriminator: ReadonlyUint8Array;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export type OmlpUpdateFeeWalletInstructionDataArgs = {};
|
|
109
|
+
|
|
110
|
+
export function getOmlpUpdateFeeWalletInstructionDataEncoder(): FixedSizeEncoder<OmlpUpdateFeeWalletInstructionDataArgs> {
|
|
111
|
+
return transformEncoder(
|
|
112
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
113
|
+
(value) => ({
|
|
114
|
+
...value,
|
|
115
|
+
discriminator: OMLP_UPDATE_FEE_WALLET_DISCRIMINATOR,
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function getOmlpUpdateFeeWalletInstructionDataDecoder(): FixedSizeDecoder<OmlpUpdateFeeWalletInstructionData> {
|
|
121
|
+
return getStructDecoder([
|
|
122
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
123
|
+
]);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function getOmlpUpdateFeeWalletInstructionDataCodec(): FixedSizeCodec<
|
|
127
|
+
OmlpUpdateFeeWalletInstructionDataArgs,
|
|
128
|
+
OmlpUpdateFeeWalletInstructionData
|
|
129
|
+
> {
|
|
130
|
+
return combineCodec(
|
|
131
|
+
getOmlpUpdateFeeWalletInstructionDataEncoder(),
|
|
132
|
+
getOmlpUpdateFeeWalletInstructionDataDecoder(),
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export type OmlpUpdateFeeWalletAsyncInput<
|
|
137
|
+
TAccountConfig extends string = string,
|
|
138
|
+
TAccountVault extends string = string,
|
|
139
|
+
TAccountMint extends string = string,
|
|
140
|
+
TAccountNewFeeWalletTokenAccount extends string = string,
|
|
141
|
+
TAccountNewFeeWallet extends string = string,
|
|
142
|
+
TAccountAdmin extends string = string,
|
|
143
|
+
TAccountTokenProgram extends string = string,
|
|
144
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
145
|
+
TAccountSystemProgram extends string = string,
|
|
146
|
+
> = {
|
|
147
|
+
config?: Address<TAccountConfig>;
|
|
148
|
+
vault: Address<TAccountVault>;
|
|
149
|
+
mint: Address<TAccountMint>;
|
|
150
|
+
newFeeWalletTokenAccount?: Address<TAccountNewFeeWalletTokenAccount>;
|
|
151
|
+
newFeeWallet: Address<TAccountNewFeeWallet>;
|
|
152
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
153
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
154
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
155
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export async function getOmlpUpdateFeeWalletInstructionAsync<
|
|
159
|
+
TAccountConfig extends string,
|
|
160
|
+
TAccountVault extends string,
|
|
161
|
+
TAccountMint extends string,
|
|
162
|
+
TAccountNewFeeWalletTokenAccount extends string,
|
|
163
|
+
TAccountNewFeeWallet extends string,
|
|
164
|
+
TAccountAdmin extends string,
|
|
165
|
+
TAccountTokenProgram extends string,
|
|
166
|
+
TAccountAssociatedTokenProgram extends string,
|
|
167
|
+
TAccountSystemProgram extends string,
|
|
168
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
169
|
+
>(
|
|
170
|
+
input: OmlpUpdateFeeWalletAsyncInput<
|
|
171
|
+
TAccountConfig,
|
|
172
|
+
TAccountVault,
|
|
173
|
+
TAccountMint,
|
|
174
|
+
TAccountNewFeeWalletTokenAccount,
|
|
175
|
+
TAccountNewFeeWallet,
|
|
176
|
+
TAccountAdmin,
|
|
177
|
+
TAccountTokenProgram,
|
|
178
|
+
TAccountAssociatedTokenProgram,
|
|
179
|
+
TAccountSystemProgram
|
|
180
|
+
>,
|
|
181
|
+
config?: { programAddress?: TProgramAddress },
|
|
182
|
+
): Promise<
|
|
183
|
+
OmlpUpdateFeeWalletInstruction<
|
|
184
|
+
TProgramAddress,
|
|
185
|
+
TAccountConfig,
|
|
186
|
+
TAccountVault,
|
|
187
|
+
TAccountMint,
|
|
188
|
+
TAccountNewFeeWalletTokenAccount,
|
|
189
|
+
TAccountNewFeeWallet,
|
|
190
|
+
TAccountAdmin,
|
|
191
|
+
TAccountTokenProgram,
|
|
192
|
+
TAccountAssociatedTokenProgram,
|
|
193
|
+
TAccountSystemProgram
|
|
194
|
+
>
|
|
195
|
+
> {
|
|
196
|
+
// Program address.
|
|
197
|
+
const programAddress =
|
|
198
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
199
|
+
|
|
200
|
+
// Original accounts.
|
|
201
|
+
const originalAccounts = {
|
|
202
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
203
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
204
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
205
|
+
newFeeWalletTokenAccount: {
|
|
206
|
+
value: input.newFeeWalletTokenAccount ?? null,
|
|
207
|
+
isWritable: true,
|
|
208
|
+
},
|
|
209
|
+
newFeeWallet: { value: input.newFeeWallet ?? null, isWritable: false },
|
|
210
|
+
admin: { value: input.admin ?? null, isWritable: true },
|
|
211
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
212
|
+
associatedTokenProgram: {
|
|
213
|
+
value: input.associatedTokenProgram ?? null,
|
|
214
|
+
isWritable: false,
|
|
215
|
+
},
|
|
216
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
217
|
+
};
|
|
218
|
+
const accounts = originalAccounts as Record<
|
|
219
|
+
keyof typeof originalAccounts,
|
|
220
|
+
ResolvedAccount
|
|
221
|
+
>;
|
|
222
|
+
|
|
223
|
+
// Resolve default values.
|
|
224
|
+
if (!accounts.config.value) {
|
|
225
|
+
accounts.config.value = await getProgramDerivedAddress({
|
|
226
|
+
programAddress,
|
|
227
|
+
seeds: [
|
|
228
|
+
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
229
|
+
],
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
if (!accounts.newFeeWalletTokenAccount.value) {
|
|
233
|
+
accounts.newFeeWalletTokenAccount.value = await getProgramDerivedAddress({
|
|
234
|
+
programAddress:
|
|
235
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">,
|
|
236
|
+
seeds: [
|
|
237
|
+
getAddressEncoder().encode(expectAddress(accounts.newFeeWallet.value)),
|
|
238
|
+
getBytesEncoder().encode(
|
|
239
|
+
new Uint8Array([
|
|
240
|
+
6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235,
|
|
241
|
+
121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133,
|
|
242
|
+
126, 255, 0, 169,
|
|
243
|
+
]),
|
|
244
|
+
),
|
|
245
|
+
getAddressEncoder().encode(expectAddress(accounts.mint.value)),
|
|
246
|
+
],
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
if (!accounts.tokenProgram.value) {
|
|
250
|
+
accounts.tokenProgram.value =
|
|
251
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
|
|
252
|
+
}
|
|
253
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
254
|
+
accounts.associatedTokenProgram.value =
|
|
255
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
256
|
+
}
|
|
257
|
+
if (!accounts.systemProgram.value) {
|
|
258
|
+
accounts.systemProgram.value =
|
|
259
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
263
|
+
return Object.freeze({
|
|
264
|
+
accounts: [
|
|
265
|
+
getAccountMeta(accounts.config),
|
|
266
|
+
getAccountMeta(accounts.vault),
|
|
267
|
+
getAccountMeta(accounts.mint),
|
|
268
|
+
getAccountMeta(accounts.newFeeWalletTokenAccount),
|
|
269
|
+
getAccountMeta(accounts.newFeeWallet),
|
|
270
|
+
getAccountMeta(accounts.admin),
|
|
271
|
+
getAccountMeta(accounts.tokenProgram),
|
|
272
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
273
|
+
getAccountMeta(accounts.systemProgram),
|
|
274
|
+
],
|
|
275
|
+
data: getOmlpUpdateFeeWalletInstructionDataEncoder().encode({}),
|
|
276
|
+
programAddress,
|
|
277
|
+
} as OmlpUpdateFeeWalletInstruction<
|
|
278
|
+
TProgramAddress,
|
|
279
|
+
TAccountConfig,
|
|
280
|
+
TAccountVault,
|
|
281
|
+
TAccountMint,
|
|
282
|
+
TAccountNewFeeWalletTokenAccount,
|
|
283
|
+
TAccountNewFeeWallet,
|
|
284
|
+
TAccountAdmin,
|
|
285
|
+
TAccountTokenProgram,
|
|
286
|
+
TAccountAssociatedTokenProgram,
|
|
287
|
+
TAccountSystemProgram
|
|
288
|
+
>);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export type OmlpUpdateFeeWalletInput<
|
|
292
|
+
TAccountConfig extends string = string,
|
|
293
|
+
TAccountVault extends string = string,
|
|
294
|
+
TAccountMint extends string = string,
|
|
295
|
+
TAccountNewFeeWalletTokenAccount extends string = string,
|
|
296
|
+
TAccountNewFeeWallet extends string = string,
|
|
297
|
+
TAccountAdmin extends string = string,
|
|
298
|
+
TAccountTokenProgram extends string = string,
|
|
299
|
+
TAccountAssociatedTokenProgram extends string = string,
|
|
300
|
+
TAccountSystemProgram extends string = string,
|
|
301
|
+
> = {
|
|
302
|
+
config: Address<TAccountConfig>;
|
|
303
|
+
vault: Address<TAccountVault>;
|
|
304
|
+
mint: Address<TAccountMint>;
|
|
305
|
+
newFeeWalletTokenAccount: Address<TAccountNewFeeWalletTokenAccount>;
|
|
306
|
+
newFeeWallet: Address<TAccountNewFeeWallet>;
|
|
307
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
308
|
+
tokenProgram?: Address<TAccountTokenProgram>;
|
|
309
|
+
associatedTokenProgram?: Address<TAccountAssociatedTokenProgram>;
|
|
310
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export function getOmlpUpdateFeeWalletInstruction<
|
|
314
|
+
TAccountConfig extends string,
|
|
315
|
+
TAccountVault extends string,
|
|
316
|
+
TAccountMint extends string,
|
|
317
|
+
TAccountNewFeeWalletTokenAccount extends string,
|
|
318
|
+
TAccountNewFeeWallet extends string,
|
|
319
|
+
TAccountAdmin extends string,
|
|
320
|
+
TAccountTokenProgram extends string,
|
|
321
|
+
TAccountAssociatedTokenProgram extends string,
|
|
322
|
+
TAccountSystemProgram extends string,
|
|
323
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
324
|
+
>(
|
|
325
|
+
input: OmlpUpdateFeeWalletInput<
|
|
326
|
+
TAccountConfig,
|
|
327
|
+
TAccountVault,
|
|
328
|
+
TAccountMint,
|
|
329
|
+
TAccountNewFeeWalletTokenAccount,
|
|
330
|
+
TAccountNewFeeWallet,
|
|
331
|
+
TAccountAdmin,
|
|
332
|
+
TAccountTokenProgram,
|
|
333
|
+
TAccountAssociatedTokenProgram,
|
|
334
|
+
TAccountSystemProgram
|
|
335
|
+
>,
|
|
336
|
+
config?: { programAddress?: TProgramAddress },
|
|
337
|
+
): OmlpUpdateFeeWalletInstruction<
|
|
338
|
+
TProgramAddress,
|
|
339
|
+
TAccountConfig,
|
|
340
|
+
TAccountVault,
|
|
341
|
+
TAccountMint,
|
|
342
|
+
TAccountNewFeeWalletTokenAccount,
|
|
343
|
+
TAccountNewFeeWallet,
|
|
344
|
+
TAccountAdmin,
|
|
345
|
+
TAccountTokenProgram,
|
|
346
|
+
TAccountAssociatedTokenProgram,
|
|
347
|
+
TAccountSystemProgram
|
|
348
|
+
> {
|
|
349
|
+
// Program address.
|
|
350
|
+
const programAddress =
|
|
351
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
352
|
+
|
|
353
|
+
// Original accounts.
|
|
354
|
+
const originalAccounts = {
|
|
355
|
+
config: { value: input.config ?? null, isWritable: false },
|
|
356
|
+
vault: { value: input.vault ?? null, isWritable: true },
|
|
357
|
+
mint: { value: input.mint ?? null, isWritable: false },
|
|
358
|
+
newFeeWalletTokenAccount: {
|
|
359
|
+
value: input.newFeeWalletTokenAccount ?? null,
|
|
360
|
+
isWritable: true,
|
|
361
|
+
},
|
|
362
|
+
newFeeWallet: { value: input.newFeeWallet ?? null, isWritable: false },
|
|
363
|
+
admin: { value: input.admin ?? null, isWritable: true },
|
|
364
|
+
tokenProgram: { value: input.tokenProgram ?? null, isWritable: false },
|
|
365
|
+
associatedTokenProgram: {
|
|
366
|
+
value: input.associatedTokenProgram ?? null,
|
|
367
|
+
isWritable: false,
|
|
368
|
+
},
|
|
369
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
370
|
+
};
|
|
371
|
+
const accounts = originalAccounts as Record<
|
|
372
|
+
keyof typeof originalAccounts,
|
|
373
|
+
ResolvedAccount
|
|
374
|
+
>;
|
|
375
|
+
|
|
376
|
+
// Resolve default values.
|
|
377
|
+
if (!accounts.tokenProgram.value) {
|
|
378
|
+
accounts.tokenProgram.value =
|
|
379
|
+
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
|
|
380
|
+
}
|
|
381
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
382
|
+
accounts.associatedTokenProgram.value =
|
|
383
|
+
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" as Address<"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL">;
|
|
384
|
+
}
|
|
385
|
+
if (!accounts.systemProgram.value) {
|
|
386
|
+
accounts.systemProgram.value =
|
|
387
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
391
|
+
return Object.freeze({
|
|
392
|
+
accounts: [
|
|
393
|
+
getAccountMeta(accounts.config),
|
|
394
|
+
getAccountMeta(accounts.vault),
|
|
395
|
+
getAccountMeta(accounts.mint),
|
|
396
|
+
getAccountMeta(accounts.newFeeWalletTokenAccount),
|
|
397
|
+
getAccountMeta(accounts.newFeeWallet),
|
|
398
|
+
getAccountMeta(accounts.admin),
|
|
399
|
+
getAccountMeta(accounts.tokenProgram),
|
|
400
|
+
getAccountMeta(accounts.associatedTokenProgram),
|
|
401
|
+
getAccountMeta(accounts.systemProgram),
|
|
402
|
+
],
|
|
403
|
+
data: getOmlpUpdateFeeWalletInstructionDataEncoder().encode({}),
|
|
404
|
+
programAddress,
|
|
405
|
+
} as OmlpUpdateFeeWalletInstruction<
|
|
406
|
+
TProgramAddress,
|
|
407
|
+
TAccountConfig,
|
|
408
|
+
TAccountVault,
|
|
409
|
+
TAccountMint,
|
|
410
|
+
TAccountNewFeeWalletTokenAccount,
|
|
411
|
+
TAccountNewFeeWallet,
|
|
412
|
+
TAccountAdmin,
|
|
413
|
+
TAccountTokenProgram,
|
|
414
|
+
TAccountAssociatedTokenProgram,
|
|
415
|
+
TAccountSystemProgram
|
|
416
|
+
>);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
export type ParsedOmlpUpdateFeeWalletInstruction<
|
|
420
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
421
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
422
|
+
> = {
|
|
423
|
+
programAddress: Address<TProgram>;
|
|
424
|
+
accounts: {
|
|
425
|
+
config: TAccountMetas[0];
|
|
426
|
+
vault: TAccountMetas[1];
|
|
427
|
+
mint: TAccountMetas[2];
|
|
428
|
+
newFeeWalletTokenAccount: TAccountMetas[3];
|
|
429
|
+
newFeeWallet: TAccountMetas[4];
|
|
430
|
+
admin: TAccountMetas[5];
|
|
431
|
+
tokenProgram: TAccountMetas[6];
|
|
432
|
+
associatedTokenProgram: TAccountMetas[7];
|
|
433
|
+
systemProgram: TAccountMetas[8];
|
|
434
|
+
};
|
|
435
|
+
data: OmlpUpdateFeeWalletInstructionData;
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
export function parseOmlpUpdateFeeWalletInstruction<
|
|
439
|
+
TProgram extends string,
|
|
440
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
441
|
+
>(
|
|
442
|
+
instruction: Instruction<TProgram> &
|
|
443
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
444
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
445
|
+
): ParsedOmlpUpdateFeeWalletInstruction<TProgram, TAccountMetas> {
|
|
446
|
+
if (instruction.accounts.length < 9) {
|
|
447
|
+
// TODO: Coded error.
|
|
448
|
+
throw new Error("Not enough accounts");
|
|
449
|
+
}
|
|
450
|
+
let accountIndex = 0;
|
|
451
|
+
const getNextAccount = () => {
|
|
452
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
453
|
+
accountIndex += 1;
|
|
454
|
+
return accountMeta;
|
|
455
|
+
};
|
|
456
|
+
return {
|
|
457
|
+
programAddress: instruction.programAddress,
|
|
458
|
+
accounts: {
|
|
459
|
+
config: getNextAccount(),
|
|
460
|
+
vault: getNextAccount(),
|
|
461
|
+
mint: getNextAccount(),
|
|
462
|
+
newFeeWalletTokenAccount: getNextAccount(),
|
|
463
|
+
newFeeWallet: getNextAccount(),
|
|
464
|
+
admin: getNextAccount(),
|
|
465
|
+
tokenProgram: getNextAccount(),
|
|
466
|
+
associatedTokenProgram: getNextAccount(),
|
|
467
|
+
systemProgram: getNextAccount(),
|
|
468
|
+
},
|
|
469
|
+
data: getOmlpUpdateFeeWalletInstructionDataDecoder().decode(
|
|
470
|
+
instruction.data,
|
|
471
|
+
),
|
|
472
|
+
};
|
|
473
|
+
}
|