@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,156 @@
|
|
|
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
|
+
getOptionDecoder,
|
|
23
|
+
getOptionEncoder,
|
|
24
|
+
getStructDecoder,
|
|
25
|
+
getStructEncoder,
|
|
26
|
+
getU8Decoder,
|
|
27
|
+
getU8Encoder,
|
|
28
|
+
transformEncoder,
|
|
29
|
+
type Account,
|
|
30
|
+
type Address,
|
|
31
|
+
type Codec,
|
|
32
|
+
type Decoder,
|
|
33
|
+
type EncodedAccount,
|
|
34
|
+
type Encoder,
|
|
35
|
+
type FetchAccountConfig,
|
|
36
|
+
type FetchAccountsConfig,
|
|
37
|
+
type MaybeAccount,
|
|
38
|
+
type MaybeEncodedAccount,
|
|
39
|
+
type Option,
|
|
40
|
+
type OptionOrNullable,
|
|
41
|
+
type ReadonlyUint8Array,
|
|
42
|
+
} from "@solana/kit";
|
|
43
|
+
|
|
44
|
+
export const CONFIG_DISCRIMINATOR = new Uint8Array([
|
|
45
|
+
155, 12, 170, 224, 30, 250, 204, 130,
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
export function getConfigDiscriminatorBytes() {
|
|
49
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(CONFIG_DISCRIMINATOR);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type Config = {
|
|
53
|
+
discriminator: ReadonlyUint8Array;
|
|
54
|
+
/** Current admin authority (governance multisig or hot wallet) */
|
|
55
|
+
admin: Address;
|
|
56
|
+
/** Optional pending admin for two-step transfer */
|
|
57
|
+
pendingAdmin: Option<Address>;
|
|
58
|
+
/** Protocol flags (reserved for future use: pausing, etc.) */
|
|
59
|
+
flags: number;
|
|
60
|
+
/** PDA bump */
|
|
61
|
+
bump: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export type ConfigArgs = {
|
|
65
|
+
/** Current admin authority (governance multisig or hot wallet) */
|
|
66
|
+
admin: Address;
|
|
67
|
+
/** Optional pending admin for two-step transfer */
|
|
68
|
+
pendingAdmin: OptionOrNullable<Address>;
|
|
69
|
+
/** Protocol flags (reserved for future use: pausing, etc.) */
|
|
70
|
+
flags: number;
|
|
71
|
+
/** PDA bump */
|
|
72
|
+
bump: number;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Gets the encoder for {@link ConfigArgs} account data. */
|
|
76
|
+
export function getConfigEncoder(): Encoder<ConfigArgs> {
|
|
77
|
+
return transformEncoder(
|
|
78
|
+
getStructEncoder([
|
|
79
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
80
|
+
["admin", getAddressEncoder()],
|
|
81
|
+
["pendingAdmin", getOptionEncoder(getAddressEncoder())],
|
|
82
|
+
["flags", getU8Encoder()],
|
|
83
|
+
["bump", getU8Encoder()],
|
|
84
|
+
]),
|
|
85
|
+
(value) => ({ ...value, discriminator: CONFIG_DISCRIMINATOR }),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Gets the decoder for {@link Config} account data. */
|
|
90
|
+
export function getConfigDecoder(): Decoder<Config> {
|
|
91
|
+
return getStructDecoder([
|
|
92
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
93
|
+
["admin", getAddressDecoder()],
|
|
94
|
+
["pendingAdmin", getOptionDecoder(getAddressDecoder())],
|
|
95
|
+
["flags", getU8Decoder()],
|
|
96
|
+
["bump", getU8Decoder()],
|
|
97
|
+
]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Gets the codec for {@link Config} account data. */
|
|
101
|
+
export function getConfigCodec(): Codec<ConfigArgs, Config> {
|
|
102
|
+
return combineCodec(getConfigEncoder(), getConfigDecoder());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function decodeConfig<TAddress extends string = string>(
|
|
106
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
107
|
+
): Account<Config, TAddress>;
|
|
108
|
+
export function decodeConfig<TAddress extends string = string>(
|
|
109
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
110
|
+
): MaybeAccount<Config, TAddress>;
|
|
111
|
+
export function decodeConfig<TAddress extends string = string>(
|
|
112
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
113
|
+
): Account<Config, TAddress> | MaybeAccount<Config, TAddress> {
|
|
114
|
+
return decodeAccount(
|
|
115
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
116
|
+
getConfigDecoder(),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export async function fetchConfig<TAddress extends string = string>(
|
|
121
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
122
|
+
address: Address<TAddress>,
|
|
123
|
+
config?: FetchAccountConfig,
|
|
124
|
+
): Promise<Account<Config, TAddress>> {
|
|
125
|
+
const maybeAccount = await fetchMaybeConfig(rpc, address, config);
|
|
126
|
+
assertAccountExists(maybeAccount);
|
|
127
|
+
return maybeAccount;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export async function fetchMaybeConfig<TAddress extends string = string>(
|
|
131
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
132
|
+
address: Address<TAddress>,
|
|
133
|
+
config?: FetchAccountConfig,
|
|
134
|
+
): Promise<MaybeAccount<Config, TAddress>> {
|
|
135
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
136
|
+
return decodeConfig(maybeAccount);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export async function fetchAllConfig(
|
|
140
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
141
|
+
addresses: Array<Address>,
|
|
142
|
+
config?: FetchAccountsConfig,
|
|
143
|
+
): Promise<Account<Config>[]> {
|
|
144
|
+
const maybeAccounts = await fetchAllMaybeConfig(rpc, addresses, config);
|
|
145
|
+
assertAccountsExist(maybeAccounts);
|
|
146
|
+
return maybeAccounts;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export async function fetchAllMaybeConfig(
|
|
150
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
151
|
+
addresses: Array<Address>,
|
|
152
|
+
config?: FetchAccountsConfig,
|
|
153
|
+
): Promise<MaybeAccount<Config>[]> {
|
|
154
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
155
|
+
return maybeAccounts.map((maybeAccount) => decodeConfig(maybeAccount));
|
|
156
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
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
|
+
getOptionDecoder,
|
|
23
|
+
getOptionEncoder,
|
|
24
|
+
getStructDecoder,
|
|
25
|
+
getStructEncoder,
|
|
26
|
+
getU16Decoder,
|
|
27
|
+
getU16Encoder,
|
|
28
|
+
getU64Decoder,
|
|
29
|
+
getU64Encoder,
|
|
30
|
+
getU8Decoder,
|
|
31
|
+
getU8Encoder,
|
|
32
|
+
transformEncoder,
|
|
33
|
+
type Account,
|
|
34
|
+
type Address,
|
|
35
|
+
type Codec,
|
|
36
|
+
type Decoder,
|
|
37
|
+
type EncodedAccount,
|
|
38
|
+
type Encoder,
|
|
39
|
+
type FetchAccountConfig,
|
|
40
|
+
type FetchAccountsConfig,
|
|
41
|
+
type MaybeAccount,
|
|
42
|
+
type MaybeEncodedAccount,
|
|
43
|
+
type Option,
|
|
44
|
+
type OptionOrNullable,
|
|
45
|
+
type ReadonlyUint8Array,
|
|
46
|
+
} from "@solana/kit";
|
|
47
|
+
import {
|
|
48
|
+
getSap2ProviderDecoder,
|
|
49
|
+
getSap2ProviderEncoder,
|
|
50
|
+
type Sap2Provider,
|
|
51
|
+
type Sap2ProviderArgs,
|
|
52
|
+
} from "../types";
|
|
53
|
+
|
|
54
|
+
export const DUAL_SOURCE_CONTRACT_DISCRIMINATOR = new Uint8Array([
|
|
55
|
+
114, 105, 97, 181, 162, 170, 126, 215,
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
export function getDualSourceContractDiscriminatorBytes() {
|
|
59
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
60
|
+
DUAL_SOURCE_CONTRACT_DISCRIMINATOR,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type DualSourceContract = {
|
|
65
|
+
discriminator: ReadonlyUint8Array;
|
|
66
|
+
/** Standard contract fields */
|
|
67
|
+
maker: Address;
|
|
68
|
+
/**
|
|
69
|
+
* Escrow account where borrowed funds were deposited
|
|
70
|
+
* This ensures funds can only be used for collateral, not misappropriated
|
|
71
|
+
*/
|
|
72
|
+
escrowAccount: Address;
|
|
73
|
+
principal: bigint;
|
|
74
|
+
accrued: bigint;
|
|
75
|
+
healthBps: number;
|
|
76
|
+
startSlot: bigint;
|
|
77
|
+
lastUpdateSlot: bigint;
|
|
78
|
+
status: number;
|
|
79
|
+
collateralFrozen: bigint;
|
|
80
|
+
nonce: bigint;
|
|
81
|
+
/** Liquidity source tracking */
|
|
82
|
+
sap1Amount: bigint;
|
|
83
|
+
sap2Amount: bigint;
|
|
84
|
+
sap1Offer: Option<Address>;
|
|
85
|
+
sap2LoanId: Option<bigint>;
|
|
86
|
+
sap2Provider: Option<Sap2Provider>;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export type DualSourceContractArgs = {
|
|
90
|
+
/** Standard contract fields */
|
|
91
|
+
maker: Address;
|
|
92
|
+
/**
|
|
93
|
+
* Escrow account where borrowed funds were deposited
|
|
94
|
+
* This ensures funds can only be used for collateral, not misappropriated
|
|
95
|
+
*/
|
|
96
|
+
escrowAccount: Address;
|
|
97
|
+
principal: number | bigint;
|
|
98
|
+
accrued: number | bigint;
|
|
99
|
+
healthBps: number;
|
|
100
|
+
startSlot: number | bigint;
|
|
101
|
+
lastUpdateSlot: number | bigint;
|
|
102
|
+
status: number;
|
|
103
|
+
collateralFrozen: number | bigint;
|
|
104
|
+
nonce: number | bigint;
|
|
105
|
+
/** Liquidity source tracking */
|
|
106
|
+
sap1Amount: number | bigint;
|
|
107
|
+
sap2Amount: number | bigint;
|
|
108
|
+
sap1Offer: OptionOrNullable<Address>;
|
|
109
|
+
sap2LoanId: OptionOrNullable<number | bigint>;
|
|
110
|
+
sap2Provider: OptionOrNullable<Sap2ProviderArgs>;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Gets the encoder for {@link DualSourceContractArgs} account data. */
|
|
114
|
+
export function getDualSourceContractEncoder(): Encoder<DualSourceContractArgs> {
|
|
115
|
+
return transformEncoder(
|
|
116
|
+
getStructEncoder([
|
|
117
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
118
|
+
["maker", getAddressEncoder()],
|
|
119
|
+
["escrowAccount", getAddressEncoder()],
|
|
120
|
+
["principal", getU64Encoder()],
|
|
121
|
+
["accrued", getU64Encoder()],
|
|
122
|
+
["healthBps", getU16Encoder()],
|
|
123
|
+
["startSlot", getU64Encoder()],
|
|
124
|
+
["lastUpdateSlot", getU64Encoder()],
|
|
125
|
+
["status", getU8Encoder()],
|
|
126
|
+
["collateralFrozen", getU64Encoder()],
|
|
127
|
+
["nonce", getU64Encoder()],
|
|
128
|
+
["sap1Amount", getU64Encoder()],
|
|
129
|
+
["sap2Amount", getU64Encoder()],
|
|
130
|
+
["sap1Offer", getOptionEncoder(getAddressEncoder())],
|
|
131
|
+
["sap2LoanId", getOptionEncoder(getU64Encoder())],
|
|
132
|
+
["sap2Provider", getOptionEncoder(getSap2ProviderEncoder())],
|
|
133
|
+
]),
|
|
134
|
+
(value) => ({
|
|
135
|
+
...value,
|
|
136
|
+
discriminator: DUAL_SOURCE_CONTRACT_DISCRIMINATOR,
|
|
137
|
+
}),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** Gets the decoder for {@link DualSourceContract} account data. */
|
|
142
|
+
export function getDualSourceContractDecoder(): Decoder<DualSourceContract> {
|
|
143
|
+
return getStructDecoder([
|
|
144
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
145
|
+
["maker", getAddressDecoder()],
|
|
146
|
+
["escrowAccount", getAddressDecoder()],
|
|
147
|
+
["principal", getU64Decoder()],
|
|
148
|
+
["accrued", getU64Decoder()],
|
|
149
|
+
["healthBps", getU16Decoder()],
|
|
150
|
+
["startSlot", getU64Decoder()],
|
|
151
|
+
["lastUpdateSlot", getU64Decoder()],
|
|
152
|
+
["status", getU8Decoder()],
|
|
153
|
+
["collateralFrozen", getU64Decoder()],
|
|
154
|
+
["nonce", getU64Decoder()],
|
|
155
|
+
["sap1Amount", getU64Decoder()],
|
|
156
|
+
["sap2Amount", getU64Decoder()],
|
|
157
|
+
["sap1Offer", getOptionDecoder(getAddressDecoder())],
|
|
158
|
+
["sap2LoanId", getOptionDecoder(getU64Decoder())],
|
|
159
|
+
["sap2Provider", getOptionDecoder(getSap2ProviderDecoder())],
|
|
160
|
+
]);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Gets the codec for {@link DualSourceContract} account data. */
|
|
164
|
+
export function getDualSourceContractCodec(): Codec<
|
|
165
|
+
DualSourceContractArgs,
|
|
166
|
+
DualSourceContract
|
|
167
|
+
> {
|
|
168
|
+
return combineCodec(
|
|
169
|
+
getDualSourceContractEncoder(),
|
|
170
|
+
getDualSourceContractDecoder(),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function decodeDualSourceContract<TAddress extends string = string>(
|
|
175
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
176
|
+
): Account<DualSourceContract, TAddress>;
|
|
177
|
+
export function decodeDualSourceContract<TAddress extends string = string>(
|
|
178
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
179
|
+
): MaybeAccount<DualSourceContract, TAddress>;
|
|
180
|
+
export function decodeDualSourceContract<TAddress extends string = string>(
|
|
181
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
182
|
+
):
|
|
183
|
+
| Account<DualSourceContract, TAddress>
|
|
184
|
+
| MaybeAccount<DualSourceContract, TAddress> {
|
|
185
|
+
return decodeAccount(
|
|
186
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
187
|
+
getDualSourceContractDecoder(),
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export async function fetchDualSourceContract<TAddress extends string = string>(
|
|
192
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
193
|
+
address: Address<TAddress>,
|
|
194
|
+
config?: FetchAccountConfig,
|
|
195
|
+
): Promise<Account<DualSourceContract, TAddress>> {
|
|
196
|
+
const maybeAccount = await fetchMaybeDualSourceContract(rpc, address, config);
|
|
197
|
+
assertAccountExists(maybeAccount);
|
|
198
|
+
return maybeAccount;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export async function fetchMaybeDualSourceContract<
|
|
202
|
+
TAddress extends string = string,
|
|
203
|
+
>(
|
|
204
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
205
|
+
address: Address<TAddress>,
|
|
206
|
+
config?: FetchAccountConfig,
|
|
207
|
+
): Promise<MaybeAccount<DualSourceContract, TAddress>> {
|
|
208
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
209
|
+
return decodeDualSourceContract(maybeAccount);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export async function fetchAllDualSourceContract(
|
|
213
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
214
|
+
addresses: Array<Address>,
|
|
215
|
+
config?: FetchAccountsConfig,
|
|
216
|
+
): Promise<Account<DualSourceContract>[]> {
|
|
217
|
+
const maybeAccounts = await fetchAllMaybeDualSourceContract(
|
|
218
|
+
rpc,
|
|
219
|
+
addresses,
|
|
220
|
+
config,
|
|
221
|
+
);
|
|
222
|
+
assertAccountsExist(maybeAccounts);
|
|
223
|
+
return maybeAccounts;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export async function fetchAllMaybeDualSourceContract(
|
|
227
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
228
|
+
addresses: Array<Address>,
|
|
229
|
+
config?: FetchAccountsConfig,
|
|
230
|
+
): Promise<MaybeAccount<DualSourceContract>[]> {
|
|
231
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
232
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
233
|
+
decodeDualSourceContract(maybeAccount),
|
|
234
|
+
);
|
|
235
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
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
|
+
getU64Decoder,
|
|
27
|
+
getU64Encoder,
|
|
28
|
+
getU8Decoder,
|
|
29
|
+
getU8Encoder,
|
|
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
|
+
|
|
44
|
+
export const ESCROW_STATE_DISCRIMINATOR = new Uint8Array([
|
|
45
|
+
19, 90, 148, 111, 55, 130, 229, 108,
|
|
46
|
+
]);
|
|
47
|
+
|
|
48
|
+
export function getEscrowStateDiscriminatorBytes() {
|
|
49
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
50
|
+
ESCROW_STATE_DISCRIMINATOR,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type EscrowState = {
|
|
55
|
+
discriminator: ReadonlyUint8Array;
|
|
56
|
+
/** The maker who owns this escrow */
|
|
57
|
+
maker: Address;
|
|
58
|
+
/** The collateral mint (e.g., WSOL) */
|
|
59
|
+
collateralMint: Address;
|
|
60
|
+
/** PDA bump */
|
|
61
|
+
bump: number;
|
|
62
|
+
/** Total deposited to escrow (maker's own funds + borrowed) */
|
|
63
|
+
deposited: bigint;
|
|
64
|
+
/** Total borrowed principal from OMLP */
|
|
65
|
+
borrowedPrincipal: bigint;
|
|
66
|
+
/** Total repaid to lenders */
|
|
67
|
+
repaidTotal: bigint;
|
|
68
|
+
/** Creation timestamp */
|
|
69
|
+
createdAt: bigint;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type EscrowStateArgs = {
|
|
73
|
+
/** The maker who owns this escrow */
|
|
74
|
+
maker: Address;
|
|
75
|
+
/** The collateral mint (e.g., WSOL) */
|
|
76
|
+
collateralMint: Address;
|
|
77
|
+
/** PDA bump */
|
|
78
|
+
bump: number;
|
|
79
|
+
/** Total deposited to escrow (maker's own funds + borrowed) */
|
|
80
|
+
deposited: number | bigint;
|
|
81
|
+
/** Total borrowed principal from OMLP */
|
|
82
|
+
borrowedPrincipal: number | bigint;
|
|
83
|
+
/** Total repaid to lenders */
|
|
84
|
+
repaidTotal: number | bigint;
|
|
85
|
+
/** Creation timestamp */
|
|
86
|
+
createdAt: number | bigint;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Gets the encoder for {@link EscrowStateArgs} account data. */
|
|
90
|
+
export function getEscrowStateEncoder(): FixedSizeEncoder<EscrowStateArgs> {
|
|
91
|
+
return transformEncoder(
|
|
92
|
+
getStructEncoder([
|
|
93
|
+
["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
|
|
94
|
+
["maker", getAddressEncoder()],
|
|
95
|
+
["collateralMint", getAddressEncoder()],
|
|
96
|
+
["bump", getU8Encoder()],
|
|
97
|
+
["deposited", getU64Encoder()],
|
|
98
|
+
["borrowedPrincipal", getU64Encoder()],
|
|
99
|
+
["repaidTotal", getU64Encoder()],
|
|
100
|
+
["createdAt", getI64Encoder()],
|
|
101
|
+
]),
|
|
102
|
+
(value) => ({ ...value, discriminator: ESCROW_STATE_DISCRIMINATOR }),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Gets the decoder for {@link EscrowState} account data. */
|
|
107
|
+
export function getEscrowStateDecoder(): FixedSizeDecoder<EscrowState> {
|
|
108
|
+
return getStructDecoder([
|
|
109
|
+
["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
|
|
110
|
+
["maker", getAddressDecoder()],
|
|
111
|
+
["collateralMint", getAddressDecoder()],
|
|
112
|
+
["bump", getU8Decoder()],
|
|
113
|
+
["deposited", getU64Decoder()],
|
|
114
|
+
["borrowedPrincipal", getU64Decoder()],
|
|
115
|
+
["repaidTotal", getU64Decoder()],
|
|
116
|
+
["createdAt", getI64Decoder()],
|
|
117
|
+
]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** Gets the codec for {@link EscrowState} account data. */
|
|
121
|
+
export function getEscrowStateCodec(): FixedSizeCodec<
|
|
122
|
+
EscrowStateArgs,
|
|
123
|
+
EscrowState
|
|
124
|
+
> {
|
|
125
|
+
return combineCodec(getEscrowStateEncoder(), getEscrowStateDecoder());
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function decodeEscrowState<TAddress extends string = string>(
|
|
129
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
130
|
+
): Account<EscrowState, TAddress>;
|
|
131
|
+
export function decodeEscrowState<TAddress extends string = string>(
|
|
132
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
133
|
+
): MaybeAccount<EscrowState, TAddress>;
|
|
134
|
+
export function decodeEscrowState<TAddress extends string = string>(
|
|
135
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
136
|
+
): Account<EscrowState, TAddress> | MaybeAccount<EscrowState, TAddress> {
|
|
137
|
+
return decodeAccount(
|
|
138
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
139
|
+
getEscrowStateDecoder(),
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export async function fetchEscrowState<TAddress extends string = string>(
|
|
144
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
145
|
+
address: Address<TAddress>,
|
|
146
|
+
config?: FetchAccountConfig,
|
|
147
|
+
): Promise<Account<EscrowState, TAddress>> {
|
|
148
|
+
const maybeAccount = await fetchMaybeEscrowState(rpc, address, config);
|
|
149
|
+
assertAccountExists(maybeAccount);
|
|
150
|
+
return maybeAccount;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export async function fetchMaybeEscrowState<TAddress extends string = string>(
|
|
154
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
155
|
+
address: Address<TAddress>,
|
|
156
|
+
config?: FetchAccountConfig,
|
|
157
|
+
): Promise<MaybeAccount<EscrowState, TAddress>> {
|
|
158
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
159
|
+
return decodeEscrowState(maybeAccount);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export async function fetchAllEscrowState(
|
|
163
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
164
|
+
addresses: Array<Address>,
|
|
165
|
+
config?: FetchAccountsConfig,
|
|
166
|
+
): Promise<Account<EscrowState>[]> {
|
|
167
|
+
const maybeAccounts = await fetchAllMaybeEscrowState(rpc, addresses, config);
|
|
168
|
+
assertAccountsExist(maybeAccounts);
|
|
169
|
+
return maybeAccounts;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export async function fetchAllMaybeEscrowState(
|
|
173
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
174
|
+
addresses: Array<Address>,
|
|
175
|
+
config?: FetchAccountsConfig,
|
|
176
|
+
): Promise<MaybeAccount<EscrowState>[]> {
|
|
177
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
178
|
+
return maybeAccounts.map((maybeAccount) => decodeEscrowState(maybeAccount));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export function getEscrowStateSize(): number {
|
|
182
|
+
return 105;
|
|
183
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
export * from "./collateralPool";
|
|
10
|
+
export * from "./config";
|
|
11
|
+
export * from "./dualSourceContract";
|
|
12
|
+
export * from "./escrowState";
|
|
13
|
+
export * from "./lenderPosition";
|
|
14
|
+
export * from "./liquidityRouter";
|
|
15
|
+
export * from "./makerCollateralShare";
|
|
16
|
+
export * from "./makerPoolShare";
|
|
17
|
+
export * from "./marketDataAccount";
|
|
18
|
+
export * from "./optionAccount";
|
|
19
|
+
export * from "./optionPool";
|
|
20
|
+
export * from "./poolLoan";
|
|
21
|
+
export * from "./positionAccount";
|
|
22
|
+
export * from "./priceUpdateV2";
|
|
23
|
+
export * from "./vault";
|
|
24
|
+
export * from "./writerPosition";
|