@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,211 @@
|
|
|
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
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
decodeAccount,
|
|
14
|
+
fetchEncodedAccount,
|
|
15
|
+
fetchEncodedAccounts,
|
|
16
|
+
fixDecoderSize,
|
|
17
|
+
fixEncoderSize,
|
|
18
|
+
getAddressDecoder,
|
|
19
|
+
getAddressEncoder,
|
|
20
|
+
getBytesDecoder,
|
|
21
|
+
getBytesEncoder,
|
|
22
|
+
getI64Decoder,
|
|
23
|
+
getI64Encoder,
|
|
24
|
+
getStructDecoder,
|
|
25
|
+
getStructEncoder,
|
|
26
|
+
getU128Decoder,
|
|
27
|
+
getU128Encoder,
|
|
28
|
+
getU64Decoder,
|
|
29
|
+
getU64Encoder,
|
|
30
|
+
getU8Decoder,
|
|
31
|
+
getU8Encoder,
|
|
32
|
+
transformEncoder,
|
|
33
|
+
type Account,
|
|
34
|
+
type Address,
|
|
35
|
+
type EncodedAccount,
|
|
36
|
+
type FetchAccountConfig,
|
|
37
|
+
type FetchAccountsConfig,
|
|
38
|
+
type FixedSizeCodec,
|
|
39
|
+
type FixedSizeDecoder,
|
|
40
|
+
type FixedSizeEncoder,
|
|
41
|
+
type MaybeAccount,
|
|
42
|
+
type MaybeEncodedAccount,
|
|
43
|
+
type ReadonlyUint8Array,
|
|
44
|
+
} from "@solana/kit";
|
|
45
|
+
|
|
46
|
+
export const LENDER_POSITION_DISCRIMINATOR = new Uint8Array([
|
|
47
|
+
165, 98, 244, 204, 209, 158, 88, 19,
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
export function getLenderPositionDiscriminatorBytes() {
|
|
51
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
52
|
+
LENDER_POSITION_DISCRIMINATOR,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type LenderPosition = {
|
|
57
|
+
discriminator: ReadonlyUint8Array;
|
|
58
|
+
/** Lender who owns this position */
|
|
59
|
+
lender: Address;
|
|
60
|
+
/** Associated vault */
|
|
61
|
+
vault: Address;
|
|
62
|
+
/** User's current deposited amount (their share of the pool) */
|
|
63
|
+
deposited: bigint;
|
|
64
|
+
/** Total interest earned by this user (lifetime) - lazily updated */
|
|
65
|
+
totalInterestEarned: bigint;
|
|
66
|
+
/** Interest already claimed/withdrawn by this user */
|
|
67
|
+
interestClaimed: bigint;
|
|
68
|
+
/** Position created timestamp */
|
|
69
|
+
createdAt: bigint;
|
|
70
|
+
/** Last update timestamp */
|
|
71
|
+
lastUpdated: bigint;
|
|
72
|
+
/** PDA bump */
|
|
73
|
+
bump: number;
|
|
74
|
+
/**
|
|
75
|
+
* Snapshot of vault's acc_interest_per_share_fp at last interaction
|
|
76
|
+
* Used to calculate pending interest: (current_index - snapshot) * deposited / FP_SCALE
|
|
77
|
+
*/
|
|
78
|
+
interestIndexSnapshotFp: bigint;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export type LenderPositionArgs = {
|
|
82
|
+
/** Lender who owns this position */
|
|
83
|
+
lender: Address;
|
|
84
|
+
/** Associated vault */
|
|
85
|
+
vault: Address;
|
|
86
|
+
/** User's current deposited amount (their share of the pool) */
|
|
87
|
+
deposited: number | bigint;
|
|
88
|
+
/** Total interest earned by this user (lifetime) - lazily updated */
|
|
89
|
+
totalInterestEarned: number | bigint;
|
|
90
|
+
/** Interest already claimed/withdrawn by this user */
|
|
91
|
+
interestClaimed: number | bigint;
|
|
92
|
+
/** Position created timestamp */
|
|
93
|
+
createdAt: number | bigint;
|
|
94
|
+
/** Last update timestamp */
|
|
95
|
+
lastUpdated: number | bigint;
|
|
96
|
+
/** PDA bump */
|
|
97
|
+
bump: number;
|
|
98
|
+
/**
|
|
99
|
+
* Snapshot of vault's acc_interest_per_share_fp at last interaction
|
|
100
|
+
* Used to calculate pending interest: (current_index - snapshot) * deposited / FP_SCALE
|
|
101
|
+
*/
|
|
102
|
+
interestIndexSnapshotFp: number | bigint;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
/** Gets the encoder for {@link LenderPositionArgs} account data. */
|
|
106
|
+
export function getLenderPositionEncoder(): FixedSizeEncoder<LenderPositionArgs> {
|
|
107
|
+
return transformEncoder(
|
|
108
|
+
getStructEncoder([
|
|
109
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
110
|
+
["lender", getAddressEncoder()],
|
|
111
|
+
["vault", getAddressEncoder()],
|
|
112
|
+
["deposited", getU64Encoder()],
|
|
113
|
+
["totalInterestEarned", getU64Encoder()],
|
|
114
|
+
["interestClaimed", getU64Encoder()],
|
|
115
|
+
["createdAt", getI64Encoder()],
|
|
116
|
+
["lastUpdated", getI64Encoder()],
|
|
117
|
+
["bump", getU8Encoder()],
|
|
118
|
+
["interestIndexSnapshotFp", getU128Encoder()],
|
|
119
|
+
]),
|
|
120
|
+
(value) => ({ ...value, discriminator: LENDER_POSITION_DISCRIMINATOR }),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Gets the decoder for {@link LenderPosition} account data. */
|
|
125
|
+
export function getLenderPositionDecoder(): FixedSizeDecoder<LenderPosition> {
|
|
126
|
+
return getStructDecoder([
|
|
127
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
128
|
+
["lender", getAddressDecoder()],
|
|
129
|
+
["vault", getAddressDecoder()],
|
|
130
|
+
["deposited", getU64Decoder()],
|
|
131
|
+
["totalInterestEarned", getU64Decoder()],
|
|
132
|
+
["interestClaimed", getU64Decoder()],
|
|
133
|
+
["createdAt", getI64Decoder()],
|
|
134
|
+
["lastUpdated", getI64Decoder()],
|
|
135
|
+
["bump", getU8Decoder()],
|
|
136
|
+
["interestIndexSnapshotFp", getU128Decoder()],
|
|
137
|
+
]);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Gets the codec for {@link LenderPosition} account data. */
|
|
141
|
+
export function getLenderPositionCodec(): FixedSizeCodec<
|
|
142
|
+
LenderPositionArgs,
|
|
143
|
+
LenderPosition
|
|
144
|
+
> {
|
|
145
|
+
return combineCodec(getLenderPositionEncoder(), getLenderPositionDecoder());
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function decodeLenderPosition<TAddress extends string = string>(
|
|
149
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
150
|
+
): Account<LenderPosition, TAddress>;
|
|
151
|
+
export function decodeLenderPosition<TAddress extends string = string>(
|
|
152
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
153
|
+
): MaybeAccount<LenderPosition, TAddress>;
|
|
154
|
+
export function decodeLenderPosition<TAddress extends string = string>(
|
|
155
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
156
|
+
): Account<LenderPosition, TAddress> | MaybeAccount<LenderPosition, TAddress> {
|
|
157
|
+
return decodeAccount(
|
|
158
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
159
|
+
getLenderPositionDecoder(),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export async function fetchLenderPosition<TAddress extends string = string>(
|
|
164
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
165
|
+
address: Address<TAddress>,
|
|
166
|
+
config?: FetchAccountConfig,
|
|
167
|
+
): Promise<Account<LenderPosition, TAddress>> {
|
|
168
|
+
const maybeAccount = await fetchMaybeLenderPosition(rpc, address, config);
|
|
169
|
+
assertAccountExists(maybeAccount);
|
|
170
|
+
return maybeAccount;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export async function fetchMaybeLenderPosition<
|
|
174
|
+
TAddress extends string = string,
|
|
175
|
+
>(
|
|
176
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
177
|
+
address: Address<TAddress>,
|
|
178
|
+
config?: FetchAccountConfig,
|
|
179
|
+
): Promise<MaybeAccount<LenderPosition, TAddress>> {
|
|
180
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
181
|
+
return decodeLenderPosition(maybeAccount);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function fetchAllLenderPosition(
|
|
185
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
186
|
+
addresses: Array<Address>,
|
|
187
|
+
config?: FetchAccountsConfig,
|
|
188
|
+
): Promise<Account<LenderPosition>[]> {
|
|
189
|
+
const maybeAccounts = await fetchAllMaybeLenderPosition(
|
|
190
|
+
rpc,
|
|
191
|
+
addresses,
|
|
192
|
+
config,
|
|
193
|
+
);
|
|
194
|
+
assertAccountsExist(maybeAccounts);
|
|
195
|
+
return maybeAccounts;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export async function fetchAllMaybeLenderPosition(
|
|
199
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
200
|
+
addresses: Array<Address>,
|
|
201
|
+
config?: FetchAccountsConfig,
|
|
202
|
+
): Promise<MaybeAccount<LenderPosition>[]> {
|
|
203
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
204
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
205
|
+
decodeLenderPosition(maybeAccount),
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function getLenderPositionSize(): number {
|
|
210
|
+
return 129;
|
|
211
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
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
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
decodeAccount,
|
|
14
|
+
fetchEncodedAccount,
|
|
15
|
+
fetchEncodedAccounts,
|
|
16
|
+
fixDecoderSize,
|
|
17
|
+
fixEncoderSize,
|
|
18
|
+
getAddressDecoder,
|
|
19
|
+
getAddressEncoder,
|
|
20
|
+
getBytesDecoder,
|
|
21
|
+
getBytesEncoder,
|
|
22
|
+
getI64Decoder,
|
|
23
|
+
getI64Encoder,
|
|
24
|
+
getStructDecoder,
|
|
25
|
+
getStructEncoder,
|
|
26
|
+
getU16Decoder,
|
|
27
|
+
getU16Encoder,
|
|
28
|
+
getU64Decoder,
|
|
29
|
+
getU64Encoder,
|
|
30
|
+
transformEncoder,
|
|
31
|
+
type Account,
|
|
32
|
+
type Address,
|
|
33
|
+
type EncodedAccount,
|
|
34
|
+
type FetchAccountConfig,
|
|
35
|
+
type FetchAccountsConfig,
|
|
36
|
+
type FixedSizeCodec,
|
|
37
|
+
type FixedSizeDecoder,
|
|
38
|
+
type FixedSizeEncoder,
|
|
39
|
+
type MaybeAccount,
|
|
40
|
+
type MaybeEncodedAccount,
|
|
41
|
+
type ReadonlyUint8Array,
|
|
42
|
+
} from "@solana/kit";
|
|
43
|
+
import {
|
|
44
|
+
getSap2ProviderDecoder,
|
|
45
|
+
getSap2ProviderEncoder,
|
|
46
|
+
type Sap2Provider,
|
|
47
|
+
type Sap2ProviderArgs,
|
|
48
|
+
} from "../types";
|
|
49
|
+
|
|
50
|
+
export const LIQUIDITY_ROUTER_DISCRIMINATOR = new Uint8Array([
|
|
51
|
+
151, 96, 76, 12, 200, 0, 147, 111,
|
|
52
|
+
]);
|
|
53
|
+
|
|
54
|
+
export function getLiquidityRouterDiscriminatorBytes() {
|
|
55
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
56
|
+
LIQUIDITY_ROUTER_DISCRIMINATOR,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type LiquidityRouter = {
|
|
61
|
+
discriminator: ReadonlyUint8Array;
|
|
62
|
+
/** SAP1: Our internal OMLP vault */
|
|
63
|
+
sap1Vault: Address;
|
|
64
|
+
/** SAP2: External protocol program (Kamino) */
|
|
65
|
+
sap2Program: Address;
|
|
66
|
+
/** SAP2 provider type (Kamino) */
|
|
67
|
+
sap2Provider: Sap2Provider;
|
|
68
|
+
/**
|
|
69
|
+
* Utilization threshold for failover (basis points)
|
|
70
|
+
* Default: 9500 (95%) - failover when SAP1 is 95% utilized
|
|
71
|
+
*/
|
|
72
|
+
utilizationThreshold: number;
|
|
73
|
+
/** Total borrowed from SAP1 (OMLP) */
|
|
74
|
+
sap1TotalBorrowed: bigint;
|
|
75
|
+
/** Total borrowed from SAP2 (Kamino) */
|
|
76
|
+
sap2TotalBorrowed: bigint;
|
|
77
|
+
/** Number of failovers that occurred */
|
|
78
|
+
failoverCount: bigint;
|
|
79
|
+
/** Admin/keeper authority */
|
|
80
|
+
authority: Address;
|
|
81
|
+
/** Created timestamp */
|
|
82
|
+
createdAt: bigint;
|
|
83
|
+
/** Last updated timestamp */
|
|
84
|
+
lastUpdated: bigint;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export type LiquidityRouterArgs = {
|
|
88
|
+
/** SAP1: Our internal OMLP vault */
|
|
89
|
+
sap1Vault: Address;
|
|
90
|
+
/** SAP2: External protocol program (Kamino) */
|
|
91
|
+
sap2Program: Address;
|
|
92
|
+
/** SAP2 provider type (Kamino) */
|
|
93
|
+
sap2Provider: Sap2ProviderArgs;
|
|
94
|
+
/**
|
|
95
|
+
* Utilization threshold for failover (basis points)
|
|
96
|
+
* Default: 9500 (95%) - failover when SAP1 is 95% utilized
|
|
97
|
+
*/
|
|
98
|
+
utilizationThreshold: number;
|
|
99
|
+
/** Total borrowed from SAP1 (OMLP) */
|
|
100
|
+
sap1TotalBorrowed: number | bigint;
|
|
101
|
+
/** Total borrowed from SAP2 (Kamino) */
|
|
102
|
+
sap2TotalBorrowed: number | bigint;
|
|
103
|
+
/** Number of failovers that occurred */
|
|
104
|
+
failoverCount: number | bigint;
|
|
105
|
+
/** Admin/keeper authority */
|
|
106
|
+
authority: Address;
|
|
107
|
+
/** Created timestamp */
|
|
108
|
+
createdAt: number | bigint;
|
|
109
|
+
/** Last updated timestamp */
|
|
110
|
+
lastUpdated: number | bigint;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Gets the encoder for {@link LiquidityRouterArgs} account data. */
|
|
114
|
+
export function getLiquidityRouterEncoder(): FixedSizeEncoder<LiquidityRouterArgs> {
|
|
115
|
+
return transformEncoder(
|
|
116
|
+
getStructEncoder([
|
|
117
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
118
|
+
["sap1Vault", getAddressEncoder()],
|
|
119
|
+
["sap2Program", getAddressEncoder()],
|
|
120
|
+
["sap2Provider", getSap2ProviderEncoder()],
|
|
121
|
+
["utilizationThreshold", getU16Encoder()],
|
|
122
|
+
["sap1TotalBorrowed", getU64Encoder()],
|
|
123
|
+
["sap2TotalBorrowed", getU64Encoder()],
|
|
124
|
+
["failoverCount", getU64Encoder()],
|
|
125
|
+
["authority", getAddressEncoder()],
|
|
126
|
+
["createdAt", getI64Encoder()],
|
|
127
|
+
["lastUpdated", getI64Encoder()],
|
|
128
|
+
]),
|
|
129
|
+
(value) => ({ ...value, discriminator: LIQUIDITY_ROUTER_DISCRIMINATOR }),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** Gets the decoder for {@link LiquidityRouter} account data. */
|
|
134
|
+
export function getLiquidityRouterDecoder(): FixedSizeDecoder<LiquidityRouter> {
|
|
135
|
+
return getStructDecoder([
|
|
136
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
137
|
+
["sap1Vault", getAddressDecoder()],
|
|
138
|
+
["sap2Program", getAddressDecoder()],
|
|
139
|
+
["sap2Provider", getSap2ProviderDecoder()],
|
|
140
|
+
["utilizationThreshold", getU16Decoder()],
|
|
141
|
+
["sap1TotalBorrowed", getU64Decoder()],
|
|
142
|
+
["sap2TotalBorrowed", getU64Decoder()],
|
|
143
|
+
["failoverCount", getU64Decoder()],
|
|
144
|
+
["authority", getAddressDecoder()],
|
|
145
|
+
["createdAt", getI64Decoder()],
|
|
146
|
+
["lastUpdated", getI64Decoder()],
|
|
147
|
+
]);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** Gets the codec for {@link LiquidityRouter} account data. */
|
|
151
|
+
export function getLiquidityRouterCodec(): FixedSizeCodec<
|
|
152
|
+
LiquidityRouterArgs,
|
|
153
|
+
LiquidityRouter
|
|
154
|
+
> {
|
|
155
|
+
return combineCodec(getLiquidityRouterEncoder(), getLiquidityRouterDecoder());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function decodeLiquidityRouter<TAddress extends string = string>(
|
|
159
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
160
|
+
): Account<LiquidityRouter, TAddress>;
|
|
161
|
+
export function decodeLiquidityRouter<TAddress extends string = string>(
|
|
162
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
163
|
+
): MaybeAccount<LiquidityRouter, TAddress>;
|
|
164
|
+
export function decodeLiquidityRouter<TAddress extends string = string>(
|
|
165
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
166
|
+
):
|
|
167
|
+
| Account<LiquidityRouter, TAddress>
|
|
168
|
+
| MaybeAccount<LiquidityRouter, TAddress> {
|
|
169
|
+
return decodeAccount(
|
|
170
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
171
|
+
getLiquidityRouterDecoder(),
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function fetchLiquidityRouter<TAddress extends string = string>(
|
|
176
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
177
|
+
address: Address<TAddress>,
|
|
178
|
+
config?: FetchAccountConfig,
|
|
179
|
+
): Promise<Account<LiquidityRouter, TAddress>> {
|
|
180
|
+
const maybeAccount = await fetchMaybeLiquidityRouter(rpc, address, config);
|
|
181
|
+
assertAccountExists(maybeAccount);
|
|
182
|
+
return maybeAccount;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export async function fetchMaybeLiquidityRouter<
|
|
186
|
+
TAddress extends string = string,
|
|
187
|
+
>(
|
|
188
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
189
|
+
address: Address<TAddress>,
|
|
190
|
+
config?: FetchAccountConfig,
|
|
191
|
+
): Promise<MaybeAccount<LiquidityRouter, TAddress>> {
|
|
192
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
193
|
+
return decodeLiquidityRouter(maybeAccount);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export async function fetchAllLiquidityRouter(
|
|
197
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
198
|
+
addresses: Array<Address>,
|
|
199
|
+
config?: FetchAccountsConfig,
|
|
200
|
+
): Promise<Account<LiquidityRouter>[]> {
|
|
201
|
+
const maybeAccounts = await fetchAllMaybeLiquidityRouter(
|
|
202
|
+
rpc,
|
|
203
|
+
addresses,
|
|
204
|
+
config,
|
|
205
|
+
);
|
|
206
|
+
assertAccountsExist(maybeAccounts);
|
|
207
|
+
return maybeAccounts;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export async function fetchAllMaybeLiquidityRouter(
|
|
211
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
212
|
+
addresses: Array<Address>,
|
|
213
|
+
config?: FetchAccountsConfig,
|
|
214
|
+
): Promise<MaybeAccount<LiquidityRouter>[]> {
|
|
215
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
216
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
217
|
+
decodeLiquidityRouter(maybeAccount),
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
export function getLiquidityRouterSize(): number {
|
|
222
|
+
return 147;
|
|
223
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
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
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
decodeAccount,
|
|
14
|
+
fetchEncodedAccount,
|
|
15
|
+
fetchEncodedAccounts,
|
|
16
|
+
fixDecoderSize,
|
|
17
|
+
fixEncoderSize,
|
|
18
|
+
getAddressDecoder,
|
|
19
|
+
getAddressEncoder,
|
|
20
|
+
getBooleanDecoder,
|
|
21
|
+
getBooleanEncoder,
|
|
22
|
+
getBytesDecoder,
|
|
23
|
+
getBytesEncoder,
|
|
24
|
+
getI64Decoder,
|
|
25
|
+
getI64Encoder,
|
|
26
|
+
getStructDecoder,
|
|
27
|
+
getStructEncoder,
|
|
28
|
+
getU64Decoder,
|
|
29
|
+
getU64Encoder,
|
|
30
|
+
getU8Decoder,
|
|
31
|
+
getU8Encoder,
|
|
32
|
+
transformEncoder,
|
|
33
|
+
type Account,
|
|
34
|
+
type Address,
|
|
35
|
+
type EncodedAccount,
|
|
36
|
+
type FetchAccountConfig,
|
|
37
|
+
type FetchAccountsConfig,
|
|
38
|
+
type FixedSizeCodec,
|
|
39
|
+
type FixedSizeDecoder,
|
|
40
|
+
type FixedSizeEncoder,
|
|
41
|
+
type MaybeAccount,
|
|
42
|
+
type MaybeEncodedAccount,
|
|
43
|
+
type ReadonlyUint8Array,
|
|
44
|
+
} from "@solana/kit";
|
|
45
|
+
|
|
46
|
+
export const MAKER_COLLATERAL_SHARE_DISCRIMINATOR = new Uint8Array([
|
|
47
|
+
44, 113, 163, 132, 92, 188, 13, 158,
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
export function getMakerCollateralShareDiscriminatorBytes() {
|
|
51
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
52
|
+
MAKER_COLLATERAL_SHARE_DISCRIMINATOR,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type MakerCollateralShare = {
|
|
57
|
+
discriminator: ReadonlyUint8Array;
|
|
58
|
+
maker: Address;
|
|
59
|
+
collateralPool: Address;
|
|
60
|
+
optionAccount: Address;
|
|
61
|
+
collateralProvided: bigint;
|
|
62
|
+
borrowedAmount: bigint;
|
|
63
|
+
interestOwed: bigint;
|
|
64
|
+
quantityBacked: bigint;
|
|
65
|
+
premiumCollected: bigint;
|
|
66
|
+
exercisePayout: bigint;
|
|
67
|
+
lenderRepayment: bigint;
|
|
68
|
+
makerReturn: bigint;
|
|
69
|
+
isSettled: boolean;
|
|
70
|
+
realizedPnl: bigint;
|
|
71
|
+
createdAt: bigint;
|
|
72
|
+
lastUpdated: bigint;
|
|
73
|
+
bump: number;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export type MakerCollateralShareArgs = {
|
|
77
|
+
maker: Address;
|
|
78
|
+
collateralPool: Address;
|
|
79
|
+
optionAccount: Address;
|
|
80
|
+
collateralProvided: number | bigint;
|
|
81
|
+
borrowedAmount: number | bigint;
|
|
82
|
+
interestOwed: number | bigint;
|
|
83
|
+
quantityBacked: number | bigint;
|
|
84
|
+
premiumCollected: number | bigint;
|
|
85
|
+
exercisePayout: number | bigint;
|
|
86
|
+
lenderRepayment: number | bigint;
|
|
87
|
+
makerReturn: number | bigint;
|
|
88
|
+
isSettled: boolean;
|
|
89
|
+
realizedPnl: number | bigint;
|
|
90
|
+
createdAt: number | bigint;
|
|
91
|
+
lastUpdated: number | bigint;
|
|
92
|
+
bump: number;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/** Gets the encoder for {@link MakerCollateralShareArgs} account data. */
|
|
96
|
+
export function getMakerCollateralShareEncoder(): FixedSizeEncoder<MakerCollateralShareArgs> {
|
|
97
|
+
return transformEncoder(
|
|
98
|
+
getStructEncoder([
|
|
99
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
100
|
+
["maker", getAddressEncoder()],
|
|
101
|
+
["collateralPool", getAddressEncoder()],
|
|
102
|
+
["optionAccount", getAddressEncoder()],
|
|
103
|
+
["collateralProvided", getU64Encoder()],
|
|
104
|
+
["borrowedAmount", getU64Encoder()],
|
|
105
|
+
["interestOwed", getU64Encoder()],
|
|
106
|
+
["quantityBacked", getU64Encoder()],
|
|
107
|
+
["premiumCollected", getU64Encoder()],
|
|
108
|
+
["exercisePayout", getU64Encoder()],
|
|
109
|
+
["lenderRepayment", getU64Encoder()],
|
|
110
|
+
["makerReturn", getU64Encoder()],
|
|
111
|
+
["isSettled", getBooleanEncoder()],
|
|
112
|
+
["realizedPnl", getI64Encoder()],
|
|
113
|
+
["createdAt", getI64Encoder()],
|
|
114
|
+
["lastUpdated", getI64Encoder()],
|
|
115
|
+
["bump", getU8Encoder()],
|
|
116
|
+
]),
|
|
117
|
+
(value) => ({
|
|
118
|
+
...value,
|
|
119
|
+
discriminator: MAKER_COLLATERAL_SHARE_DISCRIMINATOR,
|
|
120
|
+
}),
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Gets the decoder for {@link MakerCollateralShare} account data. */
|
|
125
|
+
export function getMakerCollateralShareDecoder(): FixedSizeDecoder<MakerCollateralShare> {
|
|
126
|
+
return getStructDecoder([
|
|
127
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
128
|
+
["maker", getAddressDecoder()],
|
|
129
|
+
["collateralPool", getAddressDecoder()],
|
|
130
|
+
["optionAccount", getAddressDecoder()],
|
|
131
|
+
["collateralProvided", getU64Decoder()],
|
|
132
|
+
["borrowedAmount", getU64Decoder()],
|
|
133
|
+
["interestOwed", getU64Decoder()],
|
|
134
|
+
["quantityBacked", getU64Decoder()],
|
|
135
|
+
["premiumCollected", getU64Decoder()],
|
|
136
|
+
["exercisePayout", getU64Decoder()],
|
|
137
|
+
["lenderRepayment", getU64Decoder()],
|
|
138
|
+
["makerReturn", getU64Decoder()],
|
|
139
|
+
["isSettled", getBooleanDecoder()],
|
|
140
|
+
["realizedPnl", getI64Decoder()],
|
|
141
|
+
["createdAt", getI64Decoder()],
|
|
142
|
+
["lastUpdated", getI64Decoder()],
|
|
143
|
+
["bump", getU8Decoder()],
|
|
144
|
+
]);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Gets the codec for {@link MakerCollateralShare} account data. */
|
|
148
|
+
export function getMakerCollateralShareCodec(): FixedSizeCodec<
|
|
149
|
+
MakerCollateralShareArgs,
|
|
150
|
+
MakerCollateralShare
|
|
151
|
+
> {
|
|
152
|
+
return combineCodec(
|
|
153
|
+
getMakerCollateralShareEncoder(),
|
|
154
|
+
getMakerCollateralShareDecoder(),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function decodeMakerCollateralShare<TAddress extends string = string>(
|
|
159
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
160
|
+
): Account<MakerCollateralShare, TAddress>;
|
|
161
|
+
export function decodeMakerCollateralShare<TAddress extends string = string>(
|
|
162
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
163
|
+
): MaybeAccount<MakerCollateralShare, TAddress>;
|
|
164
|
+
export function decodeMakerCollateralShare<TAddress extends string = string>(
|
|
165
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
166
|
+
):
|
|
167
|
+
| Account<MakerCollateralShare, TAddress>
|
|
168
|
+
| MaybeAccount<MakerCollateralShare, TAddress> {
|
|
169
|
+
return decodeAccount(
|
|
170
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
171
|
+
getMakerCollateralShareDecoder(),
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function fetchMakerCollateralShare<
|
|
176
|
+
TAddress extends string = string,
|
|
177
|
+
>(
|
|
178
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
179
|
+
address: Address<TAddress>,
|
|
180
|
+
config?: FetchAccountConfig,
|
|
181
|
+
): Promise<Account<MakerCollateralShare, TAddress>> {
|
|
182
|
+
const maybeAccount = await fetchMaybeMakerCollateralShare(
|
|
183
|
+
rpc,
|
|
184
|
+
address,
|
|
185
|
+
config,
|
|
186
|
+
);
|
|
187
|
+
assertAccountExists(maybeAccount);
|
|
188
|
+
return maybeAccount;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function fetchMaybeMakerCollateralShare<
|
|
192
|
+
TAddress extends string = string,
|
|
193
|
+
>(
|
|
194
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
195
|
+
address: Address<TAddress>,
|
|
196
|
+
config?: FetchAccountConfig,
|
|
197
|
+
): Promise<MaybeAccount<MakerCollateralShare, TAddress>> {
|
|
198
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
199
|
+
return decodeMakerCollateralShare(maybeAccount);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export async function fetchAllMakerCollateralShare(
|
|
203
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
204
|
+
addresses: Array<Address>,
|
|
205
|
+
config?: FetchAccountsConfig,
|
|
206
|
+
): Promise<Account<MakerCollateralShare>[]> {
|
|
207
|
+
const maybeAccounts = await fetchAllMaybeMakerCollateralShare(
|
|
208
|
+
rpc,
|
|
209
|
+
addresses,
|
|
210
|
+
config,
|
|
211
|
+
);
|
|
212
|
+
assertAccountsExist(maybeAccounts);
|
|
213
|
+
return maybeAccounts;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export async function fetchAllMaybeMakerCollateralShare(
|
|
217
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
218
|
+
addresses: Array<Address>,
|
|
219
|
+
config?: FetchAccountsConfig,
|
|
220
|
+
): Promise<MaybeAccount<MakerCollateralShare>[]> {
|
|
221
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
222
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
223
|
+
decodeMakerCollateralShare(maybeAccount),
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function getMakerCollateralShareSize(): number {
|
|
228
|
+
return 194;
|
|
229
|
+
}
|