@exponent-labs/exponent-fetcher 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.
Files changed (50) hide show
  1. package/build/exponentFetcher.d.ts +303 -31
  2. package/build/exponentFetcher.js +666 -168
  3. package/build/exponentFetcher.js.map +1 -1
  4. package/build/index.d.ts +10 -0
  5. package/build/index.js +10 -0
  6. package/build/index.js.map +1 -1
  7. package/build/utils/adrena.d.ts +13 -0
  8. package/build/utils/adrena.js +29 -0
  9. package/build/utils/adrena.js.map +1 -0
  10. package/build/utils/fragmetric.d.ts +17 -0
  11. package/build/utils/fragmetric.js +23 -0
  12. package/build/utils/fragmetric.js.map +1 -0
  13. package/build/utils/jito.d.ts +7 -0
  14. package/build/utils/jito.js +29 -0
  15. package/build/utils/jito.js.map +1 -0
  16. package/build/utils/jupiter.d.ts +30 -0
  17. package/build/utils/jupiter.js +63 -0
  18. package/build/utils/jupiter.js.map +1 -0
  19. package/build/utils/kamino.d.ts +5 -0
  20. package/build/utils/kamino.js +10 -0
  21. package/build/utils/kamino.js.map +1 -0
  22. package/build/utils/meteora.d.ts +19 -0
  23. package/build/utils/meteora.js +36 -1
  24. package/build/utils/meteora.js.map +1 -1
  25. package/build/utils/ore.d.ts +74 -0
  26. package/build/utils/ore.js +217 -0
  27. package/build/utils/ore.js.map +1 -0
  28. package/build/utils/perena.d.ts +12 -0
  29. package/build/utils/perena.js +27 -0
  30. package/build/utils/perena.js.map +1 -0
  31. package/build/utils/sanctum.d.ts +6 -0
  32. package/build/utils/sanctum.js +26 -0
  33. package/build/utils/sanctum.js.map +1 -0
  34. package/build/utils/solstice.d.ts +12 -0
  35. package/build/utils/solstice.js +45 -0
  36. package/build/utils/solstice.js.map +1 -0
  37. package/package.json +20 -18
  38. package/src/exponentFetcher.ts +1077 -222
  39. package/src/index.ts +10 -0
  40. package/src/utils/adrena.ts +44 -0
  41. package/src/utils/fragmetric.ts +34 -0
  42. package/src/utils/jito.ts +30 -0
  43. package/src/utils/jupiter.ts +98 -0
  44. package/src/utils/kamino.ts +6 -0
  45. package/src/utils/meteora.ts +73 -1
  46. package/src/utils/ore.ts +322 -0
  47. package/src/utils/perena.ts +28 -0
  48. package/src/utils/sanctum.ts +24 -0
  49. package/src/utils/solstice.ts +51 -0
  50. package/tsconfig.json +2 -0
@@ -0,0 +1,51 @@
1
+ import { decodeYieldPoolAndVestingScheduleAccounts } from "@exponent-labs/solstice-idl"
2
+
3
+ export function calculateSolsticeRedemptionRate(accounts: { yieldPool: Buffer; vestingSchedule: Buffer }): {
4
+ redemptionRate: number
5
+ totalAssets: string
6
+ sharesSupply: string
7
+ vestingAmount: string
8
+ totalVestedAssets: string
9
+ } {
10
+ // Decode accounts using solstice-idl package function
11
+ const { yieldPoolAccount, vestingScheduleAccount } = decodeYieldPoolAndVestingScheduleAccounts({
12
+ yieldPool: accounts.yieldPool,
13
+ vestingSchedule: accounts.vestingSchedule,
14
+ })
15
+
16
+ // Extract fields for calculation (convert BN to bigint)
17
+ const poolTotalAssets = BigInt(yieldPoolAccount.total_assets.toString())
18
+ const poolSharesSupply = BigInt(yieldPoolAccount.shares_supply.toString())
19
+ const vestingAmount = BigInt(vestingScheduleAccount.vesting_amount.toString())
20
+
21
+ // Calculate total vested assets (mimicking the Rust logic)
22
+ let totalVestedAssets: bigint
23
+ if (vestingAmount === 0n) {
24
+ totalVestedAssets = poolTotalAssets // If no vesting amount, all assets are considered vested
25
+ } else {
26
+ const vestingStart = BigInt(vestingScheduleAccount.start_time.toString())
27
+ const vestingEnd = BigInt(vestingScheduleAccount.end_time.toString())
28
+ const currentTime = BigInt(Math.floor(Date.now() / 1000)) // Current Unix timestamp
29
+
30
+ // Calculate unvested amount
31
+ let unvestedAmount: bigint
32
+ if (currentTime > vestingEnd) {
33
+ unvestedAmount = 0n // If current time passed the vesting end, no unvested amount
34
+ } else {
35
+ unvestedAmount = (vestingAmount * (vestingEnd - currentTime)) / (vestingEnd - vestingStart)
36
+ }
37
+
38
+ totalVestedAssets = poolTotalAssets - unvestedAmount
39
+ }
40
+
41
+ // Calculate redemption rate: (total_vested_assets + 1) / (pool_shares_supply + 1)
42
+ const redemptionRate = Number(totalVestedAssets + 1n) / Number(poolSharesSupply + 1n)
43
+
44
+ return {
45
+ redemptionRate,
46
+ totalAssets: poolTotalAssets.toString(),
47
+ sharesSupply: poolSharesSupply.toString(),
48
+ vestingAmount: vestingAmount.toString(),
49
+ totalVestedAssets: totalVestedAssets.toString(),
50
+ }
51
+ }
package/tsconfig.json CHANGED
@@ -31,8 +31,10 @@
31
31
  { "path": "../perena-sy-idl" },
32
32
  { "path": "../fragmetric-idl" },
33
33
  { "path": "../meteora-idl" },
34
+ { "path": "../exponent-orderbook-idl" },
34
35
  { "path": "../sanctum-idl" },
35
36
  { "path": "../adrena-idl" },
37
+ { "path": "../exponent-clmm-idl" },
36
38
  { "path": "../jupiter-lend-idl" },
37
39
  { "path": "../kamino-vault-idl" },
38
40
  { "path": "../jupiter-perps-idl" },