@exponent-labs/exponent-types 0.1.7 → 0.9.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/build/vault.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { BN, web3 } from "@coral-xyz/anchor";
2
1
  import { IFlavorStateJson, Flavor } from "./flavor";
3
2
  import { CpiAccountsRaw, CpiAccountsRawJson } from "./cpi";
4
3
  import { AnchorizedPNum, AnchorizedPNumJson } from "./common";
4
+ import { PublicKey } from "@solana/web3.js";
5
+ import BN from 'bn.js';
5
6
  export type VaultJson = {
6
7
  /** When does the vault start, as a UNIX timestamp */
7
8
  startTs: number;
@@ -55,6 +56,7 @@ export type VaultJson = {
55
56
  flavor: IFlavorStateJson;
56
57
  emissions: VaultEmissionJson[];
57
58
  maxPySupply: string;
59
+ state: VaultStateJson;
58
60
  };
59
61
  export interface VaultState {
60
62
  /** supply of PT */
@@ -65,26 +67,26 @@ export interface VaultState {
65
67
  /** For how long is the vault active */
66
68
  durationSeconds: number;
67
69
  /** Vault signer for token accounts, mints, SY position etc */
68
- authority: web3.PublicKey;
69
- addressLookupTable: web3.PublicKey;
70
+ authority: PublicKey;
71
+ addressLookupTable: PublicKey;
70
72
  lastSeenSyExchangeRate: number;
71
73
  allTimeHighSyExchangeRate: number;
72
74
  /** Vault-owned account for passing SY between SY program and user */
73
- escrowSy: web3.PublicKey;
75
+ escrowSy: PublicKey;
74
76
  /** Escrow account for holding deposited YT */
75
- escrowYt: web3.PublicKey;
77
+ escrowYt: PublicKey;
76
78
  /** Key to SY Program */
77
- syProgram: web3.PublicKey;
79
+ syProgram: PublicKey;
78
80
  syPosition: SyPosition;
79
81
  cpiAccounts: CpiAccountsRaw;
80
- mintPt: web3.PublicKey;
82
+ mintPt: PublicKey;
81
83
  status: number;
82
84
  minOperationSizeStrip: bigint;
83
85
  minOperationSizeMerge: bigint;
84
- mintYt: web3.PublicKey;
85
- mintSy: web3.PublicKey;
86
- yieldPositonAddress: web3.PublicKey;
87
- treasurySyTokenAccount: web3.PublicKey;
86
+ mintYt: PublicKey;
87
+ mintSy: PublicKey;
88
+ yieldPositonAddress: PublicKey;
89
+ treasurySyTokenAccount: PublicKey;
88
90
  interestBpsFee: number;
89
91
  totalSyInEscrow: bigint;
90
92
  flavor: Flavor;
@@ -92,6 +94,42 @@ export interface VaultState {
92
94
  emissions: VaultEmission[];
93
95
  maxPySupply: bigint;
94
96
  }
97
+ export interface VaultStateJson {
98
+ /** supply of PT */
99
+ ptSupply: string;
100
+ syForPt: string;
101
+ /** When does the vault start, as a UNIX timestamp */
102
+ startTs: number;
103
+ /** For how long is the vault active */
104
+ durationSeconds: number;
105
+ /** Vault signer for token accounts, mints, SY position etc */
106
+ authority: string;
107
+ addressLookupTable: string;
108
+ lastSeenSyExchangeRate: number;
109
+ allTimeHighSyExchangeRate: number;
110
+ /** Vault-owned account for passing SY between SY program and user */
111
+ escrowSy: string;
112
+ /** Escrow account for holding deposited YT */
113
+ escrowYt: string;
114
+ /** Key to SY Program */
115
+ syProgram: string;
116
+ syPosition: SyPositionJson;
117
+ cpiAccounts: CpiAccountsRawJson;
118
+ mintPt: string;
119
+ status: number;
120
+ minOperationSizeStrip: string;
121
+ minOperationSizeMerge: string;
122
+ mintYt: string;
123
+ mintSy: string;
124
+ yieldPositonAddress: string;
125
+ treasurySyTokenAccount: string;
126
+ interestBpsFee: number;
127
+ totalSyInEscrow: string;
128
+ flavor: IFlavorStateJson;
129
+ finalSyExchangeRate: number;
130
+ emissions: VaultEmissionJson[];
131
+ maxPySupply: string;
132
+ }
95
133
  export interface SyPositionJson {
96
134
  balanceSy: string;
97
135
  owner: string;
@@ -103,22 +141,22 @@ export interface SyPositionJson {
103
141
  }
104
142
  export interface SyPosition {
105
143
  balanceSy: bigint;
106
- owner: web3.PublicKey;
144
+ owner: PublicKey;
107
145
  emissions: {
108
146
  /** Last seen index for SY-to-emission exchange rate */
109
147
  lastSeenIndex: number;
110
148
  /** mint of emission token */
111
- mint: web3.PublicKey;
149
+ mint: PublicKey;
112
150
  /** How many emissions are staged to claim */
113
151
  staged: bigint;
114
152
  }[];
115
153
  }
116
154
  export interface VaultEmission {
117
- tokenAccount: web3.PublicKey;
155
+ tokenAccount: PublicKey;
118
156
  initialIndex: AnchorizedPNum;
119
157
  lastSeenIndex: AnchorizedPNum;
120
158
  finalIndex: AnchorizedPNum;
121
- treasuryTokenAccount: web3.PublicKey;
159
+ treasuryTokenAccount: PublicKey;
122
160
  feeBps: number;
123
161
  treasuryEmission: BN;
124
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exponent-labs/exponent-types",
3
- "version": "0.1.7",
3
+ "version": "0.9.0",
4
4
  "main": "build/index.js",
5
5
  "types": "build/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -8,7 +8,9 @@
8
8
  "build": "tsc --build"
9
9
  },
10
10
  "dependencies": {
11
- "@coral-xyz/anchor": "0.31.0"
11
+ "@solana/web3.js": "1.98.4",
12
+ "@solana/spl-stake-pool": "1.1.8",
13
+ "bn.js": "5.2.2"
12
14
  },
13
15
  "devDependencies": {
14
16
  "typescript": "5.4.5"
package/src/common.ts CHANGED
@@ -1,23 +1,24 @@
1
- import { BN, web3 } from "@coral-xyz/anchor"
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import BN from 'bn.js';
2
3
 
3
4
  export interface SyEmissionRaw {
4
- mint: web3.PublicKey
5
+ mint: PublicKey
5
6
  index: AnchorizedPNum
6
7
  lastSeenTotalAccruedEmissions: BN
7
8
  totalClaimedEmissions: BN
8
- tokenProgram: web3.PublicKey
9
- escrowAccount: web3.PublicKey
9
+ tokenProgram: PublicKey
10
+ escrowAccount: PublicKey
10
11
  treasuryEmission: BN
11
12
  lastSeenIndex: AnchorizedPNum
12
13
  }
13
14
 
14
15
  export interface SyEmissionRaw2 {
15
- mint: web3.PublicKey
16
+ mint: PublicKey
16
17
  index: AnchorizedPNum
17
18
  last_seen_total_accrued_emissions: BN
18
19
  total_claimed_emissions: BN
19
- token_program: web3.PublicKey
20
- escrow_account: web3.PublicKey
20
+ token_program: PublicKey
21
+ escrow_account: PublicKey
21
22
  treasury_emission: BN
22
23
  last_seen_index: AnchorizedPNum
23
24
  }
@@ -34,4 +35,4 @@ export interface SyEmissionJson {
34
35
  }
35
36
 
36
37
  export type AnchorizedPNum = { 0: BN[] }
37
- export type AnchorizedPNumJson = { 0: string[] }
38
+ export type AnchorizedPNumJson = { 0: string[] }
package/src/cpi.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { web3 } from "@coral-xyz/anchor"
1
+ import { PublicKey } from "@solana/web3.js"
2
2
 
3
3
  export interface AccountInfo {
4
- pubkey: web3.PublicKey
4
+ pubkey: PublicKey
5
5
  isSigner: boolean
6
6
  isWritable: boolean
7
7
  }
@@ -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
@@ -45,7 +68,7 @@ export type AccountInfoJson = {
45
68
 
46
69
  export function deserializeCpiAccountsRaw(serialized: CpiAccountsRawJson): CpiAccountsRaw {
47
70
  const deserializeAccountInfo = (accountInfo: AccountInfoJson): AccountInfo => ({
48
- pubkey: new web3.PublicKey(accountInfo.pubkey),
71
+ pubkey: new PublicKey(accountInfo.pubkey),
49
72
  isSigner: accountInfo.isSigner,
50
73
  isWritable: accountInfo.isWritable,
51
74
  })
@@ -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/flavor.ts CHANGED
@@ -1,41 +1,40 @@
1
- import { web3 } from "@coral-xyz/anchor"
2
1
  import { MfiSyStateJson, MfiSyState } from "./marginfi"
3
2
  import { KaminoSyState, KaminoSyStateJson } from "./kamino"
4
3
  import { JitoRestakingSyState, JitoRestakingSyStateJson } from "./jito-restaking"
5
4
  import { AnchorizedPNum } from "./common"
6
5
  import { PerenaSyState, PerenaSyStateJson } from "./perena"
7
6
  import { GenericSyState, GenericSyStateJson } from "./generic"
8
-
7
+ import {PublicKey, TransactionInstruction} from "@solana/web3.js"
9
8
  export type FlavorDiscriminator = "marginfi" | "kamino" | "jitoRestaking" | "perena" | "generic"
10
9
 
11
10
  export type MintSyArgs = {
12
11
  amountBase: string
13
- depositor: web3.PublicKey
14
- depositorBaseTokenAccount: web3.PublicKey
15
- depositorSyTokenAccount: web3.PublicKey
12
+ depositor: PublicKey
13
+ depositorBaseTokenAccount: PublicKey
14
+ depositorSyTokenAccount: PublicKey
16
15
  }
17
16
 
18
17
  export type RedeemSyArgs = {
19
18
  amountSy: string
20
- redeemer: web3.PublicKey
21
- redeemerBaseTokenAccount: web3.PublicKey
22
- redeemerSyTokenAccount: web3.PublicKey
19
+ redeemer: PublicKey
20
+ redeemerBaseTokenAccount: PublicKey
21
+ redeemerSyTokenAccount: PublicKey
23
22
  }
24
23
 
25
24
  export type InterfaceInstructionArgs = {
26
- signer: web3.PublicKey
25
+ signer: PublicKey
27
26
  amountBase: string
28
27
  }
29
28
 
30
29
  type BaseFlavorState = {
31
30
  flavor: FlavorDiscriminator
32
31
  currentSyExchangeRate: number
33
- mintBase: web3.PublicKey
34
- baseTokenProgram: web3.PublicKey
32
+ mintBase: PublicKey
33
+ baseTokenProgram: PublicKey
35
34
  emissions: {
36
35
  exchangeRate: AnchorizedPNum
37
- mint: web3.PublicKey
38
- tokenProgram: web3.PublicKey
36
+ mint: PublicKey
37
+ tokenProgram: PublicKey
39
38
  }[]
40
39
  }
41
40
 
@@ -52,12 +51,12 @@ type BaseFlavorStateJson = {
52
51
  }
53
52
 
54
53
  interface BaseFlavorTrait {
55
- ixMintSy: (args: MintSyArgs) => Promise<web3.TransactionInstruction>
56
- ixRedeemSy: (args: RedeemSyArgs) => Promise<web3.TransactionInstruction>
57
- preIxs: (args: { signer: web3.PublicKey }) => Promise<web3.TransactionInstruction[]>
58
- postIxs: (args: { signer: web3.PublicKey }) => Promise<web3.TransactionInstruction[]>
59
- preMintSyIx?: (args: InterfaceInstructionArgs) => Promise<web3.TransactionInstruction[]>
60
- postRedeemSyIx?: (args: InterfaceInstructionArgs) => Promise<web3.TransactionInstruction[]>
54
+ ixMintSy: (args: MintSyArgs) => Promise<TransactionInstruction>
55
+ ixRedeemSy: (args: RedeemSyArgs) => Promise<TransactionInstruction>
56
+ preIxs: (args: { signer: PublicKey }) => Promise<TransactionInstruction[]>
57
+ postIxs: (args: { signer: PublicKey }) => Promise<TransactionInstruction[]>
58
+ preMintSyIx?: (args: InterfaceInstructionArgs) => Promise<TransactionInstruction[]>
59
+ postRedeemSyIx?: (args: InterfaceInstructionArgs) => Promise<TransactionInstruction[]>
61
60
  }
62
61
 
63
62
  export interface FlavorKaminoState extends BaseFlavorState {
@@ -67,9 +66,9 @@ export interface FlavorKaminoState extends BaseFlavorState {
67
66
 
68
67
  export interface FlavorMarginfiState extends BaseFlavorState {
69
68
  flavor: "marginfi"
70
- bank: web3.PublicKey
71
- emissionMint?: web3.PublicKey
72
- emissionTokenProgram?: web3.PublicKey
69
+ bank: PublicKey
70
+ emissionMint?: PublicKey
71
+ emissionTokenProgram?: PublicKey
73
72
  mfiSyState: MfiSyState
74
73
  }
75
74
 
package/src/generic.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { BN, web3 } from "@coral-xyz/anchor"
2
-
1
+ import { PublicKey } from "@solana/web3.js"
3
2
  import { AnchorizedPNum, SyEmissionJson, SyEmissionRaw } from "./common"
4
-
3
+ import { StakePoolAccount } from "@solana/spl-stake-pool"
4
+ import BN from 'bn.js'
5
5
  export type InterfaceTypeGeneric =
6
6
  | {
7
7
  pyth: {
@@ -58,6 +58,19 @@ export type InterfaceTypeGeneric =
58
58
  padding: number[]
59
59
  }
60
60
  }
61
+ | {
62
+ reflect: {
63
+ padding: number[]
64
+ }
65
+ }
66
+ | {
67
+ ore: Record<string, never>
68
+ }
69
+ | {
70
+ chainlink: {
71
+ padding: number[]
72
+ }
73
+ }
61
74
  export type InterfaceTypeGenericJson =
62
75
  | {
63
76
  pyth: {
@@ -114,29 +127,51 @@ export type InterfaceTypeGenericJson =
114
127
  padding: number[]
115
128
  }
116
129
  }
130
+ | {
131
+ reflect: {
132
+ padding: number[]
133
+ }
134
+ }
135
+ | {
136
+ ore: Record<string, never>
137
+ }
138
+ | {
139
+ chainlink: {
140
+ padding: number[]
141
+ }
142
+ }
117
143
  /** Additional data that different interface types may need */
118
144
  export interface AdditionalDataGeneric {
119
145
  fragmetricData?: {
120
- receiptTokenMint: web3.PublicKey
121
- wrappedTokenMint: web3.PublicKey
146
+ receiptTokenMint: PublicKey
147
+ wrappedTokenMint: PublicKey
122
148
  }
123
149
  jupiterLendData?: {
124
- baseTokenMint: web3.PublicKey
125
- tokenReservesLiquidity: web3.PublicKey
126
- lendingSupplyPosition: web3.PublicKey
127
- rewardsRateModel: web3.PublicKey
128
- rateModel: web3.PublicKey
150
+ baseTokenMint: PublicKey
151
+ tokenReservesLiquidity: PublicKey
152
+ lendingSupplyPosition: PublicKey
153
+ rewardsRateModel: PublicKey
154
+ rateModel: PublicKey
129
155
  }
130
156
  kaminoVaultData?: {
131
- vault: web3.PublicKey
157
+ vault: PublicKey
132
158
  reserves: {
133
- reserveAddress: web3.PublicKey
134
- marketAddress: web3.PublicKey
159
+ reserveAddress: PublicKey
160
+ marketAddress: PublicKey
135
161
  }[]
136
- tokenVault: web3.PublicKey
137
- tokenMint: web3.PublicKey
138
- baseVaultAuthority: web3.PublicKey
139
- sharesMint: web3.PublicKey
162
+ tokenVault: PublicKey
163
+ tokenMint: PublicKey
164
+ baseVaultAuthority: PublicKey
165
+ sharesMint: PublicKey
166
+ }
167
+ splStakePoolData?: {
168
+ stakePoolAccount?: StakePoolAccount // Optional because it is expensive to serialize / not always needed on clients
169
+ stakePoolAddress: PublicKey
170
+ stakePoolProgramId: PublicKey // Dynamic program ID from account owner
171
+ validatorList: PublicKey
172
+ reserveStake: PublicKey
173
+ managerFeeAccount: PublicKey
174
+ poolMint: PublicKey
140
175
  }
141
176
  // Add other interface-specific data here as needed
142
177
  // meteoraData?: { ... }
@@ -153,6 +188,28 @@ export interface AdditionalDataGenericJson {
153
188
  jupiterLendData?: {
154
189
  baseTokenMint: string
155
190
  tokenReservesLiquidity: string
191
+ lendingSupplyPosition: string
192
+ rewardsRateModel: string
193
+ rateModel: string
194
+ }
195
+ kaminoVaultData?: {
196
+ vault: string
197
+ reserves: {
198
+ reserveAddress: string
199
+ marketAddress: string
200
+ }[]
201
+ tokenVault: string
202
+ tokenMint: string
203
+ baseVaultAuthority: string
204
+ sharesMint: string
205
+ }
206
+ splStakePoolData?: {
207
+ stakePoolAddress: string
208
+ stakePoolProgramId: string
209
+ validatorList: string
210
+ reserveStake: string
211
+ managerFeeAccount: string
212
+ poolMint: string
156
213
  }
157
214
  // Add other interface-specific data here as needed
158
215
  // meteoraData?: { ... }
@@ -163,7 +220,15 @@ export interface AdditionalDataGenericJson {
163
220
  export interface Hook {
164
221
  enabled: boolean
165
222
  interfaceEmissionsAccountsUntil: number
166
- programId: web3.PublicKey
223
+ programId: PublicKey
224
+ preMintHookDiscriminator: number[]
225
+ postRedeemHookDiscriminator: number[]
226
+ }
227
+
228
+ export interface HookJson {
229
+ enabled: boolean
230
+ interfaceEmissionsAccountsUntil: number
231
+ programId: string
167
232
  preMintHookDiscriminator: number[]
168
233
  postRedeemHookDiscriminator: number[]
169
234
  }
@@ -173,13 +238,13 @@ export interface HookRaw {
173
238
  interfaceEmissionsAccountsUntil: number
174
239
  preMintHookDiscriminator: Buffer
175
240
  postRedeemHookDiscriminator: Buffer
176
- programId: web3.PublicKey
241
+ programId: PublicKey
177
242
  }
178
243
 
179
244
  export interface GenericSyState {
180
- selfAddress: web3.PublicKey
245
+ selfAddress: PublicKey
181
246
  account: GenericSyMetaAccount
182
- tokenProgramBase: web3.PublicKey
247
+ tokenProgramBase: PublicKey
183
248
  syRate: number
184
249
  additionalData?: AdditionalDataGeneric
185
250
  }
@@ -206,16 +271,16 @@ export interface GenericSyMetaAccountJson {
206
271
  maxSySupply: string
207
272
  minMintSize: string
208
273
  minRedeemSize: string
209
- hook: HookRaw
274
+ hook: HookJson
210
275
  emissions: SyEmissionJson[]
211
276
  index: number
212
277
  }
213
278
 
214
279
  export interface GenericSyMetaAccount {
215
- mintSy: web3.PublicKey
216
- yieldBearingMint: web3.PublicKey
217
- tokenSyEscrow: web3.PublicKey
218
- interfaceAccounts: web3.PublicKey[]
280
+ mintSy: PublicKey
281
+ yieldBearingMint: PublicKey
282
+ tokenSyEscrow: PublicKey
283
+ interfaceAccounts: PublicKey[]
219
284
  interfaceType: InterfaceTypeGeneric
220
285
  maxSySupply: BN
221
286
  minMintSize: BN
@@ -226,15 +291,15 @@ export interface GenericSyMetaAccount {
226
291
  }
227
292
 
228
293
  export interface GenericSyMetaAccountRaw {
229
- mintSy: web3.PublicKey
230
- yieldBearingMint: web3.PublicKey
231
- tokenSyEscrow: web3.PublicKey
294
+ mintSy: PublicKey
295
+ yieldBearingMint: PublicKey
296
+ tokenSyEscrow: PublicKey
232
297
  maxSySupply: BN
233
298
  minMintSize: BN
234
299
  minRedeemSize: BN
235
300
  selfAddressBump: number[]
236
301
  emissions: SyEmissionRaw[]
237
- interfaceAccounts: web3.PublicKey[]
302
+ interfaceAccounts: PublicKey[]
238
303
  interfaceType: InterfaceTypeGeneric
239
304
  index: AnchorizedPNum
240
305
  hook: HookRaw
@@ -351,6 +416,28 @@ export function fromInterfaceTypeGenericJson(json: InterfaceTypeGenericJson): In
351
416
  return json as InterfaceTypeGeneric
352
417
  }
353
418
 
419
+ /** Convert Hook to HookJson */
420
+ export function toHookJson(hook: Hook): HookJson {
421
+ return {
422
+ enabled: hook.enabled,
423
+ interfaceEmissionsAccountsUntil: hook.interfaceEmissionsAccountsUntil,
424
+ programId: hook.programId.toString(),
425
+ preMintHookDiscriminator: hook.preMintHookDiscriminator,
426
+ postRedeemHookDiscriminator: hook.postRedeemHookDiscriminator,
427
+ }
428
+ }
429
+
430
+ /** Convert HookJson to Hook */
431
+ export function fromHookJson(json: HookJson): Hook {
432
+ return {
433
+ enabled: json.enabled,
434
+ interfaceEmissionsAccountsUntil: json.interfaceEmissionsAccountsUntil,
435
+ programId: new PublicKey(json.programId),
436
+ preMintHookDiscriminator: json.preMintHookDiscriminator,
437
+ postRedeemHookDiscriminator: json.postRedeemHookDiscriminator,
438
+ }
439
+ }
440
+
354
441
  /** Convert AdditionalDataGeneric to AdditionalDataGenericJson */
355
442
  export function toAdditionalDataGenericJson(additionalData: AdditionalDataGeneric): AdditionalDataGenericJson {
356
443
  const result: AdditionalDataGenericJson = {}
@@ -362,6 +449,41 @@ export function toAdditionalDataGenericJson(additionalData: AdditionalDataGeneri
362
449
  }
363
450
  }
364
451
 
452
+ if (additionalData.jupiterLendData) {
453
+ result.jupiterLendData = {
454
+ baseTokenMint: additionalData.jupiterLendData.baseTokenMint.toString(),
455
+ tokenReservesLiquidity: additionalData.jupiterLendData.tokenReservesLiquidity.toString(),
456
+ lendingSupplyPosition: additionalData.jupiterLendData.lendingSupplyPosition.toString(),
457
+ rewardsRateModel: additionalData.jupiterLendData.rewardsRateModel.toString(),
458
+ rateModel: additionalData.jupiterLendData.rateModel.toString(),
459
+ }
460
+ }
461
+
462
+ if (additionalData.kaminoVaultData) {
463
+ result.kaminoVaultData = {
464
+ vault: additionalData.kaminoVaultData.vault.toString(),
465
+ reserves: additionalData.kaminoVaultData.reserves.map((r) => ({
466
+ reserveAddress: r.reserveAddress.toString(),
467
+ marketAddress: r.marketAddress.toString(),
468
+ })),
469
+ tokenVault: additionalData.kaminoVaultData.tokenVault.toString(),
470
+ tokenMint: additionalData.kaminoVaultData.tokenMint.toString(),
471
+ baseVaultAuthority: additionalData.kaminoVaultData.baseVaultAuthority.toString(),
472
+ sharesMint: additionalData.kaminoVaultData.sharesMint.toString(),
473
+ }
474
+ }
475
+
476
+ if (additionalData.splStakePoolData) {
477
+ result.splStakePoolData = {
478
+ stakePoolAddress: additionalData.splStakePoolData.stakePoolAddress.toString(),
479
+ stakePoolProgramId: additionalData.splStakePoolData.stakePoolProgramId.toString(),
480
+ validatorList: additionalData.splStakePoolData.validatorList.toString(),
481
+ reserveStake: additionalData.splStakePoolData.reserveStake.toString(),
482
+ managerFeeAccount: additionalData.splStakePoolData.managerFeeAccount.toString(),
483
+ poolMint: additionalData.splStakePoolData.poolMint.toString(),
484
+ }
485
+ }
486
+
365
487
  return result
366
488
  }
367
489
 
@@ -371,8 +493,43 @@ export function fromAdditionalDataGenericJson(json: AdditionalDataGenericJson):
371
493
 
372
494
  if (json.fragmetricData) {
373
495
  result.fragmetricData = {
374
- receiptTokenMint: new web3.PublicKey(json.fragmetricData.receiptTokenMint),
375
- wrappedTokenMint: new web3.PublicKey(json.fragmetricData.wrappedTokenMint),
496
+ receiptTokenMint: new PublicKey(json.fragmetricData.receiptTokenMint),
497
+ wrappedTokenMint: new PublicKey(json.fragmetricData.wrappedTokenMint),
498
+ }
499
+ }
500
+
501
+ if (json.jupiterLendData) {
502
+ result.jupiterLendData = {
503
+ baseTokenMint: new PublicKey(json.jupiterLendData.baseTokenMint),
504
+ tokenReservesLiquidity: new PublicKey(json.jupiterLendData.tokenReservesLiquidity),
505
+ lendingSupplyPosition: new PublicKey(json.jupiterLendData.lendingSupplyPosition),
506
+ rewardsRateModel: new PublicKey(json.jupiterLendData.rewardsRateModel),
507
+ rateModel: new PublicKey(json.jupiterLendData.rateModel),
508
+ }
509
+ }
510
+
511
+ if (json.kaminoVaultData) {
512
+ result.kaminoVaultData = {
513
+ vault: new PublicKey(json.kaminoVaultData.vault),
514
+ reserves: json.kaminoVaultData.reserves.map((r) => ({
515
+ reserveAddress: new PublicKey(r.reserveAddress),
516
+ marketAddress: new PublicKey(r.marketAddress),
517
+ })),
518
+ tokenVault: new PublicKey(json.kaminoVaultData.tokenVault),
519
+ tokenMint: new PublicKey(json.kaminoVaultData.tokenMint),
520
+ baseVaultAuthority: new PublicKey(json.kaminoVaultData.baseVaultAuthority),
521
+ sharesMint: new PublicKey(json.kaminoVaultData.sharesMint),
522
+ }
523
+ }
524
+
525
+ if (json.splStakePoolData) {
526
+ result.splStakePoolData = {
527
+ stakePoolAddress: new PublicKey(json.splStakePoolData.stakePoolAddress),
528
+ stakePoolProgramId: new PublicKey(json.splStakePoolData.stakePoolProgramId),
529
+ validatorList: new PublicKey(json.splStakePoolData.validatorList),
530
+ reserveStake: new PublicKey(json.splStakePoolData.reserveStake),
531
+ managerFeeAccount: new PublicKey(json.splStakePoolData.managerFeeAccount),
532
+ poolMint: new PublicKey(json.splStakePoolData.poolMint),
376
533
  }
377
534
  }
378
535
 
@@ -382,11 +539,11 @@ export function fromAdditionalDataGenericJson(json: AdditionalDataGenericJson):
382
539
  /** Helper function to extract fragmetric data from additional data */
383
540
  export function getFragmetricDataFromAdditionalData(additionalData?: AdditionalDataGeneric):
384
541
  | {
385
- receiptTokenMint: web3.PublicKey
386
- wrappedTokenMint: web3.PublicKey
542
+ receiptTokenMint: PublicKey
543
+ wrappedTokenMint: PublicKey
387
544
  }
388
545
  | undefined {
389
546
  if (!additionalData) return undefined
390
547
 
391
548
  return additionalData.fragmetricData
392
- }
549
+ }