@epicentral/sos-sdk 0.10.1-beta → 0.10.2-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.
|
@@ -23,6 +23,7 @@ export * from "./initializeMarketData";
|
|
|
23
23
|
export * from "./initOptionPool";
|
|
24
24
|
export * from "./liquidateWriterPosition";
|
|
25
25
|
export * from "./liquidateWriterPositionRescue";
|
|
26
|
+
export * from "./migrateCollateralPoolV1ToV2";
|
|
26
27
|
export * from "./omlpCreateVault";
|
|
27
28
|
export * from "./omlpUpdateFeeWallet";
|
|
28
29
|
export * from "./omlpUpdateInterestModel";
|
|
@@ -0,0 +1,239 @@
|
|
|
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
|
+
getBytesDecoder,
|
|
14
|
+
getBytesEncoder,
|
|
15
|
+
getStructDecoder,
|
|
16
|
+
getStructEncoder,
|
|
17
|
+
transformEncoder,
|
|
18
|
+
type AccountMeta,
|
|
19
|
+
type AccountSignerMeta,
|
|
20
|
+
type Address,
|
|
21
|
+
type FixedSizeCodec,
|
|
22
|
+
type FixedSizeDecoder,
|
|
23
|
+
type FixedSizeEncoder,
|
|
24
|
+
type Instruction,
|
|
25
|
+
type InstructionWithAccounts,
|
|
26
|
+
type InstructionWithData,
|
|
27
|
+
type ReadonlyAccount,
|
|
28
|
+
type ReadonlyUint8Array,
|
|
29
|
+
type TransactionSigner,
|
|
30
|
+
type WritableAccount,
|
|
31
|
+
type WritableSignerAccount,
|
|
32
|
+
} from "@solana/kit";
|
|
33
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
34
|
+
import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
|
|
35
|
+
|
|
36
|
+
export const MIGRATE_COLLATERAL_POOL_V1_TO_V2_DISCRIMINATOR = new Uint8Array([
|
|
37
|
+
7, 151, 240, 114, 7, 75, 88, 10,
|
|
38
|
+
]);
|
|
39
|
+
|
|
40
|
+
export function getMigrateCollateralPoolV1ToV2DiscriminatorBytes() {
|
|
41
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
42
|
+
MIGRATE_COLLATERAL_POOL_V1_TO_V2_DISCRIMINATOR,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type MigrateCollateralPoolV1ToV2Instruction<
|
|
47
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
48
|
+
TAccountCollateralPool extends string | AccountMeta<string> = string,
|
|
49
|
+
TAccountOptionAccount extends string | AccountMeta<string> = string,
|
|
50
|
+
TAccountVault extends string | AccountMeta<string> = string,
|
|
51
|
+
TAccountKeeper extends string | AccountMeta<string> = string,
|
|
52
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
53
|
+
"11111111111111111111111111111111",
|
|
54
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
55
|
+
> = Instruction<TProgram> &
|
|
56
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
57
|
+
InstructionWithAccounts<
|
|
58
|
+
[
|
|
59
|
+
TAccountCollateralPool extends string
|
|
60
|
+
? WritableAccount<TAccountCollateralPool>
|
|
61
|
+
: TAccountCollateralPool,
|
|
62
|
+
TAccountOptionAccount extends string
|
|
63
|
+
? ReadonlyAccount<TAccountOptionAccount>
|
|
64
|
+
: TAccountOptionAccount,
|
|
65
|
+
TAccountVault extends string
|
|
66
|
+
? ReadonlyAccount<TAccountVault>
|
|
67
|
+
: TAccountVault,
|
|
68
|
+
TAccountKeeper extends string
|
|
69
|
+
? WritableSignerAccount<TAccountKeeper> &
|
|
70
|
+
AccountSignerMeta<TAccountKeeper>
|
|
71
|
+
: TAccountKeeper,
|
|
72
|
+
TAccountSystemProgram extends string
|
|
73
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
74
|
+
: TAccountSystemProgram,
|
|
75
|
+
...TRemainingAccounts,
|
|
76
|
+
]
|
|
77
|
+
>;
|
|
78
|
+
|
|
79
|
+
export type MigrateCollateralPoolV1ToV2InstructionData = {
|
|
80
|
+
discriminator: ReadonlyUint8Array;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export type MigrateCollateralPoolV1ToV2InstructionDataArgs = {};
|
|
84
|
+
|
|
85
|
+
export function getMigrateCollateralPoolV1ToV2InstructionDataEncoder(): FixedSizeEncoder<MigrateCollateralPoolV1ToV2InstructionDataArgs> {
|
|
86
|
+
return transformEncoder(
|
|
87
|
+
getStructEncoder([["discriminator", fixEncoderSize(getBytesEncoder(), 8)]]),
|
|
88
|
+
(value) => ({
|
|
89
|
+
...value,
|
|
90
|
+
discriminator: MIGRATE_COLLATERAL_POOL_V1_TO_V2_DISCRIMINATOR,
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function getMigrateCollateralPoolV1ToV2InstructionDataDecoder(): FixedSizeDecoder<MigrateCollateralPoolV1ToV2InstructionData> {
|
|
96
|
+
return getStructDecoder([
|
|
97
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function getMigrateCollateralPoolV1ToV2InstructionDataCodec(): FixedSizeCodec<
|
|
102
|
+
MigrateCollateralPoolV1ToV2InstructionDataArgs,
|
|
103
|
+
MigrateCollateralPoolV1ToV2InstructionData
|
|
104
|
+
> {
|
|
105
|
+
return combineCodec(
|
|
106
|
+
getMigrateCollateralPoolV1ToV2InstructionDataEncoder(),
|
|
107
|
+
getMigrateCollateralPoolV1ToV2InstructionDataDecoder(),
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type MigrateCollateralPoolV1ToV2Input<
|
|
112
|
+
TAccountCollateralPool extends string = string,
|
|
113
|
+
TAccountOptionAccount extends string = string,
|
|
114
|
+
TAccountVault extends string = string,
|
|
115
|
+
TAccountKeeper extends string = string,
|
|
116
|
+
TAccountSystemProgram extends string = string,
|
|
117
|
+
> = {
|
|
118
|
+
collateralPool: Address<TAccountCollateralPool>;
|
|
119
|
+
optionAccount: Address<TAccountOptionAccount>;
|
|
120
|
+
vault: Address<TAccountVault>;
|
|
121
|
+
keeper: TransactionSigner<TAccountKeeper>;
|
|
122
|
+
systemProgram?: Address<TAccountSystemProgram>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export function getMigrateCollateralPoolV1ToV2Instruction<
|
|
126
|
+
TAccountCollateralPool extends string,
|
|
127
|
+
TAccountOptionAccount extends string,
|
|
128
|
+
TAccountVault extends string,
|
|
129
|
+
TAccountKeeper extends string,
|
|
130
|
+
TAccountSystemProgram extends string,
|
|
131
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
132
|
+
>(
|
|
133
|
+
input: MigrateCollateralPoolV1ToV2Input<
|
|
134
|
+
TAccountCollateralPool,
|
|
135
|
+
TAccountOptionAccount,
|
|
136
|
+
TAccountVault,
|
|
137
|
+
TAccountKeeper,
|
|
138
|
+
TAccountSystemProgram
|
|
139
|
+
>,
|
|
140
|
+
config?: { programAddress?: TProgramAddress },
|
|
141
|
+
): MigrateCollateralPoolV1ToV2Instruction<
|
|
142
|
+
TProgramAddress,
|
|
143
|
+
TAccountCollateralPool,
|
|
144
|
+
TAccountOptionAccount,
|
|
145
|
+
TAccountVault,
|
|
146
|
+
TAccountKeeper,
|
|
147
|
+
TAccountSystemProgram
|
|
148
|
+
> {
|
|
149
|
+
// Program address.
|
|
150
|
+
const programAddress =
|
|
151
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
152
|
+
|
|
153
|
+
// Original accounts.
|
|
154
|
+
const originalAccounts = {
|
|
155
|
+
collateralPool: { value: input.collateralPool ?? null, isWritable: true },
|
|
156
|
+
optionAccount: { value: input.optionAccount ?? null, isWritable: false },
|
|
157
|
+
vault: { value: input.vault ?? null, isWritable: false },
|
|
158
|
+
keeper: { value: input.keeper ?? null, isWritable: true },
|
|
159
|
+
systemProgram: { value: input.systemProgram ?? null, isWritable: false },
|
|
160
|
+
};
|
|
161
|
+
const accounts = originalAccounts as Record<
|
|
162
|
+
keyof typeof originalAccounts,
|
|
163
|
+
ResolvedAccount
|
|
164
|
+
>;
|
|
165
|
+
|
|
166
|
+
// Resolve default values.
|
|
167
|
+
if (!accounts.systemProgram.value) {
|
|
168
|
+
accounts.systemProgram.value =
|
|
169
|
+
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
173
|
+
return Object.freeze({
|
|
174
|
+
accounts: [
|
|
175
|
+
getAccountMeta(accounts.collateralPool),
|
|
176
|
+
getAccountMeta(accounts.optionAccount),
|
|
177
|
+
getAccountMeta(accounts.vault),
|
|
178
|
+
getAccountMeta(accounts.keeper),
|
|
179
|
+
getAccountMeta(accounts.systemProgram),
|
|
180
|
+
],
|
|
181
|
+
data: getMigrateCollateralPoolV1ToV2InstructionDataEncoder().encode({}),
|
|
182
|
+
programAddress,
|
|
183
|
+
} as MigrateCollateralPoolV1ToV2Instruction<
|
|
184
|
+
TProgramAddress,
|
|
185
|
+
TAccountCollateralPool,
|
|
186
|
+
TAccountOptionAccount,
|
|
187
|
+
TAccountVault,
|
|
188
|
+
TAccountKeeper,
|
|
189
|
+
TAccountSystemProgram
|
|
190
|
+
>);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export type ParsedMigrateCollateralPoolV1ToV2Instruction<
|
|
194
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
195
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
196
|
+
> = {
|
|
197
|
+
programAddress: Address<TProgram>;
|
|
198
|
+
accounts: {
|
|
199
|
+
collateralPool: TAccountMetas[0];
|
|
200
|
+
optionAccount: TAccountMetas[1];
|
|
201
|
+
vault: TAccountMetas[2];
|
|
202
|
+
keeper: TAccountMetas[3];
|
|
203
|
+
systemProgram: TAccountMetas[4];
|
|
204
|
+
};
|
|
205
|
+
data: MigrateCollateralPoolV1ToV2InstructionData;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export function parseMigrateCollateralPoolV1ToV2Instruction<
|
|
209
|
+
TProgram extends string,
|
|
210
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
211
|
+
>(
|
|
212
|
+
instruction: Instruction<TProgram> &
|
|
213
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
214
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
215
|
+
): ParsedMigrateCollateralPoolV1ToV2Instruction<TProgram, TAccountMetas> {
|
|
216
|
+
if (instruction.accounts.length < 5) {
|
|
217
|
+
// TODO: Coded error.
|
|
218
|
+
throw new Error("Not enough accounts");
|
|
219
|
+
}
|
|
220
|
+
let accountIndex = 0;
|
|
221
|
+
const getNextAccount = () => {
|
|
222
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
223
|
+
accountIndex += 1;
|
|
224
|
+
return accountMeta;
|
|
225
|
+
};
|
|
226
|
+
return {
|
|
227
|
+
programAddress: instruction.programAddress,
|
|
228
|
+
accounts: {
|
|
229
|
+
collateralPool: getNextAccount(),
|
|
230
|
+
optionAccount: getNextAccount(),
|
|
231
|
+
vault: getNextAccount(),
|
|
232
|
+
keeper: getNextAccount(),
|
|
233
|
+
systemProgram: getNextAccount(),
|
|
234
|
+
},
|
|
235
|
+
data: getMigrateCollateralPoolV1ToV2InstructionDataDecoder().decode(
|
|
236
|
+
instruction.data,
|
|
237
|
+
),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
parseInitOptionPoolInstruction,
|
|
35
35
|
parseLiquidateWriterPositionInstruction,
|
|
36
36
|
parseLiquidateWriterPositionRescueInstruction,
|
|
37
|
+
parseMigrateCollateralPoolV1ToV2Instruction,
|
|
37
38
|
parseOmlpCreateVaultInstruction,
|
|
38
39
|
parseOmlpUpdateFeeWalletInstruction,
|
|
39
40
|
parseOmlpUpdateInterestModelInstruction,
|
|
@@ -74,6 +75,7 @@ import {
|
|
|
74
75
|
type ParsedInitOptionPoolInstruction,
|
|
75
76
|
type ParsedLiquidateWriterPositionInstruction,
|
|
76
77
|
type ParsedLiquidateWriterPositionRescueInstruction,
|
|
78
|
+
type ParsedMigrateCollateralPoolV1ToV2Instruction,
|
|
77
79
|
type ParsedOmlpCreateVaultInstruction,
|
|
78
80
|
type ParsedOmlpUpdateFeeWalletInstruction,
|
|
79
81
|
type ParsedOmlpUpdateInterestModelInstruction,
|
|
@@ -276,6 +278,7 @@ export enum OptionProgramInstruction {
|
|
|
276
278
|
InitializeMarketData,
|
|
277
279
|
LiquidateWriterPosition,
|
|
278
280
|
LiquidateWriterPositionRescue,
|
|
281
|
+
MigrateCollateralPoolV1ToV2,
|
|
279
282
|
OmlpCreateVault,
|
|
280
283
|
OmlpUpdateFeeWallet,
|
|
281
284
|
OmlpUpdateInterestModel,
|
|
@@ -492,6 +495,17 @@ export function identifyOptionProgramInstruction(
|
|
|
492
495
|
) {
|
|
493
496
|
return OptionProgramInstruction.LiquidateWriterPositionRescue;
|
|
494
497
|
}
|
|
498
|
+
if (
|
|
499
|
+
containsBytes(
|
|
500
|
+
data,
|
|
501
|
+
fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
502
|
+
new Uint8Array([7, 151, 240, 114, 7, 75, 88, 10]),
|
|
503
|
+
),
|
|
504
|
+
0,
|
|
505
|
+
)
|
|
506
|
+
) {
|
|
507
|
+
return OptionProgramInstruction.MigrateCollateralPoolV1ToV2;
|
|
508
|
+
}
|
|
495
509
|
if (
|
|
496
510
|
containsBytes(
|
|
497
511
|
data,
|
|
@@ -804,6 +818,9 @@ export type ParsedOptionProgramInstruction<
|
|
|
804
818
|
| ({
|
|
805
819
|
instructionType: OptionProgramInstruction.LiquidateWriterPositionRescue;
|
|
806
820
|
} & ParsedLiquidateWriterPositionRescueInstruction<TProgram>)
|
|
821
|
+
| ({
|
|
822
|
+
instructionType: OptionProgramInstruction.MigrateCollateralPoolV1ToV2;
|
|
823
|
+
} & ParsedMigrateCollateralPoolV1ToV2Instruction<TProgram>)
|
|
807
824
|
| ({
|
|
808
825
|
instructionType: OptionProgramInstruction.OmlpCreateVault;
|
|
809
826
|
} & ParsedOmlpCreateVaultInstruction<TProgram>)
|
|
@@ -998,6 +1015,13 @@ export function parseOptionProgramInstruction<TProgram extends string>(
|
|
|
998
1015
|
...parseLiquidateWriterPositionRescueInstruction(instruction),
|
|
999
1016
|
};
|
|
1000
1017
|
}
|
|
1018
|
+
case OptionProgramInstruction.MigrateCollateralPoolV1ToV2: {
|
|
1019
|
+
assertIsInstructionWithAccounts(instruction);
|
|
1020
|
+
return {
|
|
1021
|
+
instructionType: OptionProgramInstruction.MigrateCollateralPoolV1ToV2,
|
|
1022
|
+
...parseMigrateCollateralPoolV1ToV2Instruction(instruction),
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1001
1025
|
case OptionProgramInstruction.OmlpCreateVault: {
|
|
1002
1026
|
assertIsInstructionWithAccounts(instruction);
|
|
1003
1027
|
return {
|
package/package.json
CHANGED