@defisaver/positions-sdk 2.1.9-dev-spark-2 → 2.1.9-fluid-plasma

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 (114) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/CLAUDE.md +32 -0
  4. package/README.md +64 -64
  5. package/cjs/config/contracts.d.ts +12 -0
  6. package/cjs/config/contracts.js +7 -3
  7. package/cjs/fluid/index.js +32 -11
  8. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  9. package/cjs/helpers/sparkHelpers/index.d.ts +4 -4
  10. package/cjs/helpers/sparkHelpers/index.js +12 -12
  11. package/cjs/markets/fluid/index.d.ts +46 -0
  12. package/cjs/markets/fluid/index.js +436 -1
  13. package/cjs/portfolio/index.js +1 -1
  14. package/cjs/services/priceService.js +1 -1
  15. package/cjs/spark/index.d.ts +1 -3
  16. package/cjs/spark/index.js +24 -24
  17. package/cjs/types/fluid.d.ts +30 -1
  18. package/cjs/types/fluid.js +31 -1
  19. package/cjs/types/spark.d.ts +4 -3
  20. package/esm/config/contracts.d.ts +12 -0
  21. package/esm/config/contracts.js +7 -3
  22. package/esm/fluid/index.js +32 -11
  23. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  24. package/esm/helpers/sparkHelpers/index.d.ts +4 -4
  25. package/esm/helpers/sparkHelpers/index.js +13 -13
  26. package/esm/markets/fluid/index.d.ts +46 -0
  27. package/esm/markets/fluid/index.js +415 -1
  28. package/esm/portfolio/index.js +1 -1
  29. package/esm/services/priceService.js +2 -2
  30. package/esm/spark/index.d.ts +1 -3
  31. package/esm/spark/index.js +25 -25
  32. package/esm/types/fluid.d.ts +30 -1
  33. package/esm/types/fluid.js +30 -0
  34. package/esm/types/spark.d.ts +4 -3
  35. package/package.json +47 -47
  36. package/src/aaveV2/index.ts +240 -240
  37. package/src/aaveV3/index.ts +614 -614
  38. package/src/aaveV3/merit.ts +97 -97
  39. package/src/aaveV3/merkl.ts +74 -74
  40. package/src/claiming/aaveV3.ts +154 -154
  41. package/src/claiming/compV3.ts +22 -22
  42. package/src/claiming/index.ts +12 -12
  43. package/src/claiming/king.ts +66 -66
  44. package/src/claiming/morphoBlue.ts +118 -118
  45. package/src/claiming/spark.ts +225 -225
  46. package/src/compoundV2/index.ts +244 -244
  47. package/src/compoundV3/index.ts +274 -274
  48. package/src/config/contracts.ts +1255 -1251
  49. package/src/constants/index.ts +10 -10
  50. package/src/contracts.ts +120 -120
  51. package/src/curveUsd/index.ts +254 -254
  52. package/src/eulerV2/index.ts +324 -324
  53. package/src/exchange/index.ts +25 -25
  54. package/src/fluid/index.ts +1693 -1668
  55. package/src/helpers/aaveHelpers/index.ts +187 -187
  56. package/src/helpers/compoundHelpers/index.ts +283 -283
  57. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  58. package/src/helpers/eulerHelpers/index.ts +222 -222
  59. package/src/helpers/fluidHelpers/index.ts +326 -326
  60. package/src/helpers/index.ts +10 -10
  61. package/src/helpers/liquityV2Helpers/index.ts +82 -82
  62. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  63. package/src/helpers/makerHelpers/index.ts +52 -52
  64. package/src/helpers/morphoBlueHelpers/index.ts +396 -396
  65. package/src/helpers/sparkHelpers/index.ts +155 -158
  66. package/src/index.ts +47 -47
  67. package/src/liquity/index.ts +159 -159
  68. package/src/liquityV2/index.ts +657 -657
  69. package/src/llamaLend/index.ts +305 -305
  70. package/src/maker/index.ts +223 -223
  71. package/src/markets/aave/index.ts +116 -116
  72. package/src/markets/aave/marketAssets.ts +54 -54
  73. package/src/markets/compound/index.ts +238 -238
  74. package/src/markets/compound/marketsAssets.ts +97 -97
  75. package/src/markets/curveUsd/index.ts +69 -69
  76. package/src/markets/euler/index.ts +26 -26
  77. package/src/markets/fluid/index.ts +2900 -2460
  78. package/src/markets/index.ts +25 -25
  79. package/src/markets/liquityV2/index.ts +102 -102
  80. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  81. package/src/markets/llamaLend/index.ts +235 -235
  82. package/src/markets/morphoBlue/index.ts +895 -895
  83. package/src/markets/spark/index.ts +29 -29
  84. package/src/markets/spark/marketAssets.ts +12 -12
  85. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  86. package/src/morphoBlue/index.ts +274 -274
  87. package/src/portfolio/index.ts +570 -570
  88. package/src/services/priceService.ts +159 -159
  89. package/src/services/utils.ts +115 -115
  90. package/src/services/viem.ts +34 -34
  91. package/src/setup.ts +8 -8
  92. package/src/spark/index.ts +445 -456
  93. package/src/staking/eligibility.ts +53 -53
  94. package/src/staking/index.ts +1 -1
  95. package/src/staking/staking.ts +170 -170
  96. package/src/types/aave.ts +189 -189
  97. package/src/types/claiming.ts +109 -109
  98. package/src/types/common.ts +107 -107
  99. package/src/types/compound.ts +136 -136
  100. package/src/types/curveUsd.ts +123 -123
  101. package/src/types/euler.ts +175 -175
  102. package/src/types/fluid.ts +483 -452
  103. package/src/types/index.ts +13 -13
  104. package/src/types/liquity.ts +30 -30
  105. package/src/types/liquityV2.ts +126 -126
  106. package/src/types/llamaLend.ts +159 -159
  107. package/src/types/maker.ts +63 -63
  108. package/src/types/merit.ts +1 -1
  109. package/src/types/merkl.ts +70 -70
  110. package/src/types/morphoBlue.ts +194 -194
  111. package/src/types/portfolio.ts +60 -60
  112. package/src/types/spark.ts +135 -133
  113. package/src/umbrella/index.ts +69 -69
  114. package/src/umbrella/umbrellaUtils.ts +29 -29
package/.mocharc.json CHANGED
@@ -1,4 +1,4 @@
1
- {
2
- "require": "ts-node/register",
3
- "extension": ["ts"]
4
- }
1
+ {
2
+ "require": "ts-node/register",
3
+ "extension": ["ts"]
4
+ }
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- v20.17.0
1
+ v20.17.0
package/CLAUDE.md ADDED
@@ -0,0 +1,32 @@
1
+ # DeFiSaver Positions SDK
2
+
3
+ TypeScript SDK for DeFi positions tracking and management.
4
+
5
+ ## Commands
6
+
7
+ ```bash
8
+ # Development
9
+ npm run dev # Watch mode compilation
10
+ npm run build # Lint and build both CJS and ESM
11
+ npm run build:cjs # Build CommonJS
12
+ npm run build:esm # Build ES modules
13
+
14
+ # Linting
15
+ npm run lint # Lint and fix
16
+ npm run lint-check # Lint without fixing
17
+
18
+ # Testing
19
+ npm run test # Run all tests
20
+ npm run test-single # Run single test (use --name=filename)
21
+ npm run test:debugger # Run tests with debugger
22
+
23
+ # Versioning
24
+ npm run version-bump # Commit and bump patch version
25
+ ```
26
+
27
+ ## Project Structure
28
+
29
+ - `src/` - TypeScript source code
30
+ - `tests/` - Test files
31
+ - `esm/` - ES module build output
32
+ - `cjs/` - CommonJS build output
package/README.md CHANGED
@@ -1,64 +1,64 @@
1
- # DeFi Saver Positions SDK
2
-
3
- Supported protocols:
4
- - [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
5
- - [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
6
- - [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
7
- - [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
8
- - [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
9
- - [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
10
- - [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
11
- - [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
12
-
13
- ## Setup
14
- Supported Node version is v10.
15
-
16
- - run `npm install` (first time)
17
- - run `npm run build`
18
-
19
- `build` command will generate contracts and build ejs and esm folders
20
-
21
- ## How to use
22
- [All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
23
-
24
- This is a Compound V3 example, and every other protocol is similar
25
- ```js
26
- import { compoundV3 } from '@defisaver/positions-sdk';
27
-
28
-
29
- // every protocol has market data and user data getters
30
- const {
31
- getCompoundV3MarketsData,
32
- getCompoundV3AccountData,
33
- } = compoundV3;
34
-
35
- const provider = 'Your RPC provider';
36
-
37
- const user = '0x123...';
38
-
39
- const { assetsData } = await getCompoundV3MarketsData(
40
- provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
41
- 1, // network
42
- selectedMarket, // market object like in /src/markets/compound/index.ts
43
- provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
44
- );
45
-
46
- const userData = await getCompoundV3AccountData(
47
- provider,
48
- 1, // network
49
- userAddress, // EOA or DSProxy
50
- '', // proxy address of the user, or just empty string if checking for EOA
51
- {
52
- selectedMarket, // market object as in /src/markets/compound/index.ts
53
- assetsData,
54
- }
55
- );
56
- ```
57
-
58
- More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
59
-
60
- ## Testing
61
-
62
- `npm run test` - Run all tests
63
-
64
- `npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
1
+ # DeFi Saver Positions SDK
2
+
3
+ Supported protocols:
4
+ - [Maker](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/maker)
5
+ - [Spark](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/spark)
6
+ - [CrvUSD](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/curveUsd)
7
+ - [Aave V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV2)
8
+ - [Aave V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/aaveV3)
9
+ - [Compound V2](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV2)
10
+ - [Compound V3](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/compoundV3)
11
+ - [Liquity](https://github.com/defisaver/defisaver-positions-sdk/tree/main/src/liquity)
12
+
13
+ ## Setup
14
+ Supported Node version is v10.
15
+
16
+ - run `npm install` (first time)
17
+ - run `npm run build`
18
+
19
+ `build` command will generate contracts and build ejs and esm folders
20
+
21
+ ## How to use
22
+ [All available imports](https://github.com/defisaver/defisaver-positions-sdk/blob/main/src/index.ts)
23
+
24
+ This is a Compound V3 example, and every other protocol is similar
25
+ ```js
26
+ import { compoundV3 } from '@defisaver/positions-sdk';
27
+
28
+
29
+ // every protocol has market data and user data getters
30
+ const {
31
+ getCompoundV3MarketsData,
32
+ getCompoundV3AccountData,
33
+ } = compoundV3;
34
+
35
+ const provider = 'Your RPC provider';
36
+
37
+ const user = '0x123...';
38
+
39
+ const { assetsData } = await getCompoundV3MarketsData(
40
+ provider, // rpc for the network you are using (note: can be tenderly or any other testnet rpc)
41
+ 1, // network
42
+ selectedMarket, // market object like in /src/markets/compound/index.ts
43
+ provider, // this must be mainnet rpc - used for getting prices onchain and calculating apys
44
+ );
45
+
46
+ const userData = await getCompoundV3AccountData(
47
+ provider,
48
+ 1, // network
49
+ userAddress, // EOA or DSProxy
50
+ '', // proxy address of the user, or just empty string if checking for EOA
51
+ {
52
+ selectedMarket, // market object as in /src/markets/compound/index.ts
53
+ assetsData,
54
+ }
55
+ );
56
+ ```
57
+
58
+ More examples found [here](https://github.com/defisaver/defisaver-positions-sdk/tree/main/tests)
59
+
60
+ ## Testing
61
+
62
+ `npm run test` - Run all tests
63
+
64
+ `npm run test-single --name=your_test_name` - Run single test for specified name e.g. for MyTest.js test name is MyTest
@@ -71006,6 +71006,9 @@ export declare const ETHPriceFeed: {
71006
71006
  readonly "42161": {
71007
71007
  readonly address: "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612";
71008
71008
  };
71009
+ readonly "9745": {
71010
+ readonly address: "0x43A7dd2125266c5c4c26EB86cd61241132426Fe7";
71011
+ };
71009
71012
  };
71010
71013
  };
71011
71014
  export declare const BTCPriceFeed: {
@@ -71415,6 +71418,9 @@ export declare const BTCPriceFeed: {
71415
71418
  readonly "42161": {
71416
71419
  readonly address: "0x6ce185860a4963106506C203335A2910413708e9";
71417
71420
  };
71421
+ readonly "9745": {
71422
+ readonly address: "0x3Bc5434dd1Fc6a1B68625e0269B9818cDd9E21B5";
71423
+ };
71418
71424
  };
71419
71425
  };
71420
71426
  export declare const USDCPriceFeed: {
@@ -75037,6 +75043,9 @@ export declare const DFSFeedRegistry: {
75037
75043
  readonly "42161": {
75038
75044
  readonly address: "0x158E27De8B5E5bC3FA1C6D5b365a291c54f6b0Fd";
75039
75045
  };
75046
+ readonly "9745": {
75047
+ readonly address: "0x2226836ec16FF5974dFD8DF740CD461B42FAffD5";
75048
+ };
75040
75049
  };
75041
75050
  };
75042
75051
  export declare const LlamaLendView: {
@@ -81995,6 +82004,9 @@ export declare const FluidView: {
81995
82004
  readonly "8453": {
81996
82005
  readonly address: "0x6cd4D6af4F292817eA2A2311F099dF26cd015028";
81997
82006
  };
82007
+ readonly "9745": {
82008
+ readonly address: "0x27C0BAe2338cE28097122393faF90375B9395dd1";
82009
+ };
81998
82010
  readonly "42161": {
81999
82011
  readonly address: "0xf9e6d5568887ac8eC6fA33B7eefD2A176A958e71";
82000
82012
  };
@@ -989,7 +989,8 @@ exports.ETHPriceFeed = {
989
989
  "1": { "address": "0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419" },
990
990
  "10": { "address": "0x13e3Ee699D1909E989722E753853AE30b17e08c5" },
991
991
  "8453": { "address": "0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70" },
992
- "42161": { "address": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612" }
992
+ "42161": { "address": "0x639Fe6ab55C921f74e7fac1ee960C0B6293ba612" },
993
+ "9745": { "address": "0x43A7dd2125266c5c4c26EB86cd61241132426Fe7" },
993
994
  },
994
995
  };
995
996
  exports.BTCPriceFeed = {
@@ -998,7 +999,8 @@ exports.BTCPriceFeed = {
998
999
  "1": { "address": "0xF4030086522a5bEEa4988F8cA5B36dbC97BeE88c" },
999
1000
  "10": { "address": "0xD702DD976Fb76Fffc2D3963D037dfDae5b04E593" },
1000
1001
  "8453": { "address": "0x64c911996D3c6aC71f9b455B1E8E7266BcbD848F" },
1001
- "42161": { "address": "0x6ce185860a4963106506C203335A2910413708e9" }
1002
+ "42161": { "address": "0x6ce185860a4963106506C203335A2910413708e9" },
1003
+ "9745": { "address": "0x3Bc5434dd1Fc6a1B68625e0269B9818cDd9E21B5" }
1002
1004
  },
1003
1005
  };
1004
1006
  exports.USDCPriceFeed = {
@@ -1066,7 +1068,8 @@ exports.DFSFeedRegistry = {
1066
1068
  "abi": [{ "inputs": [], "name": "NonContractCall", "type": "error" }, { "inputs": [], "name": "SenderNotAdmin", "type": "error" }, { "inputs": [], "name": "SenderNotOwner", "type": "error" }, { "inputs": [], "name": "adminVault", "outputs": [{ "internalType": "contract AdminVault", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "", "type": "address" }, { "internalType": "address", "name": "", "type": "address" }], "name": "aggregators", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "getFeed", "outputs": [{ "internalType": "address", "name": "aggregator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "kill", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }], "name": "latestRoundData", "outputs": [{ "internalType": "uint80", "name": "roundId", "type": "uint80" }, { "internalType": "int256", "name": "answer", "type": "int256" }, { "internalType": "uint256", "name": "startedAt", "type": "uint256" }, { "internalType": "uint256", "name": "updatedAt", "type": "uint256" }, { "internalType": "uint80", "name": "answeredInRound", "type": "uint80" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "base", "type": "address" }, { "internalType": "address", "name": "quote", "type": "address" }, { "internalType": "address", "name": "aggregator", "type": "address" }], "name": "setFeed", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address[]", "name": "bases", "type": "address[]" }, { "internalType": "address[]", "name": "quotes", "type": "address[]" }, { "internalType": "address[]", "name": "aggregator", "type": "address[]" }], "name": "setFeeds", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_token", "type": "address" }, { "internalType": "address", "name": "_receiver", "type": "address" }, { "internalType": "uint256", "name": "_amount", "type": "uint256" }], "name": "withdrawStuckFunds", "outputs": [], "stateMutability": "nonpayable", "type": "function" }],
1067
1069
  "networks": {
1068
1070
  "8453": { "address": "0x7dFF34190d0307fC234fc7E8C152C9715083eB02" },
1069
- "42161": { "address": "0x158E27De8B5E5bC3FA1C6D5b365a291c54f6b0Fd" }
1071
+ "42161": { "address": "0x158E27De8B5E5bC3FA1C6D5b365a291c54f6b0Fd" },
1072
+ "9745": { "address": "0x2226836ec16FF5974dFD8DF740CD461B42FAffD5" }
1070
1073
  }
1071
1074
  };
1072
1075
  exports.LlamaLendView = {
@@ -1126,6 +1129,7 @@ exports.FluidView = {
1126
1129
  "networks": {
1127
1130
  "1": { "address": "0xc8df052bD7A8d76a34c09e758Dff3c6298C0115c" },
1128
1131
  "8453": { "address": "0x6cd4D6af4F292817eA2A2311F099dF26cd015028" },
1132
+ "9745": { "address": "0x27C0BAe2338cE28097122393faF90375B9395dd1" },
1129
1133
  "42161": { "address": "0xf9e6d5568887ac8eC6fA33B7eefD2A176A958e71" }
1130
1134
  }
1131
1135
  };
@@ -72,7 +72,7 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
72
72
  const chainLinkFeedAddress = (0, priceService_1.getChainlinkAssetAddress)(assetInfo.symbol, network);
73
73
  if (assetInfo.symbol === 'wstETH')
74
74
  return (0, priceService_1.getWstETHChainLinkPriceCalls)(client, network);
75
- if (assetInfo.symbol === 'weETH')
75
+ if (assetInfo.symbol === 'weETH' && network !== common_1.NetworkNumber.Plasma)
76
76
  return (0, priceService_1.getWeETHChainLinkPriceCalls)(client, network);
77
77
  if (isMainnet) {
78
78
  const feedRegistryContract = (0, contracts_1.FeedRegistryContractViem)(client, common_1.NetworkNumber.Eth);
@@ -98,7 +98,7 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
98
98
  const btcPriceChainlink = new decimal_js_1.default(results[1].result).div(1e8).toString();
99
99
  let offset = 2; // wstETH and weETH has 3 calls, while others have only 1, so we need to keep track. First 2 are static calls for eth and btc prices
100
100
  return noDuplicateTokens.reduce((acc, token, i) => {
101
- var _a;
101
+ var _a, _b;
102
102
  const assetInfo = (0, tokens_1.getAssetInfoByAddress)(token, network);
103
103
  switch (assetInfo.symbol) {
104
104
  case 'USDA':
@@ -134,16 +134,31 @@ const getChainLinkPricesForTokens = (tokens, network, client) => __awaiter(void
134
134
  break;
135
135
  }
136
136
  case 'weETH': {
137
- const { ethPrice, weETHRate, } = (0, priceService_1.parseWeETHPriceCalls)(results[i + offset].result.toString(),
138
- // @ts-ignore
139
- results[i + offset + 1].result[1].toString(), results[i + offset + 2].result.toString());
140
- offset += 2;
141
- acc[token] = new decimal_js_1.default(ethPrice).mul(weETHRate).toString();
137
+ if (network !== common_1.NetworkNumber.Plasma) {
138
+ const { ethPrice, weETHRate, } = (0, priceService_1.parseWeETHPriceCalls)(results[i + offset].result.toString(),
139
+ // @ts-ignore
140
+ results[i + offset + 1].result[1].toString(), results[i + offset + 2].result.toString());
141
+ offset += 2;
142
+ acc[token] = new decimal_js_1.default(ethPrice).mul(weETHRate).toString();
143
+ // @ts-ignore
144
+ }
145
+ else if ((_a = results[i + offset].result) === null || _a === void 0 ? void 0 : _a[1]) {
146
+ // For Plasma, use default chainlink feed (latestRoundData format)
147
+ // @ts-ignore
148
+ acc[token] = new decimal_js_1.default(results[i + offset].result[1].toString()).div(1e8).toString();
149
+ }
150
+ else if (results[i + offset].result) {
151
+ // For Plasma, use default chainlink feed (latestAnswer format)
152
+ acc[token] = new decimal_js_1.default(results[i + offset].result.toString()).div(1e8).toString();
153
+ }
154
+ else {
155
+ acc[token] = '0';
156
+ }
142
157
  break;
143
158
  }
144
159
  default:
145
160
  // @ts-ignore
146
- if ((_a = results[i + offset].result) === null || _a === void 0 ? void 0 : _a[1]) {
161
+ if ((_b = results[i + offset].result) === null || _b === void 0 ? void 0 : _b[1]) {
147
162
  // @ts-ignore
148
163
  acc[token] = new decimal_js_1.default(results[i + offset].result[1].toString()).div(1e8).toString();
149
164
  }
@@ -176,8 +191,14 @@ const getTokenPriceFromChainlink = (asset, network, provider) => __awaiter(void
176
191
  else {
177
192
  // Currently only base network is supported
178
193
  const feedRegistryContract = (0, contracts_1.DFSFeedRegistryContractViem)(provider, network);
179
- const roundPriceData = isTokenUSDA ? [0, '100000000'] : yield feedRegistryContract.read.latestRoundData([loanTokenFeedAddress, constants_1.USD_QUOTE]);
180
- loanTokenPrice = roundPriceData[1].toString();
194
+ try {
195
+ const roundPriceData = isTokenUSDA ? [0, '100000000'] : yield feedRegistryContract.read.latestRoundData([loanTokenFeedAddress, constants_1.USD_QUOTE]);
196
+ loanTokenPrice = roundPriceData[1].toString();
197
+ }
198
+ catch (err) {
199
+ console.error(`Error fetching price for ${asset.symbol} on ${network}: ${err}`);
200
+ loanTokenPrice = '0';
201
+ }
181
202
  }
182
203
  return new decimal_js_1.default(loanTokenPrice).div(1e8).toString();
183
204
  });
@@ -1194,7 +1215,7 @@ const getTokenPricePortfolio = (token, provider, network) => __awaiter(void 0, v
1194
1215
  if (token === 'wstETH') {
1195
1216
  return (0, priceService_1.getWstETHPrice)(provider, network);
1196
1217
  }
1197
- if (token === 'weETH') {
1218
+ if (token === 'weETH' && network !== common_1.NetworkNumber.Plasma) {
1198
1219
  return (0, priceService_1.getWeETHPrice)(provider, network);
1199
1220
  }
1200
1221
  const isMainnet = (0, utils_1.isMainnetNetwork)(network);
@@ -128,73 +128,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, provider, network)
128
128
  });
129
129
  exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
130
130
  const API_URL = 'https://blue-api.morpho.org/graphql';
131
- const MARKET_QUERY = `
132
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
133
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
134
- reallocatableLiquidityAssets
135
- targetBorrowUtilization
136
- loanAsset {
137
- address
138
- decimals
139
- priceUsd
140
- }
141
- state {
142
- liquidityAssets
143
- borrowAssets
144
- supplyAssets
145
- }
146
- publicAllocatorSharedLiquidity {
147
- assets
148
- vault {
149
- address
150
- name
151
- }
152
- allocationMarket {
153
- uniqueKey
154
- loanAsset {
155
- address
156
- }
157
- collateralAsset {
158
- address
159
- }
160
- irmAddress
161
- oracle {
162
- address
163
- }
164
- lltv
165
- }
166
- }
167
- loanAsset {
168
- address
169
- }
170
- collateralAsset {
171
- address
172
- }
173
- oracle {
174
- address
175
- }
176
- irmAddress
177
- lltv
178
- }
179
- }
131
+ const MARKET_QUERY = `
132
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
133
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
134
+ reallocatableLiquidityAssets
135
+ targetBorrowUtilization
136
+ loanAsset {
137
+ address
138
+ decimals
139
+ priceUsd
140
+ }
141
+ state {
142
+ liquidityAssets
143
+ borrowAssets
144
+ supplyAssets
145
+ }
146
+ publicAllocatorSharedLiquidity {
147
+ assets
148
+ vault {
149
+ address
150
+ name
151
+ }
152
+ allocationMarket {
153
+ uniqueKey
154
+ loanAsset {
155
+ address
156
+ }
157
+ collateralAsset {
158
+ address
159
+ }
160
+ irmAddress
161
+ oracle {
162
+ address
163
+ }
164
+ lltv
165
+ }
166
+ }
167
+ loanAsset {
168
+ address
169
+ }
170
+ collateralAsset {
171
+ address
172
+ }
173
+ oracle {
174
+ address
175
+ }
176
+ irmAddress
177
+ lltv
178
+ }
179
+ }
180
180
  `;
181
- const REWARDS_QUERY = `
182
- query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
183
- marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
184
- uniqueKey
185
- state {
186
- rewards {
187
- amountPerSuppliedToken
188
- supplyApr
189
- amountPerBorrowedToken
190
- borrowApr
191
- asset {
192
- address
193
- }
194
- }
195
- }
196
- }
197
- }
181
+ const REWARDS_QUERY = `
182
+ query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
183
+ marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
184
+ uniqueKey
185
+ state {
186
+ rewards {
187
+ amountPerSuppliedToken
188
+ supplyApr
189
+ amountPerBorrowedToken
190
+ borrowApr
191
+ asset {
192
+ address
193
+ }
194
+ }
195
+ }
196
+ }
197
+ }
198
198
  `;
199
199
  /**
200
200
  * Get reallocatable liquidity to a given market and target borrow utilization
@@ -7,19 +7,19 @@ export declare const sparkIsInIsolationMode: ({ usedAssets, assetsData }: {
7
7
  export declare const sparkGetCollSuppliedAssets: ({ usedAssets }: {
8
8
  usedAssets: SparkUsedAssets;
9
9
  }) => import("../../types").SparkUsedAsset[];
10
- export declare const sparkGetSuppliableAssets: ({ usedAssets, eModeCategory, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => {
10
+ export declare const sparkGetSuppliableAssets: ({ usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => {
11
11
  symbol: string;
12
12
  canBeCollateral: boolean;
13
13
  }[];
14
- export declare const sparkGetSuppliableAsCollAssets: ({ usedAssets, eModeCategory, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => {
14
+ export declare const sparkGetSuppliableAsCollAssets: ({ usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => {
15
15
  symbol: string;
16
16
  canBeCollateral: boolean;
17
17
  }[];
18
- export declare const sparkGetEmodeMutableProps: ({ eModeCategory, eModeCategoriesData, assetsData, }: SparkHelperCommon, _asset: string) => {
18
+ export declare const sparkGetEmodeMutableProps: ({ eModeCategory, assetsData, }: SparkHelperCommon, _asset: string) => {
19
19
  liquidationRatio: string;
20
20
  collateralFactor: string;
21
21
  };
22
- export declare const sparkGetAggregatedPositionData: ({ usedAssets, eModeCategory, eModeCategoriesData, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => SparkAggregatedPositionData;
22
+ export declare const sparkGetAggregatedPositionData: ({ usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network, ...rest }: SparkHelperCommon) => SparkAggregatedPositionData;
23
23
  export declare const getApyAfterValuesEstimation: (selectedMarket: SparkMarketData, actions: [{
24
24
  action: string;
25
25
  amount: string;
@@ -38,8 +38,8 @@ exports.sparkIsInIsolationMode = sparkIsInIsolationMode;
38
38
  const sparkGetCollSuppliedAssets = ({ usedAssets }) => Object.values(usedAssets).filter(({ isSupplied, collateral }) => isSupplied && collateral);
39
39
  exports.sparkGetCollSuppliedAssets = sparkGetCollSuppliedAssets;
40
40
  const sparkGetSuppliableAssets = (_a) => {
41
- var { usedAssets, eModeCategory, assetsData, selectedMarket, network } = _a, rest = __rest(_a, ["usedAssets", "eModeCategory", "assetsData", "selectedMarket", "network"]);
42
- const data = Object.assign({ usedAssets, eModeCategory, assetsData, selectedMarket, network }, rest);
41
+ var { usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network } = _a, rest = __rest(_a, ["usedAssets", "eModeCategory", "eModeCategories", "assetsData", "selectedMarket", "network"]);
42
+ const data = Object.assign({ usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network }, rest);
43
43
  const collAccountAssets = (0, exports.sparkGetCollSuppliedAssets)(data);
44
44
  const marketAssets = Object.values(assetsData);
45
45
  if ((0, exports.sparkIsInIsolationMode)(data)) {
@@ -50,27 +50,27 @@ const sparkGetSuppliableAssets = (_a) => {
50
50
  };
51
51
  exports.sparkGetSuppliableAssets = sparkGetSuppliableAssets;
52
52
  const sparkGetSuppliableAsCollAssets = (_a) => {
53
- var { usedAssets, eModeCategory, assetsData, selectedMarket, network } = _a, rest = __rest(_a, ["usedAssets", "eModeCategory", "assetsData", "selectedMarket", "network"]);
54
- return (0, exports.sparkGetSuppliableAssets)(Object.assign({ usedAssets, eModeCategory, assetsData, selectedMarket, network }, rest)).filter(({ canBeCollateral }) => canBeCollateral);
53
+ var { usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network } = _a, rest = __rest(_a, ["usedAssets", "eModeCategory", "eModeCategories", "assetsData", "selectedMarket", "network"]);
54
+ return (0, exports.sparkGetSuppliableAssets)(Object.assign({ usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network }, rest)).filter(({ canBeCollateral }) => canBeCollateral);
55
55
  };
56
56
  exports.sparkGetSuppliableAsCollAssets = sparkGetSuppliableAsCollAssets;
57
- const sparkGetEmodeMutableProps = ({ eModeCategory, eModeCategoriesData, assetsData, }, _asset) => {
58
- const asset = (0, utils_1.getNativeAssetFromWrapped)(_asset);
57
+ const sparkGetEmodeMutableProps = ({ eModeCategory, assetsData, }, _asset) => {
58
+ var _a;
59
+ const asset = (0, utils_1.wethToEth)(_asset);
59
60
  const assetData = assetsData[asset];
60
- const eModeCategoryData = (eModeCategoriesData === null || eModeCategoriesData === void 0 ? void 0 : eModeCategoriesData[eModeCategory]) || { collateralAssets: [], collateralFactor: '0', liquidationRatio: '0' };
61
61
  if (eModeCategory === 0
62
- || !eModeCategoryData.collateralAssets.includes(asset)
63
- || new decimal_js_1.default(eModeCategoryData.collateralFactor || 0).eq(0)) {
62
+ || assetData.eModeCategory !== eModeCategory
63
+ || new decimal_js_1.default(((_a = assetData === null || assetData === void 0 ? void 0 : assetData.eModeCategoryData) === null || _a === void 0 ? void 0 : _a.collateralFactor) || 0).eq(0)) {
64
64
  const { liquidationRatio, collateralFactor } = assetData;
65
65
  return ({ liquidationRatio, collateralFactor });
66
66
  }
67
- const { liquidationRatio, collateralFactor } = eModeCategoryData;
67
+ const { liquidationRatio, collateralFactor } = assetData.eModeCategoryData;
68
68
  return ({ liquidationRatio, collateralFactor });
69
69
  };
70
70
  exports.sparkGetEmodeMutableProps = sparkGetEmodeMutableProps;
71
71
  const sparkGetAggregatedPositionData = (_a) => {
72
- var { usedAssets, eModeCategory, eModeCategoriesData, assetsData, selectedMarket, network } = _a, rest = __rest(_a, ["usedAssets", "eModeCategory", "eModeCategoriesData", "assetsData", "selectedMarket", "network"]);
73
- const data = Object.assign({ usedAssets, eModeCategory, eModeCategoriesData, assetsData, selectedMarket, network }, rest);
72
+ var { usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network } = _a, rest = __rest(_a, ["usedAssets", "eModeCategory", "eModeCategories", "assetsData", "selectedMarket", "network"]);
73
+ const data = Object.assign({ usedAssets, eModeCategory, eModeCategories, assetsData, selectedMarket, network }, rest);
74
74
  const payload = {};
75
75
  payload.suppliedUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
76
76
  payload.suppliedCollateralUsd = (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied, collateral }) => isSupplied && collateral, ({ suppliedUsd }) => suppliedUsd);
@@ -116,6 +116,27 @@ export declare const FLUID_WSTETH_SUSDS_18_BASE: (networkId?: NetworkNumber) =>
116
116
  export declare const FLUID_CBBTC_SUSDS_19_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
117
117
  export declare const FLUID_LBTC_USDC_21_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
118
118
  export declare const FLUID_LBTC_SUSDS_22_BASE: (networkId?: NetworkNumber) => FluidMarketInfo;
119
+ export declare const FLUID_ETH_USDT_1_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
120
+ export declare const FLUID_ETH_USDE_2_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
121
+ export declare const FLUID_WEETH_ETH_3_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
122
+ export declare const FLUID_SUSDE_USDT_4_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
123
+ export declare const FLUID_WEETH_USDT_5_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
124
+ export declare const FLUID_WEETH_USDE_6_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
125
+ export declare const FLUID_XAUT_USDT_7_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
126
+ export declare const FLUID_XAUT_USDE_8_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
127
+ export declare const FLUID_USDE_USDT_9_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
128
+ export declare const FLUID_USDAI_USDT_10_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
129
+ export declare const FLUID_WEETH_ETH_ETH_11_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
130
+ export declare const FLUID_SUSDE_USDT_USDT_12_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
131
+ export declare const FLUID_USDE_USDT_USDT_13_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
132
+ export declare const FLUID_USDAI_USDT_USDT_14_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
133
+ export declare const FLUID_USDT_SYRUPUSDT_USDT_15_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
134
+ export declare const FLUID_XPL_USDT_16_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
135
+ export declare const FLUID_XPL_USDE_17_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
136
+ export declare const FLUID_WSTUSR_USDT_18_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
137
+ export declare const FLUID_WSTUSR_USDT_USDT_19_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
138
+ export declare const FLUID_SYRUPUSDT_USDT_20_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
139
+ export declare const FLUID_ETH_WRSETH_ETH_21_PLASMA: (networkId?: NetworkNumber) => FluidMarketInfo;
119
140
  export declare const FluidMarkets: (networkId: NetworkNumber) => {
120
141
  FLUID_ETH_USDC_1: FluidMarketInfo;
121
142
  FLUID_ETH_USDT_2: FluidMarketInfo;
@@ -233,6 +254,27 @@ export declare const FluidMarkets: (networkId: NetworkNumber) => {
233
254
  FLUID_CBBTC_SUSDS_19_BASE: FluidMarketInfo;
234
255
  FLUID_LBTC_USDC_21_BASE: FluidMarketInfo;
235
256
  FLUID_LBTC_SUSDS_22_BASE: FluidMarketInfo;
257
+ FLUID_ETH_USDT_1_PLASMA: FluidMarketInfo;
258
+ FLUID_ETH_USDE_2_PLASMA: FluidMarketInfo;
259
+ FLUID_WEETH_ETH_3_PLASMA: FluidMarketInfo;
260
+ FLUID_SUSDE_USDT_4_PLASMA: FluidMarketInfo;
261
+ FLUID_WEETH_USDT_5_PLASMA: FluidMarketInfo;
262
+ FLUID_WEETH_USDE_6_PLASMA: FluidMarketInfo;
263
+ FLUID_XAUT_USDT_7_PLASMA: FluidMarketInfo;
264
+ FLUID_XAUT_USDE_8_PLASMA: FluidMarketInfo;
265
+ FLUID_USDE_USDT_9_PLASMA: FluidMarketInfo;
266
+ FLUID_USDE_USDT_10_PLASMA: FluidMarketInfo;
267
+ FLUID_WEETH_ETH_ETH_11_PLASMA: FluidMarketInfo;
268
+ FLUID_SUSDE_USDT_USDT_12_PLASMA: FluidMarketInfo;
269
+ FLUID_USDE_USDT_USDT_13_PLASMA: FluidMarketInfo;
270
+ FLUID_USDAI_USDT_USDT_14_PLASMA: FluidMarketInfo;
271
+ FLUID_USDT_SYRUPUSDT_USDT_15_PLASMA: FluidMarketInfo;
272
+ FLUID_XPL_USDT_16_PLASMA: FluidMarketInfo;
273
+ FLUID_XPL_USDE_17_PLASMA: FluidMarketInfo;
274
+ FLUID_WSTUSR_USDT_18_PLASMA: FluidMarketInfo;
275
+ FLUID_WSTUSR_USDT_USDT_19_PLASMA: FluidMarketInfo;
276
+ FLUID_SYRUPUSDT_USDT_20_PLASMA: FluidMarketInfo;
277
+ FLUID_ETH_WRSETH_ETH_21_PLASMA: FluidMarketInfo;
236
278
  };
237
279
  export declare const getFluidVersionsDataForNetwork: (network: NetworkNumber) => FluidMarketInfo[];
238
280
  export declare const getFluidMarketInfoById: (vaultId: number, network?: NetworkNumber) => FluidMarketInfo | undefined;
@@ -260,5 +302,9 @@ export declare const FluidFTokens: (networkId: NetworkNumber) => {
260
302
  wstETH: string;
261
303
  sUSDS: string;
262
304
  GHO: string;
305
+ } | {
306
+ ETH: string;
307
+ USDT: string;
308
+ USDe: string;
263
309
  };
264
310
  export declare const getFTokenAddress: (token: string, networkId: NetworkNumber) => any;