@defisaver/positions-sdk 2.1.127-dev → 2.1.127-midnight-1-dev

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 (73) hide show
  1. package/cjs/config/contracts.d.ts +249 -0
  2. package/cjs/config/contracts.js +11 -1
  3. package/cjs/contracts.d.ts +1510 -0
  4. package/cjs/contracts.js +3 -2
  5. package/cjs/helpers/index.d.ts +1 -0
  6. package/cjs/helpers/index.js +2 -1
  7. package/cjs/helpers/morphoBlueHelpers/index.js +0 -1
  8. package/cjs/helpers/morphoMidnightHelpers/index.d.ts +50 -0
  9. package/cjs/helpers/morphoMidnightHelpers/index.js +170 -0
  10. package/cjs/index.d.ts +2 -1
  11. package/cjs/index.js +3 -1
  12. package/cjs/markets/index.d.ts +1 -0
  13. package/cjs/markets/index.js +4 -1
  14. package/cjs/markets/morphoMidnight/index.d.ts +16 -0
  15. package/cjs/markets/morphoMidnight/index.js +159 -0
  16. package/cjs/morphoBlue/index.d.ts +6 -8
  17. package/cjs/morphoBlue/index.js +40 -69
  18. package/cjs/morphoMidnight/index.d.ts +14 -0
  19. package/cjs/morphoMidnight/index.js +244 -0
  20. package/cjs/portfolio/discovery.js +4 -0
  21. package/cjs/portfolio/index.js +45 -1
  22. package/cjs/services/viem.d.ts +11 -11
  23. package/cjs/types/index.d.ts +1 -0
  24. package/cjs/types/index.js +1 -0
  25. package/cjs/types/morphoBlue.d.ts +0 -9
  26. package/cjs/types/morphoMidnight.d.ts +94 -0
  27. package/cjs/types/morphoMidnight.js +15 -0
  28. package/cjs/types/portfolio.d.ts +4 -0
  29. package/esm/config/contracts.d.ts +249 -0
  30. package/esm/config/contracts.js +9 -0
  31. package/esm/contracts.d.ts +1510 -0
  32. package/esm/contracts.js +1 -0
  33. package/esm/helpers/index.d.ts +1 -0
  34. package/esm/helpers/index.js +1 -0
  35. package/esm/helpers/morphoBlueHelpers/index.js +0 -1
  36. package/esm/helpers/morphoMidnightHelpers/index.d.ts +50 -0
  37. package/esm/helpers/morphoMidnightHelpers/index.js +159 -0
  38. package/esm/index.d.ts +2 -1
  39. package/esm/index.js +2 -1
  40. package/esm/markets/index.d.ts +1 -0
  41. package/esm/markets/index.js +1 -0
  42. package/esm/markets/morphoMidnight/index.d.ts +16 -0
  43. package/esm/markets/morphoMidnight/index.js +148 -0
  44. package/esm/morphoBlue/index.d.ts +6 -8
  45. package/esm/morphoBlue/index.js +39 -62
  46. package/esm/morphoMidnight/index.d.ts +14 -0
  47. package/esm/morphoMidnight/index.js +231 -0
  48. package/esm/portfolio/discovery.js +5 -1
  49. package/esm/portfolio/index.js +47 -3
  50. package/esm/services/viem.d.ts +11 -11
  51. package/esm/types/index.d.ts +1 -0
  52. package/esm/types/index.js +1 -0
  53. package/esm/types/morphoBlue.d.ts +0 -9
  54. package/esm/types/morphoMidnight.d.ts +94 -0
  55. package/esm/types/morphoMidnight.js +12 -0
  56. package/esm/types/portfolio.d.ts +4 -0
  57. package/package.json +1 -1
  58. package/src/config/contracts.ts +9 -0
  59. package/src/contracts.ts +1 -0
  60. package/src/helpers/index.ts +1 -0
  61. package/src/helpers/morphoBlueHelpers/index.ts +0 -1
  62. package/src/helpers/morphoMidnightHelpers/index.ts +219 -0
  63. package/src/index.ts +2 -0
  64. package/src/markets/index.ts +1 -0
  65. package/src/markets/morphoMidnight/index.ts +161 -0
  66. package/src/morphoBlue/index.ts +44 -101
  67. package/src/morphoMidnight/index.ts +261 -0
  68. package/src/portfolio/discovery.ts +6 -0
  69. package/src/portfolio/index.ts +46 -2
  70. package/src/types/index.ts +1 -0
  71. package/src/types/morphoBlue.ts +0 -11
  72. package/src/types/morphoMidnight.ts +110 -0
  73. package/src/types/portfolio.ts +4 -0
@@ -0,0 +1,110 @@
1
+ import {
2
+ EthAddress, IncentiveData, LeverageType, MMUsedAssets, NetworkNumber,
3
+ } from './common';
4
+
5
+ export enum MorphoMidnightVersions {
6
+ // BASE
7
+ // Fixed-term markets are disambiguated by maturity (YYYYMMDD), so the same pair recurs across dates.
8
+ // Sourced from the official listing at https://markets.morpho.org/fixed/base (see sitemap.xml).
9
+ MorphoMidnightCbBTCUSDC_860_20260731_Base = 'morphomidnightcbbtcusdc_860_20260731_base',
10
+ MorphoMidnightCbBTCUSDC_860_20260828_Base = 'morphomidnightcbbtcusdc_860_20260828_base',
11
+ MorphoMidnightCbBTCUSDC_860_20260925_Base = 'morphomidnightcbbtcusdc_860_20260925_base',
12
+ MorphoMidnightCbBTCUSDC_860_20261030_Base = 'morphomidnightcbbtcusdc_860_20261030_base',
13
+ MorphoMidnightCbBTCUSDC_860_20261127_Base = 'morphomidnightcbbtcusdc_860_20261127_base',
14
+ MorphoMidnightCbBTCUSDC_860_20261225_Base = 'morphomidnightcbbtcusdc_860_20261225_base',
15
+ }
16
+
17
+ export interface MorphoMidnightCollateralParams {
18
+ token: EthAddress,
19
+ lltv: number | string,
20
+ liquidationCursor: number | string,
21
+ oracle: EthAddress,
22
+ }
23
+
24
+ export interface MorphoMidnightMarketData {
25
+ chainIds: NetworkNumber[],
26
+ label: string,
27
+ shortLabel: string,
28
+ url: string,
29
+ value: MorphoMidnightVersions,
30
+ midnight: EthAddress,
31
+ loanToken: EthAddress,
32
+ collaterals: MorphoMidnightCollateralParams[],
33
+ maturity: number, // unix timestamp (seconds)
34
+ rcfThreshold: number | string,
35
+ enterGate: EthAddress,
36
+ liquidatorGate: EthAddress,
37
+ marketId: string, // bytes32, precomputed off-chain (verify with MidnightView.toId)
38
+ protocolName: string,
39
+ }
40
+
41
+ export interface MorphoMidnightAssetData {
42
+ symbol: string,
43
+ address: string,
44
+ price: string,
45
+ supplyRate: string,
46
+ borrowRate: string,
47
+ supplyIncentives: IncentiveData[],
48
+ borrowIncentives: IncentiveData[],
49
+ totalSupply?: string,
50
+ totalBorrow?: string,
51
+ canBeSupplied?: boolean,
52
+ canBeBorrowed?: boolean,
53
+ lltv?: string,
54
+ }
55
+
56
+ export type MorphoMidnightAssetsData = { [key: string]: MorphoMidnightAssetData };
57
+
58
+ export interface MorphoMidnightMarketInfo {
59
+ id: string,
60
+ loanToken: string,
61
+ collaterals: string[], // collateral symbols, index-aligned with the market's collateral set
62
+ maturity: number, // unix timestamp (seconds)
63
+ isMatured: boolean, // true once now >= maturity; no new debt can be opened
64
+ totalUnits: string, // face-value units on the market (= totalDebt + withdrawable)
65
+ withdrawable: string, // loan-token liquidity available for withdraw
66
+ totalDebt: string,
67
+ lossFactor: string, // bad-debt socialization factor applied to lender credit
68
+ tickSpacing: number, // orderbook price granularity (relevant to phase-2 rate math)
69
+ utillization: string,
70
+ assetsData: MorphoMidnightAssetsData,
71
+ }
72
+
73
+ export interface MorphoMidnightAggregatedPositionData {
74
+ suppliedUsd: string,
75
+ suppliedCollateralUsd: string,
76
+ borrowedUsd: string,
77
+ borrowLimitUsd: string,
78
+ liquidationLimitUsd: string,
79
+ leftToBorrowUsd: string,
80
+ leftToBorrow: string,
81
+ netApy: string,
82
+ incentiveUsd: string,
83
+ totalInterestUsd: string,
84
+ ltv: string,
85
+ ratio: string, // health ratio as a percentage (from MidnightView.ratio, 1e18-scaled)
86
+ healthRatio: string, // liquidationLimitUsd / borrowedUsd
87
+ leveragedType: LeverageType,
88
+ leveragedAsset?: string,
89
+ currentVolatilePairRatio?: string,
90
+ liquidationPrice?: string,
91
+ minCollRatio?: string,
92
+ collLiquidationRatio?: string,
93
+ exposure: string,
94
+ }
95
+
96
+ // Fixed-rate/YTM (derived from entry price + orderbook) is intentionally absent in MVP:
97
+ // MidnightView exposes no per-position rate, so a variable-MM-style APY would be misleading.
98
+ export interface MorphoMidnightPositionData extends MorphoMidnightAggregatedPositionData {
99
+ usedAssets: MMUsedAssets,
100
+ credit: string, // lender credit units, face value at maturity (with interest); 0 for borrowers
101
+ debt: string, // borrower debt, face value at maturity (with interest); 0 for lenders
102
+ // Borrow rate + base/interest split are orderbook-derived off-chain (from the Midnight transactions API):
103
+ // MidnightView only stores `debt` (= face value at maturity), so principal-vs-interest and the effective
104
+ // rate are computed from the fill history. Default to '0'/`debt`/'0' for lenders or when the API is unavailable.
105
+ borrowRate: string, // weighted-average borrow APY as a percent
106
+ debtBase: string, // base borrowed (principal), loan-token units
107
+ debtInterest: string, // debt − debtBase (fixed interest owed at maturity), loan-token units
108
+ maturity: number,
109
+ isMatured: boolean,
110
+ }
@@ -10,6 +10,7 @@ import { LiquityV2TroveData, LiquityV2Versions } from './liquityV2';
10
10
  import { LlamaLendUserData, LlamaLendVersionsType } from './llamaLend';
11
11
  import { CdpData } from './maker';
12
12
  import { MorphoBluePositionData, MorphoBlueVersions } from './morphoBlue';
13
+ import { MorphoMidnightPositionData, MorphoMidnightVersions } from './morphoMidnight';
13
14
  import { SparkPositionData, SparkVersions } from './spark';
14
15
 
15
16
  export interface PortfolioProtocolData<T> {
@@ -24,6 +25,9 @@ export interface PortfolioPositionsDataForAddress {
24
25
  morphoBlue: {
25
26
  [key in MorphoBlueVersions]?: PortfolioProtocolData<MorphoBluePositionData>;
26
27
  };
28
+ morphoMidnight: {
29
+ [key in MorphoMidnightVersions]?: PortfolioProtocolData<MorphoMidnightPositionData>;
30
+ };
27
31
  compoundV3: {
28
32
  [key in CompoundVersions]?: PortfolioProtocolData<CompoundV3PositionData>;
29
33
  };