@gearbox-protocol/sdk 0.0.100 → 0.0.103

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 (163) hide show
  1. package/.eslintignore +4 -0
  2. package/.eslintrc.js +52 -0
  3. package/.husky/pre-push +4 -0
  4. package/lib/apy/convexAPY.d.ts +8 -0
  5. package/lib/apy/convexAPY.js +200 -0
  6. package/lib/apy/lidoAPY.d.ts +4 -0
  7. package/lib/apy/lidoAPY.js +103 -0
  8. package/lib/config.d.ts +1 -0
  9. package/lib/config.js +2 -1
  10. package/lib/contracts/contracts.d.ts +9 -4
  11. package/lib/contracts/contracts.js +52 -14
  12. package/lib/contracts/contractsRegister.js +16 -4
  13. package/lib/core/constants.d.ts +7 -1
  14. package/lib/core/constants.js +11 -5
  15. package/lib/core/creditAccount.d.ts +3 -1
  16. package/lib/core/creditAccount.js +33 -31
  17. package/lib/core/creditManager.d.ts +13 -2
  18. package/lib/core/creditManager.js +77 -33
  19. package/lib/core/creditSession.js +14 -3
  20. package/lib/core/errors.d.ts +10 -0
  21. package/lib/core/errors.js +16 -1
  22. package/lib/core/eventOrTx.d.ts +1 -1
  23. package/lib/core/events.d.ts +19 -19
  24. package/lib/core/events.js +32 -30
  25. package/lib/core/multicall.d.ts +1 -1
  26. package/lib/core/pool.d.ts +2 -2
  27. package/lib/core/pool.js +8 -12
  28. package/lib/core/price.d.ts +2 -0
  29. package/lib/core/price.js +14 -0
  30. package/lib/core/strategy.d.ts +36 -0
  31. package/lib/core/strategy.js +57 -0
  32. package/lib/core/tokenDistributor.js +1 -1
  33. package/lib/core/transactions.d.ts +18 -3
  34. package/lib/core/transactions.js +39 -3
  35. package/lib/index.d.ts +8 -3
  36. package/lib/index.js +9 -4
  37. package/lib/oracles/priceFeeds.js +1 -1
  38. package/lib/pathfinder/convexLP.d.ts +1 -1
  39. package/lib/pathfinder/convexLP.js +26 -29
  40. package/lib/pathfinder/curveLP.d.ts +1 -1
  41. package/lib/pathfinder/curveLP.js +5 -7
  42. package/lib/pathfinder/path.d.ts +1 -1
  43. package/lib/pathfinder/path.js +38 -42
  44. package/lib/pathfinder/trade.d.ts +1 -2
  45. package/lib/pathfinder/tradeTypes.d.ts +5 -5
  46. package/lib/pathfinder/yVault.d.ts +2 -2
  47. package/lib/pathfinder/yVault.js +22 -19
  48. package/lib/payload/creditAccount.d.ts +4 -26
  49. package/lib/payload/creditManager.d.ts +3 -25
  50. package/lib/payload/pool.d.ts +2 -17
  51. package/lib/payload/pool.js +0 -1
  52. package/lib/strategies/curve.d.ts +6 -60
  53. package/lib/strategies/curve.js +6 -0
  54. package/lib/strategies/uniswapV2.js +3 -19
  55. package/lib/strategies/uniswapV3.js +1 -1
  56. package/lib/strategies/yearn.js +15 -11
  57. package/lib/tokens/convex.d.ts +3 -3
  58. package/lib/tokens/curveLP.d.ts +2 -2
  59. package/lib/tokens/curveLP.js +1 -1
  60. package/lib/tokens/gear.d.ts +2 -2
  61. package/lib/tokens/gear.js +1 -1
  62. package/lib/tokens/normal.d.ts +1 -1
  63. package/lib/tokens/token.js +9 -9
  64. package/lib/tokens/tokenData.d.ts +3 -1
  65. package/lib/tokens/tokenData.js +10 -8
  66. package/lib/tokens/yearn.d.ts +3 -3
  67. package/lib/utils/errors.d.ts +6 -0
  68. package/lib/utils/errors.js +13 -0
  69. package/lib/utils/formatter.d.ts +2 -1
  70. package/lib/utils/formatter.js +23 -15
  71. package/lib/utils/loading.d.ts +2 -1
  72. package/lib/utils/loading.js +9 -13
  73. package/lib/utils/mappers.d.ts +2 -1
  74. package/lib/utils/mappers.js +13 -5
  75. package/lib/utils/multicall.js +4 -3
  76. package/lib/utils/network.js +2 -2
  77. package/lib/utils/repeater.js +12 -24
  78. package/lib/utils/types.d.ts +1 -0
  79. package/lib/utils/validate.js +1 -1
  80. package/package.json +26 -8
  81. package/src/apy/convexAPY.ts +250 -0
  82. package/src/apy/lidoAPY.ts +89 -0
  83. package/src/config.ts +2 -1
  84. package/src/contracts/contracts.ts +73 -19
  85. package/src/contracts/contractsRegister.ts +19 -4
  86. package/src/core/constants.ts +11 -4
  87. package/src/core/creditAccount.ts +69 -37
  88. package/src/core/creditManager.ts +256 -148
  89. package/src/core/creditOperation.ts +7 -7
  90. package/src/core/creditSession.ts +25 -5
  91. package/src/core/errors.ts +25 -0
  92. package/src/core/eventOrTx.ts +8 -5
  93. package/src/core/events.ts +978 -911
  94. package/src/core/history.ts +46 -46
  95. package/src/core/multicall.ts +1 -1
  96. package/src/core/operations.ts +6 -0
  97. package/src/core/pool.ts +75 -58
  98. package/src/core/price.ts +13 -0
  99. package/src/core/strategy.ts +134 -0
  100. package/src/core/tokenDistributor.ts +2 -2
  101. package/src/core/transactions.ts +427 -350
  102. package/src/index.ts +9 -4
  103. package/src/oracles/priceFeeds.ts +523 -523
  104. package/src/pathfinder/contracts.ts +15 -13
  105. package/src/pathfinder/convexLP.ts +29 -25
  106. package/src/pathfinder/curveLP.ts +57 -53
  107. package/src/pathfinder/path.ts +158 -150
  108. package/src/pathfinder/priority.ts +11 -11
  109. package/src/pathfinder/trade.ts +84 -77
  110. package/src/pathfinder/tradeTypes.ts +98 -94
  111. package/src/pathfinder/yVault.ts +79 -63
  112. package/src/payload/creditAccount.ts +4 -26
  113. package/src/payload/creditManager.ts +4 -26
  114. package/src/payload/pool.ts +2 -19
  115. package/src/payload/token.ts +3 -3
  116. package/src/strategies/convex.ts +217 -210
  117. package/src/strategies/creditFacade.ts +70 -53
  118. package/src/strategies/curve.ts +263 -194
  119. package/src/strategies/lido.ts +33 -37
  120. package/src/strategies/uniswapV2.ts +90 -112
  121. package/src/strategies/uniswapV3.ts +114 -91
  122. package/src/strategies/yearn.ts +58 -62
  123. package/src/tokens/connectors.ts +6 -6
  124. package/src/tokens/convex.ts +297 -296
  125. package/src/tokens/curveLP.ts +170 -165
  126. package/src/tokens/gear.ts +47 -45
  127. package/src/tokens/normal.ts +801 -802
  128. package/src/tokens/token.ts +19 -10
  129. package/src/tokens/tokenData.ts +19 -9
  130. package/src/tokens/tokenType.ts +11 -11
  131. package/src/tokens/yearn.ts +126 -124
  132. package/src/utils/errors.ts +11 -0
  133. package/src/utils/formatter.ts +26 -18
  134. package/src/utils/loading.ts +14 -6
  135. package/src/utils/mappers.ts +15 -6
  136. package/src/utils/multicall.ts +6 -9
  137. package/src/utils/network.ts +21 -21
  138. package/src/utils/repeater.ts +2 -2
  139. package/src/utils/types.ts +6 -2
  140. package/src/utils/validate.ts +1 -1
  141. package/lib/core/adapters.d.ts +0 -15
  142. package/lib/core/adapters.js +0 -19
  143. package/lib/core/contracts.d.ts +0 -67
  144. package/lib/core/contracts.js +0 -254
  145. package/lib/core/contractsRegister.d.ts +0 -2
  146. package/lib/core/contractsRegister.js +0 -58
  147. package/lib/core/creditCard.d.ts +0 -13
  148. package/lib/core/creditCard.js +0 -2
  149. package/lib/core/oracles.d.ts +0 -38
  150. package/lib/core/oracles.js +0 -12
  151. package/lib/core/priceFeeds.d.ts +0 -3
  152. package/lib/core/priceFeeds.js +0 -492
  153. package/lib/core/protocols.d.ts +0 -13
  154. package/lib/core/protocols.js +0 -39
  155. package/lib/core/swap.d.ts +0 -4
  156. package/lib/core/swap.js +0 -8
  157. package/lib/core/trade.d.ts +0 -35
  158. package/lib/core/trade.js +0 -62
  159. package/lib/core/tradeTypes.d.ts +0 -79
  160. package/lib/core/tradeTypes.js +0 -21
  161. package/lib/utils/events.d.ts +0 -2
  162. package/lib/utils/events.js +0 -13
  163. package/src/utils/events.ts +0 -10
@@ -1,127 +1,105 @@
1
- import { BigNumberish } from "ethers"
1
+ import { BigNumberish } from "ethers";
2
2
 
3
-
4
- import {
5
- UniswapV2Adapter__factory
6
- } from "../types";
3
+ import { UniswapV2Adapter__factory } from "../types";
7
4
 
8
5
  import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
9
6
 
10
7
  export class UniswapV2Calls {
11
- public static swapExactTokensForTokens(
12
- amountIn: BigNumberish,
13
- amountOutMin: BigNumberish,
14
- path: Array<string>,
15
- to: string,
16
- deadline: BigNumberish
17
- ) {
18
- return UniswapV2Adapter__factory.createInterface().encodeFunctionData(
19
- "swapExactTokensForTokens",
20
- [
21
- amountIn,
22
- amountOutMin,
23
- path,
24
- to,
25
- deadline
26
- ]
27
- )
28
- }
29
-
30
- public static swapTokensForExactTokens(
31
- amountOut: BigNumberish,
32
- amountInMax: BigNumberish,
33
- path: Array<string>,
34
- to: string,
35
- deadline: BigNumberish
36
- ) {
37
- return UniswapV2Adapter__factory.createInterface().encodeFunctionData(
38
- "swapTokensForExactTokens",
39
- [
40
- amountOut,
41
- amountInMax,
42
- path,
43
- to,
44
- deadline
45
- ]
46
- )
47
- }
8
+ public static swapExactTokensForTokens(
9
+ amountIn: BigNumberish,
10
+ amountOutMin: BigNumberish,
11
+ path: Array<string>,
12
+ to: string,
13
+ deadline: BigNumberish
14
+ ) {
15
+ return UniswapV2Adapter__factory.createInterface().encodeFunctionData(
16
+ "swapExactTokensForTokens",
17
+ [amountIn, amountOutMin, path, to, deadline]
18
+ );
19
+ }
48
20
 
49
- public static swapAllTokensForTokens(
50
- rateMinRAY: BigNumberish,
51
- path: Array<string>,
52
- deadline: BigNumberish
53
- ) {
54
- return UniswapV2Adapter__factory.createInterface().encodeFunctionData(
55
- "swapAllTokensForTokens",
56
- [
57
- rateMinRAY,
58
- path,
59
- deadline
60
- ]
61
- )
62
- }
21
+ public static swapTokensForExactTokens(
22
+ amountOut: BigNumberish,
23
+ amountInMax: BigNumberish,
24
+ path: Array<string>,
25
+ to: string,
26
+ deadline: BigNumberish
27
+ ) {
28
+ return UniswapV2Adapter__factory.createInterface().encodeFunctionData(
29
+ "swapTokensForExactTokens",
30
+ [amountOut, amountInMax, path, to, deadline]
31
+ );
32
+ }
63
33
 
34
+ public static swapAllTokensForTokens(
35
+ rateMinRAY: BigNumberish,
36
+ path: Array<string>,
37
+ deadline: BigNumberish
38
+ ) {
39
+ return UniswapV2Adapter__factory.createInterface().encodeFunctionData(
40
+ "swapAllTokensForTokens",
41
+ [rateMinRAY, path, deadline]
42
+ );
43
+ }
64
44
  }
65
45
 
66
46
  export class UniswapV2Multicaller {
67
- private readonly _address: string;
68
-
69
- constructor(address: string) {
70
- this._address = address;
71
- }
72
-
73
- swapExactTokensForTokens(
74
- amountIn: BigNumberish,
75
- amountOutMin: BigNumberish,
76
- path: Array<string>,
77
- to: string,
78
- deadline: BigNumberish
79
- ): MultiCallStruct {
47
+ private readonly _address: string;
80
48
 
81
- return {
82
- target: this._address,
83
- callData: UniswapV2Calls.swapExactTokensForTokens(
84
- amountIn,
85
- amountOutMin,
86
- path,
87
- to,
88
- deadline
89
- )
90
- }
91
- }
49
+ constructor(address: string) {
50
+ this._address = address;
51
+ }
92
52
 
93
- swapTokensForExactTokens(
94
- amountOut: BigNumberish,
95
- amountInMax: BigNumberish,
96
- path: Array<string>,
97
- to: string,
98
- deadline: BigNumberish
99
- ): MultiCallStruct {
100
- return {
101
- target: this._address,
102
- callData: UniswapV2Calls.swapExactTokensForTokens(
103
- amountOut,
104
- amountInMax,
105
- path,
106
- to,
107
- deadline
108
- )
109
- }
110
- }
53
+ swapExactTokensForTokens(
54
+ amountIn: BigNumberish,
55
+ amountOutMin: BigNumberish,
56
+ path: Array<string>,
57
+ to: string,
58
+ deadline: BigNumberish
59
+ ): MultiCallStruct {
60
+ return {
61
+ target: this._address,
62
+ callData: UniswapV2Calls.swapExactTokensForTokens(
63
+ amountIn,
64
+ amountOutMin,
65
+ path,
66
+ to,
67
+ deadline
68
+ )
69
+ };
70
+ }
111
71
 
112
- swapAllTokensForTokens(
113
- rateMinRAY: BigNumberish,
114
- path: Array<string>,
115
- deadline: BigNumberish
116
- ): MultiCallStruct {
117
- return {
118
- target: this._address,
119
- callData: UniswapV2Calls.swapAllTokensForTokens(
120
- rateMinRAY,
121
- path,
122
- deadline
123
- )
124
- }
125
- }
72
+ swapTokensForExactTokens(
73
+ amountOut: BigNumberish,
74
+ amountInMax: BigNumberish,
75
+ path: Array<string>,
76
+ to: string,
77
+ deadline: BigNumberish
78
+ ): MultiCallStruct {
79
+ return {
80
+ target: this._address,
81
+ callData: UniswapV2Calls.swapExactTokensForTokens(
82
+ amountOut,
83
+ amountInMax,
84
+ path,
85
+ to,
86
+ deadline
87
+ )
88
+ };
89
+ }
126
90
 
91
+ swapAllTokensForTokens(
92
+ rateMinRAY: BigNumberish,
93
+ path: Array<string>,
94
+ deadline: BigNumberish
95
+ ): MultiCallStruct {
96
+ return {
97
+ target: this._address,
98
+ callData: UniswapV2Calls.swapAllTokensForTokens(
99
+ rateMinRAY,
100
+ path,
101
+ deadline
102
+ )
103
+ };
104
+ }
127
105
  }
@@ -1,100 +1,123 @@
1
- //import { BigNumberish } from "ethers";
1
+ // import { BigNumberish } from "ethers";
2
2
 
3
-
4
- import { UniswapV3Adapter__factory } from "../types"
5
- import { ISwapRouter, IUniswapV3Adapter } from "../types/contracts/adapters/uniswap/UniswapV3.sol/UniswapV3Adapter";
3
+ import { UniswapV3Adapter__factory } from "../types";
4
+ import {
5
+ ISwapRouter,
6
+ IUniswapV3Adapter
7
+ } from "../types/contracts/adapters/uniswap/UniswapV3.sol/UniswapV3Adapter";
6
8
 
7
9
  import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
8
10
 
9
11
  export class UniswapV3Calls {
10
- public static exactInputSingle(params: ISwapRouter.ExactInputSingleParamsStructOutput) {
11
- return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
12
- "exactInputSingle",
13
- [params]
14
- )
15
- }
16
-
17
- public static exactAllInputSingle(params: IUniswapV3Adapter.ExactAllInputSingleParamsStructOutput) {
18
- return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
19
- "exactAllInputSingle",
20
- [params]
21
- )
22
- }
23
-
24
- public static exactInput(params: ISwapRouter.ExactInputParamsStructOutput) {
25
- return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
26
- "exactInput",
27
- [params]
28
- )
29
- }
30
-
31
- public static exactAllInput(params: IUniswapV3Adapter.ExactAllInputParamsStructOutput) {
32
- return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
33
- "exactAllInput",
34
- [params]
35
- )
36
- }
37
-
38
- public static exactOutputSingle(params: ISwapRouter.ExactOutputSingleParamsStructOutput) {
39
- return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
40
- "exactOutputSingle",
41
- [params]
42
- )
43
- }
44
-
45
- public static exactOutput(params: ISwapRouter.ExactOutputParamsStructOutput) {
46
- return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
47
- "exactOutput",
48
- [params]
49
- )
50
- }
12
+ public static exactInputSingle(
13
+ params: ISwapRouter.ExactInputSingleParamsStructOutput
14
+ ) {
15
+ return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
16
+ "exactInputSingle",
17
+ [params]
18
+ );
19
+ }
20
+
21
+ public static exactAllInputSingle(
22
+ params: IUniswapV3Adapter.ExactAllInputSingleParamsStructOutput
23
+ ) {
24
+ return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
25
+ "exactAllInputSingle",
26
+ [params]
27
+ );
28
+ }
29
+
30
+ public static exactInput(params: ISwapRouter.ExactInputParamsStructOutput) {
31
+ return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
32
+ "exactInput",
33
+ [params]
34
+ );
35
+ }
36
+
37
+ public static exactAllInput(
38
+ params: IUniswapV3Adapter.ExactAllInputParamsStructOutput
39
+ ) {
40
+ return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
41
+ "exactAllInput",
42
+ [params]
43
+ );
44
+ }
45
+
46
+ public static exactOutputSingle(
47
+ params: ISwapRouter.ExactOutputSingleParamsStructOutput
48
+ ) {
49
+ return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
50
+ "exactOutputSingle",
51
+ [params]
52
+ );
53
+ }
54
+
55
+ public static exactOutput(params: ISwapRouter.ExactOutputParamsStructOutput) {
56
+ return UniswapV3Adapter__factory.createInterface().encodeFunctionData(
57
+ "exactOutput",
58
+ [params]
59
+ );
60
+ }
51
61
  }
52
62
 
53
63
  export class UniswapV3Multicaller {
54
- private readonly _address: string;
55
-
56
- constructor(address: string) {
57
- this._address = address;
58
- }
59
-
60
- exactInputSingle(params: ISwapRouter.ExactInputSingleParamsStructOutput): MultiCallStruct {
61
- return {
62
- target: this._address,
63
- callData: UniswapV3Calls.exactInputSingle(params)
64
- }
65
- }
66
-
67
- exactAllInputSingle(params: IUniswapV3Adapter.ExactAllInputSingleParamsStructOutput): MultiCallStruct {
68
- return {
69
- target: this._address,
70
- callData: UniswapV3Calls.exactAllInputSingle(params)
71
- }
72
- }
73
- exactInput(params: ISwapRouter.ExactInputParamsStructOutput): MultiCallStruct {
74
- return {
75
- target: this._address,
76
- callData: UniswapV3Calls.exactInput(params)
77
- }
78
- }
79
-
80
- exactAllInput(params: IUniswapV3Adapter.ExactAllInputParamsStructOutput): MultiCallStruct {
81
- return {
82
- target: this._address,
83
- callData: UniswapV3Calls.exactAllInput(params)
84
- }
85
- }
86
-
87
- exactOutputSingle(params: ISwapRouter.ExactOutputSingleParamsStructOutput): MultiCallStruct {
88
- return {
89
- target: this._address,
90
- callData: UniswapV3Calls.exactOutputSingle(params)
91
- }
92
- }
93
-
94
- exactOutput(params: ISwapRouter.ExactOutputParamsStructOutput): MultiCallStruct {
95
- return {
96
- target: this._address,
97
- callData: UniswapV3Calls.exactOutput(params)
98
- }
99
- }
64
+ private readonly _address: string;
65
+
66
+ constructor(address: string) {
67
+ this._address = address;
68
+ }
69
+
70
+ exactInputSingle(
71
+ params: ISwapRouter.ExactInputSingleParamsStructOutput
72
+ ): MultiCallStruct {
73
+ return {
74
+ target: this._address,
75
+ callData: UniswapV3Calls.exactInputSingle(params)
76
+ };
77
+ }
78
+
79
+ exactAllInputSingle(
80
+ params: IUniswapV3Adapter.ExactAllInputSingleParamsStructOutput
81
+ ): MultiCallStruct {
82
+ return {
83
+ target: this._address,
84
+ callData: UniswapV3Calls.exactAllInputSingle(params)
85
+ };
86
+ }
87
+
88
+ exactInput(
89
+ params: ISwapRouter.ExactInputParamsStructOutput
90
+ ): MultiCallStruct {
91
+ return {
92
+ target: this._address,
93
+ callData: UniswapV3Calls.exactInput(params)
94
+ };
95
+ }
96
+
97
+ exactAllInput(
98
+ params: IUniswapV3Adapter.ExactAllInputParamsStructOutput
99
+ ): MultiCallStruct {
100
+ return {
101
+ target: this._address,
102
+ callData: UniswapV3Calls.exactAllInput(params)
103
+ };
104
+ }
105
+
106
+ exactOutputSingle(
107
+ params: ISwapRouter.ExactOutputSingleParamsStructOutput
108
+ ): MultiCallStruct {
109
+ return {
110
+ target: this._address,
111
+ callData: UniswapV3Calls.exactOutputSingle(params)
112
+ };
113
+ }
114
+
115
+ exactOutput(
116
+ params: ISwapRouter.ExactOutputParamsStructOutput
117
+ ): MultiCallStruct {
118
+ return {
119
+ target: this._address,
120
+ callData: UniswapV3Calls.exactOutput(params)
121
+ };
122
+ }
100
123
  }
@@ -1,77 +1,73 @@
1
- import { BigNumberish } from "ethers"
1
+ import { BigNumberish } from "ethers";
2
2
 
3
-
4
- import {
5
- YearnV2Adapter__factory
6
- } from "../types"
3
+ import { YearnV2Adapter__factory } from "../types";
7
4
 
8
5
  import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
9
6
 
10
7
  export class YearnV2Calls {
11
-
12
- public static deposit(amount?: BigNumberish, recipient?: string): string {
13
- let contractInterface = YearnV2Adapter__factory.createInterface();
14
- if (amount && recipient) {
15
- return contractInterface.encodeFunctionData(
16
- "deposit(uint256,address)",
17
- [amount, recipient]
18
- );
19
- } else if (amount) {
20
- return contractInterface.encodeFunctionData(
21
- "deposit(uint256)",
22
- [amount]
23
- );
24
- } else {
25
- return contractInterface.encodeFunctionData(
26
- "deposit()"
27
- );
28
- }
8
+ public static deposit(amount?: BigNumberish, recipient?: string): string {
9
+ const contractInterface = YearnV2Adapter__factory.createInterface();
10
+ if (amount && recipient) {
11
+ return contractInterface.encodeFunctionData("deposit(uint256,address)", [
12
+ amount,
13
+ recipient
14
+ ]);
29
15
  }
16
+ if (amount) {
17
+ return contractInterface.encodeFunctionData("deposit(uint256)", [amount]);
18
+ }
19
+ return contractInterface.encodeFunctionData("deposit()");
20
+ }
30
21
 
31
- public static withdraw(maxShares?: BigNumberish, recipient?: string, maxLoss?: BigNumberish): string {
32
- let contractInterface = YearnV2Adapter__factory.createInterface();
33
- if (maxShares && recipient && maxLoss) {
34
- return contractInterface.encodeFunctionData(
35
- "withdraw(uint256,address,uint256)",
36
- [maxShares, recipient, maxLoss]
37
- );
38
- }
39
- if (maxShares && recipient) {
40
- return contractInterface.encodeFunctionData(
41
- "withdraw(uint256,address)",
42
- [maxShares, recipient]
43
- );
44
- } else if (maxShares) {
45
- return contractInterface.encodeFunctionData(
46
- "withdraw(uint256)",
47
- [maxShares]
48
- );
49
- } else {
50
- return contractInterface.encodeFunctionData(
51
- "withdraw()"
52
- );
53
- }
22
+ public static withdraw(
23
+ maxShares?: BigNumberish,
24
+ recipient?: string,
25
+ maxLoss?: BigNumberish
26
+ ): string {
27
+ const contractInterface = YearnV2Adapter__factory.createInterface();
28
+ if (maxShares && recipient && maxLoss) {
29
+ return contractInterface.encodeFunctionData(
30
+ "withdraw(uint256,address,uint256)",
31
+ [maxShares, recipient, maxLoss]
32
+ );
33
+ }
34
+ if (maxShares && recipient) {
35
+ return contractInterface.encodeFunctionData("withdraw(uint256,address)", [
36
+ maxShares,
37
+ recipient
38
+ ]);
54
39
  }
40
+ if (maxShares) {
41
+ return contractInterface.encodeFunctionData("withdraw(uint256)", [
42
+ maxShares
43
+ ]);
44
+ }
45
+ return contractInterface.encodeFunctionData("withdraw()");
46
+ }
55
47
  }
56
48
 
57
49
  export class YearnV2Multicaller {
58
- private readonly _address: string;
50
+ private readonly _address: string;
59
51
 
60
- constructor(address: string) {
61
- this._address = address;
62
- }
52
+ constructor(address: string) {
53
+ this._address = address;
54
+ }
63
55
 
64
- deposit(amount?: BigNumberish, recipient?: string): MultiCallStruct {
65
- return {
66
- target: this._address,
67
- callData: YearnV2Calls.deposit(amount, recipient)
68
- };
69
- }
56
+ deposit(amount?: BigNumberish, recipient?: string): MultiCallStruct {
57
+ return {
58
+ target: this._address,
59
+ callData: YearnV2Calls.deposit(amount, recipient)
60
+ };
61
+ }
70
62
 
71
- withdraw(maxShares?: BigNumberish, recipient?: string, maxLoss?: BigNumberish): MultiCallStruct {
72
- return {
73
- target: this._address,
74
- callData: YearnV2Calls.withdraw(maxShares, recipient, maxLoss)
75
- };
76
- }
63
+ withdraw(
64
+ maxShares?: BigNumberish,
65
+ recipient?: string,
66
+ maxLoss?: BigNumberish
67
+ ): MultiCallStruct {
68
+ return {
69
+ target: this._address,
70
+ callData: YearnV2Calls.withdraw(maxShares, recipient, maxLoss)
71
+ };
72
+ }
77
73
  }
@@ -1,8 +1,8 @@
1
- import {NormalToken} from "./normal";
1
+ import { NormalToken } from "./normal";
2
2
 
3
3
  export const connectorTokens: Array<NormalToken> = [
4
- "DAI",
5
- "USDC",
6
- "WETH",
7
- "WBTC"
8
- ];
4
+ "DAI",
5
+ "USDC",
6
+ "WETH",
7
+ "WBTC"
8
+ ];