@gearbox-protocol/sdk 1.3.3 → 1.5.0

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 (153) hide show
  1. package/lib/apy/index.d.ts +1 -0
  2. package/lib/core/adapter.d.ts +34 -0
  3. package/lib/core/adapter.js +76 -0
  4. package/lib/core/assets.d.ts +34 -0
  5. package/lib/core/assets.js +98 -0
  6. package/lib/core/constants.d.ts +1 -0
  7. package/lib/core/constants.js +3 -1
  8. package/lib/core/creditAccount.d.ts +14 -5
  9. package/lib/core/creditAccount.js +35 -3
  10. package/lib/core/creditManager.d.ts +12 -3
  11. package/lib/core/creditManager.js +34 -36
  12. package/lib/core/strategy.d.ts +15 -5
  13. package/lib/core/strategy.js +42 -7
  14. package/lib/core/trade.d.ts +49 -0
  15. package/lib/core/trade.js +70 -0
  16. package/lib/core/wcOperation.d.ts +54 -0
  17. package/lib/core/wcOperation.js +76 -0
  18. package/lib/index.d.ts +6 -0
  19. package/lib/index.js +6 -0
  20. package/lib/parsers/abstractParser.d.ts +18 -0
  21. package/lib/parsers/abstractParser.js +32 -0
  22. package/lib/parsers/convexBaseRewardPoolAdapterParser.d.ts +9 -0
  23. package/lib/parsers/convexBaseRewardPoolAdapterParser.js +60 -0
  24. package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.d.ts +1 -0
  25. package/lib/parsers/convexBaseRewardPoolAdapterParser.spec.js +24 -0
  26. package/lib/parsers/convexBoosterAdapterParser.d.ts +10 -0
  27. package/lib/parsers/convexBoosterAdapterParser.js +62 -0
  28. package/lib/parsers/convexBoosterAdapterParser.spec.d.ts +1 -0
  29. package/lib/parsers/convexBoosterAdapterParser.spec.js +20 -0
  30. package/lib/parsers/creditFacadeParser.d.ts +9 -0
  31. package/lib/parsers/creditFacadeParser.js +66 -0
  32. package/lib/parsers/creditFacadeParser.spec.d.ts +1 -0
  33. package/lib/parsers/creditFacadeParser.spec.js +27 -0
  34. package/lib/parsers/curveAdapterParser.d.ts +12 -0
  35. package/lib/parsers/curveAdapterParser.js +106 -0
  36. package/lib/parsers/curveAdapterParser.spec.d.ts +1 -0
  37. package/lib/parsers/curveAdapterParser.spec.js +49 -0
  38. package/lib/parsers/iParser.d.ts +3 -0
  39. package/lib/{types/contracts/test/suites/mainnet/IPriceFeedsRegistry.js → parsers/iParser.js} +0 -0
  40. package/lib/parsers/lidoAdapterParser.d.ts +7 -0
  41. package/lib/parsers/lidoAdapterParser.js +46 -0
  42. package/lib/parsers/lidoAdapterParser.spec.d.ts +1 -0
  43. package/lib/parsers/lidoAdapterParser.spec.js +17 -0
  44. package/lib/parsers/txParser.d.ts +18 -0
  45. package/lib/parsers/txParser.js +122 -0
  46. package/lib/parsers/uniV2AdapterParser.d.ts +8 -0
  47. package/lib/parsers/uniV2AdapterParser.js +73 -0
  48. package/lib/parsers/uniV2AdapterParser.spec.d.ts +1 -0
  49. package/lib/parsers/uniV2AdapterParser.spec.js +48 -0
  50. package/lib/parsers/uniV3AdapterParser.d.ts +9 -0
  51. package/lib/parsers/uniV3AdapterParser.js +99 -0
  52. package/lib/parsers/uniV3AdapterParser.spec.d.ts +1 -0
  53. package/lib/parsers/uniV3AdapterParser.spec.js +82 -0
  54. package/lib/parsers/yearnAdapterParser.spec.d.ts +1 -0
  55. package/lib/parsers/yearnAdapterParser.spec.js +36 -0
  56. package/lib/parsers/yearnV2AdapterParser.d.ts +7 -0
  57. package/lib/parsers/yearnV2AdapterParser.js +54 -0
  58. package/lib/tokens/convex.d.ts +4 -2
  59. package/lib/tokens/convex.js +10 -1
  60. package/lib/tokens/decimals.d.ts +2 -0
  61. package/lib/tokens/decimals.js +62 -0
  62. package/lib/tokens/tokenType.d.ts +10 -9
  63. package/lib/tokens/tokenType.js +10 -9
  64. package/lib/types/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended.d.ts +66 -2
  65. package/lib/types/contracts/interfaces/adapters/curve/ICurveV1_2AssetsAdapter.d.ts +620 -0
  66. package/lib/types/contracts/interfaces/adapters/curve/ICurveV1_2AssetsAdapter.js +2 -0
  67. package/lib/types/contracts/interfaces/adapters/curve/ICurveV1_3AssetsAdapter.d.ts +622 -0
  68. package/lib/types/contracts/interfaces/adapters/curve/ICurveV1_3AssetsAdapter.js +2 -0
  69. package/lib/types/contracts/interfaces/adapters/curve/ICurveV1_4AssetsAdapter.d.ts +648 -0
  70. package/lib/types/contracts/interfaces/adapters/curve/ICurveV1_4AssetsAdapter.js +2 -0
  71. package/lib/types/contracts/interfaces/adapters/curve/index.d.ts +3 -0
  72. package/lib/types/contracts/interfaces/adapters/index.d.ts +2 -0
  73. package/lib/types/contracts/interfaces/adapters/yearn/IYearnV2Adapter.d.ts +330 -0
  74. package/lib/types/contracts/interfaces/adapters/yearn/IYearnV2Adapter.js +2 -0
  75. package/lib/types/contracts/interfaces/adapters/yearn/index.d.ts +1 -0
  76. package/lib/types/contracts/interfaces/adapters/yearn/index.js +2 -0
  77. package/lib/types/contracts/pathfinder/interfaces/IClosePathResolver.d.ts +28 -7
  78. package/lib/types/contracts/pathfinder/interfaces/IDepositor.sol/IDepositor.d.ts +30 -9
  79. package/lib/types/contracts/pathfinder/interfaces/IDepositor.sol/IDepositorOptions.d.ts +31 -10
  80. package/lib/types/contracts/pathfinder/interfaces/ILPWorker.sol/ILPWorker.d.ts +28 -7
  81. package/lib/types/contracts/pathfinder/interfaces/ILPWorker.sol/ILPWorkerOptions.d.ts +28 -7
  82. package/lib/types/contracts/pathfinder/interfaces/IPathFinder.d.ts +24 -0
  83. package/lib/types/contracts/pathfinder/interfaces/IPathFinderComponent.d.ts +50 -0
  84. package/lib/types/contracts/pathfinder/interfaces/IPathFinderComponent.js +2 -0
  85. package/lib/types/contracts/pathfinder/interfaces/IPathResolver.d.ts +29 -8
  86. package/lib/types/contracts/pathfinder/interfaces/ISwapAggregator.d.ts +99 -15
  87. package/lib/types/contracts/pathfinder/interfaces/ISwapper.d.ts +17 -1
  88. package/lib/types/contracts/pathfinder/interfaces/IWithdrawer.sol/IWithdrawer.d.ts +53 -9
  89. package/lib/types/contracts/pathfinder/interfaces/IWithdrawer.sol/IWithdrawerOptions.d.ts +53 -9
  90. package/lib/types/contracts/pathfinder/interfaces/index.d.ts +1 -0
  91. package/lib/types/contracts/test/suites/mainnet/ITokenTestSuite.d.ts +110 -18
  92. package/lib/types/contracts/test/suites/mainnet/SupportedContracts.sol/ISupportedContracts.d.ts +50 -0
  93. package/lib/types/contracts/test/suites/mainnet/SupportedContracts.sol/ISupportedContracts.js +2 -0
  94. package/lib/types/contracts/test/suites/mainnet/SupportedContracts.sol/index.d.ts +1 -0
  95. package/lib/types/contracts/test/suites/mainnet/SupportedContracts.sol/index.js +2 -0
  96. package/lib/types/contracts/test/suites/mainnet/Tokens.sol/IToken.d.ts +60 -0
  97. package/lib/types/contracts/test/suites/mainnet/Tokens.sol/IToken.js +2 -0
  98. package/lib/types/contracts/test/suites/mainnet/Tokens.sol/index.d.ts +1 -0
  99. package/lib/types/contracts/test/suites/mainnet/Tokens.sol/index.js +2 -0
  100. package/lib/types/contracts/test/suites/mainnet/index.d.ts +4 -1
  101. package/lib/types/factories/contracts/interfaces/ICreditFacade.sol/ICreditFacadeExtended__factory.js +62 -0
  102. package/lib/types/factories/contracts/{test/suites/mainnet/IPriceFeedsRegistry__factory.d.ts → interfaces/adapters/curve/ICurveV1_2AssetsAdapter__factory.d.ts} +4 -4
  103. package/lib/types/factories/contracts/interfaces/adapters/curve/ICurveV1_2AssetsAdapter__factory.js +1066 -0
  104. package/lib/types/factories/contracts/interfaces/adapters/curve/ICurveV1_3AssetsAdapter__factory.d.ts +32 -0
  105. package/lib/types/factories/contracts/interfaces/adapters/curve/ICurveV1_3AssetsAdapter__factory.js +1066 -0
  106. package/lib/types/factories/contracts/interfaces/adapters/curve/ICurveV1_4AssetsAdapter__factory.d.ts +32 -0
  107. package/lib/types/factories/contracts/interfaces/adapters/curve/ICurveV1_4AssetsAdapter__factory.js +1066 -0
  108. package/lib/types/factories/contracts/interfaces/adapters/curve/index.d.ts +3 -0
  109. package/lib/types/factories/contracts/interfaces/adapters/curve/index.js +7 -1
  110. package/lib/types/factories/contracts/interfaces/adapters/index.d.ts +1 -0
  111. package/lib/types/factories/contracts/interfaces/adapters/index.js +2 -1
  112. package/lib/types/factories/contracts/interfaces/adapters/yearn/IYearnV2Adapter__factory.d.ts +46 -0
  113. package/lib/types/factories/contracts/interfaces/adapters/yearn/IYearnV2Adapter__factory.js +487 -0
  114. package/lib/types/factories/contracts/interfaces/adapters/yearn/index.d.ts +1 -0
  115. package/lib/types/factories/contracts/interfaces/adapters/yearn/index.js +8 -0
  116. package/lib/types/factories/contracts/pathfinder/interfaces/IClosePathResolver__factory.d.ts +12 -2
  117. package/lib/types/factories/contracts/pathfinder/interfaces/IClosePathResolver__factory.js +54 -8
  118. package/lib/types/factories/contracts/pathfinder/interfaces/IDepositor.sol/IDepositorOptions__factory.js +138 -32
  119. package/lib/types/factories/contracts/pathfinder/interfaces/IDepositor.sol/IDepositor__factory.js +110 -24
  120. package/lib/types/factories/contracts/pathfinder/interfaces/ILPWorker.sol/ILPWorkerOptions__factory.js +54 -8
  121. package/lib/types/factories/contracts/pathfinder/interfaces/ILPWorker.sol/ILPWorker__factory.js +54 -8
  122. package/lib/types/factories/contracts/pathfinder/interfaces/IPathFinderComponent__factory.d.ts +18 -0
  123. package/lib/types/factories/contracts/pathfinder/interfaces/IPathFinderComponent__factory.js +48 -0
  124. package/lib/types/factories/contracts/pathfinder/interfaces/IPathFinder__factory.js +32 -0
  125. package/lib/types/factories/contracts/pathfinder/interfaces/IPathResolver__factory.d.ts +12 -2
  126. package/lib/types/factories/contracts/pathfinder/interfaces/IPathResolver__factory.js +82 -16
  127. package/lib/types/factories/contracts/pathfinder/interfaces/ISwapAggregator__factory.js +877 -56
  128. package/lib/types/factories/contracts/pathfinder/interfaces/ISwapper__factory.d.ts +12 -2
  129. package/lib/types/factories/contracts/pathfinder/interfaces/ISwapper__factory.js +26 -0
  130. package/lib/types/factories/contracts/pathfinder/interfaces/IWithdrawer.sol/IWithdrawerOptions__factory.js +365 -24
  131. package/lib/types/factories/contracts/pathfinder/interfaces/IWithdrawer.sol/IWithdrawer__factory.js +355 -24
  132. package/lib/types/factories/contracts/pathfinder/interfaces/index.d.ts +1 -0
  133. package/lib/types/factories/contracts/pathfinder/interfaces/index.js +3 -1
  134. package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.d.ts +1 -1
  135. package/lib/types/factories/contracts/support/MultiCall.sol/Multicall2__factory.js +1 -1
  136. package/lib/types/factories/contracts/test/suites/mainnet/ITokenTestSuite__factory.d.ts +2 -12
  137. package/lib/types/factories/contracts/test/suites/mainnet/ITokenTestSuite__factory.js +140 -12
  138. package/lib/types/factories/contracts/test/suites/mainnet/SupportedContracts.sol/ISupportedContracts__factory.d.ts +22 -0
  139. package/lib/types/factories/contracts/test/suites/mainnet/{IPriceFeedsRegistry__factory.js → SupportedContracts.sol/ISupportedContracts__factory.js} +25 -17
  140. package/lib/types/factories/contracts/test/suites/mainnet/SupportedContracts.sol/index.d.ts +1 -0
  141. package/lib/types/factories/contracts/test/suites/mainnet/SupportedContracts.sol/index.js +8 -0
  142. package/lib/types/factories/contracts/test/suites/mainnet/Tokens.sol/IToken__factory.d.ts +22 -0
  143. package/lib/types/factories/contracts/test/suites/mainnet/Tokens.sol/IToken__factory.js +79 -0
  144. package/lib/types/factories/contracts/test/suites/mainnet/Tokens.sol/index.d.ts +1 -0
  145. package/lib/types/factories/contracts/test/suites/mainnet/Tokens.sol/index.js +8 -0
  146. package/lib/types/factories/contracts/test/suites/mainnet/index.d.ts +2 -1
  147. package/lib/types/factories/contracts/test/suites/mainnet/index.js +26 -3
  148. package/lib/types/index.d.ts +14 -2
  149. package/lib/types/index.js +17 -5
  150. package/lib/utils/math.d.ts +1 -0
  151. package/lib/utils/math.js +5 -1
  152. package/package.json +6 -2
  153. package/lib/types/contracts/test/suites/mainnet/IPriceFeedsRegistry.d.ts +0 -42
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var solidity_1 = require("@ethersproject/solidity");
4
+ var chai_1 = require("chai");
5
+ var ethers_1 = require("ethers");
6
+ var constants_1 = require("../core/constants");
7
+ var token_1 = require("../tokens/token");
8
+ var types_1 = require("../types");
9
+ var uniV3AdapterParser_1 = require("./uniV3AdapterParser");
10
+ var pathToUniV3Path = function (path) {
11
+ var pathWithFees = [];
12
+ var types = [];
13
+ path.forEach(function (p, num) {
14
+ pathWithFees.push(p);
15
+ types.push("address");
16
+ if (num !== path.length - 1) {
17
+ pathWithFees.push(3000);
18
+ types.push("uint24");
19
+ }
20
+ });
21
+ return (0, solidity_1.pack)(types, pathWithFees);
22
+ };
23
+ describe("UniswapV3AdapterParser test", function () {
24
+ it("swap functions works well", function () {
25
+ var parser = new uniV3AdapterParser_1.UniswapV3AdapterParser("UNISWAP_V3_ROUTER", false);
26
+ var ifc = types_1.IUniswapV3Adapter__factory.createInterface();
27
+ var parsed = parser.parse(ifc.encodeFunctionData("exactInputSingle", [
28
+ {
29
+ tokenIn: token_1.tokenDataByNetwork.Goerli["1INCH"],
30
+ tokenOut: token_1.tokenDataByNetwork.Goerli["3Crv"],
31
+ fee: 3000,
32
+ recipient: constants_1.DUMB_ADDRESS,
33
+ deadline: 12300,
34
+ amountIn: constants_1.WAD.mul(1299000),
35
+ amountOutMinimum: constants_1.WAD.mul(10200),
36
+ sqrtPriceLimitX96: 0,
37
+ },
38
+ ]));
39
+ (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactInputSingle(amountIn: 1.29M [1299000000000000000000000], amountOutMinimum: 10.20K [10200000000000000000000], path: 1INCH ==(fee: 3000)==> 3Crv)", "Incorrect parse swapExactTokensForTokens");
40
+ parsed = parser.parse(ifc.encodeFunctionData("exactInput", [
41
+ {
42
+ path: pathToUniV3Path([
43
+ token_1.tokenDataByNetwork.Mainnet.AAVE,
44
+ token_1.tokenDataByNetwork.Mainnet.LINK,
45
+ token_1.tokenDataByNetwork.Mainnet.USDC,
46
+ ]),
47
+ recipient: constants_1.DUMB_ADDRESS,
48
+ deadline: 1232131,
49
+ amountIn: constants_1.WAD.mul(12399),
50
+ amountOutMinimum: ethers_1.BigNumber.from(1e6).mul(122),
51
+ },
52
+ ]));
53
+ (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactInput(amountIn: 12.39K [12399000000000000000000], amountOutMinimum: 122.00 [122000000], path: AAVE ==(fee: 3000)==> LINK ==(fee: 3000)==> USDC", "Incorrect parse swapExactTokensForTokens");
54
+ parsed = parser.parse(ifc.encodeFunctionData("exactOutputSingle", [
55
+ {
56
+ tokenIn: token_1.tokenDataByNetwork.Goerli["1INCH"],
57
+ tokenOut: token_1.tokenDataByNetwork.Goerli.USDC,
58
+ fee: 10000,
59
+ recipient: constants_1.DUMB_ADDRESS,
60
+ deadline: 12300,
61
+ amountInMaximum: constants_1.WAD.mul(149).div(1000),
62
+ amountOut: 102e6,
63
+ sqrtPriceLimitX96: 0,
64
+ },
65
+ ]));
66
+ (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactOutputSingle(amountInMaximum: 0.14 [149000000000000000], amountOut: 102.00 [102000000], path: 1INCH ==(fee: 10000)==> USDC)", "Incorrect parse swapExactTokensForTokens");
67
+ parsed = parser.parse(ifc.encodeFunctionData("exactOutput", [
68
+ {
69
+ path: pathToUniV3Path([
70
+ token_1.tokenDataByNetwork.Mainnet.AAVE,
71
+ token_1.tokenDataByNetwork.Mainnet.LINK,
72
+ token_1.tokenDataByNetwork.Mainnet.USDC,
73
+ ]),
74
+ recipient: constants_1.DUMB_ADDRESS,
75
+ deadline: 1232131,
76
+ amountInMaximum: 123e6,
77
+ amountOut: constants_1.WAD.mul(122),
78
+ },
79
+ ]));
80
+ (0, chai_1.expect)(parsed).to.be.eq("UniswapV3Adapter[UNISWAP_V3_ROUTER].exactOutput(amountInMaximum: 123.00 [123000000], amountOut: 122.00 [122000000000000000000], path: USDC ==(fee: 3000)==> LINK ==(fee: 3000)==> AAVE", "Incorrect parse swapExactTokensForTokens");
81
+ });
82
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var chai_1 = require("chai");
4
+ var constants_1 = require("../core/constants");
5
+ var yearn_1 = require("../types/factories/contracts/interfaces/adapters/yearn");
6
+ var yearnV2AdapterParser_1 = require("./yearnV2AdapterParser");
7
+ describe("YearnV2AdapterParser test", function () {
8
+ it("deposit / withdraw functions works well", function () {
9
+ var parser = new yearnV2AdapterParser_1.YearnV2AdapterParser("YEARN_CURVE_STETH_VAULT", false);
10
+ var ifc = yearn_1.IYearnV2Adapter__factory.createInterface();
11
+ var parsed = parser.parse(ifc.encodeFunctionData("deposit()"));
12
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].deposit()", "Incorrect parse deposit()");
13
+ parsed = parser.parse(ifc.encodeFunctionData("deposit(uint256)", [constants_1.WAD.mul(19000)]));
14
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].deposit(amount: 19.00K [19000000000000000000000])", "Incorrect parse deposit(amount)");
15
+ parsed = parser.parse(ifc.encodeFunctionData("deposit(uint256,address)", [
16
+ constants_1.WAD.mul(19000),
17
+ constants_1.DUMB_ADDRESS,
18
+ ]));
19
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].deposit(amount: 19.00K [19000000000000000000000], address: ".concat(constants_1.DUMB_ADDRESS, ")"), "Incorrect parse deposit(amount,address)");
20
+ parsed = parser.parse(ifc.encodeFunctionData("withdraw()"));
21
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].withdraw()", "Incorrect parse withdraw()");
22
+ parsed = parser.parse(ifc.encodeFunctionData("withdraw(uint256)", [constants_1.WAD.mul(19000)]));
23
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].withdraw(amount: 19.00K [19000000000000000000000])", "Incorrect parse withdraw(amount)");
24
+ parsed = parser.parse(ifc.encodeFunctionData("withdraw(uint256,address)", [
25
+ constants_1.WAD.mul(19000),
26
+ constants_1.DUMB_ADDRESS,
27
+ ]));
28
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].withdraw(amount: 19.00K [19000000000000000000000], address: ".concat(constants_1.DUMB_ADDRESS, ")"), "Incorrect parse withdraw(amount,address)");
29
+ parsed = parser.parse(ifc.encodeFunctionData("withdraw(uint256,address,uint256)", [
30
+ constants_1.WAD.mul(19000),
31
+ constants_1.DUMB_ADDRESS,
32
+ 555,
33
+ ]));
34
+ (0, chai_1.expect)(parsed).to.be.eq("YearnV2Adapter[YEARN_CURVE_STETH_VAULT].withdraw(amount: 19.00K [19000000000000000000000], address: ".concat(constants_1.DUMB_ADDRESS, ", maxLoss: 555)"), "Incorrect parse withdraw(amount,address,uint256)");
35
+ });
36
+ });
@@ -0,0 +1,7 @@
1
+ import { SupportedContract } from "../contracts/contracts";
2
+ import { AbstractParser } from "./abstractParser";
3
+ import { IParser } from "./iParser";
4
+ export declare class YearnV2AdapterParser extends AbstractParser implements IParser {
5
+ constructor(contract: SupportedContract, isContract: boolean);
6
+ parse(calldata: string): string;
7
+ }
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.YearnV2AdapterParser = void 0;
19
+ var contracts_1 = require("../contracts/contracts");
20
+ var types_1 = require("../types");
21
+ var abstractParser_1 = require("./abstractParser");
22
+ var YearnV2AdapterParser = /** @class */ (function (_super) {
23
+ __extends(YearnV2AdapterParser, _super);
24
+ function YearnV2AdapterParser(contract, isContract) {
25
+ var _this = _super.call(this, contract) || this;
26
+ _this.ifc = types_1.IYVault__factory.createInterface();
27
+ if (!isContract)
28
+ _this.adapterName = "YearnV2Adapter";
29
+ return _this;
30
+ }
31
+ YearnV2AdapterParser.prototype.parse = function (calldata) {
32
+ var _a = this.parseSelector(calldata), functionFragment = _a.functionFragment, functionName = _a.functionName;
33
+ switch (functionFragment.name) {
34
+ case "deposit":
35
+ case "withdraw":
36
+ case "deposit(uint256)":
37
+ case "withdraw(uint256)":
38
+ case "withdraw(uint256,address,uint256)": {
39
+ var _b = this.decodeFunctionData(functionFragment, calldata), amount = _b[0], address = _b[1], maxLoss = _b[2];
40
+ var yvSym = this.tokenSymbol(contracts_1.contractsByNetwork.Mainnet[this.contract]);
41
+ var amountStr = amount
42
+ ? "amount: ".concat(this.formatBN(amount, yvSym))
43
+ : "";
44
+ var addressStr = address ? ", address: ".concat(address) : "";
45
+ var maxLossStr = maxLoss ? ", maxLoss: ".concat(maxLoss) : "";
46
+ return "".concat(functionName, "(").concat(amountStr).concat(addressStr).concat(maxLossStr, ")");
47
+ }
48
+ default:
49
+ return "".concat(functionName, ": Unknown operation ").concat(functionFragment.name, " with calldata ").concat(calldata);
50
+ }
51
+ };
52
+ return YearnV2AdapterParser;
53
+ }(abstractParser_1.AbstractParser));
54
+ exports.YearnV2AdapterParser = YearnV2AdapterParser;
@@ -1,7 +1,7 @@
1
- import type { ConvexPoolContract } from "../contracts/contracts";
1
+ import type { ConvexPoolContract, SupportedContract } from "../contracts/contracts";
2
2
  import { TradeAction } from "../pathfinder/tradeTypes";
3
3
  import type { CurveLPToken } from "./curveLP";
4
- import type { TokenBase } from "./token";
4
+ import type { SupportedToken, TokenBase } from "./token";
5
5
  import { TokenType } from "./tokenType";
6
6
  export declare type ConvexLPToken = "cvx3Crv" | "cvxsteCRV" | "cvxFRAX3CRV" | "cvxLUSD3CRV" | "cvxcrvPlain3andSUSD" | "cvxgusd3CRV";
7
7
  export declare type ConvexStakedPhantomToken = "stkcvx3Crv" | "stkcvxsteCRV" | "stkcvxFRAX3CRV" | "stkcvxLUSD3CRV" | "stkcvxcrvPlain3andSUSD" | "stkcvxgusd3CRV";
@@ -25,4 +25,6 @@ export declare const convexTokens: Record<ConvexLPToken | ConvexStakedPhantomTok
25
25
  export declare const isConvexToken: (t: unknown) => t is ConvexLPToken | ConvexStakedPhantomToken;
26
26
  export declare const isConvexLPToken: (t: unknown) => t is ConvexLPToken;
27
27
  export declare const isConvexStakedPhantomToken: (t: unknown) => t is ConvexStakedPhantomToken;
28
+ export declare const convexPoolByPid: Record<number, SupportedContract>;
29
+ export declare const convexLpTokenByPid: Record<number, SupportedToken>;
28
30
  export {};
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.isConvexStakedPhantomToken = exports.isConvexLPToken = exports.isConvexToken = exports.convexTokens = void 0;
14
+ exports.convexLpTokenByPid = exports.convexPoolByPid = exports.isConvexStakedPhantomToken = exports.isConvexLPToken = exports.isConvexToken = exports.convexTokens = void 0;
15
15
  var tradeTypes_1 = require("../pathfinder/tradeTypes");
16
16
  var tokenType_1 = require("./tokenType");
17
17
  var convexLpTokens = {
@@ -297,3 +297,12 @@ var isConvexStakedPhantomToken = function (t) {
297
297
  !!convexStakedPhantomTokens[t];
298
298
  };
299
299
  exports.isConvexStakedPhantomToken = isConvexStakedPhantomToken;
300
+ exports.convexPoolByPid = Object.values(convexLpTokens).reduce(function (acc, value) {
301
+ acc[value.pid] = value.pool;
302
+ return acc;
303
+ }, {});
304
+ exports.convexLpTokenByPid = Object.entries(convexLpTokens).reduce(function (acc, _a) {
305
+ var token = _a[0], data = _a[1];
306
+ acc[data.pid] = token;
307
+ return acc;
308
+ }, {});
@@ -0,0 +1,2 @@
1
+ import { SupportedToken } from "./token";
2
+ export declare const decimals: Record<SupportedToken, number>;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decimals = void 0;
4
+ exports.decimals = {
5
+ "1INCH": 18,
6
+ AAVE: 18,
7
+ COMP: 18,
8
+ CRV: 18,
9
+ DAI: 18,
10
+ DPI: 18,
11
+ FEI: 18,
12
+ LINK: 18,
13
+ SNX: 18,
14
+ SUSHI: 18,
15
+ UNI: 18,
16
+ USDC: 6,
17
+ USDT: 6,
18
+ WBTC: 8,
19
+ WETH: 18,
20
+ YFI: 18,
21
+ STETH: 18,
22
+ FTM: 18,
23
+ CVX: 18,
24
+ FRAX: 18,
25
+ FXS: 18,
26
+ LDO: 18,
27
+ SPELL: 18,
28
+ LUSD: 18,
29
+ sUSD: 18,
30
+ GUSD: 2,
31
+ LUNA: 18,
32
+ LQTY: 18,
33
+ "3Crv": 18,
34
+ steCRV: 18,
35
+ crvPlain3andSUSD: 18,
36
+ FRAX3CRV: 18,
37
+ LUSD3CRV: 18,
38
+ gusd3CRV: 18,
39
+ cvx3Crv: 18,
40
+ cvxsteCRV: 18,
41
+ cvxFRAX3CRV: 18,
42
+ cvxLUSD3CRV: 18,
43
+ cvxcrvPlain3andSUSD: 18,
44
+ cvxgusd3CRV: 18,
45
+ stkcvx3Crv: 18,
46
+ stkcvxsteCRV: 18,
47
+ stkcvxFRAX3CRV: 18,
48
+ stkcvxLUSD3CRV: 18,
49
+ stkcvxcrvPlain3andSUSD: 18,
50
+ stkcvxgusd3CRV: 18,
51
+ yvDAI: 18,
52
+ yvUSDC: 6,
53
+ yvWETH: 18,
54
+ yvWBTC: 8,
55
+ yvCurve_stETH: 18,
56
+ yvCurve_FRAX: 18,
57
+ dDAI: 18,
58
+ dUSDC: 6,
59
+ dWBTC: 8,
60
+ dWETH: 18,
61
+ GEAR: 18,
62
+ };
@@ -1,11 +1,12 @@
1
1
  export declare enum TokenType {
2
- NORMAL_TOKEN = 0,
3
- CURVE_LP_TOKEN = 1,
4
- YEARN_ON_NORMAL_TOKEN = 2,
5
- YEARN_ON_CURVE_TOKEN = 3,
6
- CONVEX_LP_TOKEN = 4,
7
- CONVEX_STAKED_TOKEN = 5,
8
- DIESEL_LP_TOKEN = 6,
9
- GEAR_TOKEN = 7,
10
- C_TOKEN = 8
2
+ NO_TOKEN = 0,
3
+ NORMAL_TOKEN = 1,
4
+ CURVE_LP_TOKEN = 2,
5
+ YEARN_ON_NORMAL_TOKEN = 3,
6
+ YEARN_ON_CURVE_TOKEN = 4,
7
+ CONVEX_LP_TOKEN = 5,
8
+ CONVEX_STAKED_TOKEN = 6,
9
+ DIESEL_LP_TOKEN = 7,
10
+ GEAR_TOKEN = 8,
11
+ C_TOKEN = 9
11
12
  }
@@ -3,13 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TokenType = void 0;
4
4
  var TokenType;
5
5
  (function (TokenType) {
6
- TokenType[TokenType["NORMAL_TOKEN"] = 0] = "NORMAL_TOKEN";
7
- TokenType[TokenType["CURVE_LP_TOKEN"] = 1] = "CURVE_LP_TOKEN";
8
- TokenType[TokenType["YEARN_ON_NORMAL_TOKEN"] = 2] = "YEARN_ON_NORMAL_TOKEN";
9
- TokenType[TokenType["YEARN_ON_CURVE_TOKEN"] = 3] = "YEARN_ON_CURVE_TOKEN";
10
- TokenType[TokenType["CONVEX_LP_TOKEN"] = 4] = "CONVEX_LP_TOKEN";
11
- TokenType[TokenType["CONVEX_STAKED_TOKEN"] = 5] = "CONVEX_STAKED_TOKEN";
12
- TokenType[TokenType["DIESEL_LP_TOKEN"] = 6] = "DIESEL_LP_TOKEN";
13
- TokenType[TokenType["GEAR_TOKEN"] = 7] = "GEAR_TOKEN";
14
- TokenType[TokenType["C_TOKEN"] = 8] = "C_TOKEN";
6
+ TokenType[TokenType["NO_TOKEN"] = 0] = "NO_TOKEN";
7
+ TokenType[TokenType["NORMAL_TOKEN"] = 1] = "NORMAL_TOKEN";
8
+ TokenType[TokenType["CURVE_LP_TOKEN"] = 2] = "CURVE_LP_TOKEN";
9
+ TokenType[TokenType["YEARN_ON_NORMAL_TOKEN"] = 3] = "YEARN_ON_NORMAL_TOKEN";
10
+ TokenType[TokenType["YEARN_ON_CURVE_TOKEN"] = 4] = "YEARN_ON_CURVE_TOKEN";
11
+ TokenType[TokenType["CONVEX_LP_TOKEN"] = 5] = "CONVEX_LP_TOKEN";
12
+ TokenType[TokenType["CONVEX_STAKED_TOKEN"] = 6] = "CONVEX_STAKED_TOKEN";
13
+ TokenType[TokenType["DIESEL_LP_TOKEN"] = 7] = "DIESEL_LP_TOKEN";
14
+ TokenType[TokenType["GEAR_TOKEN"] = 8] = "GEAR_TOKEN";
15
+ TokenType[TokenType["C_TOKEN"] = 9] = "C_TOKEN";
15
16
  })(TokenType = exports.TokenType || (exports.TokenType = {}));
@@ -1,4 +1,4 @@
1
- import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, PopulatedTransaction, Signer, utils } from "ethers";
1
+ import type { BaseContract, BigNumber, BigNumberish, BytesLike, CallOverrides, ContractTransaction, Overrides, PayableOverrides, PopulatedTransaction, Signer, utils } from "ethers";
2
2
  import type { FunctionFragment, Result } from "@ethersproject/abi";
3
3
  import type { Listener, Provider } from "@ethersproject/providers";
4
4
  import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent } from "../../../common";
@@ -12,13 +12,25 @@ export declare type BalanceStructOutput = [string, BigNumber] & {
12
12
  };
13
13
  export interface ICreditFacadeExtendedInterface extends utils.Interface {
14
14
  functions: {
15
+ "addCollateral(address,address,uint256)": FunctionFragment;
16
+ "decreaseDebt(uint256)": FunctionFragment;
15
17
  "disableToken(address)": FunctionFragment;
18
+ "enableToken(address)": FunctionFragment;
19
+ "increaseDebt(uint256)": FunctionFragment;
16
20
  "revertIfReceivedLessThan((address,uint256)[])": FunctionFragment;
17
21
  };
18
- getFunction(nameOrSignatureOrTopic: "disableToken" | "revertIfReceivedLessThan"): FunctionFragment;
22
+ getFunction(nameOrSignatureOrTopic: "addCollateral" | "decreaseDebt" | "disableToken" | "enableToken" | "increaseDebt" | "revertIfReceivedLessThan"): FunctionFragment;
23
+ encodeFunctionData(functionFragment: "addCollateral", values: [string, string, BigNumberish]): string;
24
+ encodeFunctionData(functionFragment: "decreaseDebt", values: [BigNumberish]): string;
19
25
  encodeFunctionData(functionFragment: "disableToken", values: [string]): string;
26
+ encodeFunctionData(functionFragment: "enableToken", values: [string]): string;
27
+ encodeFunctionData(functionFragment: "increaseDebt", values: [BigNumberish]): string;
20
28
  encodeFunctionData(functionFragment: "revertIfReceivedLessThan", values: [BalanceStruct[]]): string;
29
+ decodeFunctionResult(functionFragment: "addCollateral", data: BytesLike): Result;
30
+ decodeFunctionResult(functionFragment: "decreaseDebt", data: BytesLike): Result;
21
31
  decodeFunctionResult(functionFragment: "disableToken", data: BytesLike): Result;
32
+ decodeFunctionResult(functionFragment: "enableToken", data: BytesLike): Result;
33
+ decodeFunctionResult(functionFragment: "increaseDebt", data: BytesLike): Result;
22
34
  decodeFunctionResult(functionFragment: "revertIfReceivedLessThan", data: BytesLike): Result;
23
35
  events: {};
24
36
  }
@@ -37,36 +49,88 @@ export interface ICreditFacadeExtended extends BaseContract {
37
49
  once: OnEvent<this>;
38
50
  removeListener: OnEvent<this>;
39
51
  functions: {
52
+ addCollateral(onBehalfOf: string, token: string, amount: BigNumberish, overrides?: PayableOverrides & {
53
+ from?: string | Promise<string>;
54
+ }): Promise<ContractTransaction>;
55
+ decreaseDebt(amount: BigNumberish, overrides?: Overrides & {
56
+ from?: string | Promise<string>;
57
+ }): Promise<ContractTransaction>;
40
58
  disableToken(token: string, overrides?: Overrides & {
41
59
  from?: string | Promise<string>;
42
60
  }): Promise<ContractTransaction>;
61
+ enableToken(token: string, overrides?: Overrides & {
62
+ from?: string | Promise<string>;
63
+ }): Promise<ContractTransaction>;
64
+ increaseDebt(amount: BigNumberish, overrides?: Overrides & {
65
+ from?: string | Promise<string>;
66
+ }): Promise<ContractTransaction>;
43
67
  revertIfReceivedLessThan(expected: BalanceStruct[], overrides?: Overrides & {
44
68
  from?: string | Promise<string>;
45
69
  }): Promise<ContractTransaction>;
46
70
  };
71
+ addCollateral(onBehalfOf: string, token: string, amount: BigNumberish, overrides?: PayableOverrides & {
72
+ from?: string | Promise<string>;
73
+ }): Promise<ContractTransaction>;
74
+ decreaseDebt(amount: BigNumberish, overrides?: Overrides & {
75
+ from?: string | Promise<string>;
76
+ }): Promise<ContractTransaction>;
47
77
  disableToken(token: string, overrides?: Overrides & {
48
78
  from?: string | Promise<string>;
49
79
  }): Promise<ContractTransaction>;
80
+ enableToken(token: string, overrides?: Overrides & {
81
+ from?: string | Promise<string>;
82
+ }): Promise<ContractTransaction>;
83
+ increaseDebt(amount: BigNumberish, overrides?: Overrides & {
84
+ from?: string | Promise<string>;
85
+ }): Promise<ContractTransaction>;
50
86
  revertIfReceivedLessThan(expected: BalanceStruct[], overrides?: Overrides & {
51
87
  from?: string | Promise<string>;
52
88
  }): Promise<ContractTransaction>;
53
89
  callStatic: {
90
+ addCollateral(onBehalfOf: string, token: string, amount: BigNumberish, overrides?: CallOverrides): Promise<void>;
91
+ decreaseDebt(amount: BigNumberish, overrides?: CallOverrides): Promise<void>;
54
92
  disableToken(token: string, overrides?: CallOverrides): Promise<void>;
93
+ enableToken(token: string, overrides?: CallOverrides): Promise<void>;
94
+ increaseDebt(amount: BigNumberish, overrides?: CallOverrides): Promise<void>;
55
95
  revertIfReceivedLessThan(expected: BalanceStruct[], overrides?: CallOverrides): Promise<void>;
56
96
  };
57
97
  filters: {};
58
98
  estimateGas: {
99
+ addCollateral(onBehalfOf: string, token: string, amount: BigNumberish, overrides?: PayableOverrides & {
100
+ from?: string | Promise<string>;
101
+ }): Promise<BigNumber>;
102
+ decreaseDebt(amount: BigNumberish, overrides?: Overrides & {
103
+ from?: string | Promise<string>;
104
+ }): Promise<BigNumber>;
59
105
  disableToken(token: string, overrides?: Overrides & {
60
106
  from?: string | Promise<string>;
61
107
  }): Promise<BigNumber>;
108
+ enableToken(token: string, overrides?: Overrides & {
109
+ from?: string | Promise<string>;
110
+ }): Promise<BigNumber>;
111
+ increaseDebt(amount: BigNumberish, overrides?: Overrides & {
112
+ from?: string | Promise<string>;
113
+ }): Promise<BigNumber>;
62
114
  revertIfReceivedLessThan(expected: BalanceStruct[], overrides?: Overrides & {
63
115
  from?: string | Promise<string>;
64
116
  }): Promise<BigNumber>;
65
117
  };
66
118
  populateTransaction: {
119
+ addCollateral(onBehalfOf: string, token: string, amount: BigNumberish, overrides?: PayableOverrides & {
120
+ from?: string | Promise<string>;
121
+ }): Promise<PopulatedTransaction>;
122
+ decreaseDebt(amount: BigNumberish, overrides?: Overrides & {
123
+ from?: string | Promise<string>;
124
+ }): Promise<PopulatedTransaction>;
67
125
  disableToken(token: string, overrides?: Overrides & {
68
126
  from?: string | Promise<string>;
69
127
  }): Promise<PopulatedTransaction>;
128
+ enableToken(token: string, overrides?: Overrides & {
129
+ from?: string | Promise<string>;
130
+ }): Promise<PopulatedTransaction>;
131
+ increaseDebt(amount: BigNumberish, overrides?: Overrides & {
132
+ from?: string | Promise<string>;
133
+ }): Promise<PopulatedTransaction>;
70
134
  revertIfReceivedLessThan(expected: BalanceStruct[], overrides?: Overrides & {
71
135
  from?: string | Promise<string>;
72
136
  }): Promise<PopulatedTransaction>;