@epicentral/sos-sdk 0.13.2-beta → 0.14.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 +3 -2
- package/accounts/pdas.ts +31 -2
- package/client/lookup-table.ts +1 -1
- package/generated/instructions/borrowFromPool.ts +70 -56
- package/generated/instructions/index.ts +1 -0
- package/generated/instructions/transferMarketDataAuthority.ts +313 -0
- package/generated/programs/optionProgram.ts +16 -384
- package/generated/types/index.ts +1 -0
- package/generated/types/marketDataAuthorityTransferred.ts +56 -0
- package/package.json +1 -1
- package/shared/option-program-parser.ts +6 -0
- package/short/builders.ts +29 -28
- package/short/pool.ts +2 -4
|
@@ -0,0 +1,313 @@
|
|
|
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
|
+
transformEncoder,
|
|
21
|
+
type AccountMeta,
|
|
22
|
+
type AccountSignerMeta,
|
|
23
|
+
type Address,
|
|
24
|
+
type FixedSizeCodec,
|
|
25
|
+
type FixedSizeDecoder,
|
|
26
|
+
type FixedSizeEncoder,
|
|
27
|
+
type Instruction,
|
|
28
|
+
type InstructionWithAccounts,
|
|
29
|
+
type InstructionWithData,
|
|
30
|
+
type ReadonlyAccount,
|
|
31
|
+
type ReadonlySignerAccount,
|
|
32
|
+
type ReadonlyUint8Array,
|
|
33
|
+
type TransactionSigner,
|
|
34
|
+
type WritableAccount,
|
|
35
|
+
} from "@solana/kit";
|
|
36
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
37
|
+
import {
|
|
38
|
+
expectAddress,
|
|
39
|
+
getAccountMetaFactory,
|
|
40
|
+
type ResolvedAccount,
|
|
41
|
+
} from "../shared";
|
|
42
|
+
|
|
43
|
+
export const TRANSFER_MARKET_DATA_AUTHORITY_DISCRIMINATOR = new Uint8Array([
|
|
44
|
+
81, 39, 144, 5, 135, 201, 220, 167,
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
export function getTransferMarketDataAuthorityDiscriminatorBytes() {
|
|
48
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
49
|
+
TRANSFER_MARKET_DATA_AUTHORITY_DISCRIMINATOR,
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type TransferMarketDataAuthorityInstruction<
|
|
54
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
55
|
+
TAccountMarketData extends string | AccountMeta<string> = string,
|
|
56
|
+
TAccountUnderlyingAsset extends string | AccountMeta<string> = string,
|
|
57
|
+
TAccountAuthority extends string | AccountMeta<string> = string,
|
|
58
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
59
|
+
> = Instruction<TProgram> &
|
|
60
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
61
|
+
InstructionWithAccounts<
|
|
62
|
+
[
|
|
63
|
+
TAccountMarketData extends string
|
|
64
|
+
? WritableAccount<TAccountMarketData>
|
|
65
|
+
: TAccountMarketData,
|
|
66
|
+
TAccountUnderlyingAsset extends string
|
|
67
|
+
? ReadonlyAccount<TAccountUnderlyingAsset>
|
|
68
|
+
: TAccountUnderlyingAsset,
|
|
69
|
+
TAccountAuthority extends string
|
|
70
|
+
? ReadonlySignerAccount<TAccountAuthority> &
|
|
71
|
+
AccountSignerMeta<TAccountAuthority>
|
|
72
|
+
: TAccountAuthority,
|
|
73
|
+
...TRemainingAccounts,
|
|
74
|
+
]
|
|
75
|
+
>;
|
|
76
|
+
|
|
77
|
+
export type TransferMarketDataAuthorityInstructionData = {
|
|
78
|
+
discriminator: ReadonlyUint8Array;
|
|
79
|
+
newAuthority: Address;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export type TransferMarketDataAuthorityInstructionDataArgs = {
|
|
83
|
+
newAuthority: Address;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export function getTransferMarketDataAuthorityInstructionDataEncoder(): FixedSizeEncoder<TransferMarketDataAuthorityInstructionDataArgs> {
|
|
87
|
+
return transformEncoder(
|
|
88
|
+
getStructEncoder([
|
|
89
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
90
|
+
["newAuthority", getAddressEncoder()],
|
|
91
|
+
]),
|
|
92
|
+
(value) => ({
|
|
93
|
+
...value,
|
|
94
|
+
discriminator: TRANSFER_MARKET_DATA_AUTHORITY_DISCRIMINATOR,
|
|
95
|
+
}),
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getTransferMarketDataAuthorityInstructionDataDecoder(): FixedSizeDecoder<TransferMarketDataAuthorityInstructionData> {
|
|
100
|
+
return getStructDecoder([
|
|
101
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
102
|
+
["newAuthority", getAddressDecoder()],
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function getTransferMarketDataAuthorityInstructionDataCodec(): FixedSizeCodec<
|
|
107
|
+
TransferMarketDataAuthorityInstructionDataArgs,
|
|
108
|
+
TransferMarketDataAuthorityInstructionData
|
|
109
|
+
> {
|
|
110
|
+
return combineCodec(
|
|
111
|
+
getTransferMarketDataAuthorityInstructionDataEncoder(),
|
|
112
|
+
getTransferMarketDataAuthorityInstructionDataDecoder(),
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type TransferMarketDataAuthorityAsyncInput<
|
|
117
|
+
TAccountMarketData extends string = string,
|
|
118
|
+
TAccountUnderlyingAsset extends string = string,
|
|
119
|
+
TAccountAuthority extends string = string,
|
|
120
|
+
> = {
|
|
121
|
+
marketData?: Address<TAccountMarketData>;
|
|
122
|
+
underlyingAsset: Address<TAccountUnderlyingAsset>;
|
|
123
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
124
|
+
newAuthority: TransferMarketDataAuthorityInstructionDataArgs["newAuthority"];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export async function getTransferMarketDataAuthorityInstructionAsync<
|
|
128
|
+
TAccountMarketData extends string,
|
|
129
|
+
TAccountUnderlyingAsset extends string,
|
|
130
|
+
TAccountAuthority extends string,
|
|
131
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
132
|
+
>(
|
|
133
|
+
input: TransferMarketDataAuthorityAsyncInput<
|
|
134
|
+
TAccountMarketData,
|
|
135
|
+
TAccountUnderlyingAsset,
|
|
136
|
+
TAccountAuthority
|
|
137
|
+
>,
|
|
138
|
+
config?: { programAddress?: TProgramAddress },
|
|
139
|
+
): Promise<
|
|
140
|
+
TransferMarketDataAuthorityInstruction<
|
|
141
|
+
TProgramAddress,
|
|
142
|
+
TAccountMarketData,
|
|
143
|
+
TAccountUnderlyingAsset,
|
|
144
|
+
TAccountAuthority
|
|
145
|
+
>
|
|
146
|
+
> {
|
|
147
|
+
// Program address.
|
|
148
|
+
const programAddress =
|
|
149
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
150
|
+
|
|
151
|
+
// Original accounts.
|
|
152
|
+
const originalAccounts = {
|
|
153
|
+
marketData: { value: input.marketData ?? null, isWritable: true },
|
|
154
|
+
underlyingAsset: {
|
|
155
|
+
value: input.underlyingAsset ?? null,
|
|
156
|
+
isWritable: false,
|
|
157
|
+
},
|
|
158
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
159
|
+
};
|
|
160
|
+
const accounts = originalAccounts as Record<
|
|
161
|
+
keyof typeof originalAccounts,
|
|
162
|
+
ResolvedAccount
|
|
163
|
+
>;
|
|
164
|
+
|
|
165
|
+
// Original args.
|
|
166
|
+
const args = { ...input };
|
|
167
|
+
|
|
168
|
+
// Resolve default values.
|
|
169
|
+
if (!accounts.marketData.value) {
|
|
170
|
+
accounts.marketData.value = await getProgramDerivedAddress({
|
|
171
|
+
programAddress,
|
|
172
|
+
seeds: [
|
|
173
|
+
getBytesEncoder().encode(
|
|
174
|
+
new Uint8Array([109, 97, 114, 107, 101, 116, 95, 100, 97, 116, 97]),
|
|
175
|
+
),
|
|
176
|
+
getAddressEncoder().encode(
|
|
177
|
+
expectAddress(accounts.underlyingAsset.value),
|
|
178
|
+
),
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
184
|
+
return Object.freeze({
|
|
185
|
+
accounts: [
|
|
186
|
+
getAccountMeta(accounts.marketData),
|
|
187
|
+
getAccountMeta(accounts.underlyingAsset),
|
|
188
|
+
getAccountMeta(accounts.authority),
|
|
189
|
+
],
|
|
190
|
+
data: getTransferMarketDataAuthorityInstructionDataEncoder().encode(
|
|
191
|
+
args as TransferMarketDataAuthorityInstructionDataArgs,
|
|
192
|
+
),
|
|
193
|
+
programAddress,
|
|
194
|
+
} as TransferMarketDataAuthorityInstruction<
|
|
195
|
+
TProgramAddress,
|
|
196
|
+
TAccountMarketData,
|
|
197
|
+
TAccountUnderlyingAsset,
|
|
198
|
+
TAccountAuthority
|
|
199
|
+
>);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type TransferMarketDataAuthorityInput<
|
|
203
|
+
TAccountMarketData extends string = string,
|
|
204
|
+
TAccountUnderlyingAsset extends string = string,
|
|
205
|
+
TAccountAuthority extends string = string,
|
|
206
|
+
> = {
|
|
207
|
+
marketData: Address<TAccountMarketData>;
|
|
208
|
+
underlyingAsset: Address<TAccountUnderlyingAsset>;
|
|
209
|
+
authority: TransactionSigner<TAccountAuthority>;
|
|
210
|
+
newAuthority: TransferMarketDataAuthorityInstructionDataArgs["newAuthority"];
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export function getTransferMarketDataAuthorityInstruction<
|
|
214
|
+
TAccountMarketData extends string,
|
|
215
|
+
TAccountUnderlyingAsset extends string,
|
|
216
|
+
TAccountAuthority extends string,
|
|
217
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
218
|
+
>(
|
|
219
|
+
input: TransferMarketDataAuthorityInput<
|
|
220
|
+
TAccountMarketData,
|
|
221
|
+
TAccountUnderlyingAsset,
|
|
222
|
+
TAccountAuthority
|
|
223
|
+
>,
|
|
224
|
+
config?: { programAddress?: TProgramAddress },
|
|
225
|
+
): TransferMarketDataAuthorityInstruction<
|
|
226
|
+
TProgramAddress,
|
|
227
|
+
TAccountMarketData,
|
|
228
|
+
TAccountUnderlyingAsset,
|
|
229
|
+
TAccountAuthority
|
|
230
|
+
> {
|
|
231
|
+
// Program address.
|
|
232
|
+
const programAddress =
|
|
233
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
234
|
+
|
|
235
|
+
// Original accounts.
|
|
236
|
+
const originalAccounts = {
|
|
237
|
+
marketData: { value: input.marketData ?? null, isWritable: true },
|
|
238
|
+
underlyingAsset: {
|
|
239
|
+
value: input.underlyingAsset ?? null,
|
|
240
|
+
isWritable: false,
|
|
241
|
+
},
|
|
242
|
+
authority: { value: input.authority ?? null, isWritable: false },
|
|
243
|
+
};
|
|
244
|
+
const accounts = originalAccounts as Record<
|
|
245
|
+
keyof typeof originalAccounts,
|
|
246
|
+
ResolvedAccount
|
|
247
|
+
>;
|
|
248
|
+
|
|
249
|
+
// Original args.
|
|
250
|
+
const args = { ...input };
|
|
251
|
+
|
|
252
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
253
|
+
return Object.freeze({
|
|
254
|
+
accounts: [
|
|
255
|
+
getAccountMeta(accounts.marketData),
|
|
256
|
+
getAccountMeta(accounts.underlyingAsset),
|
|
257
|
+
getAccountMeta(accounts.authority),
|
|
258
|
+
],
|
|
259
|
+
data: getTransferMarketDataAuthorityInstructionDataEncoder().encode(
|
|
260
|
+
args as TransferMarketDataAuthorityInstructionDataArgs,
|
|
261
|
+
),
|
|
262
|
+
programAddress,
|
|
263
|
+
} as TransferMarketDataAuthorityInstruction<
|
|
264
|
+
TProgramAddress,
|
|
265
|
+
TAccountMarketData,
|
|
266
|
+
TAccountUnderlyingAsset,
|
|
267
|
+
TAccountAuthority
|
|
268
|
+
>);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export type ParsedTransferMarketDataAuthorityInstruction<
|
|
272
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
273
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
274
|
+
> = {
|
|
275
|
+
programAddress: Address<TProgram>;
|
|
276
|
+
accounts: {
|
|
277
|
+
marketData: TAccountMetas[0];
|
|
278
|
+
underlyingAsset: TAccountMetas[1];
|
|
279
|
+
authority: TAccountMetas[2];
|
|
280
|
+
};
|
|
281
|
+
data: TransferMarketDataAuthorityInstructionData;
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
export function parseTransferMarketDataAuthorityInstruction<
|
|
285
|
+
TProgram extends string,
|
|
286
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
287
|
+
>(
|
|
288
|
+
instruction: Instruction<TProgram> &
|
|
289
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
290
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
291
|
+
): ParsedTransferMarketDataAuthorityInstruction<TProgram, TAccountMetas> {
|
|
292
|
+
if (instruction.accounts.length < 3) {
|
|
293
|
+
// TODO: Coded error.
|
|
294
|
+
throw new Error("Not enough accounts");
|
|
295
|
+
}
|
|
296
|
+
let accountIndex = 0;
|
|
297
|
+
const getNextAccount = () => {
|
|
298
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
299
|
+
accountIndex += 1;
|
|
300
|
+
return accountMeta;
|
|
301
|
+
};
|
|
302
|
+
return {
|
|
303
|
+
programAddress: instruction.programAddress,
|
|
304
|
+
accounts: {
|
|
305
|
+
marketData: getNextAccount(),
|
|
306
|
+
underlyingAsset: getNextAccount(),
|
|
307
|
+
authority: getNextAccount(),
|
|
308
|
+
},
|
|
309
|
+
data: getTransferMarketDataAuthorityInstructionDataDecoder().decode(
|
|
310
|
+
instruction.data,
|
|
311
|
+
),
|
|
312
|
+
};
|
|
313
|
+
}
|