@defisaver/positions-sdk 0.0.200 → 0.0.201-fluid-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 (125) hide show
  1. package/.mocharc.json +4 -4
  2. package/.nvmrc +1 -1
  3. package/README.md +69 -69
  4. package/cjs/config/contracts.d.ts +43 -0
  5. package/cjs/config/contracts.js +6 -0
  6. package/cjs/contracts.d.ts +1 -0
  7. package/cjs/contracts.js +2 -1
  8. package/cjs/fluid/index.d.ts +38 -0
  9. package/cjs/fluid/index.js +163 -0
  10. package/cjs/helpers/fluidHelpers/index.d.ts +6 -0
  11. package/cjs/helpers/fluidHelpers/index.js +40 -0
  12. package/cjs/helpers/index.d.ts +1 -0
  13. package/cjs/helpers/index.js +2 -1
  14. package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
  15. package/cjs/index.d.ts +2 -1
  16. package/cjs/index.js +3 -1
  17. package/cjs/markets/aave/marketAssets.js +1 -1
  18. package/cjs/markets/fluid/index.d.ts +174 -0
  19. package/cjs/markets/fluid/index.js +1286 -0
  20. package/cjs/markets/index.d.ts +1 -0
  21. package/cjs/markets/index.js +3 -1
  22. package/cjs/types/contracts/generated/FluidView.d.ts +318 -0
  23. package/cjs/types/contracts/generated/FluidView.js +5 -0
  24. package/cjs/types/contracts/generated/index.d.ts +1 -0
  25. package/cjs/types/fluid.d.ts +225 -0
  26. package/cjs/types/fluid.js +129 -0
  27. package/cjs/types/index.d.ts +1 -0
  28. package/cjs/types/index.js +1 -0
  29. package/esm/config/contracts.d.ts +43 -0
  30. package/esm/config/contracts.js +6 -0
  31. package/esm/contracts.d.ts +1 -0
  32. package/esm/contracts.js +1 -0
  33. package/esm/fluid/index.d.ts +38 -0
  34. package/esm/fluid/index.js +153 -0
  35. package/esm/helpers/fluidHelpers/index.d.ts +6 -0
  36. package/esm/helpers/fluidHelpers/index.js +33 -0
  37. package/esm/helpers/index.d.ts +1 -0
  38. package/esm/helpers/index.js +1 -0
  39. package/esm/helpers/morphoBlueHelpers/index.js +66 -66
  40. package/esm/index.d.ts +2 -1
  41. package/esm/index.js +2 -1
  42. package/esm/markets/aave/marketAssets.js +1 -1
  43. package/esm/markets/fluid/index.d.ts +174 -0
  44. package/esm/markets/fluid/index.js +1196 -0
  45. package/esm/markets/index.d.ts +1 -0
  46. package/esm/markets/index.js +1 -0
  47. package/esm/types/contracts/generated/FluidView.d.ts +318 -0
  48. package/esm/types/contracts/generated/FluidView.js +4 -0
  49. package/esm/types/contracts/generated/index.d.ts +1 -0
  50. package/esm/types/fluid.d.ts +225 -0
  51. package/esm/types/fluid.js +126 -0
  52. package/esm/types/index.d.ts +1 -0
  53. package/esm/types/index.js +1 -0
  54. package/package.json +49 -49
  55. package/src/aaveV2/index.ts +227 -227
  56. package/src/aaveV3/index.ts +625 -625
  57. package/src/assets/index.ts +60 -60
  58. package/src/chickenBonds/index.ts +123 -123
  59. package/src/compoundV2/index.ts +220 -220
  60. package/src/compoundV3/index.ts +291 -291
  61. package/src/config/contracts.js +1115 -1109
  62. package/src/constants/index.ts +6 -6
  63. package/src/contracts.ts +134 -133
  64. package/src/curveUsd/index.ts +229 -229
  65. package/src/eulerV2/index.ts +303 -303
  66. package/src/exchange/index.ts +17 -17
  67. package/src/fluid/index.ts +220 -0
  68. package/src/helpers/aaveHelpers/index.ts +198 -198
  69. package/src/helpers/chickenBondsHelpers/index.ts +23 -23
  70. package/src/helpers/compoundHelpers/index.ts +246 -246
  71. package/src/helpers/curveUsdHelpers/index.ts +40 -40
  72. package/src/helpers/eulerHelpers/index.ts +232 -232
  73. package/src/helpers/fluidHelpers/index.ts +54 -0
  74. package/src/helpers/index.ts +11 -10
  75. package/src/helpers/liquityV2Helpers/index.ts +79 -79
  76. package/src/helpers/llamaLendHelpers/index.ts +53 -53
  77. package/src/helpers/makerHelpers/index.ts +94 -94
  78. package/src/helpers/morphoBlueHelpers/index.ts +365 -365
  79. package/src/helpers/sparkHelpers/index.ts +150 -150
  80. package/src/index.ts +52 -50
  81. package/src/liquity/index.ts +116 -116
  82. package/src/liquityV2/index.ts +227 -227
  83. package/src/llamaLend/index.ts +275 -275
  84. package/src/maker/index.ts +117 -117
  85. package/src/markets/aave/index.ts +152 -152
  86. package/src/markets/aave/marketAssets.ts +44 -44
  87. package/src/markets/compound/index.ts +213 -213
  88. package/src/markets/compound/marketsAssets.ts +82 -82
  89. package/src/markets/curveUsd/index.ts +69 -69
  90. package/src/markets/euler/index.ts +26 -26
  91. package/src/markets/fluid/index.ts +1290 -0
  92. package/src/markets/index.ts +25 -24
  93. package/src/markets/liquityV2/index.ts +43 -43
  94. package/src/markets/llamaLend/contractAddresses.ts +141 -141
  95. package/src/markets/llamaLend/index.ts +235 -235
  96. package/src/markets/morphoBlue/index.ts +895 -895
  97. package/src/markets/spark/index.ts +29 -29
  98. package/src/markets/spark/marketAssets.ts +10 -10
  99. package/src/moneymarket/moneymarketCommonService.ts +80 -80
  100. package/src/morphoAaveV2/index.ts +256 -256
  101. package/src/morphoAaveV3/index.ts +631 -631
  102. package/src/morphoBlue/index.ts +204 -204
  103. package/src/multicall/index.ts +22 -22
  104. package/src/services/dsrService.ts +15 -15
  105. package/src/services/priceService.ts +62 -62
  106. package/src/services/utils.ts +56 -56
  107. package/src/setup.ts +8 -8
  108. package/src/spark/index.ts +461 -461
  109. package/src/staking/staking.ts +220 -220
  110. package/src/types/aave.ts +271 -271
  111. package/src/types/chickenBonds.ts +45 -45
  112. package/src/types/common.ts +84 -84
  113. package/src/types/compound.ts +131 -131
  114. package/src/types/contracts/generated/FluidView.ts +399 -0
  115. package/src/types/contracts/generated/index.ts +1 -0
  116. package/src/types/curveUsd.ts +118 -118
  117. package/src/types/euler.ts +171 -171
  118. package/src/types/fluid.ts +240 -0
  119. package/src/types/index.ts +12 -11
  120. package/src/types/liquity.ts +30 -30
  121. package/src/types/liquityV2.ts +118 -118
  122. package/src/types/llamaLend.ts +155 -155
  123. package/src/types/maker.ts +50 -50
  124. package/src/types/morphoBlue.ts +192 -192
  125. package/src/types/spark.ts +131 -131
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FluidVaultType = exports.FluidBaseDepositToken = exports.FluidArbitrumDepositToken = exports.FluidMainnetDepositToken = exports.FluidBaseVersions = exports.FluidArbitrumVersion = exports.FluidMainnetVersion = void 0;
4
+ const common_1 = require("./common");
5
+ var FluidMainnetVersion;
6
+ (function (FluidMainnetVersion) {
7
+ FluidMainnetVersion["ETH_USDC_1"] = "ETH_USDC_1";
8
+ FluidMainnetVersion["ETH_USDT_2"] = "ETH_USDT_2";
9
+ FluidMainnetVersion["WSTETH_ETH_3"] = "WSTETH_ETH_3";
10
+ FluidMainnetVersion["WSTETH_USDC_4"] = "WSTETH_USDC_4";
11
+ FluidMainnetVersion["WSTETH_USDT_5"] = "WSTETH_USDT_5";
12
+ FluidMainnetVersion["WEETH_WSTETH_6"] = "WEETH_WSTETH_6";
13
+ FluidMainnetVersion["SUSDE_USDC_7"] = "SUSDE_USDC_7";
14
+ FluidMainnetVersion["SUSDE_USDT_8"] = "SUSDE_USDT_8";
15
+ FluidMainnetVersion["WEETH_USDC_9"] = "WEETH_USDC_9";
16
+ FluidMainnetVersion["WEETH_USDT_10"] = "WEETH_USDT_10";
17
+ FluidMainnetVersion["ETH_USDC_11"] = "ETH_USDC_11";
18
+ FluidMainnetVersion["ETH_USDT_12"] = "ETH_USDT_12";
19
+ FluidMainnetVersion["WSTETH_ETH_13"] = "WSTETH_ETH_13";
20
+ FluidMainnetVersion["WSTETH_USDC_14"] = "WSTETH_USDC_14";
21
+ FluidMainnetVersion["WSTETH_USDT_15"] = "WSTETH_USDT_15";
22
+ FluidMainnetVersion["WEETH_WSTETH_16"] = "WEETH_WSTETH_16";
23
+ FluidMainnetVersion["SUSDE_USDC_17"] = "SUSDE_USDC_17";
24
+ FluidMainnetVersion["SUSDE_USDT_18"] = "SUSDE_USDT_18";
25
+ FluidMainnetVersion["WEETH_USDC_19"] = "WEETH_USDC_19";
26
+ FluidMainnetVersion["WEETH_USDT_20"] = "WEETH_USDT_20";
27
+ FluidMainnetVersion["WBTC_USDC_21"] = "WBTC_USDC_21";
28
+ FluidMainnetVersion["WBTC_USDT_22"] = "WBTC_USDT_22";
29
+ FluidMainnetVersion["WBTC_ETH_23"] = "WBTC_ETH_23";
30
+ FluidMainnetVersion["ETH_WBTC_24"] = "ETH_WBTC_24";
31
+ FluidMainnetVersion["WSTETH_WBTC_25"] = "WSTETH_WBTC_25";
32
+ FluidMainnetVersion["WEETH_WBTC_26"] = "WEETH_WBTC_26";
33
+ FluidMainnetVersion["WEETHS_WSTETH_27"] = "WEETHS_WSTETH_27";
34
+ FluidMainnetVersion["CBBTC_ETH_28"] = "CBBTC_ETH_28";
35
+ FluidMainnetVersion["CBBTC_USDC_29"] = "CBBTC_USDC_29";
36
+ FluidMainnetVersion["CBBTC_USDT_30"] = "CBBTC_USDT_30";
37
+ FluidMainnetVersion["ETH_CBBTC_31"] = "ETH_CBBTC_31";
38
+ FluidMainnetVersion["WEETH_CBBTC_32"] = "WEETH_CBBTC_32";
39
+ FluidMainnetVersion["WSTETH_CBBTC_33"] = "WSTETH_CBBTC_33";
40
+ FluidMainnetVersion["WSTETH_ETH_WSTETH_ETH_44"] = "WSTETH_ETH_WSTETH_ETH_44";
41
+ FluidMainnetVersion["ETH_USDC_USDT_45"] = "ETH_USDC_USDT_45";
42
+ FluidMainnetVersion["WSTETH_USDC_USDT_46"] = "WSTETH_USDC_USDT_46";
43
+ FluidMainnetVersion["WEETH_USDC_USDT_47"] = "WEETH_USDC_USDT_47";
44
+ FluidMainnetVersion["WBTC_USDC_USDT_48"] = "WBTC_USDC_USDT_48";
45
+ FluidMainnetVersion["CBBTC_USDC_USDT_49"] = "CBBTC_USDC_USDT_49";
46
+ FluidMainnetVersion["SUSDE_USDC_USDT_50"] = "SUSDE_USDC_USDT_50";
47
+ FluidMainnetVersion["WBTC_CBBTC_WBTC_CBBTC_51"] = "WBTC_CBBTC_WBTC_CBBTC_51";
48
+ FluidMainnetVersion["WBTC_CBBTC_USDC_52"] = "WBTC_CBBTC_USDC_52";
49
+ FluidMainnetVersion["WBTC_CBBTC_USDT_53"] = "WBTC_CBBTC_USDT_53";
50
+ FluidMainnetVersion["ETH_GHO_54"] = "ETH_GHO_54";
51
+ FluidMainnetVersion["WSTETH_GHO_55"] = "WSTETH_GHO_55";
52
+ FluidMainnetVersion["SUSDE_GHO_56"] = "SUSDE_GHO_56";
53
+ FluidMainnetVersion["WEETH_GHO_57"] = "WEETH_GHO_57";
54
+ FluidMainnetVersion["SUSDS_GHO_58"] = "SUSDS_GHO_58";
55
+ FluidMainnetVersion["WBTC_GHO_59"] = "WBTC_GHO_59";
56
+ FluidMainnetVersion["CBBTC_GHO_60"] = "CBBTC_GHO_60";
57
+ FluidMainnetVersion["GHO_USDC_GHO_USDC_61"] = "GHO_USDC_GHO_USDC_61";
58
+ FluidMainnetVersion["WEETH_ETH_WSTETH_74"] = "WEETH_ETH_WSTETH_74";
59
+ FluidMainnetVersion["USDC_ETH_USDC_ETH_77"] = "USDC_ETH_USDC_ETH_77";
60
+ FluidMainnetVersion["RSETH_ETH_WSTETH_78"] = "RSETH_ETH_WSTETH_78";
61
+ FluidMainnetVersion["RSETH_WSTETH_79"] = "RSETH_WSTETH_79";
62
+ FluidMainnetVersion["WEETHS_ETH_WSTETH_80"] = "WEETHS_ETH_WSTETH_80";
63
+ })(FluidMainnetVersion || (exports.FluidMainnetVersion = FluidMainnetVersion = {}));
64
+ var FluidArbitrumVersion;
65
+ (function (FluidArbitrumVersion) {
66
+ FluidArbitrumVersion["ETH_USDC_1_ARB"] = "ETH_USDC_1_ARB";
67
+ FluidArbitrumVersion["ETH_USDT_2_ARB"] = "ETH_USDT_2_ARB";
68
+ FluidArbitrumVersion["WSTETH_USDC_3_ARB"] = "WSTETH_USDC_3_ARB";
69
+ FluidArbitrumVersion["WSTETH_USDT_4_ARB"] = "WSTETH_USDT_4_ARB";
70
+ FluidArbitrumVersion["WSTETH_ETH_5_ARB"] = "WSTETH_ETH_5_ARB";
71
+ FluidArbitrumVersion["WEETH_WSTETH_6_ARB"] = "WEETH_WSTETH_6_ARB";
72
+ FluidArbitrumVersion["WEETH_USDC_7_ARB"] = "WEETH_USDC_7_ARB";
73
+ FluidArbitrumVersion["WEETH_USDT_8_ARB"] = "WEETH_USDT_8_ARB";
74
+ FluidArbitrumVersion["ETH_ARB_9_ARB"] = "ETH_ARB_9_ARB";
75
+ FluidArbitrumVersion["ARB_USDC_10_ARB"] = "ARB_USDC_10_ARB";
76
+ FluidArbitrumVersion["ARB_USDT_11_ARB"] = "ARB_USDT_11_ARB";
77
+ FluidArbitrumVersion["WSTETH_ETH_WSTETH_ETH_16_ARB"] = "WSTETH_ETH_WSTETH_ETH_16_ARB";
78
+ FluidArbitrumVersion["WEETH_ETH_WSTETH_17_ARB"] = "WEETH_ETH_WSTETH_17_ARB";
79
+ })(FluidArbitrumVersion || (exports.FluidArbitrumVersion = FluidArbitrumVersion = {}));
80
+ var FluidBaseVersions;
81
+ (function (FluidBaseVersions) {
82
+ FluidBaseVersions["ETH_USDC_1_BASE"] = "ETH_USDC_1_BASE";
83
+ FluidBaseVersions["WSTETH_USDC_2_BASE"] = "WSTETH_USDC_2_BASE";
84
+ FluidBaseVersions["WSTETH_ETH_3_BASE"] = "WSTETH_ETH_3_BASE";
85
+ FluidBaseVersions["WEETH_WSTETH_4_BASE"] = "WEETH_WSTETH_4_BASE";
86
+ FluidBaseVersions["WEETH_USDC_5_BASE"] = "WEETH_USDC_5_BASE";
87
+ FluidBaseVersions["CBETH_USDC_6_BASE"] = "CBETH_USDC_6_BASE";
88
+ FluidBaseVersions["CBBTC_USDC_7_BASE"] = "CBBTC_USDC_7_BASE";
89
+ FluidBaseVersions["CBBTC_EURC_8_BASE"] = "CBBTC_EURC_8_BASE";
90
+ FluidBaseVersions["CBETH_EURC_9_BASE"] = "CBETH_EURC_9_BASE";
91
+ FluidBaseVersions["ETH_EURC_10_BASE"] = "ETH_EURC_10_BASE";
92
+ FluidBaseVersions["WEETH_EURC_11_BASE"] = "WEETH_EURC_11_BASE";
93
+ FluidBaseVersions["WSTETH_EURC_12_BASE"] = "WSTETH_EURC_12_BASE";
94
+ FluidBaseVersions["CBBTC_ETH_13_BASE"] = "CBBTC_ETH_13_BASE";
95
+ FluidBaseVersions["ETH_CBBTC_14_BASE"] = "ETH_CBBTC_14_BASE";
96
+ FluidBaseVersions["WEETH_CBBTC_15_BASE"] = "WEETH_CBBTC_15_BASE";
97
+ FluidBaseVersions["WSTETH_CBBTC_16_BASE"] = "WSTETH_CBBTC_16_BASE";
98
+ })(FluidBaseVersions || (exports.FluidBaseVersions = FluidBaseVersions = {}));
99
+ var FluidMainnetDepositToken;
100
+ (function (FluidMainnetDepositToken) {
101
+ FluidMainnetDepositToken["ETH"] = "ETH";
102
+ FluidMainnetDepositToken["wstETH"] = "wstETH";
103
+ FluidMainnetDepositToken["USDC"] = "USDC";
104
+ FluidMainnetDepositToken["USDT"] = "USDT";
105
+ FluidMainnetDepositToken["GHO"] = "GHO";
106
+ })(FluidMainnetDepositToken || (exports.FluidMainnetDepositToken = FluidMainnetDepositToken = {}));
107
+ var FluidArbitrumDepositToken;
108
+ (function (FluidArbitrumDepositToken) {
109
+ FluidArbitrumDepositToken["ETH"] = "ETH";
110
+ FluidArbitrumDepositToken["wstETH"] = "wstETH";
111
+ FluidArbitrumDepositToken["USDC"] = "USDC";
112
+ FluidArbitrumDepositToken["USDT"] = "USDT";
113
+ FluidArbitrumDepositToken["ARB"] = "ARB";
114
+ })(FluidArbitrumDepositToken || (exports.FluidArbitrumDepositToken = FluidArbitrumDepositToken = {}));
115
+ var FluidBaseDepositToken;
116
+ (function (FluidBaseDepositToken) {
117
+ FluidBaseDepositToken["ETH"] = "ETH";
118
+ FluidBaseDepositToken["USDC"] = "USDC";
119
+ FluidBaseDepositToken["wstETH"] = "wstETH";
120
+ FluidBaseDepositToken["EURC"] = "EURC";
121
+ })(FluidBaseDepositToken || (exports.FluidBaseDepositToken = FluidBaseDepositToken = {}));
122
+ var FluidVaultType;
123
+ (function (FluidVaultType) {
124
+ FluidVaultType["T1"] = "T1";
125
+ FluidVaultType["T2"] = "T2";
126
+ FluidVaultType["T3"] = "T3";
127
+ FluidVaultType["T4"] = "T4";
128
+ FluidVaultType["Unknown"] = "Unknown";
129
+ })(FluidVaultType || (exports.FluidVaultType = FluidVaultType = {}));
@@ -9,3 +9,4 @@ export * from './chickenBonds';
9
9
  export * from './morphoBlue';
10
10
  export * from './llamaLend';
11
11
  export * from './euler';
12
+ export * from './fluid';
@@ -25,3 +25,4 @@ __exportStar(require("./chickenBonds"), exports);
25
25
  __exportStar(require("./morphoBlue"), exports);
26
26
  __exportStar(require("./llamaLend"), exports);
27
27
  __exportStar(require("./euler"), exports);
28
+ __exportStar(require("./fluid"), exports);
@@ -7599,3 +7599,46 @@ export namespace EulerV2View {
7599
7599
  };
7600
7600
  export { networks_84 as networks };
7601
7601
  }
7602
+ export namespace FluidView {
7603
+ let abi_85: ({
7604
+ inputs: {
7605
+ internalType: string;
7606
+ name: string;
7607
+ type: string;
7608
+ }[];
7609
+ name: string;
7610
+ outputs: {
7611
+ internalType: string;
7612
+ name: string;
7613
+ type: string;
7614
+ }[];
7615
+ stateMutability: string;
7616
+ type: string;
7617
+ } | {
7618
+ inputs: {
7619
+ internalType: string;
7620
+ name: string;
7621
+ type: string;
7622
+ }[];
7623
+ name: string;
7624
+ outputs: {
7625
+ components: {
7626
+ internalType: string;
7627
+ name: string;
7628
+ type: string;
7629
+ }[];
7630
+ internalType: string;
7631
+ name: string;
7632
+ type: string;
7633
+ }[];
7634
+ stateMutability: string;
7635
+ type: string;
7636
+ })[];
7637
+ export { abi_85 as abi };
7638
+ let networks_85: {
7639
+ "1": {
7640
+ address: string;
7641
+ };
7642
+ };
7643
+ export { networks_85 as networks };
7644
+ }
@@ -1104,5 +1104,11 @@ module.exports = {
1104
1104
  "networks": {
1105
1105
  "1": { "address": "0x8932E46Ecf96b5Fe033F5e27Ab6dC755Cb668967" }
1106
1106
  }
1107
+ },
1108
+ "FluidView": {
1109
+ "abi": [{ "inputs": [], "name": "feedRegistry", "outputs": [{ "internalType": "contract IFeedRegistry", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveTokenPriceInETH", "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveTokenPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveV3TokenPriceInETH", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getAaveV3TokenPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getAddrForChainlinkOracle", "outputs": [{ "internalType": "address", "name": "tokenAddrForChainlinkUsage", "type": "address" }], "stateMutability": "pure", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getChainlinkPriceInETH", "outputs": [{ "internalType": "int256", "name": "chainlinkPriceInETH", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }, { "internalType": "bool", "name": "_useFallback", "type": "bool" }], "name": "getChainlinkPriceInUSD", "outputs": [{ "internalType": "int256", "name": "chainlinkPriceInUSD", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getPositionByNftId", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition", "name": "position", "type": "tuple" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData", "name": "vault", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getPriceInETH", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }], "name": "getPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "_nftId", "type": "uint256" }], "name": "getRatio", "outputs": [{ "internalType": "uint256", "name": "ratio", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }, { "internalType": "uint80", "name": "_roundId", "type": "uint80" }, { "internalType": "contract IAggregatorV3", "name": "aggregator", "type": "address" }], "name": "getRoundInfo", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "updateTimestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_inputTokenAddr", "type": "address" }, { "internalType": "uint80", "name": "_roundId", "type": "uint80" }], "name": "getRoundInfo", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }, { "internalType": "uint256", "name": "updateTimestamp", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getSparkTokenPriceInETH", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_tokenAddr", "type": "address" }], "name": "getSparkTokenPriceInUSD", "outputs": [{ "internalType": "uint256", "name": "price", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserNftIds", "outputs": [{ "internalType": "uint256[]", "name": "", "type": "uint256[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_user", "type": "address" }], "name": "getUserPositions", "outputs": [{ "components": [{ "internalType": "uint256", "name": "nftId", "type": "uint256" }, { "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "bool", "name": "isLiquidated", "type": "bool" }, { "internalType": "bool", "name": "isSupplyPosition", "type": "bool" }, { "internalType": "uint256", "name": "supply", "type": "uint256" }, { "internalType": "uint256", "name": "borrow", "type": "uint256" }, { "internalType": "uint256", "name": "ratio", "type": "uint256" }, { "internalType": "int256", "name": "tick", "type": "int256" }, { "internalType": "uint256", "name": "tickId", "type": "uint256" }], "internalType": "struct FluidView.UserPosition[]", "name": "positions", "type": "tuple[]" }, { "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData[]", "name": "vaults", "type": "tuple[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256[]", "name": "_ids", "type": "uint256[]" }, { "internalType": "bool", "name": "_fetchAll", "type": "bool" }], "name": "getVaultAddresses", "outputs": [{ "internalType": "address[]", "name": "", "type": "address[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "_vault", "type": "address" }], "name": "getVaultData", "outputs": [{ "components": [{ "internalType": "address", "name": "vault", "type": "address" }, { "internalType": "uint256", "name": "vaultId", "type": "uint256" }, { "internalType": "uint256", "name": "vaultType", "type": "uint256" }, { "internalType": "bool", "name": "isSmartColl", "type": "bool" }, { "internalType": "bool", "name": "isSmartDebt", "type": "bool" }, { "internalType": "address", "name": "supplyToken0", "type": "address" }, { "internalType": "address", "name": "supplyToken1", "type": "address" }, { "internalType": "address", "name": "borrowToken0", "type": "address" }, { "internalType": "address", "name": "borrowToken1", "type": "address" }, { "internalType": "uint256", "name": "supplyToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "supplyToken1Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken0Decimals", "type": "uint256" }, { "internalType": "uint256", "name": "borrowToken1Decimals", "type": "uint256" }, { "internalType": "uint16", "name": "collateralFactor", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationThreshold", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationMaxLimit", "type": "uint16" }, { "internalType": "uint16", "name": "withdrawalGap", "type": "uint16" }, { "internalType": "uint16", "name": "liquidationPenalty", "type": "uint16" }, { "internalType": "uint16", "name": "borrowFee", "type": "uint16" }, { "internalType": "address", "name": "oracle", "type": "address" }, { "internalType": "uint256", "name": "oraclePriceOperate", "type": "uint256" }, { "internalType": "uint256", "name": "oraclePriceLiquidate", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfSupplyToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken0InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "priceOfBorrowToken1InUSD", "type": "uint256" }, { "internalType": "uint256", "name": "vaultSupplyExchangePrice", "type": "uint256" }, { "internalType": "uint256", "name": "vaultBorrowExchangePrice", "type": "uint256" }, { "internalType": "int256", "name": "supplyRateVault", "type": "int256" }, { "internalType": "int256", "name": "borrowRateVault", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateSupply", "type": "int256" }, { "internalType": "int256", "name": "rewardsOrFeeRateBorrow", "type": "int256" }, { "internalType": "uint256", "name": "totalPositions", "type": "uint256" }, { "internalType": "uint256", "name": "totalSupplyVault", "type": "uint256" }, { "internalType": "uint256", "name": "totalBorrowVault", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawable", "type": "uint256" }, { "internalType": "uint256", "name": "baseWithdrawalLimit", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "withdrawExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowableUntilLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowable", "type": "uint256" }, { "internalType": "uint256", "name": "borrowLimitUtilization", "type": "uint256" }, { "internalType": "uint256", "name": "maxBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandPercent", "type": "uint256" }, { "internalType": "uint256", "name": "borrowExpandDuration", "type": "uint256" }, { "internalType": "uint256", "name": "baseBorrowLimit", "type": "uint256" }, { "internalType": "uint256", "name": "minimumBorrowing", "type": "uint256" }], "internalType": "struct FluidView.VaultData", "name": "vaultData", "type": "tuple" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "int256", "name": "_btcPrice", "type": "int256" }], "name": "getWBtcPrice", "outputs": [{ "internalType": "int256", "name": "wBtcPrice", "type": "int256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "int256", "name": "_stEthPrice", "type": "int256" }], "name": "getWStEthPrice", "outputs": [{ "internalType": "int256", "name": "wStEthPrice", "type": "int256" }], "stateMutability": "view", "type": "function" }],
1110
+ "networks": {
1111
+ "1": { "address": "0xBAc6dc3edB72Bc705Ab4e31F2a2151Fe06550D9B" }
1112
+ }
1107
1113
  }
1108
1114
  };
@@ -49,3 +49,4 @@ export declare const MorphoBlueViewContract: (web3: Web3, network: NetworkNumber
49
49
  export declare const LlamaLendViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LlamaLendView;
50
50
  export declare const LiquityV2ViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.LiquityV2View;
51
51
  export declare const EulerV2ViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.EulerV2View;
52
+ export declare const FluidViewContract: (web3: Web3, network: NetworkNumber, block?: Blockish) => ContractTypes.FluidView;
package/esm/contracts.js CHANGED
@@ -81,3 +81,4 @@ export const MorphoBlueViewContract = createContractFromConfigFunc('MorphoBlueVi
81
81
  export const LlamaLendViewContract = createContractFromConfigFunc('LlamaLendView');
82
82
  export const LiquityV2ViewContract = createContractFromConfigFunc('LiquityV2View');
83
83
  export const EulerV2ViewContract = createContractFromConfigFunc('EulerV2View');
84
+ export const FluidViewContract = createContractFromConfigFunc('FluidView');
@@ -0,0 +1,38 @@
1
+ import Web3 from 'web3';
2
+ import { EthAddress, NetworkNumber } from '../types/common';
3
+ import { FluidAssetsData, FluidMarketData, FluidMarketInfo, FluidVaultData, InnerFluidMarketData } from '../types';
4
+ export declare const EMPTY_USED_ASSET: {
5
+ isSupplied: boolean;
6
+ isBorrowed: boolean;
7
+ supplied: string;
8
+ suppliedUsd: string;
9
+ borrowed: string;
10
+ borrowedUsd: string;
11
+ symbol: string;
12
+ collateral: boolean;
13
+ };
14
+ export declare const EMPTY_FLUID_DATA: {
15
+ usedAssets: {};
16
+ suppliedUsd: string;
17
+ borrowedUsd: string;
18
+ borrowLimitUsd: string;
19
+ leftToBorrowUsd: string;
20
+ ratio: string;
21
+ minRatio: string;
22
+ netApy: string;
23
+ incentiveUsd: string;
24
+ totalInterestUsd: string;
25
+ isSubscribedToAutomation: boolean;
26
+ automationResubscribeRequired: boolean;
27
+ lastUpdated: number;
28
+ };
29
+ export declare const getFluidMarketData: (web3: Web3, network: NetworkNumber, market: FluidMarketInfo) => Promise<FluidMarketData>;
30
+ export declare const getFluidVaultIdsForUser: (web3: Web3, network: NetworkNumber, user: EthAddress) => Promise<string[]>;
31
+ export declare const getFluidPosition: (web3: Web3, network: NetworkNumber, vaultId: string, extractedState: {
32
+ assetsData: FluidAssetsData;
33
+ marketData: InnerFluidMarketData;
34
+ }) => Promise<FluidVaultData>;
35
+ export declare const getFluidPositionWithMarket: (web3: Web3, network: NetworkNumber, vaultId: string) => Promise<{
36
+ userData: FluidVaultData;
37
+ marketData: FluidMarketData;
38
+ }>;
@@ -0,0 +1,153 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import Dec from 'decimal.js';
11
+ import { getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
12
+ import { FluidVaultType, } from '../types';
13
+ import { FluidViewContract } from '../contracts';
14
+ import { getEthAmountForDecimals } from '../services/utils';
15
+ import { getFluidAggregatedData } from '../helpers/fluidHelpers';
16
+ export const EMPTY_USED_ASSET = {
17
+ isSupplied: false,
18
+ isBorrowed: false,
19
+ supplied: '0',
20
+ suppliedUsd: '0',
21
+ borrowed: '0',
22
+ borrowedUsd: '0',
23
+ symbol: '',
24
+ collateral: false,
25
+ };
26
+ const parseVaultType = (vaultType) => {
27
+ switch (vaultType) {
28
+ case 10000: return FluidVaultType.T1;
29
+ case 20000: return FluidVaultType.T2;
30
+ case 30000: return FluidVaultType.T3;
31
+ case 40000: return FluidVaultType.T4;
32
+ default: return FluidVaultType.Unknown;
33
+ }
34
+ };
35
+ const parseMarketData = (data) => {
36
+ const collAsset = getAssetInfoByAddress(data.supplyToken0);
37
+ const debtAsset = getAssetInfoByAddress(data.borrowToken0);
38
+ const collAssetData = {
39
+ symbol: collAsset.symbol,
40
+ address: collAsset.address,
41
+ price: getEthAmountForDecimals(data.priceOfSupplyToken0InUSD, 8),
42
+ totalSupply: data.totalSupplyVault,
43
+ totalBorrow: data.totalBorrowVault,
44
+ canBeSupplied: true,
45
+ canBeBorrowed: false,
46
+ supplyRate: new Dec(data.supplyRateVault).div(100).toString(),
47
+ borrowRate: '0',
48
+ };
49
+ const debtAssetData = {
50
+ symbol: debtAsset.symbol,
51
+ address: debtAsset.address,
52
+ price: getEthAmountForDecimals(data.priceOfBorrowToken0InUSD, 8),
53
+ totalSupply: data.totalSupplyVault,
54
+ totalBorrow: data.totalBorrowVault,
55
+ canBeSupplied: false,
56
+ canBeBorrowed: true,
57
+ supplyRate: '0',
58
+ borrowRate: new Dec(data.borrowRateVault).div(100).toString(),
59
+ };
60
+ const assetsData = {
61
+ [collAsset.symbol]: collAssetData,
62
+ [debtAsset.symbol]: debtAssetData,
63
+ };
64
+ const marketData = {
65
+ vaultId: +data.vaultId,
66
+ isSmartColl: data.isSmartColl,
67
+ isSmartDebt: data.isSmartDebt,
68
+ marketAddress: data.vault,
69
+ vaultType: parseVaultType(+data.vaultType),
70
+ oracle: data.oracle,
71
+ liquidationPenaltyPercent: new Dec(data.liquidationPenalty).div(100).toString(),
72
+ collFactor: new Dec(data.collateralFactor).div(10000).toString(),
73
+ liquidationRatio: new Dec(data.liquidationThreshold).div(100).toString(),
74
+ collAsset0: collAsset.symbol,
75
+ debtAsset0: debtAsset.symbol,
76
+ totalPositions: data.totalPositions,
77
+ totalSupplyVault: getEthAmountForDecimals(data.totalSupplyVault, collAsset.decimals),
78
+ totalBorrowVault: getEthAmountForDecimals(data.totalBorrowVault, debtAsset.decimals),
79
+ withdrawalLimit: getEthAmountForDecimals(data.withdrawalLimit, collAsset.decimals),
80
+ withdrawableUntilLimit: getEthAmountForDecimals(data.withdrawableUntilLimit, collAsset.decimals),
81
+ withdrawable: getEthAmountForDecimals(data.withdrawable, collAsset.decimals),
82
+ borrowLimit: getEthAmountForDecimals(data.borrowLimit, debtAsset.decimals),
83
+ borrowableUntilLimit: getEthAmountForDecimals(data.borrowableUntilLimit, debtAsset.decimals),
84
+ borrowable: getEthAmountForDecimals(data.borrowable, debtAsset.decimals),
85
+ borrowLimitUtilization: getEthAmountForDecimals(data.borrowLimitUtilization, debtAsset.decimals),
86
+ maxBorrowLimit: getEthAmountForDecimals(data.maxBorrowLimit, debtAsset.decimals),
87
+ baseBorrowLimit: getEthAmountForDecimals(data.baseBorrowLimit, debtAsset.decimals),
88
+ minimumBorrowing: getEthAmountForDecimals(data.minimumBorrowing, debtAsset.decimals),
89
+ };
90
+ return {
91
+ assetsData,
92
+ marketData,
93
+ };
94
+ };
95
+ export const EMPTY_FLUID_DATA = {
96
+ usedAssets: {},
97
+ suppliedUsd: '0',
98
+ borrowedUsd: '0',
99
+ borrowLimitUsd: '0',
100
+ leftToBorrowUsd: '0',
101
+ ratio: '0',
102
+ minRatio: '0',
103
+ netApy: '0',
104
+ incentiveUsd: '0',
105
+ totalInterestUsd: '0',
106
+ isSubscribedToAutomation: false,
107
+ automationResubscribeRequired: false,
108
+ lastUpdated: Date.now(),
109
+ };
110
+ const parseUserData = (userPositionData, vaultData) => {
111
+ const { assetsData, marketData, } = vaultData;
112
+ const payload = Object.assign(Object.assign({ owner: userPositionData.owner, vaultId: marketData.vaultId }, EMPTY_FLUID_DATA), { lastUpdated: Date.now() });
113
+ const collAsset = getAssetInfo(marketData.collAsset0);
114
+ const debtAsset = getAssetInfo(marketData.debtAsset0);
115
+ const supplied = getEthAmountForDecimals(userPositionData.supply, collAsset.decimals);
116
+ const borrowed = getEthAmountForDecimals(userPositionData.borrow, debtAsset.decimals);
117
+ const collUsedAsset = Object.assign(Object.assign({}, EMPTY_USED_ASSET), { symbol: collAsset.symbol, collateral: true, supplied, suppliedUsd: new Dec(supplied).mul(assetsData[collAsset.symbol].price).toString(), isSupplied: new Dec(supplied).gt(0) });
118
+ const debtUsedAsset = Object.assign(Object.assign({}, EMPTY_USED_ASSET), { symbol: debtAsset.symbol, collateral: false, borrowed, borrowedUsd: new Dec(borrowed).mul(assetsData[debtAsset.symbol].price).toString(), isBorrowed: new Dec(borrowed).gt(0) });
119
+ const usedAssets = {
120
+ [collAsset.symbol]: collUsedAsset,
121
+ [debtAsset.symbol]: debtUsedAsset,
122
+ };
123
+ return Object.assign(Object.assign(Object.assign({}, payload), { usedAssets }), getFluidAggregatedData({
124
+ usedAssets,
125
+ assetsData,
126
+ marketData,
127
+ }));
128
+ };
129
+ export const getFluidMarketData = (web3, network, market) => __awaiter(void 0, void 0, void 0, function* () {
130
+ const view = FluidViewContract(web3, network);
131
+ const data = yield view.methods.getVaultData(market.marketAddress).call();
132
+ return parseMarketData(data);
133
+ });
134
+ export const getFluidVaultIdsForUser = (web3, network, user) => __awaiter(void 0, void 0, void 0, function* () {
135
+ const view = FluidViewContract(web3, network);
136
+ return view.methods.getUserNftIds(user).call();
137
+ });
138
+ export const getFluidPosition = (web3, network, vaultId, extractedState) => __awaiter(void 0, void 0, void 0, function* () {
139
+ const view = FluidViewContract(web3, network);
140
+ const data = yield view.methods.getPositionByNftId(vaultId).call();
141
+ const userPositionData = data[0];
142
+ return parseUserData(userPositionData, extractedState);
143
+ });
144
+ export const getFluidPositionWithMarket = (web3, network, vaultId) => __awaiter(void 0, void 0, void 0, function* () {
145
+ const view = FluidViewContract(web3, network);
146
+ const data = yield view.methods.getPositionByNftId(vaultId).call();
147
+ const marketData = parseMarketData(data.vault);
148
+ const userData = parseUserData(data.position, marketData);
149
+ return {
150
+ userData,
151
+ marketData,
152
+ };
153
+ });
@@ -0,0 +1,6 @@
1
+ import { FluidAggregatedVaultData, FluidAssetsData, FluidUsedAssets, InnerFluidMarketData } from '../../types';
2
+ export declare const getFluidAggregatedData: ({ usedAssets, assetsData, marketData, }: {
3
+ usedAssets: FluidUsedAssets;
4
+ marketData: InnerFluidMarketData;
5
+ assetsData: FluidAssetsData;
6
+ }) => FluidAggregatedVaultData;
@@ -0,0 +1,33 @@
1
+ import Dec from 'decimal.js';
2
+ import { calcLeverageLiqPrice, getAssetsTotal, isLeveragedPos } from '../../moneymarket';
3
+ import { calculateNetApy } from '../../staking';
4
+ export const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }) => {
5
+ const payload = {};
6
+ payload.suppliedUsd = getAssetsTotal(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd);
7
+ payload.borrowedUsd = getAssetsTotal(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd);
8
+ const { netApy, incentiveUsd, totalInterestUsd } = calculateNetApy({ usedAssets, assetsData: assetsData });
9
+ payload.netApy = netApy;
10
+ payload.incentiveUsd = incentiveUsd;
11
+ payload.totalInterestUsd = totalInterestUsd;
12
+ const collFactor = marketData.collFactor;
13
+ const liqRatio = marketData.liquidationRatio;
14
+ payload.borrowLimitUsd = new Dec(payload.suppliedUsd).mul(collFactor).toString();
15
+ payload.liquidationLimitUsd = new Dec(payload.suppliedUsd).mul(liqRatio).div(100).toString();
16
+ const leftToBorrowUsd = new Dec(payload.borrowLimitUsd).sub(payload.borrowedUsd);
17
+ payload.leftToBorrowUsd = leftToBorrowUsd.lte('0') ? '0' : leftToBorrowUsd.toString();
18
+ payload.ratio = +payload.suppliedUsd ? new Dec(payload.borrowLimitUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
19
+ payload.collRatio = +payload.suppliedUsd ? new Dec(payload.suppliedUsd).div(payload.borrowedUsd).mul(100).toString() : '0';
20
+ const { leveragedType, leveragedAsset } = isLeveragedPos(usedAssets);
21
+ payload.leveragedType = leveragedType;
22
+ if (leveragedType !== '') {
23
+ payload.leveragedAsset = leveragedAsset;
24
+ let assetPrice = assetsData[leveragedAsset].price;
25
+ if (leveragedType === 'lsd-leverage') {
26
+ // Treat ETH like a stablecoin in a long stETH position
27
+ payload.leveragedLsdAssetRatio = new Dec(assetsData[leveragedAsset].price).div(assetsData.ETH.price).toDP(18).toString();
28
+ assetPrice = new Dec(assetPrice).div(assetsData.ETH.price).toString();
29
+ }
30
+ payload.liquidationPrice = calcLeverageLiqPrice(leveragedType, assetPrice, payload.borrowedUsd, payload.liquidationLimitUsd);
31
+ }
32
+ return payload;
33
+ };
@@ -8,3 +8,4 @@ export * as morphoBlueHelpers from './morphoBlueHelpers';
8
8
  export * as llamaLendHelpers from './llamaLendHelpers';
9
9
  export * as liquityV2Helpers from './liquityV2Helpers';
10
10
  export * as eulerV2Helpers from './eulerHelpers';
11
+ export * as fluidHelpers from './fluidHelpers';
@@ -8,3 +8,4 @@ export * as morphoBlueHelpers from './morphoBlueHelpers';
8
8
  export * as llamaLendHelpers from './llamaLendHelpers';
9
9
  export * as liquityV2Helpers from './liquityV2Helpers';
10
10
  export * as eulerV2Helpers from './eulerHelpers';
11
+ export * as fluidHelpers from './fluidHelpers';