impermax-sdk 2.1.515 → 2.1.518

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 (38) hide show
  1. package/lib/config/amms.d.ts +3 -1
  2. package/lib/config/amms.js +9 -1
  3. package/lib/config/chainId.js +1 -0
  4. package/lib/config/contracts/claim-aggregators.js +1 -0
  5. package/lib/config/contracts/ibexes.js +2 -1
  6. package/lib/config/contracts/impermax-chef.js +1 -0
  7. package/lib/config/contracts/impermax-config-manager.js +1 -0
  8. package/lib/config/contracts/impermax-factories.js +3 -0
  9. package/lib/config/contracts/imxes.js +2 -1
  10. package/lib/config/contracts/lending-vault-watcher.js +2 -1
  11. package/lib/config/contracts/merkle-distributors.js +6 -3
  12. package/lib/config/contracts/routers.js +10 -3
  13. package/lib/config/contracts/simple-uniswap-oracles.js +2 -1
  14. package/lib/config/contracts/weths.js +2 -1
  15. package/lib/config/debank-ids.js +1 -0
  16. package/lib/config/endpoints/merkle-distributors.js +3 -0
  17. package/lib/config/eth.js +2 -0
  18. package/lib/config/farms.d.ts +3 -1
  19. package/lib/config/farms.js +5 -2
  20. package/lib/config/nftlp.js +5 -1
  21. package/lib/config/private-api.js +4 -0
  22. package/lib/config/subgraphs.d.ts +2 -0
  23. package/lib/config/subgraphs.js +11 -5
  24. package/lib/config/types.d.ts +2 -1
  25. package/lib/config/types.js +1 -0
  26. package/lib/config/whitelist.js +5 -1
  27. package/lib/offchain/account/lendingPool/offchainAccountCollateralV2.d.ts +4 -4
  28. package/lib/offchain/account/lendingPool/offchainAccountCollateralV2.js +29 -16
  29. package/lib/offchain/lendingPool/offchainLendingPool.js +1 -1
  30. package/lib/offchain/offchainAPRHelper.js +2 -1
  31. package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.d.ts +4 -4
  32. package/lib/onchain/account/lendingPool/onchainAccountCollateralV2.js +31 -17
  33. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.d.ts +1 -0
  34. package/lib/onchain/impermaxFactory/lendingPool/onchainLendingPool.js +4 -0
  35. package/lib/utils/position/solidlyStable/index.d.ts +41 -0
  36. package/lib/utils/position/solidlyStable/index.js +93 -0
  37. package/lib/utils/position/uniswapV2/index.js +1 -1
  38. package/package.json +1 -1
@@ -55,7 +55,8 @@ export declare enum Amms {
55
55
  blackhole = "blackhole",
56
56
  blackhole1 = "blackhole1",
57
57
  aeroCL = "aeroCL",
58
- etherex = "etherex"
58
+ etherex = "etherex",
59
+ hyperswap = "hyperswap"
59
60
  }
60
61
  export declare const hrAmms: {
61
62
  uniswap: string;
@@ -114,6 +115,7 @@ export declare const hrAmms: {
114
115
  blackhole1: string;
115
116
  aeroCL: string;
116
117
  etherex: string;
118
+ hyperswap: string;
117
119
  };
118
120
  export declare const AMM_FACTORY: AmmIndex;
119
121
  export declare function getAmmByFactory(network: Networks, address: Address): Amms | null;
@@ -60,6 +60,7 @@ var Amms;
60
60
  Amms["blackhole1"] = "blackhole1";
61
61
  Amms["aeroCL"] = "aeroCL";
62
62
  Amms["etherex"] = "etherex";
63
+ Amms["hyperswap"] = "hyperswap";
63
64
  })(Amms = exports.Amms || (exports.Amms = {}));
64
65
  exports.hrAmms = {
65
66
  [Amms.uniswap]: 'UniswapV2',
@@ -117,7 +118,8 @@ exports.hrAmms = {
117
118
  [Amms.blackhole]: 'Blackhole',
118
119
  [Amms.blackhole1]: 'Blackhole',
119
120
  [Amms.aeroCL]: 'Aero Slipstream',
120
- [Amms.etherex]: 'Etherex'
121
+ [Amms.etherex]: 'Etherex',
122
+ [Amms.hyperswap]: 'HyperSwap'
121
123
  };
122
124
  exports.AMM_FACTORY = {
123
125
  [types_1.Networks.Ropsten]: {
@@ -226,6 +228,9 @@ exports.AMM_FACTORY = {
226
228
  [types_1.Networks.Unichain]: {
227
229
  [Amms.uniswapv3]: '0x1f98400000000000000000000000000000000003'
228
230
  },
231
+ [types_1.Networks.HyperEVM]: {
232
+ [Amms.hyperswap]: '0xB1c0fa0B789320044A6F623cFe5eBda9562602E3'
233
+ }
229
234
  };
230
235
  function getAmmByFactory(network, address) {
231
236
  if (!address)
@@ -300,6 +305,7 @@ exports.AMM_SUBGRAPH_URLS = {
300
305
  [types_1.Networks.Sonic]: {},
301
306
  [types_1.Networks.Linea]: {},
302
307
  [types_1.Networks.Unichain]: {},
308
+ [types_1.Networks.HyperEVM]: {}
303
309
  };
304
310
  exports.ADD_LIQUIDITY_URLS = {
305
311
  [types_1.Networks.Ropsten]: {
@@ -399,6 +405,7 @@ exports.ADD_LIQUIDITY_URLS = {
399
405
  [Amms.etherex]: 'https://www.etherex.finance/liquidity'
400
406
  },
401
407
  [types_1.Networks.Unichain]: {},
408
+ [types_1.Networks.HyperEVM]: {}
402
409
  };
403
410
  exports.AMM_LP_FEE = {
404
411
  [types_1.Networks.Ropsten]: {
@@ -497,4 +504,5 @@ exports.AMM_LP_FEE = {
497
504
  [Amms.etherex]: 0
498
505
  },
499
506
  [types_1.Networks.Unichain]: {},
507
+ [types_1.Networks.HyperEVM]: {}
500
508
  };
@@ -26,4 +26,5 @@ exports.CHAIN_IDS = {
26
26
  [types_1.Networks.Sonic]: 146,
27
27
  [types_1.Networks.Linea]: 59144,
28
28
  [types_1.Networks.Unichain]: 130,
29
+ [types_1.Networks.HyperEVM]: 999,
29
30
  };
@@ -26,4 +26,5 @@ exports.CLAIM_AGGREGATOR = {
26
26
  [types_1.Networks.Sonic]: '',
27
27
  [types_1.Networks.Linea]: '',
28
28
  [types_1.Networks.Unichain]: '',
29
+ [types_1.Networks.HyperEVM]: '',
29
30
  };
@@ -25,7 +25,8 @@ exports.IBEX = {
25
25
  [types_1.Networks.Real]: '',
26
26
  [types_1.Networks.Sonic]: '0x55d1d7edbc417dce5efa0df53d9445176efd3920',
27
27
  [types_1.Networks.Linea]: '0xcf0f95e34f25d1bb3d9cad3cbb2eb40dab7c3841',
28
- [types_1.Networks.Unichain]: ''
28
+ [types_1.Networks.Unichain]: '',
29
+ [types_1.Networks.HyperEVM]: '',
29
30
  };
30
31
  // Stkaing module
31
32
  exports.XIBEX = {
@@ -27,4 +27,5 @@ exports.IMPERMAX_CHEF = {
27
27
  [types_1.Networks.Sonic]: '',
28
28
  [types_1.Networks.Linea]: '',
29
29
  [types_1.Networks.Unichain]: '',
30
+ [types_1.Networks.HyperEVM]: '',
30
31
  };
@@ -26,4 +26,5 @@ exports.IMPERMAX_CONFIG_MANAGER = {
26
26
  [types_1.Networks.Sonic]: '0x1A3e33E38D2e70D43f65772f63c5B3f52073b37E',
27
27
  [types_1.Networks.Linea]: '0x3A65E736b534B3A3703Eb081b93118852Bf1796a',
28
28
  [types_1.Networks.Unichain]: '',
29
+ [types_1.Networks.HyperEVM]: '0xdbdd8535cf4efc77a47bc82d514175ff6c9d011c',
29
30
  };
@@ -78,6 +78,9 @@ exports.IMPERMAX_FACTORY = {
78
78
  [types_1.Networks.Unichain]: {
79
79
  [types_1.Factory.V3]: '0x50E7116c4a9624a2d562Ee0Ab5209F3834C15E14'
80
80
  },
81
+ [types_1.Networks.HyperEVM]: {
82
+ [types_1.Factory.V3]: '0x171d48161223a3ddb4659e093291f8f32f4e95ef'
83
+ },
81
84
  };
82
85
  function getFactoryByAddress(network, address) {
83
86
  if (!address)
@@ -25,5 +25,6 @@ exports.IMX = {
25
25
  [types_1.Networks.Real]: '',
26
26
  [types_1.Networks.Sonic]: '',
27
27
  [types_1.Networks.Linea]: '',
28
- [types_1.Networks.Unichain]: ''
28
+ [types_1.Networks.Unichain]: '',
29
+ [types_1.Networks.HyperEVM]: '',
29
30
  };
@@ -25,5 +25,6 @@ exports.LENDING_VAULT_WATCHER = {
25
25
  [types_1.Networks.Real]: '',
26
26
  [types_1.Networks.Sonic]: '0x0680AD510475844a0555914FD38979B31FdA3b2f',
27
27
  [types_1.Networks.Linea]: '0x0680AD510475844a0555914FD38979B31FdA3b2f',
28
- [types_1.Networks.Unichain]: '0x638855078c2190118cc8228e62ec4781e970d1ED'
28
+ [types_1.Networks.Unichain]: '0x638855078c2190118cc8228e62ec4781e970d1ED',
29
+ [types_1.Networks.HyperEVM]: '',
29
30
  };
@@ -25,7 +25,8 @@ exports.MERKLE_DISTRIBUTOR_IBEX = {
25
25
  [types_1.Networks.Real]: '',
26
26
  [types_1.Networks.Sonic]: '',
27
27
  [types_1.Networks.Linea]: '',
28
- [types_1.Networks.Unichain]: ''
28
+ [types_1.Networks.Unichain]: '',
29
+ [types_1.Networks.HyperEVM]: ''
29
30
  };
30
31
  exports.MERKLE_DISTRIBUTOR_IBEX_2 = {
31
32
  [types_1.Networks.Polygon]: '0x1c813cDd6dAecE2CB83C52F0798504e42816E9C5',
@@ -50,7 +51,8 @@ exports.MERKLE_DISTRIBUTOR_IBEX_2 = {
50
51
  [types_1.Networks.Real]: '',
51
52
  [types_1.Networks.Sonic]: '',
52
53
  [types_1.Networks.Linea]: '',
53
- [types_1.Networks.Unichain]: ''
54
+ [types_1.Networks.Unichain]: '',
55
+ [types_1.Networks.HyperEVM]: ''
54
56
  };
55
57
  exports.MERKLE_DISTRIBUTOR_ETH = {
56
58
  [types_1.Networks.Polygon]: '0x7ce2f634f0698ecdca051ef1dc4be96ef3d05a62',
@@ -75,5 +77,6 @@ exports.MERKLE_DISTRIBUTOR_ETH = {
75
77
  [types_1.Networks.Real]: '',
76
78
  [types_1.Networks.Sonic]: '',
77
79
  [types_1.Networks.Linea]: '',
78
- [types_1.Networks.Unichain]: ''
80
+ [types_1.Networks.Unichain]: '',
81
+ [types_1.Networks.HyperEVM]: ''
79
82
  };
@@ -25,7 +25,8 @@ exports.POOL_TOKEN_ROUTER = {
25
25
  [types_1.Networks.Optimism]: '0xbEDD49c1aB7c57EFebDdC094245920aebfd70Cf2',
26
26
  [types_1.Networks.Sonic]: '0x35A0e3C5adbddF6D917353f9b468C5cdE80ee380',
27
27
  [types_1.Networks.Linea]: '0x1c44FD7514525e1669f6E316D66dcBb42930aAd0',
28
- [types_1.Networks.Unichain]: '0xE3FE59FB4237A1D49C721e517B3c6CFc7f34E4Ec'
28
+ [types_1.Networks.Unichain]: '0xE3FE59FB4237A1D49C721e517B3c6CFc7f34E4Ec',
29
+ [types_1.Networks.HyperEVM]: '0x36050bf50679a178b6a24c4ff91369eaff0defa3',
29
30
  };
30
31
  // TODO: currently this router only supports stakedLpToken
31
32
  exports.ROUTER = {
@@ -104,6 +105,7 @@ exports.ROUTER = {
104
105
  [types_1.Factory.SOL_STABLE]: '',
105
106
  },
106
107
  [types_1.Networks.Unichain]: {},
108
+ [types_1.Networks.HyperEVM]: {},
107
109
  };
108
110
  exports.ACTIONS_GETTER = {
109
111
  [types_1.Networks.Ropsten]: '',
@@ -128,7 +130,8 @@ exports.ACTIONS_GETTER = {
128
130
  [types_1.Networks.Optimism]: '0x8fBF7406ABFdF703D384e38DC1071B5DFf228F88',
129
131
  [types_1.Networks.Sonic]: '0x58Fe056eff8729a1d42f99d8ce83a9fE81920907',
130
132
  [types_1.Networks.Linea]: '0x121f8cEf8010151C2cbF613848118bd105f15D80',
131
- [types_1.Networks.Unichain]: '0x732113815f1ecf7be18360c25b3d84328cfc0448'
133
+ [types_1.Networks.Unichain]: '0x732113815f1ecf7be18360c25b3d84328cfc0448',
134
+ [types_1.Networks.HyperEVM]: '0x6c21983b79d97d7789872cdc08dc90e0153b776a'
132
135
  };
133
136
  exports.ROUTER_V3 = {
134
137
  [types_1.Networks.Ropsten]: {},
@@ -161,6 +164,9 @@ exports.ROUTER_V3 = {
161
164
  [types_1.Networks.Linea]: {},
162
165
  [types_1.Networks.Unichain]: {
163
166
  [types_1.Extension.UniswapV3]: '0x58c5Ca4Ba713A9BBD2A95aCcbC9f545718C822C5'
167
+ },
168
+ [types_1.Networks.HyperEVM]: {
169
+ [types_1.Extension.UniswapV3]: '0x7d5b92380a1727f909cfe1b267379abfd87437c5'
164
170
  }
165
171
  };
166
172
  exports.STAKING_ROUTER = {
@@ -186,5 +192,6 @@ exports.STAKING_ROUTER = {
186
192
  [types_1.Networks.Optimism]: '',
187
193
  [types_1.Networks.Sonic]: '',
188
194
  [types_1.Networks.Linea]: '',
189
- [types_1.Networks.Unichain]: ''
195
+ [types_1.Networks.Unichain]: '',
196
+ [types_1.Networks.HyperEVM]: ''
190
197
  };
@@ -48,5 +48,6 @@ exports.SIMPLE_UNISWAP_ORACLE = {
48
48
  },
49
49
  [types_1.Networks.Sonic]: {},
50
50
  [types_1.Networks.Linea]: {},
51
- [types_1.Networks.Unichain]: {}
51
+ [types_1.Networks.Unichain]: {},
52
+ [types_1.Networks.HyperEVM]: {}
52
53
  };
@@ -26,5 +26,6 @@ exports.WETH = {
26
26
  [types_1.Networks.Real]: '0x90c6E93849E06EC7478ba24522329d14A5954Df4',
27
27
  [types_1.Networks.Sonic]: '0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38',
28
28
  [types_1.Networks.Linea]: '0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f',
29
- [types_1.Networks.Unichain]: '0x4200000000000000000000000000000000000006' // weth
29
+ [types_1.Networks.Unichain]: '0x4200000000000000000000000000000000000006',
30
+ [types_1.Networks.HyperEVM]: '0x5555555555555555555555555555555555555555' // whype
30
31
  };
@@ -26,4 +26,5 @@ exports.DEBANK_IDS = {
26
26
  [types_1.Networks.Sonic]: 'sonic',
27
27
  [types_1.Networks.Linea]: 'linea',
28
28
  [types_1.Networks.Unichain]: 'unichain',
29
+ [types_1.Networks.HyperEVM]: 'hyperliquid'
29
30
  };
@@ -26,6 +26,7 @@ exports.MERKLE_URL_IBEX = {
26
26
  [types_1.Networks.Sonic]: '',
27
27
  [types_1.Networks.Linea]: '',
28
28
  [types_1.Networks.Unichain]: '',
29
+ [types_1.Networks.HyperEVM]: '',
29
30
  };
30
31
  exports.MERKLE_URL_IBEX_2 = {
31
32
  [types_1.Networks.Polygon]: 'https://misty-rice-9880.impermax.workers.dev',
@@ -51,6 +52,7 @@ exports.MERKLE_URL_IBEX_2 = {
51
52
  [types_1.Networks.Sonic]: '',
52
53
  [types_1.Networks.Linea]: '',
53
54
  [types_1.Networks.Unichain]: '',
55
+ [types_1.Networks.HyperEVM]: '',
54
56
  };
55
57
  exports.MERKLE_URL_ETH = {
56
58
  [types_1.Networks.Polygon]: 'https://damp-hill-13d0.impermax.workers.dev',
@@ -76,4 +78,5 @@ exports.MERKLE_URL_ETH = {
76
78
  [types_1.Networks.Sonic]: '',
77
79
  [types_1.Networks.Linea]: '',
78
80
  [types_1.Networks.Unichain]: '',
81
+ [types_1.Networks.HyperEVM]: '',
79
82
  };
package/lib/config/eth.js CHANGED
@@ -26,6 +26,7 @@ exports.ETH_NAME = {
26
26
  [types_1.Networks.Sonic]: 'S',
27
27
  [types_1.Networks.Linea]: 'Ethereum',
28
28
  [types_1.Networks.Unichain]: 'Ethereum',
29
+ [types_1.Networks.HyperEVM]: 'Hyperliquid'
29
30
  };
30
31
  exports.ETH_SYMBOL = {
31
32
  [types_1.Networks.Ropsten]: 'ETH',
@@ -51,4 +52,5 @@ exports.ETH_SYMBOL = {
51
52
  [types_1.Networks.Sonic]: 'S',
52
53
  [types_1.Networks.Linea]: 'ETH',
53
54
  [types_1.Networks.Unichain]: 'ETH',
55
+ [types_1.Networks.HyperEVM]: 'HYPE'
54
56
  };
@@ -53,7 +53,8 @@ export declare enum Farms {
53
53
  nileStable = "nileStable",
54
54
  equalizerStable = "equalizerStable",
55
55
  velodromeStable = "velodromeStable",
56
- etherex = "etherex"
56
+ etherex = "etherex",
57
+ hyperswap = "hyperswap"
57
58
  }
58
59
  export declare const hrFarms: {
59
60
  quickswapOld: string;
@@ -107,6 +108,7 @@ export declare const hrFarms: {
107
108
  equalizerStable: string;
108
109
  velodromeStable: string;
109
110
  etherex: string;
111
+ hyperswap: string;
110
112
  };
111
113
  export type FarmIndex = {
112
114
  [key in Networks]: {
@@ -58,6 +58,7 @@ var Farms;
58
58
  Farms["equalizerStable"] = "equalizerStable";
59
59
  Farms["velodromeStable"] = "velodromeStable";
60
60
  Farms["etherex"] = "etherex";
61
+ Farms["hyperswap"] = "hyperswap";
61
62
  })(Farms = exports.Farms || (exports.Farms = {}));
62
63
  exports.hrFarms = {
63
64
  [Farms.quickswapOld]: 'QuickSwap',
@@ -110,7 +111,8 @@ exports.hrFarms = {
110
111
  [Farms.nileStable]: 'Nile Stable',
111
112
  [Farms.equalizerStable]: 'Equalizer Stable',
112
113
  [Farms.velodromeStable]: 'Velodrome Stable',
113
- [Farms.etherex]: 'Etherex'
114
+ [Farms.etherex]: 'Etherex',
115
+ [Farms.hyperswap]: 'HyperSwap'
114
116
  };
115
117
  exports.STAKED_LP_FACTORY = {
116
118
  [types_1.Networks.Ropsten]: {},
@@ -209,7 +211,8 @@ exports.STAKED_LP_FACTORY = {
209
211
  [Farms.nileStable]: '0xB037874dE77E7b4505261301d2F3CE2fb9036cA7',
210
212
  [Farms.etherex]: '0xc0b920f6f1d6122b8187c031554dc8194f644592'
211
213
  },
212
- [types_1.Networks.Unichain]: {}
214
+ [types_1.Networks.Unichain]: {},
215
+ [types_1.Networks.HyperEVM]: {}
213
216
  };
214
217
  function getFarmByStakedLPFactory(network, address) {
215
218
  if (!address)
@@ -45,7 +45,8 @@ exports.NFTLP_SUBGRAPH_URL = {
45
45
  "https://unichain-nftlp-uniswapv3.up.railway.app/",
46
46
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmSnT5owQNvbpxr4sXpt2PSRkyJgm52CYrZEZUbhx4T2ad"
47
47
  ]
48
- }
48
+ },
49
+ [types_1.Networks.HyperEVM]: {} // TODO: Ponder
49
50
  };
50
51
  // NFTLP Factory addresses for each network
51
52
  exports.NFTLP_FACTORY = {
@@ -78,6 +79,9 @@ exports.NFTLP_FACTORY = {
78
79
  [types_1.Networks.Linea]: {},
79
80
  [types_1.Networks.Unichain]: {
80
81
  [types_1.Extension.UniswapV3]: "0x62b45128b3c2783d5b1f86e6db92c9aa43eed6af"
82
+ },
83
+ [types_1.Networks.HyperEVM]: {
84
+ [types_1.Extension.UniswapV3]: "0x6b031e1c622140374ed1908b689e7ea9ddb1f884"
81
85
  }
82
86
  };
83
87
  // Helper to get subgraph endpoints
@@ -36,6 +36,7 @@ exports.IMPERMAX_POOLS_API = {
36
36
  [types_1.Networks.Sonic]: {},
37
37
  [types_1.Networks.Linea]: {},
38
38
  [types_1.Networks.Unichain]: {},
39
+ [types_1.Networks.HyperEVM]: {}
39
40
  };
40
41
  // API: Lending vaults
41
42
  exports.IMPERMAX_VAULT_API = {
@@ -78,6 +79,7 @@ exports.IMPERMAX_VAULT_API = {
78
79
  [types_1.Networks.Unichain]: {
79
80
  [types_1.VaultType.LENDING]: "https://unichain-lendingvaults-production.up.railway.app/"
80
81
  },
82
+ [types_1.Networks.HyperEVM]: {}
81
83
  };
82
84
  // API: NFTLP
83
85
  exports.NFTLP_API = {
@@ -111,6 +113,7 @@ exports.NFTLP_API = {
111
113
  [types_1.Networks.Unichain]: {
112
114
  [types_1.Extension.UniswapV3]: "https://unichain-nftlp-uniswapv3.up.railway.app/"
113
115
  },
116
+ [types_1.Networks.HyperEVM]: {}
114
117
  };
115
118
  // API: Positions/NFTLP TVL
116
119
  exports.NFTLP_POSITIONS_API = {
@@ -144,4 +147,5 @@ exports.NFTLP_POSITIONS_API = {
144
147
  [types_1.Networks.Unichain]: {
145
148
  [types_1.Extension.UniswapV3]: "https://positions-aggregator-production.up.railway.app/api/"
146
149
  },
150
+ [types_1.Networks.HyperEVM]: {}
147
151
  };
@@ -27,6 +27,7 @@ export declare const CONFIG_MANAGER_SUBGRAPH_URL: {
27
27
  sonic: string;
28
28
  linea: string;
29
29
  unichain: string;
30
+ "hyper-evm": string;
30
31
  };
31
32
  export declare const WHITELIST_SUBGRAPH_URL: {
32
33
  ropsten: string;
@@ -46,4 +47,5 @@ export declare const WHITELIST_SUBGRAPH_URL: {
46
47
  mantle: string;
47
48
  base: string;
48
49
  unichain: string;
50
+ "hyper-evm": string;
49
51
  };
@@ -165,6 +165,7 @@ exports.IMPERMAX_SUBGRAPH_URL = {
165
165
  'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmXgE8G1DG3jrepAFRsrssSY7Lu9hg1CJ6ufg1HgADcyZJ'
166
166
  ]
167
167
  },
168
+ [types_1.Networks.HyperEVM]: {}
168
169
  };
169
170
  // TODO: Since these are part of core we should add redundancy like above, left arrays to fill
170
171
  exports.VAULT_SUBGRAPH_URL = {
@@ -242,7 +243,8 @@ exports.VAULT_SUBGRAPH_URL = {
242
243
  "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmWeKz58sHj3Sge34wF1VgZfdPHXKHDCC1ZAYWCdBFSsSm",
243
244
  "https://unichain-lendingvaults-production.up.railway.app/"
244
245
  ]
245
- }
246
+ },
247
+ [types_1.Networks.HyperEVM]: {}
246
248
  };
247
249
  exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
248
250
  [types_1.Networks.Ropsten]: "",
@@ -268,7 +270,8 @@ exports.IMPERMAX_CHEF_SUBGRAPH_URL = {
268
270
  [types_1.Networks.Real]: "",
269
271
  [types_1.Networks.Sonic]: "",
270
272
  [types_1.Networks.Linea]: "",
271
- [types_1.Networks.Unichain]: ""
273
+ [types_1.Networks.Unichain]: "",
274
+ [types_1.Networks.HyperEVM]: ""
272
275
  };
273
276
  exports.BLOCKS_SUBGRAPH_URL = {
274
277
  [types_1.Networks.Ropsten]: "",
@@ -293,7 +296,8 @@ exports.BLOCKS_SUBGRAPH_URL = {
293
296
  [types_1.Networks.Optimism]: "",
294
297
  [types_1.Networks.Sonic]: "",
295
298
  [types_1.Networks.Linea]: "",
296
- [types_1.Networks.Unichain]: ""
299
+ [types_1.Networks.Unichain]: "",
300
+ [types_1.Networks.HyperEVM]: ""
297
301
  };
298
302
  exports.XIBEX_SUBGRAPH_URL = {
299
303
  [types_1.Networks.Arbitrum]: ["https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmZNQ3vScFpP14gfYmrVXrxwkZSWsfroC5dWyJZh6hpN3s"],
@@ -320,7 +324,8 @@ exports.CONFIG_MANAGER_SUBGRAPH_URL = {
320
324
  [types_1.Networks.Real]: "https://api.goldsky.com/api/public/project_cm2d5q4l4w31601vz4swb3vmi/subgraphs/impermax-config-manager-real/1.0/gn",
321
325
  [types_1.Networks.Sonic]: "https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmVz8i4ACXuUNTT2re2cHnNqqw9UNco2mUrj4m6WYm1QM5",
322
326
  [types_1.Networks.Linea]: 'https://gateway.thegraph.com/api/e9bbf185bbf657f7ea313387cdf0e5ce/deployments/id/QmaTZ5eckYUp3YqTiaqMoGEc1CzndhA7e8x1FLZmvsUd5J',
323
- [types_1.Networks.Unichain]: ""
327
+ [types_1.Networks.Unichain]: "",
328
+ [types_1.Networks.HyperEVM]: ""
324
329
  };
325
330
  exports.WHITELIST_SUBGRAPH_URL = {
326
331
  [types_1.Networks.Ropsten]: "",
@@ -339,5 +344,6 @@ exports.WHITELIST_SUBGRAPH_URL = {
339
344
  [types_1.Networks.Sxnetwork]: "",
340
345
  [types_1.Networks.Mantle]: "",
341
346
  [types_1.Networks.Base]: "https://api.studio.thegraph.com/query/46041/impermax-whitelist-base/v0.0.1",
342
- [types_1.Networks.Unichain]: ""
347
+ [types_1.Networks.Unichain]: "",
348
+ [types_1.Networks.HyperEVM]: ""
343
349
  };
@@ -22,7 +22,8 @@ export declare enum Networks {
22
22
  Real = "re.al",
23
23
  Sonic = "sonic",
24
24
  Linea = "linea",
25
- Unichain = "unichain"
25
+ Unichain = "unichain",
26
+ HyperEVM = "hyper-evm"
26
27
  }
27
28
  export declare enum Factory {
28
29
  V2V1 = "1",
@@ -26,6 +26,7 @@ var Networks;
26
26
  Networks["Sonic"] = "sonic";
27
27
  Networks["Linea"] = "linea";
28
28
  Networks["Unichain"] = "unichain";
29
+ Networks["HyperEVM"] = "hyper-evm";
29
30
  })(Networks = exports.Networks || (exports.Networks = {}));
30
31
  // FACTORIES
31
32
  var Factory;
@@ -279,7 +279,8 @@ exports.WHITELISTED_PAIRS = {
279
279
  "0x242DF683a84F4ae2C77AcaBA7e1579AfFD6E5A09",
280
280
  "0x0393C31fDe67edA8E49D29D7A7E004cEb2FA29e8", // USDC/USDT0 univ3
281
281
  ],
282
- }
282
+ },
283
+ [types_1.Networks.HyperEVM]: {}
283
284
  };
284
285
  exports.WHITELISTED_OLD = {
285
286
  [types_1.Networks.Ropsten]: {},
@@ -697,6 +698,7 @@ exports.WHITELISTED_OLD = {
697
698
  ],
698
699
  },
699
700
  [types_1.Networks.Unichain]: {},
701
+ [types_1.Networks.HyperEVM]: {}
700
702
  };
701
703
  // TODO
702
704
  // SHOW WARNING IF A USER HAVE FUNDS DEPOSITED IN A BLACKLISTED PAIR AND THEY CAN BE WITHDRAWN
@@ -896,6 +898,7 @@ exports.BLACKLISTED = {
896
898
  [types_1.Factory.SOLV2]: [],
897
899
  },
898
900
  [types_1.Networks.Unichain]: {},
901
+ [types_1.Networks.HyperEVM]: {}
899
902
  };
900
903
  exports.DISABLED_BORROWS = {
901
904
  [types_1.Networks.Ropsten]: [],
@@ -923,4 +926,5 @@ exports.DISABLED_BORROWS = {
923
926
  [types_1.Networks.Sonic]: [],
924
927
  [types_1.Networks.Linea]: [],
925
928
  [types_1.Networks.Unichain]: [],
929
+ [types_1.Networks.HyperEVM]: []
926
930
  };
@@ -2,12 +2,12 @@ import OffchainAccountCollateral from "./offchainAccountCollateral";
2
2
  import OffchainAccountLendingPoolV2 from "./offchainAccountLendingPoolV2";
3
3
  import OffchainAccountPoolToken from "../offchainAccountPoolToken";
4
4
  import OffchainCollateralV2 from "../../lendingPool/offchainCollateralV2";
5
- import { UniswapV2Position } from "../../../utils/position";
5
+ import GenericPosition from "../../../utils/position/genericPosition";
6
6
  export default class OffchainAccountCollateralV2 extends OffchainAccountPoolToken implements OffchainAccountCollateral {
7
7
  protected readonly lendingPool: OffchainAccountLendingPoolV2;
8
8
  protected readonly poolToken: OffchainCollateralV2;
9
9
  protected cache: {
10
- positionsObject?: Promise<UniswapV2Position>;
10
+ positionsObject?: Promise<GenericPosition>;
11
11
  };
12
12
  constructor(lendingPool: OffchainAccountLendingPoolV2);
13
13
  getAccount: () => import("..").default;
@@ -17,6 +17,6 @@ export default class OffchainAccountCollateralV2 extends OffchainAccountPoolToke
17
17
  getTokens(): Promise<number>;
18
18
  getAmount(): Promise<number>;
19
19
  private getLiquidity;
20
- createPositionObject(): Promise<UniswapV2Position>;
21
- getPositionObject(): Promise<UniswapV2Position>;
20
+ createPositionObject(): Promise<GenericPosition>;
21
+ getPositionObject(): Promise<GenericPosition>;
22
22
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const offchainAccountPoolToken_1 = __importDefault(require("../offchainAccountPoolToken"));
7
7
  const position_1 = require("../../../utils/position");
8
8
  const utils_1 = require("../../../utils");
9
+ const solidlyStable_1 = __importDefault(require("../../../utils/position/solidlyStable"));
9
10
  class OffchainAccountCollateralV2 extends offchainAccountPoolToken_1.default {
10
11
  constructor(lendingPool) {
11
12
  super();
@@ -35,22 +36,34 @@ class OffchainAccountCollateralV2 extends offchainAccountPoolToken_1.default {
35
36
  }
36
37
  // Notice: createNewPositionObject is not needed for V2
37
38
  async createPositionObject() {
38
- //if (await this.getLendingPool().getLendingPool().isStable()) {
39
- // TODO return stablePosition
40
- //} else {
41
- return new position_1.UniswapV2Position({
42
- liquidity: await this.getLiquidity(),
43
- debtX: await this.getLendingPool().getBorrowableA().getBorrowedAmount(),
44
- debtY: await this.getLendingPool().getBorrowableB().getBorrowedAmount(),
45
- marketPrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
46
- oraclePrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
47
- safetyMargin: await this.getLendingPool().getSafetyMargin(),
48
- liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
49
- borrowableX: await this.getLendingPool().getLendingPool().getBorrowableA().createBorrowableObject(),
50
- borrowableY: await this.getLendingPool().getLendingPool().getBorrowableB().createBorrowableObject(),
51
- baseRate: (await this.getLendingPool().getLendingPool().getTotalAPR()) / utils_1.SECONDS_IN_YEAR,
52
- });
53
- //}
39
+ if (this.getLendingPool().getLendingPool().isStableFactory()) {
40
+ return new solidlyStable_1.default({
41
+ liquidity: await this.getLiquidity(),
42
+ debtX: await this.getLendingPool().getBorrowableA().getBorrowedAmount(),
43
+ debtY: await this.getLendingPool().getBorrowableB().getBorrowedAmount(),
44
+ marketPrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
45
+ oraclePrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
46
+ safetyMargin: await this.getLendingPool().getSafetyMargin(),
47
+ liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
48
+ borrowableX: await this.getLendingPool().getLendingPool().getBorrowableA().createBorrowableObject(),
49
+ borrowableY: await this.getLendingPool().getLendingPool().getBorrowableB().createBorrowableObject(),
50
+ baseRate: (await this.getLendingPool().getLendingPool().getTotalAPR()) / utils_1.SECONDS_IN_YEAR,
51
+ });
52
+ }
53
+ else {
54
+ return new position_1.UniswapV2Position({
55
+ liquidity: await this.getLiquidity(),
56
+ debtX: await this.getLendingPool().getBorrowableA().getBorrowedAmount(),
57
+ debtY: await this.getLendingPool().getBorrowableB().getBorrowedAmount(),
58
+ marketPrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
59
+ oraclePrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
60
+ safetyMargin: await this.getLendingPool().getSafetyMargin(),
61
+ liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
62
+ borrowableX: await this.getLendingPool().getLendingPool().getBorrowableA().createBorrowableObject(),
63
+ borrowableY: await this.getLendingPool().getLendingPool().getBorrowableB().createBorrowableObject(),
64
+ baseRate: (await this.getLendingPool().getLendingPool().getTotalAPR()) / utils_1.SECONDS_IN_YEAR,
65
+ });
66
+ }
54
67
  }
55
68
  async getPositionObject() {
56
69
  if (!this.cache.positionsObject)
@@ -157,7 +157,7 @@ class OffchainLendingPool {
157
157
  return false;
158
158
  }
159
159
  isStableFactory() {
160
- return this.factory === types_1.Factory.SOL_STABLE;
160
+ return factories_1.STABLE_FACTORIES.includes(this.factory);
161
161
  }
162
162
  normalizeTokenSymbol(symbol) {
163
163
  const tokenMappings = {
@@ -24,7 +24,8 @@ const LlamaChains = {
24
24
  [types_1.Networks.Blast]: "blast",
25
25
  [types_1.Networks.Sonic]: "sonic",
26
26
  [types_1.Networks.Linea]: "linea",
27
- [types_1.Networks.Unichain]: "unichain"
27
+ [types_1.Networks.Unichain]: "unichain",
28
+ [types_1.Networks.HyperEVM]: "hyperliquid"
28
29
  };
29
30
  // Class to get the APR from DefiLlama directly, only makes 1 call to api and caches all pools
30
31
  class OffchainAPRHelper {
@@ -4,12 +4,12 @@ import OnchainAccountCollateral from "./onchainAccountCollateral";
4
4
  import { OnchainCollateralV2 } from "../../impermaxFactory/lendingPool";
5
5
  import OnchainAccountLendingPoolV2 from "./onchainAccountLendingPoolV2";
6
6
  import OnchainInteractionsCollateralV2 from "../../interactions/lendingPool/onchainInteractionsCollateralV2";
7
- import { UniswapV2Position } from "../../../utils/position";
7
+ import GenericPosition from "../../../utils/position/genericPosition";
8
8
  export default class OnchainAccountCollateralV2 extends OnchainAccountPoolToken implements OnchainAccountCollateral {
9
9
  protected readonly lendingPool: OnchainAccountLendingPoolV2;
10
10
  protected readonly poolToken: OnchainCollateralV2;
11
11
  protected collateralCache: {
12
- positionsObject?: Promise<UniswapV2Position>;
12
+ positionsObject?: Promise<GenericPosition>;
13
13
  };
14
14
  constructor(lendingPool: OnchainAccountLendingPoolV2);
15
15
  getLendingPool: () => OnchainAccountLendingPoolV2;
@@ -22,6 +22,6 @@ export default class OnchainAccountCollateralV2 extends OnchainAccountPoolToken
22
22
  getOffchainAccountCollateral: () => Promise<OffchainAccountCollateralV2>;
23
23
  cleanCache(): void;
24
24
  private getLiquidity;
25
- createPositionObject(lockStateChange?: boolean): Promise<UniswapV2Position>;
26
- getPositionObject(): Promise<UniswapV2Position>;
25
+ createPositionObject(lockStateChange?: boolean): Promise<GenericPosition>;
26
+ getPositionObject(): Promise<GenericPosition>;
27
27
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const onchainAccountPoolToken_1 = __importDefault(require("../onchainAccountPoolToken"));
7
7
  const position_1 = require("../../../utils/position");
8
8
  const utils_1 = require("../../../utils");
9
+ const solidlyStable_1 = __importDefault(require("../../../utils/position/solidlyStable"));
9
10
  class OnchainAccountCollateralV2 extends onchainAccountPoolToken_1.default {
10
11
  constructor(lendingPool) {
11
12
  super();
@@ -35,24 +36,37 @@ class OnchainAccountCollateralV2 extends onchainAccountPoolToken_1.default {
35
36
  }
36
37
  // Notice: createNewPositionObject is not needed for V2
37
38
  async createPositionObject(lockStateChange = false) {
38
- //if (await this.getLendingPool().getLendingPool().isStable()) {
39
- // TODO return stablePosition
40
- //} else {
41
39
  const offchainLendingPool = await this.getLendingPool().getLendingPool().getOffchainLendingPool();
42
- return new position_1.UniswapV2Position({
43
- liquidity: await this.getLiquidity(),
44
- debtX: await this.getLendingPool().getBorrowableA().getBorrowed(),
45
- debtY: await this.getLendingPool().getBorrowableB().getBorrowed(),
46
- marketPrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
47
- oraclePrice: await this.getLendingPool().getLendingPool().getTWAPPrice(),
48
- safetyMargin: await this.getLendingPool().getSafetyMargin(),
49
- liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
50
- borrowableX: await this.getLendingPool().getLendingPool().getBorrowableA().createBorrowableObject(lockStateChange),
51
- borrowableY: await this.getLendingPool().getLendingPool().getBorrowableB().createBorrowableObject(lockStateChange),
52
- baseRate: offchainLendingPool ? (await offchainLendingPool.getTotalAPR()) / utils_1.SECONDS_IN_YEAR : 0,
53
- lockStateChange,
54
- });
55
- //}
40
+ if (this.getLendingPool().getLendingPool().isStableFactory()) {
41
+ return new solidlyStable_1.default({
42
+ liquidity: await this.getLiquidity(),
43
+ debtX: await this.getLendingPool().getBorrowableA().getBorrowed(),
44
+ debtY: await this.getLendingPool().getBorrowableB().getBorrowed(),
45
+ marketPrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
46
+ oraclePrice: await this.getLendingPool().getLendingPool().getTWAPPrice(),
47
+ safetyMargin: await this.getLendingPool().getSafetyMargin(),
48
+ liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
49
+ borrowableX: await this.getLendingPool().getLendingPool().getBorrowableA().createBorrowableObject(lockStateChange),
50
+ borrowableY: await this.getLendingPool().getLendingPool().getBorrowableB().createBorrowableObject(lockStateChange),
51
+ baseRate: offchainLendingPool ? (await offchainLendingPool.getTotalAPR()) / utils_1.SECONDS_IN_YEAR : 0,
52
+ lockStateChange,
53
+ });
54
+ }
55
+ else {
56
+ return new position_1.UniswapV2Position({
57
+ liquidity: await this.getLiquidity(),
58
+ debtX: await this.getLendingPool().getBorrowableA().getBorrowed(),
59
+ debtY: await this.getLendingPool().getBorrowableB().getBorrowed(),
60
+ marketPrice: await this.getLendingPool().getLendingPool().getMarketPrice(),
61
+ oraclePrice: await this.getLendingPool().getLendingPool().getTWAPPrice(),
62
+ safetyMargin: await this.getLendingPool().getSafetyMargin(),
63
+ liquidationPenalty: await this.getLendingPool().getLiquidationPenalty(),
64
+ borrowableX: await this.getLendingPool().getLendingPool().getBorrowableA().createBorrowableObject(lockStateChange),
65
+ borrowableY: await this.getLendingPool().getLendingPool().getBorrowableB().createBorrowableObject(lockStateChange),
66
+ baseRate: offchainLendingPool ? (await offchainLendingPool.getTotalAPR()) / utils_1.SECONDS_IN_YEAR : 0,
67
+ lockStateChange,
68
+ });
69
+ }
56
70
  }
57
71
  async getPositionObject() {
58
72
  if (!this.collateralCache.positionsObject)
@@ -36,6 +36,7 @@ export default abstract class OnchainLendingPool {
36
36
  protected getContractHelper: () => import("../..").OnchainContractsHelper;
37
37
  cleanCache(): void;
38
38
  getOffchainLendingPool(): Promise<OffchainLendingPool>;
39
+ isStableFactory(): boolean;
39
40
  private initializeLendingPoolAddresses;
40
41
  private getLendingPoolAddresses;
41
42
  getCollateralAddress(): Promise<string>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const types_1 = require("../../../config/types");
4
+ const factories_1 = require("../../../config/factories");
4
5
  class OnchainLendingPool {
5
6
  constructor(impermaxFactory, id) {
6
7
  this.cache = {};
@@ -32,6 +33,9 @@ class OnchainLendingPool {
32
33
  throw new Error("getOffchainLendingPool");
33
34
  return lendingPool;
34
35
  }
36
+ isStableFactory() {
37
+ return factories_1.STABLE_FACTORIES.includes(this.impermaxFactory.getFactory());
38
+ }
35
39
  async initializeLendingPoolAddresses() {
36
40
  const lPool = await (await this.impermaxFactory.getFactoryContract()).methods.getLendingPool(this.id).call();
37
41
  return {
@@ -0,0 +1,41 @@
1
+ import GenericPosition from "../genericPosition";
2
+ import { BorrowableEntity } from "../../borrowable/borrowableEntity";
3
+ export interface SolidlyStablePositionParams {
4
+ liquidity: number;
5
+ debtX: number;
6
+ debtY: number;
7
+ marketPrice: number;
8
+ oraclePrice: number;
9
+ safetyMargin: number;
10
+ liquidationPenalty: number;
11
+ borrowableX: BorrowableEntity;
12
+ borrowableY: BorrowableEntity;
13
+ baseRate: number;
14
+ lockStateChange?: boolean;
15
+ }
16
+ export declare class SolidlyStablePosition extends GenericPosition {
17
+ baseRate: number;
18
+ constructor(params: SolidlyStablePositionParams);
19
+ protected checkLock(): void;
20
+ /**
21
+ * protected SETTERS
22
+ */
23
+ protected setLiquidity(liquidity: number): void;
24
+ /**
25
+ * protected GETTERS
26
+ */
27
+ private liquidityCache;
28
+ private getRealXRealYGivenLiquidityAndPrice;
29
+ protected getRealXGivenLiquidityAndPrice(liquidity: number, price: number): number;
30
+ protected getRealYGivenLiquidityAndPrice(liquidity: number, price: number): number;
31
+ /**
32
+ * PUBLIC GETTERS
33
+ */
34
+ getBaseRate(): number;
35
+ getOptimalLiquidity(amountX: number, amountY: number): {
36
+ liquidity: number;
37
+ amountX: number;
38
+ amountY: number;
39
+ };
40
+ }
41
+ export default SolidlyStablePosition;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SolidlyStablePosition = void 0;
7
+ const genericPosition_1 = __importDefault(require("../genericPosition"));
8
+ const lliquidity_math_1 = require("../../lliquidity-math");
9
+ class SolidlyStablePosition extends genericPosition_1.default {
10
+ constructor(params) {
11
+ super(params);
12
+ this.baseRate = params.baseRate;
13
+ }
14
+ checkLock() {
15
+ if (this.lockStateChange)
16
+ throw Error("Can't change state of original position object");
17
+ else
18
+ this.state++;
19
+ }
20
+ /**
21
+ * protected SETTERS
22
+ */
23
+ setLiquidity(liquidity) {
24
+ if (Number.isNaN(liquidity) || liquidity === Infinity)
25
+ return;
26
+ this.liquidity = Math.max(liquidity, 0);
27
+ }
28
+ getRealXRealYGivenLiquidityAndPrice(liquidity, price) {
29
+ const cached = this.liquidityCache[liquidity][price];
30
+ if (cached)
31
+ return cached;
32
+ // always use a price > 1 to ensure a ratio > 1
33
+ const priceAbs = price > 1 ? price : 1 / price;
34
+ const STARTING_POINT = 1000;
35
+ let ratio = STARTING_POINT;
36
+ let ratioHigh = STARTING_POINT;
37
+ let ratioLow = 1;
38
+ // binary search for ratio
39
+ for (let i = 0; i < 1000; i++) {
40
+ const priceTmp = (0, lliquidity_math_1.solidlyStable_getPriceFromReserves)(1, ratio);
41
+ if (Math.abs((priceTmp - 1) - (priceAbs - 1)) < 1e-6)
42
+ break;
43
+ if (priceTmp < price) {
44
+ ratioHigh = ratio;
45
+ ratio = Math.sqrt(ratio * ratioLow);
46
+ }
47
+ else {
48
+ ratioLow = ratio;
49
+ ratio = Math.sqrt(ratio * ratioHigh);
50
+ }
51
+ }
52
+ // assuming an initial position where k = liquidity and price = 1
53
+ // x^3*y+x*y^3=2*k^4
54
+ const k = ratio + ratio ** 3;
55
+ const adj = Math.sqrt(Math.sqrt(k / 2));
56
+ let realX = liquidity / adj;
57
+ let realY = realX * ratio;
58
+ if (price < 1)
59
+ [realX, realY] = [realY, realX];
60
+ const result = { realX, realY };
61
+ this.liquidityCache[liquidity][price] = result;
62
+ return result;
63
+ }
64
+ getRealXGivenLiquidityAndPrice(liquidity, price) {
65
+ return (this.getRealXRealYGivenLiquidityAndPrice(liquidity, price).realX);
66
+ }
67
+ getRealYGivenLiquidityAndPrice(liquidity, price) {
68
+ return (this.getRealXRealYGivenLiquidityAndPrice(liquidity, price).realY);
69
+ }
70
+ /**
71
+ * PUBLIC GETTERS
72
+ */
73
+ getBaseRate() {
74
+ return this.baseRate;
75
+ }
76
+ // amountX and amountY are expected to have the same sign
77
+ getOptimalLiquidity(amountX, amountY) {
78
+ const sampleX = this.getRealXGivenLiquidity(1);
79
+ const sampleY = this.getRealYGivenLiquidity(1);
80
+ if (Math.abs(amountX) / sampleX > Math.abs(amountY) / sampleY)
81
+ amountX = amountY / sampleY * sampleX;
82
+ else
83
+ amountY = amountX / sampleX * sampleY;
84
+ const liquidity = amountX / sampleX;
85
+ return {
86
+ liquidity: Number.isNaN(liquidity) ? 0 : liquidity ?? 0,
87
+ amountX: Number.isNaN(amountX) ? 0 : amountX ?? 0,
88
+ amountY: Number.isNaN(amountY) ? 0 : amountY ?? 0,
89
+ };
90
+ }
91
+ }
92
+ exports.SolidlyStablePosition = SolidlyStablePosition;
93
+ exports.default = SolidlyStablePosition;
@@ -22,7 +22,7 @@ class UniswapV2Position extends genericPosition_1.default {
22
22
  setLiquidity(liquidity) {
23
23
  if (Number.isNaN(liquidity) || liquidity === Infinity)
24
24
  return;
25
- this.liquidity = liquidity;
25
+ this.liquidity = Math.max(liquidity, 0);
26
26
  }
27
27
  /**
28
28
  * protected GETTERS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.515",
3
+ "version": "2.1.518",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",