@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,245 @@
|
|
|
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 ReadonlySignerAccount,
|
|
31
|
+
type ReadonlyUint8Array,
|
|
32
|
+
type TransactionSigner,
|
|
33
|
+
type WritableAccount,
|
|
34
|
+
} from "@solana/kit";
|
|
35
|
+
import { OPTION_PROGRAM_PROGRAM_ADDRESS } from "../programs";
|
|
36
|
+
import { getAccountMetaFactory, type ResolvedAccount } from "../shared";
|
|
37
|
+
|
|
38
|
+
export const TRANSFER_ADMIN_DISCRIMINATOR = new Uint8Array([
|
|
39
|
+
42, 242, 66, 106, 228, 10, 111, 156,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export function getTransferAdminDiscriminatorBytes() {
|
|
43
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
44
|
+
TRANSFER_ADMIN_DISCRIMINATOR,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export type TransferAdminInstruction<
|
|
49
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
50
|
+
TAccountConfig extends string | AccountMeta<string> = string,
|
|
51
|
+
TAccountAdmin extends string | AccountMeta<string> = string,
|
|
52
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
53
|
+
> = Instruction<TProgram> &
|
|
54
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
55
|
+
InstructionWithAccounts<
|
|
56
|
+
[
|
|
57
|
+
TAccountConfig extends string
|
|
58
|
+
? WritableAccount<TAccountConfig>
|
|
59
|
+
: TAccountConfig,
|
|
60
|
+
TAccountAdmin extends string
|
|
61
|
+
? ReadonlySignerAccount<TAccountAdmin> &
|
|
62
|
+
AccountSignerMeta<TAccountAdmin>
|
|
63
|
+
: TAccountAdmin,
|
|
64
|
+
...TRemainingAccounts,
|
|
65
|
+
]
|
|
66
|
+
>;
|
|
67
|
+
|
|
68
|
+
export type TransferAdminInstructionData = {
|
|
69
|
+
discriminator: ReadonlyUint8Array;
|
|
70
|
+
newAdmin: Address;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type TransferAdminInstructionDataArgs = { newAdmin: Address };
|
|
74
|
+
|
|
75
|
+
export function getTransferAdminInstructionDataEncoder(): FixedSizeEncoder<TransferAdminInstructionDataArgs> {
|
|
76
|
+
return transformEncoder(
|
|
77
|
+
getStructEncoder([
|
|
78
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
79
|
+
["newAdmin", getAddressEncoder()],
|
|
80
|
+
]),
|
|
81
|
+
(value) => ({ ...value, discriminator: TRANSFER_ADMIN_DISCRIMINATOR }),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getTransferAdminInstructionDataDecoder(): FixedSizeDecoder<TransferAdminInstructionData> {
|
|
86
|
+
return getStructDecoder([
|
|
87
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
88
|
+
["newAdmin", getAddressDecoder()],
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function getTransferAdminInstructionDataCodec(): FixedSizeCodec<
|
|
93
|
+
TransferAdminInstructionDataArgs,
|
|
94
|
+
TransferAdminInstructionData
|
|
95
|
+
> {
|
|
96
|
+
return combineCodec(
|
|
97
|
+
getTransferAdminInstructionDataEncoder(),
|
|
98
|
+
getTransferAdminInstructionDataDecoder(),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type TransferAdminAsyncInput<
|
|
103
|
+
TAccountConfig extends string = string,
|
|
104
|
+
TAccountAdmin extends string = string,
|
|
105
|
+
> = {
|
|
106
|
+
config?: Address<TAccountConfig>;
|
|
107
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
108
|
+
newAdmin: TransferAdminInstructionDataArgs["newAdmin"];
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export async function getTransferAdminInstructionAsync<
|
|
112
|
+
TAccountConfig extends string,
|
|
113
|
+
TAccountAdmin extends string,
|
|
114
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
115
|
+
>(
|
|
116
|
+
input: TransferAdminAsyncInput<TAccountConfig, TAccountAdmin>,
|
|
117
|
+
config?: { programAddress?: TProgramAddress },
|
|
118
|
+
): Promise<
|
|
119
|
+
TransferAdminInstruction<TProgramAddress, TAccountConfig, TAccountAdmin>
|
|
120
|
+
> {
|
|
121
|
+
// Program address.
|
|
122
|
+
const programAddress =
|
|
123
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
124
|
+
|
|
125
|
+
// Original accounts.
|
|
126
|
+
const originalAccounts = {
|
|
127
|
+
config: { value: input.config ?? null, isWritable: true },
|
|
128
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
129
|
+
};
|
|
130
|
+
const accounts = originalAccounts as Record<
|
|
131
|
+
keyof typeof originalAccounts,
|
|
132
|
+
ResolvedAccount
|
|
133
|
+
>;
|
|
134
|
+
|
|
135
|
+
// Original args.
|
|
136
|
+
const args = { ...input };
|
|
137
|
+
|
|
138
|
+
// Resolve default values.
|
|
139
|
+
if (!accounts.config.value) {
|
|
140
|
+
accounts.config.value = await getProgramDerivedAddress({
|
|
141
|
+
programAddress,
|
|
142
|
+
seeds: [
|
|
143
|
+
getBytesEncoder().encode(new Uint8Array([99, 111, 110, 102, 105, 103])),
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
149
|
+
return Object.freeze({
|
|
150
|
+
accounts: [getAccountMeta(accounts.config), getAccountMeta(accounts.admin)],
|
|
151
|
+
data: getTransferAdminInstructionDataEncoder().encode(
|
|
152
|
+
args as TransferAdminInstructionDataArgs,
|
|
153
|
+
),
|
|
154
|
+
programAddress,
|
|
155
|
+
} as TransferAdminInstruction<
|
|
156
|
+
TProgramAddress,
|
|
157
|
+
TAccountConfig,
|
|
158
|
+
TAccountAdmin
|
|
159
|
+
>);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export type TransferAdminInput<
|
|
163
|
+
TAccountConfig extends string = string,
|
|
164
|
+
TAccountAdmin extends string = string,
|
|
165
|
+
> = {
|
|
166
|
+
config: Address<TAccountConfig>;
|
|
167
|
+
admin: TransactionSigner<TAccountAdmin>;
|
|
168
|
+
newAdmin: TransferAdminInstructionDataArgs["newAdmin"];
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export function getTransferAdminInstruction<
|
|
172
|
+
TAccountConfig extends string,
|
|
173
|
+
TAccountAdmin extends string,
|
|
174
|
+
TProgramAddress extends Address = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
175
|
+
>(
|
|
176
|
+
input: TransferAdminInput<TAccountConfig, TAccountAdmin>,
|
|
177
|
+
config?: { programAddress?: TProgramAddress },
|
|
178
|
+
): TransferAdminInstruction<TProgramAddress, TAccountConfig, TAccountAdmin> {
|
|
179
|
+
// Program address.
|
|
180
|
+
const programAddress =
|
|
181
|
+
config?.programAddress ?? OPTION_PROGRAM_PROGRAM_ADDRESS;
|
|
182
|
+
|
|
183
|
+
// Original accounts.
|
|
184
|
+
const originalAccounts = {
|
|
185
|
+
config: { value: input.config ?? null, isWritable: true },
|
|
186
|
+
admin: { value: input.admin ?? null, isWritable: false },
|
|
187
|
+
};
|
|
188
|
+
const accounts = originalAccounts as Record<
|
|
189
|
+
keyof typeof originalAccounts,
|
|
190
|
+
ResolvedAccount
|
|
191
|
+
>;
|
|
192
|
+
|
|
193
|
+
// Original args.
|
|
194
|
+
const args = { ...input };
|
|
195
|
+
|
|
196
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
|
|
197
|
+
return Object.freeze({
|
|
198
|
+
accounts: [getAccountMeta(accounts.config), getAccountMeta(accounts.admin)],
|
|
199
|
+
data: getTransferAdminInstructionDataEncoder().encode(
|
|
200
|
+
args as TransferAdminInstructionDataArgs,
|
|
201
|
+
),
|
|
202
|
+
programAddress,
|
|
203
|
+
} as TransferAdminInstruction<
|
|
204
|
+
TProgramAddress,
|
|
205
|
+
TAccountConfig,
|
|
206
|
+
TAccountAdmin
|
|
207
|
+
>);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export type ParsedTransferAdminInstruction<
|
|
211
|
+
TProgram extends string = typeof OPTION_PROGRAM_PROGRAM_ADDRESS,
|
|
212
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
213
|
+
> = {
|
|
214
|
+
programAddress: Address<TProgram>;
|
|
215
|
+
accounts: {
|
|
216
|
+
config: TAccountMetas[0];
|
|
217
|
+
admin: TAccountMetas[1];
|
|
218
|
+
};
|
|
219
|
+
data: TransferAdminInstructionData;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export function parseTransferAdminInstruction<
|
|
223
|
+
TProgram extends string,
|
|
224
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
225
|
+
>(
|
|
226
|
+
instruction: Instruction<TProgram> &
|
|
227
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
228
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
229
|
+
): ParsedTransferAdminInstruction<TProgram, TAccountMetas> {
|
|
230
|
+
if (instruction.accounts.length < 2) {
|
|
231
|
+
// TODO: Coded error.
|
|
232
|
+
throw new Error("Not enough accounts");
|
|
233
|
+
}
|
|
234
|
+
let accountIndex = 0;
|
|
235
|
+
const getNextAccount = () => {
|
|
236
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
237
|
+
accountIndex += 1;
|
|
238
|
+
return accountMeta;
|
|
239
|
+
};
|
|
240
|
+
return {
|
|
241
|
+
programAddress: instruction.programAddress,
|
|
242
|
+
accounts: { config: getNextAccount(), admin: getNextAccount() },
|
|
243
|
+
data: getTransferAdminInstructionDataDecoder().decode(instruction.data),
|
|
244
|
+
};
|
|
245
|
+
}
|