@exponent-labs/exponent-types 0.1.7 → 0.1.8
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/build/cpi.d.ts +32 -0
- package/build/cpi.js.map +1 -1
- package/build/generic.d.ts +56 -1
- package/build/generic.js +87 -1
- package/build/generic.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.js +1 -0
- package/build/index.js.map +1 -1
- package/build/kamino.d.ts +2 -0
- package/build/orderbook.d.ts +145 -0
- package/build/orderbook.js +13 -0
- package/build/orderbook.js.map +1 -0
- package/build/vault.d.ts +37 -0
- package/package.json +3 -2
- package/src/cpi.ts +40 -0
- package/src/generic.ts +149 -1
- package/src/index.ts +2 -1
- package/src/kamino.ts +2 -0
- package/src/orderbook.ts +187 -0
- package/src/vault.ts +65 -0
package/build/cpi.d.ts
CHANGED
|
@@ -12,6 +12,14 @@ export interface CpiMeta<T> {
|
|
|
12
12
|
claimEmission: T[][];
|
|
13
13
|
getPositionState: T[];
|
|
14
14
|
}
|
|
15
|
+
/** Generic container for ExponentCore CPI account lists */
|
|
16
|
+
export interface ExponentCoreCpiMeta<T> {
|
|
17
|
+
depositYt: T[];
|
|
18
|
+
withdrawYt: T[];
|
|
19
|
+
stripSy: T[];
|
|
20
|
+
mergeSy: T[];
|
|
21
|
+
collectInterest: T[];
|
|
22
|
+
}
|
|
15
23
|
/** The on-chain storage for CPI accounts, which references an ALT */
|
|
16
24
|
export interface CpiAccountIndex {
|
|
17
25
|
/** Index in the Address Lookup Table */
|
|
@@ -21,8 +29,12 @@ export interface CpiAccountIndex {
|
|
|
21
29
|
}
|
|
22
30
|
/** Raw account infos for CPI that include the Pubkey */
|
|
23
31
|
export type CpiAccountsRaw = CpiMeta<AccountInfo>;
|
|
32
|
+
/** Raw account infos for CPI that include the Pubkey */
|
|
33
|
+
export type ExponentCoreCpiAccountsRaw = ExponentCoreCpiMeta<AccountInfo>;
|
|
24
34
|
/** This account is stored in state on the vault/market to track indexes in the ALT */
|
|
25
35
|
export type CpiAccountIndexes = CpiMeta<CpiAccountIndex>;
|
|
36
|
+
/** This account is stored in state on the vault/market to track indexes in the ALT */
|
|
37
|
+
export type ExponentCoreCpiIndexes = ExponentCoreCpiMeta<CpiAccountIndex>;
|
|
26
38
|
export interface CpiAccountsRawJson {
|
|
27
39
|
getSyState: AccountInfoJson[];
|
|
28
40
|
withdrawSy: AccountInfoJson[];
|
|
@@ -30,6 +42,13 @@ export interface CpiAccountsRawJson {
|
|
|
30
42
|
claimEmission: AccountInfoJson[][];
|
|
31
43
|
getPositionState: AccountInfoJson[];
|
|
32
44
|
}
|
|
45
|
+
export interface ExponentCoreCpiAccountsRawJson {
|
|
46
|
+
depositYt: AccountInfoJson[];
|
|
47
|
+
withdrawYt: AccountInfoJson[];
|
|
48
|
+
stripSy: AccountInfoJson[];
|
|
49
|
+
mergeSy: AccountInfoJson[];
|
|
50
|
+
collectInterest: AccountInfoJson[];
|
|
51
|
+
}
|
|
33
52
|
export type AccountInfoJson = {
|
|
34
53
|
pubkey: string;
|
|
35
54
|
isSigner: boolean;
|
|
@@ -37,3 +56,16 @@ export type AccountInfoJson = {
|
|
|
37
56
|
};
|
|
38
57
|
export declare function deserializeCpiAccountsRaw(serialized: CpiAccountsRawJson): CpiAccountsRaw;
|
|
39
58
|
export declare function serializeCpiAccountsRaw(cpiAccounts: CpiAccountsRaw): CpiAccountsRawJson;
|
|
59
|
+
/** MarketThree/CLMM only uses a subset of ExponentCore CPI accounts (strip and merge) */
|
|
60
|
+
export interface MarketCpiCoreMeta<T> {
|
|
61
|
+
stripSy: T[];
|
|
62
|
+
mergeSy: T[];
|
|
63
|
+
}
|
|
64
|
+
export interface MarketCpiCoreAccountsRawJson {
|
|
65
|
+
stripSy: AccountInfoJson[];
|
|
66
|
+
mergeSy: AccountInfoJson[];
|
|
67
|
+
}
|
|
68
|
+
/** Type alias for MarketThree's CPI core accounts with pubkeys */
|
|
69
|
+
export type MarketCpiCoreAccountsRaw = MarketCpiCoreMeta<AccountInfo>;
|
|
70
|
+
/** Type alias for MarketThree's CPI core accounts stored in state */
|
|
71
|
+
export type MarketCpiCoreIndexes = MarketCpiCoreMeta<CpiAccountIndex>;
|
package/build/cpi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cpi.js","sourceRoot":"","sources":["../src/cpi.ts"],"names":[],"mappings":";;;AAAA,8CAAwC;
|
|
1
|
+
{"version":3,"file":"cpi.js","sourceRoot":"","sources":["../src/cpi.ts"],"names":[],"mappings":";;;AAAA,8CAAwC;AAoExC,SAAgB,yBAAyB,CAAC,UAA8B;IACtE,MAAM,sBAAsB,GAAG,CAAC,WAA4B,EAAe,EAAE,CAAC,CAAC;QAC7E,MAAM,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC;QAC9C,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,UAAU,EAAE,WAAW,CAAC,UAAU;KACnC,CAAC,CAAA;IACF,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC7D,UAAU,EAAE,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC7D,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,sBAAsB,CAAC;QAC3D,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAC/F,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,CAAC,GAAG,CAAC,sBAAsB,CAAC;KAC1E,CAAA;AACH,CAAC;AAbD,8DAaC;AAED,SAAgB,uBAAuB,CAAC,WAA2B;IACjE,MAAM,oBAAoB,GAAG,CAAC,WAAwB,EAAE,EAAE,CAAC,CAAC;QAC1D,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,QAAQ,EAAE;QACrC,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,UAAU,EAAE,WAAW,CAAC,UAAU;KACnC,CAAC,CAAA;IAEF,OAAO;QACL,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,oBAAoB,CAAC;QAC5D,UAAU,EAAE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,oBAAoB,CAAC;QAC5D,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,oBAAoB,CAAC;QAC1D,aAAa,EAAE,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;QAC9F,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,oBAAoB,CAAC;KACzE,CAAA;AACH,CAAC;AAdD,0DAcC"}
|
package/build/generic.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { BN, web3 } from "@coral-xyz/anchor";
|
|
4
4
|
import { AnchorizedPNum, SyEmissionJson, SyEmissionRaw } from "./common";
|
|
5
|
+
import { StakePoolAccount } from "@solana/spl-stake-pool";
|
|
5
6
|
export type InterfaceTypeGeneric = {
|
|
6
7
|
pyth: {
|
|
7
8
|
lastSlot: BN;
|
|
@@ -44,6 +45,12 @@ export type InterfaceTypeGeneric = {
|
|
|
44
45
|
solstice: {
|
|
45
46
|
padding: number[];
|
|
46
47
|
};
|
|
48
|
+
} | {
|
|
49
|
+
reflect: {
|
|
50
|
+
padding: number[];
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
ore: Record<string, never>;
|
|
47
54
|
};
|
|
48
55
|
export type InterfaceTypeGenericJson = {
|
|
49
56
|
pyth: {
|
|
@@ -87,6 +94,12 @@ export type InterfaceTypeGenericJson = {
|
|
|
87
94
|
solstice: {
|
|
88
95
|
padding: number[];
|
|
89
96
|
};
|
|
97
|
+
} | {
|
|
98
|
+
reflect: {
|
|
99
|
+
padding: number[];
|
|
100
|
+
};
|
|
101
|
+
} | {
|
|
102
|
+
ore: Record<string, never>;
|
|
90
103
|
};
|
|
91
104
|
/** Additional data that different interface types may need */
|
|
92
105
|
export interface AdditionalDataGeneric {
|
|
@@ -112,6 +125,15 @@ export interface AdditionalDataGeneric {
|
|
|
112
125
|
baseVaultAuthority: web3.PublicKey;
|
|
113
126
|
sharesMint: web3.PublicKey;
|
|
114
127
|
};
|
|
128
|
+
splStakePoolData?: {
|
|
129
|
+
stakePoolAccount?: StakePoolAccount;
|
|
130
|
+
stakePoolAddress: web3.PublicKey;
|
|
131
|
+
stakePoolProgramId: web3.PublicKey;
|
|
132
|
+
validatorList: web3.PublicKey;
|
|
133
|
+
reserveStake: web3.PublicKey;
|
|
134
|
+
managerFeeAccount: web3.PublicKey;
|
|
135
|
+
poolMint: web3.PublicKey;
|
|
136
|
+
};
|
|
115
137
|
}
|
|
116
138
|
/** JSON version of additional data */
|
|
117
139
|
export interface AdditionalDataGenericJson {
|
|
@@ -122,6 +144,28 @@ export interface AdditionalDataGenericJson {
|
|
|
122
144
|
jupiterLendData?: {
|
|
123
145
|
baseTokenMint: string;
|
|
124
146
|
tokenReservesLiquidity: string;
|
|
147
|
+
lendingSupplyPosition: string;
|
|
148
|
+
rewardsRateModel: string;
|
|
149
|
+
rateModel: string;
|
|
150
|
+
};
|
|
151
|
+
kaminoVaultData?: {
|
|
152
|
+
vault: string;
|
|
153
|
+
reserves: {
|
|
154
|
+
reserveAddress: string;
|
|
155
|
+
marketAddress: string;
|
|
156
|
+
}[];
|
|
157
|
+
tokenVault: string;
|
|
158
|
+
tokenMint: string;
|
|
159
|
+
baseVaultAuthority: string;
|
|
160
|
+
sharesMint: string;
|
|
161
|
+
};
|
|
162
|
+
splStakePoolData?: {
|
|
163
|
+
stakePoolAddress: string;
|
|
164
|
+
stakePoolProgramId: string;
|
|
165
|
+
validatorList: string;
|
|
166
|
+
reserveStake: string;
|
|
167
|
+
managerFeeAccount: string;
|
|
168
|
+
poolMint: string;
|
|
125
169
|
};
|
|
126
170
|
}
|
|
127
171
|
export interface Hook {
|
|
@@ -131,6 +175,13 @@ export interface Hook {
|
|
|
131
175
|
preMintHookDiscriminator: number[];
|
|
132
176
|
postRedeemHookDiscriminator: number[];
|
|
133
177
|
}
|
|
178
|
+
export interface HookJson {
|
|
179
|
+
enabled: boolean;
|
|
180
|
+
interfaceEmissionsAccountsUntil: number;
|
|
181
|
+
programId: string;
|
|
182
|
+
preMintHookDiscriminator: number[];
|
|
183
|
+
postRedeemHookDiscriminator: number[];
|
|
184
|
+
}
|
|
134
185
|
export interface HookRaw {
|
|
135
186
|
enabled: boolean;
|
|
136
187
|
interfaceEmissionsAccountsUntil: number;
|
|
@@ -166,7 +217,7 @@ export interface GenericSyMetaAccountJson {
|
|
|
166
217
|
maxSySupply: string;
|
|
167
218
|
minMintSize: string;
|
|
168
219
|
minRedeemSize: string;
|
|
169
|
-
hook:
|
|
220
|
+
hook: HookJson;
|
|
170
221
|
emissions: SyEmissionJson[];
|
|
171
222
|
index: number;
|
|
172
223
|
}
|
|
@@ -202,6 +253,10 @@ export declare function deserializeGenericSyMetaAccountRaw(raw: GenericSyMetaAcc
|
|
|
202
253
|
export declare function toInterfaceTypeGenericJson(interfaceType: InterfaceTypeGeneric): InterfaceTypeGenericJson;
|
|
203
254
|
/** Convert InterfaceTypeGenericJson to InterfaceTypeGeneric */
|
|
204
255
|
export declare function fromInterfaceTypeGenericJson(json: InterfaceTypeGenericJson): InterfaceTypeGeneric;
|
|
256
|
+
/** Convert Hook to HookJson */
|
|
257
|
+
export declare function toHookJson(hook: Hook): HookJson;
|
|
258
|
+
/** Convert HookJson to Hook */
|
|
259
|
+
export declare function fromHookJson(json: HookJson): Hook;
|
|
205
260
|
/** Convert AdditionalDataGeneric to AdditionalDataGenericJson */
|
|
206
261
|
export declare function toAdditionalDataGenericJson(additionalData: AdditionalDataGeneric): AdditionalDataGenericJson;
|
|
207
262
|
/** Convert AdditionalDataGenericJson to AdditionalDataGeneric */
|
package/build/generic.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFragmetricDataFromAdditionalData = exports.fromAdditionalDataGenericJson = exports.toAdditionalDataGenericJson = exports.fromInterfaceTypeGenericJson = exports.toInterfaceTypeGenericJson = exports.deserializeGenericSyMetaAccountRaw = void 0;
|
|
3
|
+
exports.getFragmetricDataFromAdditionalData = exports.fromAdditionalDataGenericJson = exports.toAdditionalDataGenericJson = exports.fromHookJson = exports.toHookJson = exports.fromInterfaceTypeGenericJson = exports.toInterfaceTypeGenericJson = exports.deserializeGenericSyMetaAccountRaw = void 0;
|
|
4
4
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
5
5
|
function deserializeGenericSyMetaAccountRaw(raw) {
|
|
6
6
|
return {
|
|
@@ -112,6 +112,28 @@ function fromInterfaceTypeGenericJson(json) {
|
|
|
112
112
|
return json;
|
|
113
113
|
}
|
|
114
114
|
exports.fromInterfaceTypeGenericJson = fromInterfaceTypeGenericJson;
|
|
115
|
+
/** Convert Hook to HookJson */
|
|
116
|
+
function toHookJson(hook) {
|
|
117
|
+
return {
|
|
118
|
+
enabled: hook.enabled,
|
|
119
|
+
interfaceEmissionsAccountsUntil: hook.interfaceEmissionsAccountsUntil,
|
|
120
|
+
programId: hook.programId.toString(),
|
|
121
|
+
preMintHookDiscriminator: hook.preMintHookDiscriminator,
|
|
122
|
+
postRedeemHookDiscriminator: hook.postRedeemHookDiscriminator,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
exports.toHookJson = toHookJson;
|
|
126
|
+
/** Convert HookJson to Hook */
|
|
127
|
+
function fromHookJson(json) {
|
|
128
|
+
return {
|
|
129
|
+
enabled: json.enabled,
|
|
130
|
+
interfaceEmissionsAccountsUntil: json.interfaceEmissionsAccountsUntil,
|
|
131
|
+
programId: new anchor_1.web3.PublicKey(json.programId),
|
|
132
|
+
preMintHookDiscriminator: json.preMintHookDiscriminator,
|
|
133
|
+
postRedeemHookDiscriminator: json.postRedeemHookDiscriminator,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
exports.fromHookJson = fromHookJson;
|
|
115
137
|
/** Convert AdditionalDataGeneric to AdditionalDataGenericJson */
|
|
116
138
|
function toAdditionalDataGenericJson(additionalData) {
|
|
117
139
|
const result = {};
|
|
@@ -121,6 +143,38 @@ function toAdditionalDataGenericJson(additionalData) {
|
|
|
121
143
|
wrappedTokenMint: additionalData.fragmetricData.wrappedTokenMint.toString(),
|
|
122
144
|
};
|
|
123
145
|
}
|
|
146
|
+
if (additionalData.jupiterLendData) {
|
|
147
|
+
result.jupiterLendData = {
|
|
148
|
+
baseTokenMint: additionalData.jupiterLendData.baseTokenMint.toString(),
|
|
149
|
+
tokenReservesLiquidity: additionalData.jupiterLendData.tokenReservesLiquidity.toString(),
|
|
150
|
+
lendingSupplyPosition: additionalData.jupiterLendData.lendingSupplyPosition.toString(),
|
|
151
|
+
rewardsRateModel: additionalData.jupiterLendData.rewardsRateModel.toString(),
|
|
152
|
+
rateModel: additionalData.jupiterLendData.rateModel.toString(),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
if (additionalData.kaminoVaultData) {
|
|
156
|
+
result.kaminoVaultData = {
|
|
157
|
+
vault: additionalData.kaminoVaultData.vault.toString(),
|
|
158
|
+
reserves: additionalData.kaminoVaultData.reserves.map((r) => ({
|
|
159
|
+
reserveAddress: r.reserveAddress.toString(),
|
|
160
|
+
marketAddress: r.marketAddress.toString(),
|
|
161
|
+
})),
|
|
162
|
+
tokenVault: additionalData.kaminoVaultData.tokenVault.toString(),
|
|
163
|
+
tokenMint: additionalData.kaminoVaultData.tokenMint.toString(),
|
|
164
|
+
baseVaultAuthority: additionalData.kaminoVaultData.baseVaultAuthority.toString(),
|
|
165
|
+
sharesMint: additionalData.kaminoVaultData.sharesMint.toString(),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (additionalData.splStakePoolData) {
|
|
169
|
+
result.splStakePoolData = {
|
|
170
|
+
stakePoolAddress: additionalData.splStakePoolData.stakePoolAddress.toString(),
|
|
171
|
+
stakePoolProgramId: additionalData.splStakePoolData.stakePoolProgramId.toString(),
|
|
172
|
+
validatorList: additionalData.splStakePoolData.validatorList.toString(),
|
|
173
|
+
reserveStake: additionalData.splStakePoolData.reserveStake.toString(),
|
|
174
|
+
managerFeeAccount: additionalData.splStakePoolData.managerFeeAccount.toString(),
|
|
175
|
+
poolMint: additionalData.splStakePoolData.poolMint.toString(),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
124
178
|
return result;
|
|
125
179
|
}
|
|
126
180
|
exports.toAdditionalDataGenericJson = toAdditionalDataGenericJson;
|
|
@@ -133,6 +187,38 @@ function fromAdditionalDataGenericJson(json) {
|
|
|
133
187
|
wrappedTokenMint: new anchor_1.web3.PublicKey(json.fragmetricData.wrappedTokenMint),
|
|
134
188
|
};
|
|
135
189
|
}
|
|
190
|
+
if (json.jupiterLendData) {
|
|
191
|
+
result.jupiterLendData = {
|
|
192
|
+
baseTokenMint: new anchor_1.web3.PublicKey(json.jupiterLendData.baseTokenMint),
|
|
193
|
+
tokenReservesLiquidity: new anchor_1.web3.PublicKey(json.jupiterLendData.tokenReservesLiquidity),
|
|
194
|
+
lendingSupplyPosition: new anchor_1.web3.PublicKey(json.jupiterLendData.lendingSupplyPosition),
|
|
195
|
+
rewardsRateModel: new anchor_1.web3.PublicKey(json.jupiterLendData.rewardsRateModel),
|
|
196
|
+
rateModel: new anchor_1.web3.PublicKey(json.jupiterLendData.rateModel),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
if (json.kaminoVaultData) {
|
|
200
|
+
result.kaminoVaultData = {
|
|
201
|
+
vault: new anchor_1.web3.PublicKey(json.kaminoVaultData.vault),
|
|
202
|
+
reserves: json.kaminoVaultData.reserves.map((r) => ({
|
|
203
|
+
reserveAddress: new anchor_1.web3.PublicKey(r.reserveAddress),
|
|
204
|
+
marketAddress: new anchor_1.web3.PublicKey(r.marketAddress),
|
|
205
|
+
})),
|
|
206
|
+
tokenVault: new anchor_1.web3.PublicKey(json.kaminoVaultData.tokenVault),
|
|
207
|
+
tokenMint: new anchor_1.web3.PublicKey(json.kaminoVaultData.tokenMint),
|
|
208
|
+
baseVaultAuthority: new anchor_1.web3.PublicKey(json.kaminoVaultData.baseVaultAuthority),
|
|
209
|
+
sharesMint: new anchor_1.web3.PublicKey(json.kaminoVaultData.sharesMint),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (json.splStakePoolData) {
|
|
213
|
+
result.splStakePoolData = {
|
|
214
|
+
stakePoolAddress: new anchor_1.web3.PublicKey(json.splStakePoolData.stakePoolAddress),
|
|
215
|
+
stakePoolProgramId: new anchor_1.web3.PublicKey(json.splStakePoolData.stakePoolProgramId),
|
|
216
|
+
validatorList: new anchor_1.web3.PublicKey(json.splStakePoolData.validatorList),
|
|
217
|
+
reserveStake: new anchor_1.web3.PublicKey(json.splStakePoolData.reserveStake),
|
|
218
|
+
managerFeeAccount: new anchor_1.web3.PublicKey(json.splStakePoolData.managerFeeAccount),
|
|
219
|
+
poolMint: new anchor_1.web3.PublicKey(json.splStakePoolData.poolMint),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
136
222
|
return result;
|
|
137
223
|
}
|
|
138
224
|
exports.fromAdditionalDataGenericJson = fromAdditionalDataGenericJson;
|
package/build/generic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;
|
|
1
|
+
{"version":3,"file":"generic.js","sourceRoot":"","sources":["../src/generic.ts"],"names":[],"mappings":";;;AAAA,8CAA4C;AA0S5C,SAAgB,kCAAkC,CAAC,GAA4B;IA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IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC;YAC/E,UAAU,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC;SAChE,CAAA;IACH,CAAC;IAED,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAC1B,MAAM,CAAC,gBAAgB,GAAG;YACxB,gBAAgB,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,gBAAgB,CAAC;YAC5E,kBAAkB,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC;YAChF,aAAa,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC;YACtE,YAAY,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC;YACpE,iBAAiB,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,CAAC;YAC9E,QAAQ,EAAE,IAAI,aAAI,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC;SAC7D,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AA9CD,sEA8CC;AAED,sEAAsE;AACtE,SAAgB,mCAAmC,CAAC,cAAsC;IAMxF,IAAI,CAAC,cAAc;QAAE,OAAO,SAAS,CAAA;IAErC,OAAO,cAAc,CAAC,cAAc,CAAA;AACtC,CAAC;AATD,kFASC"}
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -20,6 +20,7 @@ __exportStar(require("./kamino"), exports);
|
|
|
20
20
|
__exportStar(require("./marginfi"), exports);
|
|
21
21
|
__exportStar(require("./perena"), exports);
|
|
22
22
|
__exportStar(require("./vault"), exports);
|
|
23
|
+
__exportStar(require("./orderbook"), exports);
|
|
23
24
|
__exportStar(require("./cpi"), exports);
|
|
24
25
|
__exportStar(require("./trade"), exports);
|
|
25
26
|
__exportStar(require("./liquidity"), exports);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2CAAwB;AACxB,mDAAgC;AAChC,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB;AACxB,0CAAuB;AACvB,wCAAqB;AACrB,0CAAuB;AACvB,8CAA2B;AAC3B,4CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2CAAwB;AACxB,mDAAgC;AAChC,2CAAwB;AACxB,6CAA0B;AAC1B,2CAAwB;AACxB,0CAAuB;AACvB,8CAA2B;AAC3B,wCAAqB;AACrB,0CAAuB;AACvB,8CAA2B;AAC3B,4CAAyB"}
|
package/build/kamino.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export interface KaminoSyState {
|
|
|
11
11
|
tokenProgramBase: web3.PublicKey;
|
|
12
12
|
klendProgramId: web3.PublicKey;
|
|
13
13
|
klendMarketId: web3.PublicKey;
|
|
14
|
+
scopePriceFeed?: web3.PublicKey;
|
|
14
15
|
}
|
|
15
16
|
export interface KaminoSyStateJson {
|
|
16
17
|
selfAddress: string;
|
|
@@ -21,6 +22,7 @@ export interface KaminoSyStateJson {
|
|
|
21
22
|
tokenProgramBase: string;
|
|
22
23
|
klendProgramId: string;
|
|
23
24
|
klendMarketId: string;
|
|
25
|
+
scopePriceFeed?: string;
|
|
24
26
|
}
|
|
25
27
|
export interface KaminoSyMetaAccount {
|
|
26
28
|
kaminoReserve: web3.PublicKey;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { web3 } from "@coral-xyz/anchor";
|
|
2
|
+
import { CpiAccountsRaw, ExponentCoreCpiAccountsRaw } from "./cpi";
|
|
3
|
+
import { Flavor } from "./flavor";
|
|
4
|
+
export declare const MAX_PRICE_NODES = 100;
|
|
5
|
+
export declare const MAX_OFFERS = 500;
|
|
6
|
+
export declare const MAX_USER_ESCROWS = 250;
|
|
7
|
+
export declare const PRICE_NODE_REGISTERS = 3;
|
|
8
|
+
export declare const OFFER_REGISTERS = 1;
|
|
9
|
+
export declare const ESCROW_REGISTERS = 0;
|
|
10
|
+
/** ─── Orderbook Financials ─────────────────────────────────────────────────── */
|
|
11
|
+
export interface OrderbookFinancials {
|
|
12
|
+
/** Expiration timestamp (unix seconds) */
|
|
13
|
+
expirationTs: number;
|
|
14
|
+
/** SY token balance */
|
|
15
|
+
syBalance: bigint;
|
|
16
|
+
/** YT token balance */
|
|
17
|
+
ytBalance: bigint;
|
|
18
|
+
/** PT token balance */
|
|
19
|
+
ptBalance: bigint;
|
|
20
|
+
ytFeeBalance: bigint;
|
|
21
|
+
syFeeBalance: bigint;
|
|
22
|
+
ptFeeBalance: bigint;
|
|
23
|
+
stagedSy: bigint;
|
|
24
|
+
}
|
|
25
|
+
/** ─── Configuration Options ─────────────────────────────────────────────────── */
|
|
26
|
+
export interface ConfigurationOptions {
|
|
27
|
+
priceDecimals: number;
|
|
28
|
+
thresholdAmount: bigint;
|
|
29
|
+
lnMakerFeeRate: number;
|
|
30
|
+
lnTakerFeeRate: number;
|
|
31
|
+
}
|
|
32
|
+
export interface PriceTreeNode {
|
|
33
|
+
/** The price tick (key into the tree) */
|
|
34
|
+
key: number;
|
|
35
|
+
/** Head indexes of the linked lists of offers at this price */
|
|
36
|
+
firstOfferSellYt: number;
|
|
37
|
+
firstOfferBuyYt: number;
|
|
38
|
+
lastOfferSellYt: number;
|
|
39
|
+
lastOfferBuyYt: number;
|
|
40
|
+
/** Index of this node’s parent in the price_nodes slab */
|
|
41
|
+
parent: number;
|
|
42
|
+
/** Index of this node’s left child */
|
|
43
|
+
left: number;
|
|
44
|
+
/** Index of this node’s right child */
|
|
45
|
+
right: number;
|
|
46
|
+
}
|
|
47
|
+
export interface OfferNode {
|
|
48
|
+
/** Internal register 1 (the free‐list link when unused) */
|
|
49
|
+
nextOfferPointer: number;
|
|
50
|
+
/** Internal register 3 (the free‐list link when unused) */
|
|
51
|
+
pricePointer: number;
|
|
52
|
+
/** SY/PT/YT amount deposited */
|
|
53
|
+
amount: BigInt;
|
|
54
|
+
/** Index of the user escrow that owns this offer */
|
|
55
|
+
userVaultPointer: number;
|
|
56
|
+
/** Expiry timestamp (unix seconds) */
|
|
57
|
+
expiryAt: number;
|
|
58
|
+
/** Creation timestamp (unix seconds) */
|
|
59
|
+
createdAt: number;
|
|
60
|
+
/** True if this is a PT order */
|
|
61
|
+
virtualOffer: boolean;
|
|
62
|
+
/** Offer‐type flag */
|
|
63
|
+
orderTypeFlag: number;
|
|
64
|
+
/** Fill‐or‐kill flag */
|
|
65
|
+
fillOrKill: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface UserEscrowNode {
|
|
68
|
+
/** The user’s Pubkey */
|
|
69
|
+
user: web3.PublicKey;
|
|
70
|
+
/** Yield‐index for this user (protocol’s Number type) */
|
|
71
|
+
yieldIndex: number;
|
|
72
|
+
/** Token amounts held */
|
|
73
|
+
ptAmount: bigint;
|
|
74
|
+
syAmount: bigint;
|
|
75
|
+
ytAmount: bigint;
|
|
76
|
+
stakedYtAmount: bigint;
|
|
77
|
+
/** When unused, the free‐list link */
|
|
78
|
+
staged: bigint;
|
|
79
|
+
}
|
|
80
|
+
/** ─── Full On-chain Orderbook ───────────────────────────────────────────────── */
|
|
81
|
+
export interface Orderbook {
|
|
82
|
+
/** PDA link to vault */
|
|
83
|
+
vault: web3.PublicKey;
|
|
84
|
+
/** PDA link to a vault-owned YT position */
|
|
85
|
+
yieldPosition: web3.PublicKey;
|
|
86
|
+
/** Address Lookup Table key for the orderbook */
|
|
87
|
+
addressLookupTable: web3.PublicKey;
|
|
88
|
+
/** Address of the Exponent Core program */
|
|
89
|
+
exponentCoreProgram: web3.PublicKey;
|
|
90
|
+
/** Address of the Sy program */
|
|
91
|
+
syProgram: web3.PublicKey;
|
|
92
|
+
/** Orderbook-owned escrow for SY tokens */
|
|
93
|
+
tokenEscrowSy: web3.PublicKey;
|
|
94
|
+
/** Orderbook-owned escrow for YT tokens */
|
|
95
|
+
tokenEscrowYt: web3.PublicKey;
|
|
96
|
+
/** Orderbook-owned escrow for PT tokens */
|
|
97
|
+
tokenEscrowPt: web3.PublicKey;
|
|
98
|
+
admin: web3.PublicKey;
|
|
99
|
+
/** CPI accounts storage key */
|
|
100
|
+
cpiAccountOrderbook: web3.PublicKey;
|
|
101
|
+
/** How many price nodes are currently in use */
|
|
102
|
+
nodeCount: number;
|
|
103
|
+
financials: OrderbookFinancials;
|
|
104
|
+
/** All PriceNode entries (fixed capacity) */
|
|
105
|
+
prices: PriceTreeNode[];
|
|
106
|
+
/** All Offer entries (fixed capacity) */
|
|
107
|
+
offers: OfferNode[];
|
|
108
|
+
/** All UserEscrow entries (fixed capacity) */
|
|
109
|
+
userEscrows: UserEscrowNode[];
|
|
110
|
+
/** PDA bump seed for the orderbook authority */
|
|
111
|
+
signerBump: number;
|
|
112
|
+
}
|
|
113
|
+
export interface OrderbookState {
|
|
114
|
+
/** PDA link to vault */
|
|
115
|
+
vault: web3.PublicKey;
|
|
116
|
+
/** PDA link to a vault-owned YT position */
|
|
117
|
+
yieldPosition: web3.PublicKey;
|
|
118
|
+
/** Address Lookup Table key for the orderbook */
|
|
119
|
+
addressLookupTable: web3.PublicKey;
|
|
120
|
+
/** Address of the Exponent Core program */
|
|
121
|
+
exponentCoreProgram: web3.PublicKey;
|
|
122
|
+
/** Address of the Exponent Core program */
|
|
123
|
+
syProgram: web3.PublicKey;
|
|
124
|
+
/** Orderbook-owned escrow for SY tokens */
|
|
125
|
+
tokenEscrowSy: web3.PublicKey;
|
|
126
|
+
/** Orderbook-owned escrow for YT tokens */
|
|
127
|
+
tokenEscrowYt: web3.PublicKey;
|
|
128
|
+
/** Orderbook-owned escrow for PT tokens */
|
|
129
|
+
tokenEscrowPt: web3.PublicKey;
|
|
130
|
+
/** CPI accounts storage key */
|
|
131
|
+
cpiAccountOrderbook: web3.PublicKey;
|
|
132
|
+
/** Admin key */
|
|
133
|
+
admin: web3.PublicKey;
|
|
134
|
+
configurationOptions: ConfigurationOptions;
|
|
135
|
+
financials: OrderbookFinancials;
|
|
136
|
+
/** All PriceNode entries (fixed capacity) */
|
|
137
|
+
prices: PriceTreeNode[];
|
|
138
|
+
/** All Offer entries (fixed capacity) */
|
|
139
|
+
offers: OfferNode[];
|
|
140
|
+
/** All UserEscrow entries (fixed capacity) */
|
|
141
|
+
userEscrows: UserEscrowNode[];
|
|
142
|
+
syCpiAccounts: CpiAccountsRaw;
|
|
143
|
+
exponentCoreCpiAccounts: ExponentCoreCpiAccountsRaw;
|
|
144
|
+
flavor: Flavor;
|
|
145
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ESCROW_REGISTERS = exports.OFFER_REGISTERS = exports.PRICE_NODE_REGISTERS = exports.MAX_USER_ESCROWS = exports.MAX_OFFERS = exports.MAX_PRICE_NODES = void 0;
|
|
4
|
+
exports.MAX_PRICE_NODES = 100;
|
|
5
|
+
exports.MAX_OFFERS = 500;
|
|
6
|
+
exports.MAX_USER_ESCROWS = 250;
|
|
7
|
+
// RedBlackTree uses 3 registers per node: parent, left, right
|
|
8
|
+
exports.PRICE_NODE_REGISTERS = 3;
|
|
9
|
+
// Offer allocator uses 1 register per node (free‐list pointer)
|
|
10
|
+
exports.OFFER_REGISTERS = 1;
|
|
11
|
+
// UserEscrow allocator uses 0 registers
|
|
12
|
+
exports.ESCROW_REGISTERS = 0;
|
|
13
|
+
//# sourceMappingURL=orderbook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orderbook.js","sourceRoot":"","sources":["../src/orderbook.ts"],"names":[],"mappings":";;;AAKa,QAAA,eAAe,GAAG,GAAG,CAAA;AACrB,QAAA,UAAU,GAAG,GAAG,CAAA;AAChB,QAAA,gBAAgB,GAAG,GAAG,CAAA;AACnC,8DAA8D;AACjD,QAAA,oBAAoB,GAAG,CAAC,CAAA;AACrC,+DAA+D;AAClD,QAAA,eAAe,GAAG,CAAC,CAAA;AAChC,wCAAwC;AAC3B,QAAA,gBAAgB,GAAG,CAAC,CAAA"}
|
package/build/vault.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export type VaultJson = {
|
|
|
55
55
|
flavor: IFlavorStateJson;
|
|
56
56
|
emissions: VaultEmissionJson[];
|
|
57
57
|
maxPySupply: string;
|
|
58
|
+
state: VaultStateJson;
|
|
58
59
|
};
|
|
59
60
|
export interface VaultState {
|
|
60
61
|
/** supply of PT */
|
|
@@ -92,6 +93,42 @@ export interface VaultState {
|
|
|
92
93
|
emissions: VaultEmission[];
|
|
93
94
|
maxPySupply: bigint;
|
|
94
95
|
}
|
|
96
|
+
export interface VaultStateJson {
|
|
97
|
+
/** supply of PT */
|
|
98
|
+
ptSupply: string;
|
|
99
|
+
syForPt: string;
|
|
100
|
+
/** When does the vault start, as a UNIX timestamp */
|
|
101
|
+
startTs: number;
|
|
102
|
+
/** For how long is the vault active */
|
|
103
|
+
durationSeconds: number;
|
|
104
|
+
/** Vault signer for token accounts, mints, SY position etc */
|
|
105
|
+
authority: string;
|
|
106
|
+
addressLookupTable: string;
|
|
107
|
+
lastSeenSyExchangeRate: number;
|
|
108
|
+
allTimeHighSyExchangeRate: number;
|
|
109
|
+
/** Vault-owned account for passing SY between SY program and user */
|
|
110
|
+
escrowSy: string;
|
|
111
|
+
/** Escrow account for holding deposited YT */
|
|
112
|
+
escrowYt: string;
|
|
113
|
+
/** Key to SY Program */
|
|
114
|
+
syProgram: string;
|
|
115
|
+
syPosition: SyPositionJson;
|
|
116
|
+
cpiAccounts: CpiAccountsRawJson;
|
|
117
|
+
mintPt: string;
|
|
118
|
+
status: number;
|
|
119
|
+
minOperationSizeStrip: string;
|
|
120
|
+
minOperationSizeMerge: string;
|
|
121
|
+
mintYt: string;
|
|
122
|
+
mintSy: string;
|
|
123
|
+
yieldPositonAddress: string;
|
|
124
|
+
treasurySyTokenAccount: string;
|
|
125
|
+
interestBpsFee: number;
|
|
126
|
+
totalSyInEscrow: string;
|
|
127
|
+
flavor: IFlavorStateJson;
|
|
128
|
+
finalSyExchangeRate: number;
|
|
129
|
+
emissions: VaultEmissionJson[];
|
|
130
|
+
maxPySupply: string;
|
|
131
|
+
}
|
|
95
132
|
export interface SyPositionJson {
|
|
96
133
|
balanceSy: string;
|
|
97
134
|
owner: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exponent-labs/exponent-types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"main": "build/index.js",
|
|
5
5
|
"types": "build/index.d.ts",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"build": "tsc --build"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@coral-xyz/anchor": "0.31.0"
|
|
11
|
+
"@coral-xyz/anchor": "0.31.0",
|
|
12
|
+
"@solana/spl-stake-pool": "1.1.8"
|
|
12
13
|
},
|
|
13
14
|
"devDependencies": {
|
|
14
15
|
"typescript": "5.4.5"
|
package/src/cpi.ts
CHANGED
|
@@ -15,6 +15,15 @@ export interface CpiMeta<T> {
|
|
|
15
15
|
getPositionState: T[]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/** Generic container for ExponentCore CPI account lists */
|
|
19
|
+
export interface ExponentCoreCpiMeta<T> {
|
|
20
|
+
depositYt: T[]
|
|
21
|
+
withdrawYt: T[]
|
|
22
|
+
stripSy: T[]
|
|
23
|
+
mergeSy: T[]
|
|
24
|
+
collectInterest: T[]
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
/** The on-chain storage for CPI accounts, which references an ALT */
|
|
19
28
|
export interface CpiAccountIndex {
|
|
20
29
|
/** Index in the Address Lookup Table */
|
|
@@ -26,9 +35,15 @@ export interface CpiAccountIndex {
|
|
|
26
35
|
/** Raw account infos for CPI that include the Pubkey */
|
|
27
36
|
export type CpiAccountsRaw = CpiMeta<AccountInfo>
|
|
28
37
|
|
|
38
|
+
/** Raw account infos for CPI that include the Pubkey */
|
|
39
|
+
export type ExponentCoreCpiAccountsRaw = ExponentCoreCpiMeta<AccountInfo>
|
|
40
|
+
|
|
29
41
|
/** This account is stored in state on the vault/market to track indexes in the ALT */
|
|
30
42
|
export type CpiAccountIndexes = CpiMeta<CpiAccountIndex>
|
|
31
43
|
|
|
44
|
+
/** This account is stored in state on the vault/market to track indexes in the ALT */
|
|
45
|
+
export type ExponentCoreCpiIndexes = ExponentCoreCpiMeta<CpiAccountIndex>
|
|
46
|
+
|
|
32
47
|
export interface CpiAccountsRawJson {
|
|
33
48
|
getSyState: AccountInfoJson[]
|
|
34
49
|
withdrawSy: AccountInfoJson[]
|
|
@@ -37,6 +52,14 @@ export interface CpiAccountsRawJson {
|
|
|
37
52
|
getPositionState: AccountInfoJson[]
|
|
38
53
|
}
|
|
39
54
|
|
|
55
|
+
export interface ExponentCoreCpiAccountsRawJson {
|
|
56
|
+
depositYt: AccountInfoJson[]
|
|
57
|
+
withdrawYt: AccountInfoJson[]
|
|
58
|
+
stripSy: AccountInfoJson[]
|
|
59
|
+
mergeSy: AccountInfoJson[]
|
|
60
|
+
collectInterest: AccountInfoJson[]
|
|
61
|
+
}
|
|
62
|
+
|
|
40
63
|
export type AccountInfoJson = {
|
|
41
64
|
pubkey: string
|
|
42
65
|
isSigner: boolean
|
|
@@ -73,3 +96,20 @@ export function serializeCpiAccountsRaw(cpiAccounts: CpiAccountsRaw): CpiAccount
|
|
|
73
96
|
getPositionState: cpiAccounts.getPositionState.map(serializeAccountInfo),
|
|
74
97
|
}
|
|
75
98
|
}
|
|
99
|
+
|
|
100
|
+
/** MarketThree/CLMM only uses a subset of ExponentCore CPI accounts (strip and merge) */
|
|
101
|
+
export interface MarketCpiCoreMeta<T> {
|
|
102
|
+
stripSy: T[]
|
|
103
|
+
mergeSy: T[]
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface MarketCpiCoreAccountsRawJson {
|
|
107
|
+
stripSy: AccountInfoJson[]
|
|
108
|
+
mergeSy: AccountInfoJson[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Type alias for MarketThree's CPI core accounts with pubkeys */
|
|
112
|
+
export type MarketCpiCoreAccountsRaw = MarketCpiCoreMeta<AccountInfo>
|
|
113
|
+
|
|
114
|
+
/** Type alias for MarketThree's CPI core accounts stored in state */
|
|
115
|
+
export type MarketCpiCoreIndexes = MarketCpiCoreMeta<CpiAccountIndex>
|
package/src/generic.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BN, web3 } from "@coral-xyz/anchor"
|
|
2
2
|
|
|
3
3
|
import { AnchorizedPNum, SyEmissionJson, SyEmissionRaw } from "./common"
|
|
4
|
+
import { StakePoolAccount } from "@solana/spl-stake-pool"
|
|
4
5
|
|
|
5
6
|
export type InterfaceTypeGeneric =
|
|
6
7
|
| {
|
|
@@ -58,6 +59,14 @@ export type InterfaceTypeGeneric =
|
|
|
58
59
|
padding: number[]
|
|
59
60
|
}
|
|
60
61
|
}
|
|
62
|
+
| {
|
|
63
|
+
reflect: {
|
|
64
|
+
padding: number[]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
| {
|
|
68
|
+
ore: Record<string, never>
|
|
69
|
+
}
|
|
61
70
|
export type InterfaceTypeGenericJson =
|
|
62
71
|
| {
|
|
63
72
|
pyth: {
|
|
@@ -114,6 +123,14 @@ export type InterfaceTypeGenericJson =
|
|
|
114
123
|
padding: number[]
|
|
115
124
|
}
|
|
116
125
|
}
|
|
126
|
+
| {
|
|
127
|
+
reflect: {
|
|
128
|
+
padding: number[]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
| {
|
|
132
|
+
ore: Record<string, never>
|
|
133
|
+
}
|
|
117
134
|
/** Additional data that different interface types may need */
|
|
118
135
|
export interface AdditionalDataGeneric {
|
|
119
136
|
fragmetricData?: {
|
|
@@ -138,6 +155,15 @@ export interface AdditionalDataGeneric {
|
|
|
138
155
|
baseVaultAuthority: web3.PublicKey
|
|
139
156
|
sharesMint: web3.PublicKey
|
|
140
157
|
}
|
|
158
|
+
splStakePoolData?: {
|
|
159
|
+
stakePoolAccount?: StakePoolAccount // Optional because it is expensive to serialize / not always needed on clients
|
|
160
|
+
stakePoolAddress: web3.PublicKey
|
|
161
|
+
stakePoolProgramId: web3.PublicKey // Dynamic program ID from account owner
|
|
162
|
+
validatorList: web3.PublicKey
|
|
163
|
+
reserveStake: web3.PublicKey
|
|
164
|
+
managerFeeAccount: web3.PublicKey
|
|
165
|
+
poolMint: web3.PublicKey
|
|
166
|
+
}
|
|
141
167
|
// Add other interface-specific data here as needed
|
|
142
168
|
// meteoraData?: { ... }
|
|
143
169
|
// sanctumData?: { ... }
|
|
@@ -153,6 +179,28 @@ export interface AdditionalDataGenericJson {
|
|
|
153
179
|
jupiterLendData?: {
|
|
154
180
|
baseTokenMint: string
|
|
155
181
|
tokenReservesLiquidity: string
|
|
182
|
+
lendingSupplyPosition: string
|
|
183
|
+
rewardsRateModel: string
|
|
184
|
+
rateModel: string
|
|
185
|
+
}
|
|
186
|
+
kaminoVaultData?: {
|
|
187
|
+
vault: string
|
|
188
|
+
reserves: {
|
|
189
|
+
reserveAddress: string
|
|
190
|
+
marketAddress: string
|
|
191
|
+
}[]
|
|
192
|
+
tokenVault: string
|
|
193
|
+
tokenMint: string
|
|
194
|
+
baseVaultAuthority: string
|
|
195
|
+
sharesMint: string
|
|
196
|
+
}
|
|
197
|
+
splStakePoolData?: {
|
|
198
|
+
stakePoolAddress: string
|
|
199
|
+
stakePoolProgramId: string
|
|
200
|
+
validatorList: string
|
|
201
|
+
reserveStake: string
|
|
202
|
+
managerFeeAccount: string
|
|
203
|
+
poolMint: string
|
|
156
204
|
}
|
|
157
205
|
// Add other interface-specific data here as needed
|
|
158
206
|
// meteoraData?: { ... }
|
|
@@ -168,6 +216,14 @@ export interface Hook {
|
|
|
168
216
|
postRedeemHookDiscriminator: number[]
|
|
169
217
|
}
|
|
170
218
|
|
|
219
|
+
export interface HookJson {
|
|
220
|
+
enabled: boolean
|
|
221
|
+
interfaceEmissionsAccountsUntil: number
|
|
222
|
+
programId: string
|
|
223
|
+
preMintHookDiscriminator: number[]
|
|
224
|
+
postRedeemHookDiscriminator: number[]
|
|
225
|
+
}
|
|
226
|
+
|
|
171
227
|
export interface HookRaw {
|
|
172
228
|
enabled: boolean
|
|
173
229
|
interfaceEmissionsAccountsUntil: number
|
|
@@ -206,7 +262,7 @@ export interface GenericSyMetaAccountJson {
|
|
|
206
262
|
maxSySupply: string
|
|
207
263
|
minMintSize: string
|
|
208
264
|
minRedeemSize: string
|
|
209
|
-
hook:
|
|
265
|
+
hook: HookJson
|
|
210
266
|
emissions: SyEmissionJson[]
|
|
211
267
|
index: number
|
|
212
268
|
}
|
|
@@ -351,6 +407,28 @@ export function fromInterfaceTypeGenericJson(json: InterfaceTypeGenericJson): In
|
|
|
351
407
|
return json as InterfaceTypeGeneric
|
|
352
408
|
}
|
|
353
409
|
|
|
410
|
+
/** Convert Hook to HookJson */
|
|
411
|
+
export function toHookJson(hook: Hook): HookJson {
|
|
412
|
+
return {
|
|
413
|
+
enabled: hook.enabled,
|
|
414
|
+
interfaceEmissionsAccountsUntil: hook.interfaceEmissionsAccountsUntil,
|
|
415
|
+
programId: hook.programId.toString(),
|
|
416
|
+
preMintHookDiscriminator: hook.preMintHookDiscriminator,
|
|
417
|
+
postRedeemHookDiscriminator: hook.postRedeemHookDiscriminator,
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Convert HookJson to Hook */
|
|
422
|
+
export function fromHookJson(json: HookJson): Hook {
|
|
423
|
+
return {
|
|
424
|
+
enabled: json.enabled,
|
|
425
|
+
interfaceEmissionsAccountsUntil: json.interfaceEmissionsAccountsUntil,
|
|
426
|
+
programId: new web3.PublicKey(json.programId),
|
|
427
|
+
preMintHookDiscriminator: json.preMintHookDiscriminator,
|
|
428
|
+
postRedeemHookDiscriminator: json.postRedeemHookDiscriminator,
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
354
432
|
/** Convert AdditionalDataGeneric to AdditionalDataGenericJson */
|
|
355
433
|
export function toAdditionalDataGenericJson(additionalData: AdditionalDataGeneric): AdditionalDataGenericJson {
|
|
356
434
|
const result: AdditionalDataGenericJson = {}
|
|
@@ -362,6 +440,41 @@ export function toAdditionalDataGenericJson(additionalData: AdditionalDataGeneri
|
|
|
362
440
|
}
|
|
363
441
|
}
|
|
364
442
|
|
|
443
|
+
if (additionalData.jupiterLendData) {
|
|
444
|
+
result.jupiterLendData = {
|
|
445
|
+
baseTokenMint: additionalData.jupiterLendData.baseTokenMint.toString(),
|
|
446
|
+
tokenReservesLiquidity: additionalData.jupiterLendData.tokenReservesLiquidity.toString(),
|
|
447
|
+
lendingSupplyPosition: additionalData.jupiterLendData.lendingSupplyPosition.toString(),
|
|
448
|
+
rewardsRateModel: additionalData.jupiterLendData.rewardsRateModel.toString(),
|
|
449
|
+
rateModel: additionalData.jupiterLendData.rateModel.toString(),
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (additionalData.kaminoVaultData) {
|
|
454
|
+
result.kaminoVaultData = {
|
|
455
|
+
vault: additionalData.kaminoVaultData.vault.toString(),
|
|
456
|
+
reserves: additionalData.kaminoVaultData.reserves.map((r) => ({
|
|
457
|
+
reserveAddress: r.reserveAddress.toString(),
|
|
458
|
+
marketAddress: r.marketAddress.toString(),
|
|
459
|
+
})),
|
|
460
|
+
tokenVault: additionalData.kaminoVaultData.tokenVault.toString(),
|
|
461
|
+
tokenMint: additionalData.kaminoVaultData.tokenMint.toString(),
|
|
462
|
+
baseVaultAuthority: additionalData.kaminoVaultData.baseVaultAuthority.toString(),
|
|
463
|
+
sharesMint: additionalData.kaminoVaultData.sharesMint.toString(),
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
if (additionalData.splStakePoolData) {
|
|
468
|
+
result.splStakePoolData = {
|
|
469
|
+
stakePoolAddress: additionalData.splStakePoolData.stakePoolAddress.toString(),
|
|
470
|
+
stakePoolProgramId: additionalData.splStakePoolData.stakePoolProgramId.toString(),
|
|
471
|
+
validatorList: additionalData.splStakePoolData.validatorList.toString(),
|
|
472
|
+
reserveStake: additionalData.splStakePoolData.reserveStake.toString(),
|
|
473
|
+
managerFeeAccount: additionalData.splStakePoolData.managerFeeAccount.toString(),
|
|
474
|
+
poolMint: additionalData.splStakePoolData.poolMint.toString(),
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
365
478
|
return result
|
|
366
479
|
}
|
|
367
480
|
|
|
@@ -376,6 +489,41 @@ export function fromAdditionalDataGenericJson(json: AdditionalDataGenericJson):
|
|
|
376
489
|
}
|
|
377
490
|
}
|
|
378
491
|
|
|
492
|
+
if (json.jupiterLendData) {
|
|
493
|
+
result.jupiterLendData = {
|
|
494
|
+
baseTokenMint: new web3.PublicKey(json.jupiterLendData.baseTokenMint),
|
|
495
|
+
tokenReservesLiquidity: new web3.PublicKey(json.jupiterLendData.tokenReservesLiquidity),
|
|
496
|
+
lendingSupplyPosition: new web3.PublicKey(json.jupiterLendData.lendingSupplyPosition),
|
|
497
|
+
rewardsRateModel: new web3.PublicKey(json.jupiterLendData.rewardsRateModel),
|
|
498
|
+
rateModel: new web3.PublicKey(json.jupiterLendData.rateModel),
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (json.kaminoVaultData) {
|
|
503
|
+
result.kaminoVaultData = {
|
|
504
|
+
vault: new web3.PublicKey(json.kaminoVaultData.vault),
|
|
505
|
+
reserves: json.kaminoVaultData.reserves.map((r) => ({
|
|
506
|
+
reserveAddress: new web3.PublicKey(r.reserveAddress),
|
|
507
|
+
marketAddress: new web3.PublicKey(r.marketAddress),
|
|
508
|
+
})),
|
|
509
|
+
tokenVault: new web3.PublicKey(json.kaminoVaultData.tokenVault),
|
|
510
|
+
tokenMint: new web3.PublicKey(json.kaminoVaultData.tokenMint),
|
|
511
|
+
baseVaultAuthority: new web3.PublicKey(json.kaminoVaultData.baseVaultAuthority),
|
|
512
|
+
sharesMint: new web3.PublicKey(json.kaminoVaultData.sharesMint),
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
if (json.splStakePoolData) {
|
|
517
|
+
result.splStakePoolData = {
|
|
518
|
+
stakePoolAddress: new web3.PublicKey(json.splStakePoolData.stakePoolAddress),
|
|
519
|
+
stakePoolProgramId: new web3.PublicKey(json.splStakePoolData.stakePoolProgramId),
|
|
520
|
+
validatorList: new web3.PublicKey(json.splStakePoolData.validatorList),
|
|
521
|
+
reserveStake: new web3.PublicKey(json.splStakePoolData.reserveStake),
|
|
522
|
+
managerFeeAccount: new web3.PublicKey(json.splStakePoolData.managerFeeAccount),
|
|
523
|
+
poolMint: new web3.PublicKey(json.splStakePoolData.poolMint),
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
379
527
|
return result
|
|
380
528
|
}
|
|
381
529
|
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { SyEmissionRaw, SyEmissionJson } from "./common"
|
|
1
|
+
export { SyEmissionRaw, SyEmissionJson, AnchorizedPNum, AnchorizedPNumJson } from "./common"
|
|
2
2
|
export * from "./flavor"
|
|
3
3
|
export * from "./jito-restaking"
|
|
4
4
|
export * from "./kamino"
|
|
5
5
|
export * from "./marginfi"
|
|
6
6
|
export * from "./perena"
|
|
7
7
|
export * from "./vault"
|
|
8
|
+
export * from "./orderbook"
|
|
8
9
|
export * from "./cpi"
|
|
9
10
|
export * from "./trade"
|
|
10
11
|
export * from "./liquidity"
|
package/src/kamino.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface KaminoSyState {
|
|
|
13
13
|
tokenProgramBase: web3.PublicKey
|
|
14
14
|
klendProgramId: web3.PublicKey
|
|
15
15
|
klendMarketId: web3.PublicKey
|
|
16
|
+
scopePriceFeed?: web3.PublicKey
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export interface KaminoSyStateJson {
|
|
@@ -24,6 +25,7 @@ export interface KaminoSyStateJson {
|
|
|
24
25
|
tokenProgramBase: string
|
|
25
26
|
klendProgramId: string
|
|
26
27
|
klendMarketId: string
|
|
28
|
+
scopePriceFeed?: string
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export interface KaminoSyMetaAccount {
|
package/src/orderbook.ts
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { web3 } from "@coral-xyz/anchor"
|
|
2
|
+
|
|
3
|
+
import { CpiAccountsRaw, ExponentCoreCpiAccountsRaw } from "./cpi"
|
|
4
|
+
import { Flavor } from "./flavor"
|
|
5
|
+
|
|
6
|
+
export const MAX_PRICE_NODES = 100
|
|
7
|
+
export const MAX_OFFERS = 500
|
|
8
|
+
export const MAX_USER_ESCROWS = 250
|
|
9
|
+
// RedBlackTree uses 3 registers per node: parent, left, right
|
|
10
|
+
export const PRICE_NODE_REGISTERS = 3
|
|
11
|
+
// Offer allocator uses 1 register per node (free‐list pointer)
|
|
12
|
+
export const OFFER_REGISTERS = 1
|
|
13
|
+
// UserEscrow allocator uses 0 registers
|
|
14
|
+
export const ESCROW_REGISTERS = 0
|
|
15
|
+
|
|
16
|
+
/** ─── Orderbook Financials ─────────────────────────────────────────────────── */
|
|
17
|
+
export interface OrderbookFinancials {
|
|
18
|
+
/** Expiration timestamp (unix seconds) */
|
|
19
|
+
expirationTs: number
|
|
20
|
+
/** SY token balance */
|
|
21
|
+
syBalance: bigint
|
|
22
|
+
/** YT token balance */
|
|
23
|
+
ytBalance: bigint
|
|
24
|
+
/** PT token balance */
|
|
25
|
+
ptBalance: bigint
|
|
26
|
+
|
|
27
|
+
/// Balance of YT fee in the orderbook
|
|
28
|
+
/// This amount is tracked separately to prevent bugs from token transfers directly to the orderbook
|
|
29
|
+
ytFeeBalance: bigint
|
|
30
|
+
|
|
31
|
+
/// Balance of SY fee in the orderbook
|
|
32
|
+
/// This amount is tracked separately to prevent bugs from token transfers directly to the orderbook
|
|
33
|
+
syFeeBalance: bigint
|
|
34
|
+
|
|
35
|
+
/// Balance of PT fee in the orderbook
|
|
36
|
+
/// This amount is tracked separately to prevent bugs from token transfers directly to the orderbook
|
|
37
|
+
ptFeeBalance: bigint
|
|
38
|
+
|
|
39
|
+
/// Balance of staged SY in the orderbook
|
|
40
|
+
stagedSy: bigint
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** ─── Configuration Options ─────────────────────────────────────────────────── */
|
|
44
|
+
export interface ConfigurationOptions {
|
|
45
|
+
priceDecimals: number
|
|
46
|
+
thresholdAmount: bigint
|
|
47
|
+
lnMakerFeeRate: number
|
|
48
|
+
lnTakerFeeRate: number
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface PriceTreeNode {
|
|
52
|
+
/** The price tick (key into the tree) */
|
|
53
|
+
key: number
|
|
54
|
+
/** Head indexes of the linked lists of offers at this price */
|
|
55
|
+
firstOfferSellYt: number
|
|
56
|
+
firstOfferBuyYt: number
|
|
57
|
+
lastOfferSellYt: number
|
|
58
|
+
lastOfferBuyYt: number
|
|
59
|
+
/** Index of this node’s parent in the price_nodes slab */
|
|
60
|
+
parent: number
|
|
61
|
+
/** Index of this node’s left child */
|
|
62
|
+
left: number
|
|
63
|
+
/** Index of this node’s right child */
|
|
64
|
+
right: number
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface OfferNode {
|
|
68
|
+
/** Internal register 1 (the free‐list link when unused) */
|
|
69
|
+
nextOfferPointer: number
|
|
70
|
+
|
|
71
|
+
/** Internal register 3 (the free‐list link when unused) */
|
|
72
|
+
pricePointer: number
|
|
73
|
+
|
|
74
|
+
/** SY/PT/YT amount deposited */
|
|
75
|
+
amount: BigInt
|
|
76
|
+
/** Index of the user escrow that owns this offer */
|
|
77
|
+
userVaultPointer: number
|
|
78
|
+
/** Expiry timestamp (unix seconds) */
|
|
79
|
+
expiryAt: number
|
|
80
|
+
/** Creation timestamp (unix seconds) */
|
|
81
|
+
createdAt: number
|
|
82
|
+
/** True if this is a PT order */
|
|
83
|
+
virtualOffer: boolean
|
|
84
|
+
/** Offer‐type flag */
|
|
85
|
+
orderTypeFlag: number
|
|
86
|
+
/** Fill‐or‐kill flag */
|
|
87
|
+
fillOrKill: boolean
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface UserEscrowNode {
|
|
91
|
+
/** The user’s Pubkey */
|
|
92
|
+
user: web3.PublicKey
|
|
93
|
+
/** Yield‐index for this user (protocol’s Number type) */
|
|
94
|
+
yieldIndex: number
|
|
95
|
+
/** Token amounts held */
|
|
96
|
+
ptAmount: bigint
|
|
97
|
+
syAmount: bigint
|
|
98
|
+
ytAmount: bigint
|
|
99
|
+
stakedYtAmount: bigint
|
|
100
|
+
/** When unused, the free‐list link */
|
|
101
|
+
staged: bigint
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** ─── Full On-chain Orderbook ───────────────────────────────────────────────── */
|
|
105
|
+
export interface Orderbook {
|
|
106
|
+
/** PDA link to vault */
|
|
107
|
+
vault: web3.PublicKey
|
|
108
|
+
/** PDA link to a vault-owned YT position */
|
|
109
|
+
yieldPosition: web3.PublicKey
|
|
110
|
+
/** Address Lookup Table key for the orderbook */
|
|
111
|
+
addressLookupTable: web3.PublicKey
|
|
112
|
+
/** Address of the Exponent Core program */
|
|
113
|
+
exponentCoreProgram: web3.PublicKey
|
|
114
|
+
/** Address of the Sy program */
|
|
115
|
+
syProgram: web3.PublicKey
|
|
116
|
+
/** Orderbook-owned escrow for SY tokens */
|
|
117
|
+
tokenEscrowSy: web3.PublicKey
|
|
118
|
+
/** Orderbook-owned escrow for YT tokens */
|
|
119
|
+
tokenEscrowYt: web3.PublicKey
|
|
120
|
+
/** Orderbook-owned escrow for PT tokens */
|
|
121
|
+
tokenEscrowPt: web3.PublicKey
|
|
122
|
+
|
|
123
|
+
/// Admin key
|
|
124
|
+
admin: web3.PublicKey
|
|
125
|
+
|
|
126
|
+
/** CPI accounts storage key */
|
|
127
|
+
cpiAccountOrderbook: web3.PublicKey
|
|
128
|
+
|
|
129
|
+
/** How many price nodes are currently in use */
|
|
130
|
+
nodeCount: number
|
|
131
|
+
|
|
132
|
+
financials: OrderbookFinancials
|
|
133
|
+
|
|
134
|
+
/** All PriceNode entries (fixed capacity) */
|
|
135
|
+
prices: PriceTreeNode[]
|
|
136
|
+
|
|
137
|
+
/** All Offer entries (fixed capacity) */
|
|
138
|
+
offers: OfferNode[]
|
|
139
|
+
|
|
140
|
+
/** All UserEscrow entries (fixed capacity) */
|
|
141
|
+
userEscrows: UserEscrowNode[]
|
|
142
|
+
|
|
143
|
+
/** PDA bump seed for the orderbook authority */
|
|
144
|
+
signerBump: number
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export interface OrderbookState {
|
|
148
|
+
/** PDA link to vault */
|
|
149
|
+
vault: web3.PublicKey
|
|
150
|
+
/** PDA link to a vault-owned YT position */
|
|
151
|
+
yieldPosition: web3.PublicKey
|
|
152
|
+
/** Address Lookup Table key for the orderbook */
|
|
153
|
+
addressLookupTable: web3.PublicKey
|
|
154
|
+
/** Address of the Exponent Core program */
|
|
155
|
+
exponentCoreProgram: web3.PublicKey
|
|
156
|
+
/** Address of the Exponent Core program */
|
|
157
|
+
syProgram: web3.PublicKey
|
|
158
|
+
/** Orderbook-owned escrow for SY tokens */
|
|
159
|
+
tokenEscrowSy: web3.PublicKey
|
|
160
|
+
/** Orderbook-owned escrow for YT tokens */
|
|
161
|
+
tokenEscrowYt: web3.PublicKey
|
|
162
|
+
/** Orderbook-owned escrow for PT tokens */
|
|
163
|
+
tokenEscrowPt: web3.PublicKey
|
|
164
|
+
/** CPI accounts storage key */
|
|
165
|
+
cpiAccountOrderbook: web3.PublicKey
|
|
166
|
+
/** Admin key */
|
|
167
|
+
admin: web3.PublicKey
|
|
168
|
+
|
|
169
|
+
configurationOptions: ConfigurationOptions
|
|
170
|
+
|
|
171
|
+
financials: OrderbookFinancials
|
|
172
|
+
|
|
173
|
+
/** All PriceNode entries (fixed capacity) */
|
|
174
|
+
prices: PriceTreeNode[]
|
|
175
|
+
|
|
176
|
+
/** All Offer entries (fixed capacity) */
|
|
177
|
+
offers: OfferNode[]
|
|
178
|
+
|
|
179
|
+
/** All UserEscrow entries (fixed capacity) */
|
|
180
|
+
userEscrows: UserEscrowNode[]
|
|
181
|
+
|
|
182
|
+
syCpiAccounts: CpiAccountsRaw
|
|
183
|
+
|
|
184
|
+
exponentCoreCpiAccounts: ExponentCoreCpiAccountsRaw
|
|
185
|
+
|
|
186
|
+
flavor: Flavor
|
|
187
|
+
}
|
package/src/vault.ts
CHANGED
|
@@ -83,6 +83,8 @@ export type VaultJson = {
|
|
|
83
83
|
emissions: VaultEmissionJson[]
|
|
84
84
|
|
|
85
85
|
maxPySupply: string
|
|
86
|
+
|
|
87
|
+
state: VaultStateJson
|
|
86
88
|
}
|
|
87
89
|
export interface VaultState {
|
|
88
90
|
/** supply of PT */
|
|
@@ -149,6 +151,69 @@ export interface VaultState {
|
|
|
149
151
|
maxPySupply: bigint
|
|
150
152
|
}
|
|
151
153
|
|
|
154
|
+
export interface VaultStateJson {
|
|
155
|
+
/** supply of PT */
|
|
156
|
+
ptSupply: string
|
|
157
|
+
|
|
158
|
+
syForPt: string
|
|
159
|
+
|
|
160
|
+
/** When does the vault start, as a UNIX timestamp */
|
|
161
|
+
startTs: number
|
|
162
|
+
|
|
163
|
+
/** For how long is the vault active */
|
|
164
|
+
durationSeconds: number
|
|
165
|
+
|
|
166
|
+
/** Vault signer for token accounts, mints, SY position etc */
|
|
167
|
+
authority: string
|
|
168
|
+
|
|
169
|
+
addressLookupTable: string
|
|
170
|
+
|
|
171
|
+
lastSeenSyExchangeRate: number
|
|
172
|
+
|
|
173
|
+
allTimeHighSyExchangeRate: number
|
|
174
|
+
|
|
175
|
+
/** Vault-owned account for passing SY between SY program and user */
|
|
176
|
+
escrowSy: string
|
|
177
|
+
|
|
178
|
+
/** Escrow account for holding deposited YT */
|
|
179
|
+
escrowYt: string
|
|
180
|
+
|
|
181
|
+
/** Key to SY Program */
|
|
182
|
+
syProgram: string
|
|
183
|
+
|
|
184
|
+
syPosition: SyPositionJson
|
|
185
|
+
|
|
186
|
+
cpiAccounts: CpiAccountsRawJson
|
|
187
|
+
|
|
188
|
+
mintPt: string
|
|
189
|
+
|
|
190
|
+
status: number
|
|
191
|
+
|
|
192
|
+
minOperationSizeStrip: string
|
|
193
|
+
|
|
194
|
+
minOperationSizeMerge: string
|
|
195
|
+
|
|
196
|
+
mintYt: string
|
|
197
|
+
|
|
198
|
+
mintSy: string
|
|
199
|
+
|
|
200
|
+
yieldPositonAddress: string
|
|
201
|
+
|
|
202
|
+
treasurySyTokenAccount: string
|
|
203
|
+
|
|
204
|
+
interestBpsFee: number
|
|
205
|
+
|
|
206
|
+
totalSyInEscrow: string
|
|
207
|
+
|
|
208
|
+
flavor: IFlavorStateJson
|
|
209
|
+
|
|
210
|
+
finalSyExchangeRate: number
|
|
211
|
+
|
|
212
|
+
emissions: VaultEmissionJson[]
|
|
213
|
+
|
|
214
|
+
maxPySupply: string
|
|
215
|
+
}
|
|
216
|
+
|
|
152
217
|
export interface SyPositionJson {
|
|
153
218
|
balanceSy: string
|
|
154
219
|
owner: string
|