@gearbox-protocol/sdk 0.0.102 → 0.0.105

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 (129) hide show
  1. package/.eslintignore +5 -0
  2. package/.eslintrc.js +52 -0
  3. package/.husky/pre-push +4 -0
  4. package/lib/apy/convexAPY.js +3 -5
  5. package/lib/apy/lidoAPY.js +8 -9
  6. package/lib/contracts/contracts.d.ts +5 -2
  7. package/lib/contracts/contracts.js +19 -18
  8. package/lib/core/constants.d.ts +1 -1
  9. package/lib/core/constants.js +2 -2
  10. package/lib/core/creditAccount.js +7 -5
  11. package/lib/core/creditManager.d.ts +1 -1
  12. package/lib/core/creditManager.js +1 -7
  13. package/lib/core/creditSession.js +14 -3
  14. package/lib/core/eventOrTx.d.ts +1 -1
  15. package/lib/core/events.d.ts +19 -19
  16. package/lib/core/events.js +23 -21
  17. package/lib/core/pool.d.ts +1 -1
  18. package/lib/core/pool.js +1 -7
  19. package/lib/core/price.js +6 -1
  20. package/lib/core/strategy.d.ts +1 -3
  21. package/lib/core/strategy.js +14 -13
  22. package/lib/core/tokenDistributor.js +1 -1
  23. package/lib/core/transactions.d.ts +18 -3
  24. package/lib/core/transactions.js +39 -3
  25. package/lib/index.d.ts +8 -2
  26. package/lib/index.js +8 -1
  27. package/lib/oracles/priceFeeds.js +1 -1
  28. package/lib/pathfinder/convexLP.d.ts +1 -1
  29. package/lib/pathfinder/convexLP.js +26 -29
  30. package/lib/pathfinder/curveLP.d.ts +1 -1
  31. package/lib/pathfinder/curveLP.js +5 -7
  32. package/lib/pathfinder/path.d.ts +1 -1
  33. package/lib/pathfinder/path.js +38 -42
  34. package/lib/pathfinder/trade.d.ts +1 -2
  35. package/lib/pathfinder/tradeTypes.d.ts +5 -5
  36. package/lib/pathfinder/yVault.d.ts +2 -2
  37. package/lib/pathfinder/yVault.js +18 -15
  38. package/lib/strategies/convex.d.ts +12 -0
  39. package/lib/strategies/convex.js +74 -1
  40. package/lib/strategies/creditFacade.d.ts +1 -0
  41. package/lib/strategies/creditFacade.js +3 -0
  42. package/lib/strategies/curve.d.ts +15 -60
  43. package/lib/strategies/curve.js +74 -1
  44. package/lib/strategies/lido.d.ts +6 -0
  45. package/lib/strategies/lido.js +23 -1
  46. package/lib/strategies/uniswapV2.d.ts +1 -0
  47. package/lib/strategies/uniswapV2.js +6 -19
  48. package/lib/strategies/uniswapV3.d.ts +1 -0
  49. package/lib/strategies/uniswapV3.js +4 -1
  50. package/lib/strategies/yearn.d.ts +8 -0
  51. package/lib/strategies/yearn.js +92 -12
  52. package/lib/tokens/convex.d.ts +3 -3
  53. package/lib/tokens/curveLP.d.ts +7 -2
  54. package/lib/tokens/curveLP.js +8 -1
  55. package/lib/tokens/gear.d.ts +2 -2
  56. package/lib/tokens/gear.js +1 -1
  57. package/lib/tokens/normal.d.ts +1 -1
  58. package/lib/tokens/token.js +4 -4
  59. package/lib/tokens/tokenData.d.ts +3 -1
  60. package/lib/tokens/tokenData.js +10 -8
  61. package/lib/tokens/yearn.d.ts +6 -2
  62. package/lib/tokens/yearn.js +6 -0
  63. package/lib/utils/errors.d.ts +6 -0
  64. package/lib/utils/errors.js +13 -0
  65. package/lib/utils/formatter.d.ts +1 -1
  66. package/lib/utils/formatter.js +17 -14
  67. package/lib/utils/loading.d.ts +2 -1
  68. package/lib/utils/loading.js +9 -13
  69. package/lib/utils/mappers.js +2 -2
  70. package/lib/utils/network.js +2 -2
  71. package/lib/utils/repeater.js +12 -24
  72. package/lib/utils/validate.js +1 -1
  73. package/package.json +24 -7
  74. package/src/apy/convexAPY.ts +6 -6
  75. package/src/apy/lidoAPY.ts +12 -11
  76. package/src/contracts/contracts.ts +27 -17
  77. package/src/core/constants.ts +1 -1
  78. package/src/core/creditAccount.ts +28 -5
  79. package/src/core/creditManager.ts +29 -4
  80. package/src/core/creditOperation.ts +7 -7
  81. package/src/core/creditSession.ts +25 -5
  82. package/src/core/errors.ts +1 -0
  83. package/src/core/eventOrTx.ts +8 -5
  84. package/src/core/events.ts +85 -24
  85. package/src/core/history.ts +46 -46
  86. package/src/core/operations.ts +6 -0
  87. package/src/core/pool.ts +16 -4
  88. package/src/core/price.ts +7 -3
  89. package/src/core/strategy.ts +27 -23
  90. package/src/core/tokenDistributor.ts +2 -2
  91. package/src/core/transactions.ts +427 -350
  92. package/src/index.ts +10 -3
  93. package/src/oracles/priceFeeds.ts +523 -523
  94. package/src/pathfinder/contracts.ts +15 -13
  95. package/src/pathfinder/convexLP.ts +29 -25
  96. package/src/pathfinder/curveLP.ts +57 -53
  97. package/src/pathfinder/path.ts +17 -9
  98. package/src/pathfinder/priority.ts +11 -11
  99. package/src/pathfinder/trade.ts +84 -77
  100. package/src/pathfinder/tradeTypes.ts +98 -94
  101. package/src/pathfinder/yVault.ts +26 -11
  102. package/src/payload/token.ts +3 -3
  103. package/src/strategies/convex.ts +361 -186
  104. package/src/strategies/creditFacade.ts +74 -53
  105. package/src/strategies/curve.ts +400 -189
  106. package/src/strategies/lido.ts +70 -32
  107. package/src/strategies/uniswapV2.ts +93 -111
  108. package/src/strategies/uniswapV3.ts +118 -91
  109. package/src/strategies/yearn.ts +187 -60
  110. package/src/tokens/connectors.ts +6 -6
  111. package/src/tokens/convex.ts +297 -296
  112. package/src/tokens/curveLP.ts +176 -165
  113. package/src/tokens/gear.ts +47 -45
  114. package/src/tokens/normal.ts +801 -802
  115. package/src/tokens/token.ts +9 -5
  116. package/src/tokens/tokenData.ts +19 -9
  117. package/src/tokens/tokenType.ts +11 -11
  118. package/src/tokens/yearn.ts +130 -124
  119. package/src/utils/errors.ts +11 -0
  120. package/src/utils/formatter.ts +22 -18
  121. package/src/utils/loading.ts +14 -6
  122. package/src/utils/mappers.ts +8 -6
  123. package/src/utils/multicall.ts +2 -0
  124. package/src/utils/network.ts +21 -21
  125. package/src/utils/repeater.ts +2 -2
  126. package/src/utils/validate.ts +1 -1
  127. package/lib/utils/events.d.ts +0 -2
  128. package/lib/utils/events.js +0 -13
  129. package/src/utils/events.ts +0 -10
package/.eslintignore ADDED
@@ -0,0 +1,5 @@
1
+ node_modules
2
+ lib
3
+ src/types
4
+ .eslintrc.js
5
+ *.d.ts
package/.eslintrc.js ADDED
@@ -0,0 +1,52 @@
1
+ module.exports = {
2
+ root: true,
3
+ parser: "@typescript-eslint/parser",
4
+ parserOptions: {
5
+ project: ["./tsconfig.json"],
6
+ tsconfigRootDir: __dirname
7
+ },
8
+ plugins: ["@typescript-eslint", "prettier"],
9
+ extends: [
10
+ "airbnb-base",
11
+ "airbnb-typescript/base",
12
+ "plugin:import/recommended",
13
+ "prettier"
14
+ ],
15
+ settings: {
16
+ "import/resolver": {
17
+ typescript: {},
18
+ node: {
19
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
20
+ moduleDirectory: ["node_modules", "./"]
21
+ }
22
+ },
23
+ react: {
24
+ version: "detect"
25
+ }
26
+ },
27
+ rules: {
28
+ "prettier/prettier": "error",
29
+ "import/no-extraneous-dependencies": ["error", { devDependencies: true }],
30
+ "@typescript-eslint/no-use-before-define": [
31
+ "error",
32
+ {
33
+ functions: false,
34
+ classes: false
35
+ }
36
+ ],
37
+ "no-console": ["error", { allow: ["warn", "error", "debug"] }],
38
+ "@typescript-eslint/default-param-last": ["warn"],
39
+
40
+ "no-nested-ternary": ["warn"],
41
+ "@typescript-eslint/no-unused-vars": ["warn"],
42
+ "no-underscore-dangle": ["error", { allowAfterThis: true }],
43
+
44
+ "react/no-unused-prop-types": ["off"], // switch on when necessary
45
+ "max-classes-per-file": ["off"],
46
+ "react/jsx-props-no-spreading": ["off"],
47
+ "react/no-array-index-key": ["off"],
48
+ "react/require-default-props": ["off"],
49
+ "import/prefer-default-export": ["off"],
50
+ "react/jsx-no-useless-fragment": ["off"]
51
+ }
52
+ };
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env sh
2
+ . "$(dirname -- "$0")/_/husky.sh"
3
+
4
+ yarn prepush
@@ -79,14 +79,12 @@ function getConvexApy(pool, provider, networkType, getTokenPrice) {
79
79
  basePoolAddress = contractsList[pool];
80
80
  swapPoolAddress = contractsList[curveSwapByPool[pool]];
81
81
  cvxAddress = tokenList.CVX;
82
- extraPoolAddresses = poolParams.extraRewards.map(function (d) {
83
- return d.poolAddress[networkType];
84
- });
82
+ extraPoolAddresses = poolParams.extraRewards.map(function (d) { return d.poolAddress[networkType]; });
85
83
  return [4 /*yield*/, getPoolData(basePoolAddress, swapPoolAddress, cvxAddress, extraPoolAddresses, provider)];
86
84
  case 1:
87
85
  _a = _b.sent(), basePoolRate = _a[0], basePoolSupply = _a[1], vPrice = _a[2], cvxSupply = _a[3], extra = _a.slice(4);
88
- cvxPrice = getTokenPrice(tokenList["CVX"]);
89
- crvPrice = getTokenPrice(tokenList["CRV"]);
86
+ cvxPrice = getTokenPrice(tokenList.CVX);
87
+ crvPrice = getTokenPrice(tokenList.CRV);
90
88
  crvPerSecond = basePoolRate;
91
89
  virtualSupply = basePoolSupply.mul(vPrice).div(constants_1.WAD);
92
90
  crvPerUnderlying = crvPerSecond.mul(constants_1.WAD).div(virtualSupply);
@@ -42,9 +42,8 @@ var contracts_1 = require("../contracts/contracts");
42
42
  var token_1 = require("../tokens/token");
43
43
  var constants_1 = require("../core/constants");
44
44
  var types_1 = require("../types");
45
- var lidoOracleAddress = contracts_1.contractParams.LIDO_STETH_GATEWAY
46
- .oracle;
47
- var lidoStEthAddress = {
45
+ var lidoOracles = contracts_1.contractParams.LIDO_STETH_GATEWAY.oracle;
46
+ var lidoStEth = {
48
47
  Mainnet: token_1.tokenDataByNetwork.Mainnet.STETH,
49
48
  Kovan: token_1.tokenDataByNetwork.Kovan.STETH
50
49
  };
@@ -54,13 +53,13 @@ function getLidoApy(provider, networkType) {
54
53
  return __generator(this, function (_c) {
55
54
  switch (_c.label) {
56
55
  case 0:
57
- if (!lidoOracleAddress[networkType]) {
58
- throw "No Lido APR oracle found on current network: ".concat(networkType);
56
+ if (!lidoOracles[networkType]) {
57
+ throw new Error("No Lido APR oracle found on current network: ".concat(networkType));
59
58
  }
60
- if (!lidoStEthAddress[networkType]) {
61
- throw "No Lido stETH found on current network: ".concat(networkType);
59
+ if (!lidoStEth[networkType]) {
60
+ throw new Error("No Lido stETH found on current network: ".concat(networkType));
62
61
  }
63
- return [4 /*yield*/, geLidoData(lidoOracleAddress[networkType], lidoStEthAddress[networkType], provider, networkType)];
62
+ return [4 /*yield*/, geLidoData(lidoOracles[networkType], lidoStEth[networkType], provider, networkType)];
64
63
  case 1:
65
64
  _a = _c.sent(), _b = _a[0], postTotalPooledEther = _b.postTotalPooledEther, preTotalPooledEther = _b.preTotalPooledEther, timeElapsed = _b.timeElapsed, fee = _a[1];
66
65
  lidoAPRRay = postTotalPooledEther
@@ -74,6 +73,7 @@ function getLidoApy(provider, networkType) {
74
73
  });
75
74
  }
76
75
  exports.getLidoApy = getLidoApy;
76
+ exports.LIDO_FEE_DECIMALS = 10000;
77
77
  function geLidoData(lidoOracleAddress, stETHAddress, provider, network) {
78
78
  return __awaiter(this, void 0, void 0, function () {
79
79
  var calls, _a, stats, _b, fee;
@@ -101,4 +101,3 @@ function geLidoData(lidoOracleAddress, stETHAddress, provider, network) {
101
101
  });
102
102
  });
103
103
  }
104
- exports.LIDO_FEE_DECIMALS = 10000;
@@ -1,8 +1,9 @@
1
+ import type { YearnLPToken } from "../tokens/yearn";
1
2
  import { AdapterInterface } from "./adapters";
2
3
  import { NetworkType } from "../core/constants";
3
4
  import { Protocols } from "./protocols";
4
5
  import { ConvexStakedPhantomToken } from "../tokens/convex";
5
- import { CurveLPToken } from "../tokens/curveLP";
6
+ import type { CurveLPToken } from "../tokens/curveLP";
6
7
  import { NormalToken } from "../tokens/normal";
7
8
  export declare type UniswapV2Contract = "UNISWAP_V2_ROUTER" | "SUSHISWAP_ROUTER";
8
9
  export declare type CurvePoolContract = "CURVE_3CRV_POOL" | "CURVE_STETH_GATEWAY" | "CURVE_FRAX_POOL" | "CURVE_LUSD_POOL" | "CURVE_GUSD_POOL" | "CURVE_SUSD_POOL" | "CURVE_SUSD_DEPOSIT";
@@ -34,11 +35,13 @@ export declare type CurveSteCRVPoolParams = {
34
35
  protocol: Protocols.Curve;
35
36
  type: AdapterInterface.CURVE_V1_STECRV_POOL;
36
37
  pool: Record<NetworkType, string>;
38
+ tokens: ["WETH", "STETH"];
37
39
  lpToken: "steCRV";
38
40
  } & BaseContractParams;
39
- declare type YearnParams = {
41
+ export declare type YearnParams = {
40
42
  protocol: Protocols.Yearn;
41
43
  type: AdapterInterface.YEARN_V2;
44
+ shareToken: YearnLPToken;
42
45
  } & BaseContractParams;
43
46
  declare type ConvexParams = {
44
47
  protocol: Protocols.Convex;
@@ -12,11 +12,6 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.contractsByAddress = exports.contractParams = exports.UNISWAP_V3_QUOTER = exports.contractsByNetwork = void 0;
15
- /*
16
- * SPDX-License-Identifier: BSL-1.1
17
- * Gearbox. Generalized leverage protocol, which allows to take leverage and then use it across other DeFi protocols and platforms in a composable way.
18
- * (c) Gearbox.fi, 2021
19
- */
20
15
  var mappers_1 = require("../utils/mappers");
21
16
  var adapters_1 = require("./adapters");
22
17
  var protocols_1 = require("./protocols");
@@ -123,6 +118,7 @@ exports.contractParams = {
123
118
  Mainnet: "0xDC24316b9AE028F1497c275EB9192a3Ea0f67022",
124
119
  Kovan: "0xF5C73b58B70709e89aA1D322d48b0D0C71123cB4"
125
120
  },
121
+ tokens: ["WETH", "STETH"],
126
122
  lpToken: "steCRV"
127
123
  },
128
124
  CURVE_FRAX_POOL: {
@@ -130,14 +126,14 @@ exports.contractParams = {
130
126
  protocol: protocols_1.Protocols.Curve,
131
127
  type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
132
128
  lpToken: "FRAX3CRV",
133
- tokens: ["3Crv", "FRAX"]
129
+ tokens: ["FRAX", "3Crv"]
134
130
  },
135
131
  CURVE_LUSD_POOL: {
136
132
  name: "Curve LUSD",
137
133
  protocol: protocols_1.Protocols.Curve,
138
134
  type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
139
135
  lpToken: "LUSD3CRV",
140
- tokens: ["3Crv", "LUSD"]
136
+ tokens: ["LUSD", "3Crv"]
141
137
  },
142
138
  CURVE_SUSD_POOL: {
143
139
  name: "Curve SUSD",
@@ -152,45 +148,50 @@ exports.contractParams = {
152
148
  protocol: protocols_1.Protocols.Curve,
153
149
  type: adapters_1.AdapterInterface.CURVE_V1_WRAPPER,
154
150
  lpToken: "crvPlain3andSUSD",
155
- tokens: ["DAI", "USDC", "USDT", "sUSD"],
156
- wrapper: "CURVE_SUSD_DEPOSIT"
151
+ tokens: ["DAI", "USDC", "USDT", "sUSD"]
157
152
  },
158
153
  CURVE_GUSD_POOL: {
159
154
  name: "Curve GUSD",
160
155
  protocol: protocols_1.Protocols.Curve,
161
156
  type: adapters_1.AdapterInterface.CURVE_V1_2ASSETS,
162
157
  lpToken: "gusd3CRV",
163
- tokens: ["3Crv", "FRAX"]
158
+ tokens: ["GUSD", "3Crv"]
164
159
  },
165
160
  YEARN_DAI_VAULT: {
166
161
  name: "Yearn DAI",
167
162
  protocol: protocols_1.Protocols.Yearn,
168
- type: adapters_1.AdapterInterface.YEARN_V2
163
+ type: adapters_1.AdapterInterface.YEARN_V2,
164
+ shareToken: "yvDAI"
169
165
  },
170
166
  YEARN_USDC_VAULT: {
171
167
  name: "Yearn USDC",
172
168
  protocol: protocols_1.Protocols.Yearn,
173
- type: adapters_1.AdapterInterface.YEARN_V2
169
+ type: adapters_1.AdapterInterface.YEARN_V2,
170
+ shareToken: "yvUSDC"
174
171
  },
175
172
  YEARN_WETH_VAULT: {
176
173
  name: "Yearn WETH",
177
174
  protocol: protocols_1.Protocols.Yearn,
178
- type: adapters_1.AdapterInterface.YEARN_V2
175
+ type: adapters_1.AdapterInterface.YEARN_V2,
176
+ shareToken: "yvWETH"
179
177
  },
180
178
  YEARN_WBTC_VAULT: {
181
179
  name: "Yearn WBTC",
182
180
  protocol: protocols_1.Protocols.Yearn,
183
- type: adapters_1.AdapterInterface.YEARN_V2
181
+ type: adapters_1.AdapterInterface.YEARN_V2,
182
+ shareToken: "yvWBTC"
184
183
  },
185
184
  YEARN_CURVE_FRAX_VAULT: {
186
185
  name: "Yearn Curve FRAX",
187
186
  protocol: protocols_1.Protocols.Yearn,
188
- type: adapters_1.AdapterInterface.YEARN_V2
187
+ type: adapters_1.AdapterInterface.YEARN_V2,
188
+ shareToken: "yvCurve_FRAX"
189
189
  },
190
190
  YEARN_CURVE_STETH_VAULT: {
191
191
  name: "Yearn Curve STETH",
192
192
  protocol: protocols_1.Protocols.Yearn,
193
- type: adapters_1.AdapterInterface.YEARN_V2
193
+ type: adapters_1.AdapterInterface.YEARN_V2,
194
+ shareToken: "yvCurve_stETH"
194
195
  },
195
196
  CONVEX_BOOSTER: {
196
197
  name: "Convex BOOSTER",
@@ -288,6 +289,6 @@ exports.contractParams = {
288
289
  }
289
290
  };
290
291
  exports.contractsByAddress = (0, mappers_1.objectEntries)(exports.contractsByNetwork).reduce(function (acc, _a) {
291
- var _ = _a[0], contracts = _a[1];
292
- return __assign(__assign({}, acc), (0, mappers_1.filterEmptyKeys)((0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(contracts))));
292
+ var contracts = _a[1];
293
+ return (__assign(__assign({}, acc), (0, mappers_1.filterEmptyKeys)((0, mappers_1.keyToLowercase)((0, mappers_1.swapKeyValue)(contracts)))));
293
294
  }, {});
@@ -20,4 +20,4 @@ export declare const UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = 9300;
20
20
  export declare const timeRanges: Record<string, number>;
21
21
  export declare const LEVERAGE_DECIMALS = 100;
22
22
  export declare const SLIPPAGE_DECIMALS = 100;
23
- export declare const ADDRESS_0x0 = "0x0000000000000000000000000000000000000000";
23
+ export declare const ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ADDRESS_0x0 = exports.SLIPPAGE_DECIMALS = exports.LEVERAGE_DECIMALS = exports.timeRanges = exports.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = exports.LIQUIDATION_DISCOUNTED_SUM = exports.PERCENTAGE_FACTOR = exports.PERCENTAGE_DECIMALS = exports.SECONDS_PER_YEAR = exports.PRICE_DECIMALS = exports.PRICE_DECIMALS_POW = exports.WAD = exports.WAD_DECIMALS_POW = exports.halfRAY = exports.RAY = exports.RAY_DECIMALS_POW = exports.getNetworkType = exports.LOCAL_NETWORK = exports.KOVAN_NETWORK = exports.MAINNET_NETWORK = exports.MAX_INT = void 0;
3
+ exports.ADDRESS_0X0 = exports.SLIPPAGE_DECIMALS = exports.LEVERAGE_DECIMALS = exports.timeRanges = exports.UNDERLYING_TOKEN_LIQUIDATION_THRESHOLD = exports.LIQUIDATION_DISCOUNTED_SUM = exports.PERCENTAGE_FACTOR = exports.PERCENTAGE_DECIMALS = exports.SECONDS_PER_YEAR = exports.PRICE_DECIMALS = exports.PRICE_DECIMALS_POW = exports.WAD = exports.WAD_DECIMALS_POW = exports.halfRAY = exports.RAY = exports.RAY_DECIMALS_POW = exports.getNetworkType = exports.LOCAL_NETWORK = exports.KOVAN_NETWORK = exports.MAINNET_NETWORK = exports.MAX_INT = void 0;
4
4
  var ethers_1 = require("ethers");
5
5
  exports.MAX_INT = ethers_1.BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
6
6
  exports.MAINNET_NETWORK = 1;
@@ -39,4 +39,4 @@ exports.timeRanges = {
39
39
  };
40
40
  exports.LEVERAGE_DECIMALS = 100;
41
41
  exports.SLIPPAGE_DECIMALS = 100;
42
- exports.ADDRESS_0x0 = "0x0000000000000000000000000000000000000000";
42
+ exports.ADDRESS_0X0 = "0x0000000000000000000000000000000000000000";
@@ -74,11 +74,13 @@ function sortBalances(balances, prices, tokens) {
74
74
  var price2 = prices[addr2Lc] || constants_1.PRICE_DECIMALS;
75
75
  var totalPrice1 = (0, price_1.calcTotalPrice)(price1, amount1, token1 === null || token1 === void 0 ? void 0 : token1.decimals);
76
76
  var totalPrice2 = (0, price_1.calcTotalPrice)(price2, amount2, token2 === null || token2 === void 0 ? void 0 : token2.decimals);
77
- return totalPrice1.eq(totalPrice2)
78
- ? tokensAbcComparator(token1, token2)
79
- : totalPrice1.gt(totalPrice2)
80
- ? -1
81
- : 1;
77
+ if (totalPrice1.eq(totalPrice2)) {
78
+ return tokensAbcComparator(token1, token2);
79
+ }
80
+ if (totalPrice1.gt(totalPrice2)) {
81
+ return -1;
82
+ }
83
+ return 1;
82
84
  });
83
85
  }
84
86
  exports.sortBalances = sortBalances;
@@ -22,8 +22,8 @@ export declare class CreditManagerData {
22
22
  readonly degenNFT: string;
23
23
  readonly isIncreaseDebtForbidden: boolean;
24
24
  readonly forbiddenTokenMask: BigNumber;
25
+ readonly isPaused: boolean;
25
26
  constructor(payload: CreditManagerDataPayload);
26
- get isPaused(): boolean;
27
27
  getContractETH(signer: Signer | ethers.providers.Provider): ICreditManager;
28
28
  contractToAdapter(contractAddress: string): string | undefined;
29
29
  encodeAddCollateral(accountAddress: string, tokenAddress: string, amount: BigNumber): MultiCall;
@@ -33,6 +33,7 @@ var constants_1 = require("./constants");
33
33
  var errors_1 = require("./errors");
34
34
  var CreditManagerData = /** @class */ (function () {
35
35
  function CreditManagerData(payload) {
36
+ this.isPaused = false;
36
37
  this.id = payload.addr;
37
38
  this.address = payload.addr;
38
39
  this.underlyingToken = payload.underlying || "";
@@ -67,13 +68,6 @@ var CreditManagerData = /** @class */ (function () {
67
68
  this.isIncreaseDebtForbidden = payload.isIncreaseDebtForbidden || false;
68
69
  this.forbiddenTokenMask = ethers_1.BigNumber.from(payload.forbiddenTokenMask || 0);
69
70
  }
70
- Object.defineProperty(CreditManagerData.prototype, "isPaused", {
71
- get: function () {
72
- return false;
73
- },
74
- enumerable: false,
75
- configurable: true
76
- });
77
71
  CreditManagerData.prototype.getContractETH = function (signer) {
78
72
  return types_1.ICreditManager__factory.connect(this.address, signer);
79
73
  };
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -11,7 +22,7 @@ var statusEnum = [
11
22
  "active",
12
23
  "closed",
13
24
  "repaid",
14
- "liquidated",
25
+ "liquidated"
15
26
  ];
16
27
  var CreditSession = /** @class */ (function () {
17
28
  function CreditSession(payload) {
@@ -33,8 +44,8 @@ var CreditSession = /** @class */ (function () {
33
44
  ethers_1.BigNumber.from(payload.healthFactor || 0).toNumber() / constants_1.PERCENTAGE_FACTOR;
34
45
  this.score = payload.score;
35
46
  this.operations = (payload.operations || []).map(function (op) {
36
- op.date = (0, moment_1.default)(op.timestamp * 1000).format("Do MMM YYYY");
37
- return op;
47
+ var formattedOp = __assign(__assign({}, op), { date: (0, moment_1.default)(op.timestamp * 1000).format("Do MMM YYYY") });
48
+ return formattedOp;
38
49
  });
39
50
  this.sinceDate = (0, moment_1.default)(payload.sinceTimestamp * 1000).format("Do MMM YYYY");
40
51
  this.closedAtDate = (0, moment_1.default)(payload.closedAtTimestamp * 1000).format("Do MMM YYYY");
@@ -1,5 +1,5 @@
1
1
  import { TokenData } from "../tokens/tokenData";
2
- import { TxSerialized } from "./transactions";
2
+ import type { TxSerialized } from "./transactions";
3
3
  export interface Display {
4
4
  toString(tokenData: Record<string, TokenData>): string;
5
5
  }
@@ -1,5 +1,5 @@
1
- import { TokenData } from "../tokens/tokenData";
2
1
  import { BigNumber } from "ethers";
2
+ import { TokenData } from "../tokens/tokenData";
3
3
  import { EVMEvent, EVMTx, EVMEventProps } from "./eventOrTx";
4
4
  export interface EventSerialized {
5
5
  type: "EventAddLiquidity" | "EventRemoveLiquidity" | "EventOpenCreditAccount" | "EventCloseCreditAccount" | "EventLiquidateCreditAccount" | "EventRepayCreditAccount" | "EventAddCollateral" | "EventIncreaseBorrowAmount" | "EventCMNewParameters" | "EventTokenAllowed" | "EventTokenForbidden" | "EventContractAllowed" | "EventContractForbidden" | "EventNewFastCheckParameters" | "EventPriceOracleUpdated" | "EventTransferPluginAllowed" | "EventNewInterestRateModel" | "EventNewCreditManagerConnected" | "EventBorrowForbidden" | "EventNewExpectedLiquidityLimit" | "EventNewWithdrawFee" | "EventNewPriceFeed" | "EventTakeForever" | "EventPaused" | "EventUnPaused" | "EventPausableAdminAdded" | "EventPausableAdminRemoved" | "EventUnpausableAdminAdded" | "EventUnpausableAdminRemoved" | "EventOwnershipTransferred";
@@ -82,7 +82,7 @@ export declare class EventRepayCreditAccount extends EVMEvent {
82
82
  readonly underlyingToken: string;
83
83
  readonly creditManager: string;
84
84
  constructor(opts: RepayCreditAccountProps);
85
- toString(_: Record<string, TokenData>): string;
85
+ toString(): string;
86
86
  }
87
87
  interface AddCollateralProps extends EVMEventProps {
88
88
  amount: string;
@@ -182,7 +182,7 @@ export declare class EventContractAllowed extends EVMEvent {
182
182
  readonly adapter: string;
183
183
  readonly status: EventContractAllowedStatus;
184
184
  constructor(opts: ContractAllowedProps);
185
- toString(_: Record<string, TokenData>): string;
185
+ toString(): string;
186
186
  }
187
187
  interface ContractForbiddenProps extends EVMEventProps {
188
188
  creditManager: string;
@@ -192,7 +192,7 @@ export declare class EventContractForbidden extends EVMEvent {
192
192
  readonly creditManager: string;
193
193
  readonly protocol: string;
194
194
  constructor(opts: ContractForbiddenProps);
195
- toString(_: Record<string, TokenData>): string;
195
+ toString(): string;
196
196
  }
197
197
  interface NewFastCheckParametersProps extends EVMEventProps {
198
198
  creditManager: string;
@@ -208,7 +208,7 @@ export declare class EventNewFastCheckParameters extends EVMEvent {
208
208
  readonly prevChiThreshold?: number;
209
209
  readonly prevFastCheckDelay?: number;
210
210
  constructor(opts: NewFastCheckParametersProps);
211
- toString(_: Record<string, TokenData>): string;
211
+ toString(): string;
212
212
  }
213
213
  interface PriceOracleUpdatedProps extends EVMEventProps {
214
214
  creditManager: string;
@@ -218,7 +218,7 @@ export declare class EventPriceOracleUpdated extends EVMEvent {
218
218
  readonly creditManager: string;
219
219
  readonly priceOracle: string;
220
220
  constructor(opts: PriceOracleUpdatedProps);
221
- toString(_: Record<string, TokenData>): string;
221
+ toString(): string;
222
222
  }
223
223
  interface TransferPluginAllowedProps extends EVMEventProps {
224
224
  creditManager: string;
@@ -230,7 +230,7 @@ export declare class EventTransferPluginAllowed extends EVMEvent {
230
230
  readonly plugin: string;
231
231
  readonly state: boolean;
232
232
  constructor(opts: TransferPluginAllowedProps);
233
- toString(_: Record<string, TokenData>): string;
233
+ toString(): string;
234
234
  }
235
235
  interface NewInterestRateModelProps extends EVMEventProps {
236
236
  pool: string;
@@ -240,7 +240,7 @@ export declare class EventNewInterestRateModel extends EVMEvent {
240
240
  readonly pool: string;
241
241
  readonly newInterestRateModel: string;
242
242
  constructor(opts: NewInterestRateModelProps);
243
- toString(_: Record<string, TokenData>): string;
243
+ toString(): string;
244
244
  }
245
245
  interface NewCreditManagerConnectedProps extends EVMEventProps {
246
246
  pool: string;
@@ -250,7 +250,7 @@ export declare class EventNewCreditManagerConnected extends EVMEvent {
250
250
  readonly pool: string;
251
251
  readonly creditManager: string;
252
252
  constructor(opts: NewCreditManagerConnectedProps);
253
- toString(_: Record<string, TokenData>): string;
253
+ toString(): string;
254
254
  }
255
255
  interface BorrowForbiddenProps extends EVMEventProps {
256
256
  pool: string;
@@ -260,7 +260,7 @@ export declare class EventBorrowForbidden extends EVMEvent {
260
260
  readonly pool: string;
261
261
  readonly creditManager: string;
262
262
  constructor(opts: BorrowForbiddenProps);
263
- toString(_: Record<string, TokenData>): string;
263
+ toString(): string;
264
264
  }
265
265
  interface NewExpectedLiquidityLimitProps extends EVMEventProps {
266
266
  pool: string;
@@ -288,7 +288,7 @@ export declare class EventNewWithdrawFee extends EVMEvent {
288
288
  readonly newFee: number;
289
289
  readonly prevFee: number;
290
290
  constructor(opts: NewWithdrawFeeProps);
291
- toString(_: Record<string, TokenData>): string;
291
+ toString(): string;
292
292
  }
293
293
  interface NewPriceFeedProps extends EVMEventProps {
294
294
  token: string;
@@ -308,7 +308,7 @@ export declare class EventTakeForever extends EVMEvent {
308
308
  readonly creditAccount: string;
309
309
  readonly to: string;
310
310
  constructor(opts: TakeForeverProps);
311
- toString(_: Record<string, TokenData>): string;
311
+ toString(): string;
312
312
  }
313
313
  interface PausedProps extends EVMEventProps {
314
314
  contract: string;
@@ -316,7 +316,7 @@ interface PausedProps extends EVMEventProps {
316
316
  export declare class EventPaused extends EVMEvent {
317
317
  readonly contract: string;
318
318
  constructor(opts: PausedProps);
319
- toString(_: Record<string, TokenData>): string;
319
+ toString(): string;
320
320
  }
321
321
  interface UnPausedProps extends EVMEventProps {
322
322
  contract: string;
@@ -324,7 +324,7 @@ interface UnPausedProps extends EVMEventProps {
324
324
  export declare class EventUnPaused extends EVMEvent {
325
325
  readonly contract: string;
326
326
  constructor(opts: UnPausedProps);
327
- toString(_: Record<string, TokenData>): string;
327
+ toString(): string;
328
328
  }
329
329
  interface PausableAdminAddedProps extends EVMEventProps {
330
330
  admin: string;
@@ -332,7 +332,7 @@ interface PausableAdminAddedProps extends EVMEventProps {
332
332
  export declare class EventPausableAdminAdded extends EVMEvent {
333
333
  readonly admin: string;
334
334
  constructor(opts: PausableAdminAddedProps);
335
- toString(_: Record<string, TokenData>): string;
335
+ toString(): string;
336
336
  }
337
337
  interface PausableAdminRemovedProps extends EVMEventProps {
338
338
  admin: string;
@@ -340,7 +340,7 @@ interface PausableAdminRemovedProps extends EVMEventProps {
340
340
  export declare class EventPausableAdminRemoved extends EVMEvent {
341
341
  readonly admin: string;
342
342
  constructor(opts: PausableAdminRemovedProps);
343
- toString(_: Record<string, TokenData>): string;
343
+ toString(): string;
344
344
  }
345
345
  interface UnPausableAdminAddedProps extends EVMEventProps {
346
346
  admin: string;
@@ -348,7 +348,7 @@ interface UnPausableAdminAddedProps extends EVMEventProps {
348
348
  export declare class EventUnPausableAdminAdded extends EVMEvent {
349
349
  readonly admin: string;
350
350
  constructor(opts: UnPausableAdminAddedProps);
351
- toString(_: Record<string, TokenData>): string;
351
+ toString(): string;
352
352
  }
353
353
  interface UnPausableAdminRemovedProps extends EVMEventProps {
354
354
  admin: string;
@@ -356,7 +356,7 @@ interface UnPausableAdminRemovedProps extends EVMEventProps {
356
356
  export declare class EventUnPausableAdminRemoved extends EVMEvent {
357
357
  readonly admin: string;
358
358
  constructor(opts: UnPausableAdminRemovedProps);
359
- toString(_: Record<string, TokenData>): string;
359
+ toString(): string;
360
360
  }
361
361
  interface TransferOwnershipProps extends EVMEventProps {
362
362
  admin: string;
@@ -364,6 +364,6 @@ interface TransferOwnershipProps extends EVMEventProps {
364
364
  export declare class EventTransferOwnership extends EVMEvent {
365
365
  readonly newOwner: string;
366
366
  constructor(opts: TransferOwnershipProps);
367
- toString(_: Record<string, TokenData>): string;
367
+ toString(): string;
368
368
  }
369
369
  export {};