@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,233 +1,240 @@
1
1
  import { BigNumberish } from "ethers";
2
2
 
3
3
  import {
4
- ConvexV1BoosterAdapter__factory,
5
- ConvexV1BaseRewardPoolAdapter__factory,
6
- ConvexV1ClaimZapAdapter__factory
7
- } from "../types"
4
+ ConvexV1BoosterAdapter__factory,
5
+ ConvexV1BaseRewardPoolAdapter__factory,
6
+ ConvexV1ClaimZapAdapter__factory
7
+ } from "../types";
8
8
 
9
9
  import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
10
10
 
11
11
  export class ConvexBoosterCalls {
12
- public static deposit(pid: BigNumberish, amount: BigNumberish, stake: boolean) {
13
- return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
14
- "deposit",
15
- [pid, amount, stake]
16
- );
17
- }
18
-
19
- public static depositAll(pid: BigNumberish, stake: boolean) {
20
- return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
21
- "depositAll",
22
- [pid, stake]
23
- );
24
- }
25
-
26
- public static withdraw(pid: BigNumberish, amount: BigNumberish) {
27
- return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
28
- "withdraw",
29
- [pid, amount]
30
- );
31
- }
32
-
33
- public static withdrawAll(pid: BigNumberish) {
34
- return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
35
- "withdrawAll",
36
- [pid]
37
- );
38
- }
12
+ public static deposit(
13
+ pid: BigNumberish,
14
+ amount: BigNumberish,
15
+ stake: boolean
16
+ ) {
17
+ return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
18
+ "deposit",
19
+ [pid, amount, stake]
20
+ );
21
+ }
22
+
23
+ public static depositAll(pid: BigNumberish, stake: boolean) {
24
+ return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
25
+ "depositAll",
26
+ [pid, stake]
27
+ );
28
+ }
29
+
30
+ public static withdraw(pid: BigNumberish, amount: BigNumberish) {
31
+ return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
32
+ "withdraw",
33
+ [pid, amount]
34
+ );
35
+ }
36
+
37
+ public static withdrawAll(pid: BigNumberish) {
38
+ return ConvexV1BoosterAdapter__factory.createInterface().encodeFunctionData(
39
+ "withdrawAll",
40
+ [pid]
41
+ );
42
+ }
39
43
  }
40
44
 
41
45
  export class ConvexPoolCalls {
42
- public static stake(amount: BigNumberish) {
43
- return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
44
- "stake",
45
- [amount]
46
- );
47
- }
48
-
49
- public static stakeAll() {
50
- return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
51
- "stakeAll"
52
- );
53
- }
54
-
55
- public static withdraw(amount: BigNumberish, claim: boolean) {
56
- return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
57
- "withdraw",
58
- [amount, claim]
59
- );
60
- }
61
-
62
- public static withdrawAll(claim: boolean) {
63
- return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
64
- "withdrawAll",
65
- [claim]
66
- );
67
- }
68
-
69
- public static withdrawAndUnwrap(amount: BigNumberish, claim: boolean) {
70
- return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
71
- "withdrawAndUnwrap",
72
- [amount, claim]
73
- );
74
- }
75
-
76
- public static withdrawAllAndUnwrap(claim: boolean) {
77
- return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
78
- "withdrawAllAndUnwrap",
79
- [claim]
80
- );
81
- }
46
+ public static stake(amount: BigNumberish) {
47
+ return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
48
+ "stake",
49
+ [amount]
50
+ );
51
+ }
52
+
53
+ public static stakeAll() {
54
+ return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
55
+ "stakeAll"
56
+ );
57
+ }
58
+
59
+ public static withdraw(amount: BigNumberish, claim: boolean) {
60
+ return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
61
+ "withdraw",
62
+ [amount, claim]
63
+ );
64
+ }
65
+
66
+ public static withdrawAll(claim: boolean) {
67
+ return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
68
+ "withdrawAll",
69
+ [claim]
70
+ );
71
+ }
72
+
73
+ public static withdrawAndUnwrap(amount: BigNumberish, claim: boolean) {
74
+ return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
75
+ "withdrawAndUnwrap",
76
+ [amount, claim]
77
+ );
78
+ }
79
+
80
+ public static withdrawAllAndUnwrap(claim: boolean) {
81
+ return ConvexV1BaseRewardPoolAdapter__factory.createInterface().encodeFunctionData(
82
+ "withdrawAllAndUnwrap",
83
+ [claim]
84
+ );
85
+ }
82
86
  }
83
87
 
84
-
85
88
  export class ConvexClaimZapCalls {
86
- public static claimRewards(
87
- rewardContracts: Array<string>,
88
- extraRewardContracts: Array<string>,
89
- tokenRewardContracts: Array<string>,
90
- tokenRewardTokens: Array<string>,
91
- depositCrvMaxAmount: BigNumberish,
92
- minAmountOut: BigNumberish,
93
- depositCvxMaxAmount: BigNumberish,
94
- spendCvxAmount: BigNumberish,
95
- options: BigNumberish
96
- ) {
97
- return ConvexV1ClaimZapAdapter__factory.createInterface().encodeFunctionData(
98
- "claimRewards",
99
- [
100
- rewardContracts,
101
- extraRewardContracts,
102
- tokenRewardContracts,
103
- tokenRewardTokens,
104
- depositCrvMaxAmount,
105
- minAmountOut,
106
- depositCvxMaxAmount,
107
- spendCvxAmount,
108
- options
109
- ]
110
- );
111
- }
89
+ public static claimRewards(
90
+ rewardContracts: Array<string>,
91
+ extraRewardContracts: Array<string>,
92
+ tokenRewardContracts: Array<string>,
93
+ tokenRewardTokens: Array<string>,
94
+ depositCrvMaxAmount: BigNumberish,
95
+ minAmountOut: BigNumberish,
96
+ depositCvxMaxAmount: BigNumberish,
97
+ spendCvxAmount: BigNumberish,
98
+ options: BigNumberish
99
+ ) {
100
+ return ConvexV1ClaimZapAdapter__factory.createInterface().encodeFunctionData(
101
+ "claimRewards",
102
+ [
103
+ rewardContracts,
104
+ extraRewardContracts,
105
+ tokenRewardContracts,
106
+ tokenRewardTokens,
107
+ depositCrvMaxAmount,
108
+ minAmountOut,
109
+ depositCvxMaxAmount,
110
+ spendCvxAmount,
111
+ options
112
+ ]
113
+ );
114
+ }
112
115
  }
113
116
 
114
117
  export class ConvexBoosterMulticaller {
115
- private readonly _address: string;
116
-
117
- constructor(address: string) {
118
- this._address = address;
119
- }
120
-
121
- deposit(pid: BigNumberish, amount: BigNumberish, stake: boolean): MultiCallStruct {
122
- return {
123
- target: this._address,
124
- callData: ConvexBoosterCalls.deposit(pid, amount, stake)
125
- }
126
- }
127
-
128
- depositAll(pid: BigNumberish, stake: boolean): MultiCallStruct {
129
- return {
130
- target: this._address,
131
- callData: ConvexBoosterCalls.depositAll(pid, stake)
132
- }
133
- }
134
-
135
- withdraw(pid: BigNumberish, amount: BigNumberish): MultiCallStruct {
136
- return {
137
- target: this._address,
138
- callData: ConvexBoosterCalls.withdraw(pid, amount)
139
- }
140
- }
141
-
142
- withdrawAll(pid: BigNumberish): MultiCallStruct {
143
- return {
144
- target: this._address,
145
- callData: ConvexBoosterCalls.withdrawAll(pid)
146
- }
147
- }
118
+ private readonly _address: string;
119
+
120
+ constructor(address: string) {
121
+ this._address = address;
122
+ }
123
+
124
+ deposit(
125
+ pid: BigNumberish,
126
+ amount: BigNumberish,
127
+ stake: boolean
128
+ ): MultiCallStruct {
129
+ return {
130
+ target: this._address,
131
+ callData: ConvexBoosterCalls.deposit(pid, amount, stake)
132
+ };
133
+ }
134
+
135
+ depositAll(pid: BigNumberish, stake: boolean): MultiCallStruct {
136
+ return {
137
+ target: this._address,
138
+ callData: ConvexBoosterCalls.depositAll(pid, stake)
139
+ };
140
+ }
141
+
142
+ withdraw(pid: BigNumberish, amount: BigNumberish): MultiCallStruct {
143
+ return {
144
+ target: this._address,
145
+ callData: ConvexBoosterCalls.withdraw(pid, amount)
146
+ };
147
+ }
148
+
149
+ withdrawAll(pid: BigNumberish): MultiCallStruct {
150
+ return {
151
+ target: this._address,
152
+ callData: ConvexBoosterCalls.withdrawAll(pid)
153
+ };
154
+ }
148
155
  }
149
156
 
150
157
  export class ConvexPoolMulticaller {
151
- private readonly _address: string;
152
-
153
- constructor(address: string) {
154
- this._address = address;
155
- }
156
-
157
- stake(amount: BigNumberish): MultiCallStruct {
158
- return {
159
- target: this._address,
160
- callData: ConvexPoolCalls.stake(amount)
161
- }
162
- }
163
-
164
- stakeAll(): MultiCallStruct {
165
- return {
166
- target: this._address,
167
- callData: ConvexPoolCalls.stakeAll()
168
- }
169
- }
170
-
171
- withdraw(amount: BigNumberish, claim: boolean): MultiCallStruct {
172
- return {
173
- target: this._address,
174
- callData: ConvexPoolCalls.withdraw(amount, claim)
175
- }
176
- }
177
-
178
- withdrawAll(claim: boolean): MultiCallStruct {
179
- return {
180
- target: this._address,
181
- callData: ConvexPoolCalls.withdrawAll(claim)
182
- }
183
- }
184
-
185
- withdrawAndUnwrap(amount: BigNumberish, claim: boolean): MultiCallStruct {
186
- return {
187
- target: this._address,
188
- callData: ConvexPoolCalls.withdrawAndUnwrap(amount, claim)
189
- }
190
- }
191
-
192
- withdrawAllAndUnwrap(claim: boolean) {
193
- return {
194
- target: this._address,
195
- callData: ConvexPoolCalls.withdrawAllAndUnwrap(claim)
196
- }
197
- }
158
+ private readonly _address: string;
159
+
160
+ constructor(address: string) {
161
+ this._address = address;
162
+ }
163
+
164
+ stake(amount: BigNumberish): MultiCallStruct {
165
+ return {
166
+ target: this._address,
167
+ callData: ConvexPoolCalls.stake(amount)
168
+ };
169
+ }
170
+
171
+ stakeAll(): MultiCallStruct {
172
+ return {
173
+ target: this._address,
174
+ callData: ConvexPoolCalls.stakeAll()
175
+ };
176
+ }
177
+
178
+ withdraw(amount: BigNumberish, claim: boolean): MultiCallStruct {
179
+ return {
180
+ target: this._address,
181
+ callData: ConvexPoolCalls.withdraw(amount, claim)
182
+ };
183
+ }
184
+
185
+ withdrawAll(claim: boolean): MultiCallStruct {
186
+ return {
187
+ target: this._address,
188
+ callData: ConvexPoolCalls.withdrawAll(claim)
189
+ };
190
+ }
191
+
192
+ withdrawAndUnwrap(amount: BigNumberish, claim: boolean): MultiCallStruct {
193
+ return {
194
+ target: this._address,
195
+ callData: ConvexPoolCalls.withdrawAndUnwrap(amount, claim)
196
+ };
197
+ }
198
+
199
+ withdrawAllAndUnwrap(claim: boolean) {
200
+ return {
201
+ target: this._address,
202
+ callData: ConvexPoolCalls.withdrawAllAndUnwrap(claim)
203
+ };
204
+ }
198
205
  }
199
206
 
200
207
  export class ConvexClaimZapMulticaller {
201
- private readonly _address: string;
202
-
203
- constructor(address: string) {
204
- this._address = address;
205
- }
206
-
207
- claimRewards(
208
- rewardContracts: Array<string>,
209
- extraRewardContracts: Array<string>,
210
- tokenRewardContracts: Array<string>,
211
- tokenRewardTokens: Array<string>,
212
- depositCrvMaxAmount: BigNumberish,
213
- minAmountOut: BigNumberish,
214
- depositCvxMaxAmount: BigNumberish,
215
- spendCvxAmount: BigNumberish,
216
- options: BigNumberish
217
- ): MultiCallStruct {
218
- return {
219
- target: this._address,
220
- callData: ConvexClaimZapCalls.claimRewards(
221
- rewardContracts,
222
- extraRewardContracts,
223
- tokenRewardContracts,
224
- tokenRewardTokens,
225
- depositCrvMaxAmount,
226
- minAmountOut,
227
- depositCvxMaxAmount,
228
- spendCvxAmount,
229
- options
230
- )
231
- }
232
- }
208
+ private readonly _address: string;
209
+
210
+ constructor(address: string) {
211
+ this._address = address;
212
+ }
213
+
214
+ claimRewards(
215
+ rewardContracts: Array<string>,
216
+ extraRewardContracts: Array<string>,
217
+ tokenRewardContracts: Array<string>,
218
+ tokenRewardTokens: Array<string>,
219
+ depositCrvMaxAmount: BigNumberish,
220
+ minAmountOut: BigNumberish,
221
+ depositCvxMaxAmount: BigNumberish,
222
+ spendCvxAmount: BigNumberish,
223
+ options: BigNumberish
224
+ ): MultiCallStruct {
225
+ return {
226
+ target: this._address,
227
+ callData: ConvexClaimZapCalls.claimRewards(
228
+ rewardContracts,
229
+ extraRewardContracts,
230
+ tokenRewardContracts,
231
+ tokenRewardTokens,
232
+ depositCrvMaxAmount,
233
+ minAmountOut,
234
+ depositCvxMaxAmount,
235
+ spendCvxAmount,
236
+ options
237
+ )
238
+ };
239
+ }
233
240
  }
@@ -1,70 +1,87 @@
1
1
  import { BigNumberish } from "ethers";
2
2
 
3
- import { ICreditFacade__factory, ICreditFacadeBalanceChecker__factory } from "../types";
3
+ import {
4
+ ICreditFacade__factory,
5
+ ICreditFacadeBalanceChecker__factory
6
+ } from "../types";
4
7
  import { MultiCallStruct } from "../types/contracts/interfaces/ICreditFacade.sol/ICreditFacade";
5
8
 
6
9
  export class CreditFacadeCalls {
7
- public static addCollateral(onBehalfOf: string, token: string, amount: BigNumberish) {
8
- return ICreditFacade__factory.createInterface().encodeFunctionData(
9
- "addCollateral",
10
- [onBehalfOf, token, amount]
11
- )
12
- }
10
+ public static addCollateral(
11
+ onBehalfOf: string,
12
+ token: string,
13
+ amount: BigNumberish
14
+ ) {
15
+ return ICreditFacade__factory.createInterface().encodeFunctionData(
16
+ "addCollateral",
17
+ [onBehalfOf, token, amount]
18
+ );
19
+ }
13
20
 
14
- public static increaseDebt(amount: BigNumberish) {
15
- return ICreditFacade__factory.createInterface().encodeFunctionData(
16
- "increaseDebt",
17
- [amount]
18
- )
19
- }
21
+ public static increaseDebt(amount: BigNumberish) {
22
+ return ICreditFacade__factory.createInterface().encodeFunctionData(
23
+ "increaseDebt",
24
+ [amount]
25
+ );
26
+ }
20
27
 
21
- public static decreaseDebt(amount: BigNumberish) {
22
- return ICreditFacade__factory.createInterface().encodeFunctionData(
23
- "decreaseDebt",
24
- [amount]
25
- )
26
- }
28
+ public static decreaseDebt(amount: BigNumberish) {
29
+ return ICreditFacade__factory.createInterface().encodeFunctionData(
30
+ "decreaseDebt",
31
+ [amount]
32
+ );
33
+ }
27
34
 
28
- public static revertIfBalanceLessThan(token: string, minBalance: BigNumberish) {
29
- return ICreditFacadeBalanceChecker__factory.createInterface().encodeFunctionData(
30
- "revertIfBalanceLessThan",
31
- [token, minBalance]
32
- )
33
- }
35
+ public static revertIfBalanceLessThan(
36
+ token: string,
37
+ minBalance: BigNumberish
38
+ ) {
39
+ return ICreditFacadeBalanceChecker__factory.createInterface().encodeFunctionData(
40
+ "revertIfBalanceLessThan",
41
+ [token, minBalance]
42
+ );
43
+ }
34
44
  }
35
45
 
36
46
  export class CreditFacadeMulticaller {
37
- private readonly _address: string;
47
+ private readonly _address: string;
38
48
 
39
- constructor(address: string) {
40
- this._address = address;
41
- }
49
+ constructor(address: string) {
50
+ this._address = address;
51
+ }
42
52
 
43
- addCollateral(onBehalfOf: string, token: string, amount: BigNumberish): MultiCallStruct {
44
- return {
45
- target: this._address,
46
- callData: CreditFacadeCalls.addCollateral(onBehalfOf, token, amount)
47
- }
48
- }
53
+ addCollateral(
54
+ onBehalfOf: string,
55
+ token: string,
56
+ amount: BigNumberish
57
+ ): MultiCallStruct {
58
+ return {
59
+ target: this._address,
60
+ callData: CreditFacadeCalls.addCollateral(onBehalfOf, token, amount)
61
+ };
62
+ }
49
63
 
50
- increaseDebt(amount: BigNumberish): MultiCallStruct {
51
- return {
52
- target: this._address,
53
- callData: CreditFacadeCalls.increaseDebt(amount)
54
- }
55
- }
64
+ increaseDebt(amount: BigNumberish): MultiCallStruct {
65
+ return {
66
+ target: this._address,
67
+ callData: CreditFacadeCalls.increaseDebt(amount)
68
+ };
69
+ }
56
70
 
57
- decreaseDebt(amount: BigNumberish): MultiCallStruct {
58
- return {
59
- target: this._address,
60
- callData: CreditFacadeCalls.decreaseDebt(amount)
61
- }
62
- }
71
+ decreaseDebt(amount: BigNumberish): MultiCallStruct {
72
+ return {
73
+ target: this._address,
74
+ callData: CreditFacadeCalls.decreaseDebt(amount)
75
+ };
76
+ }
63
77
 
64
- revertIfBalanceLessThan(token: string, minBalance: BigNumberish): MultiCallStruct {
65
- return {
66
- target: this._address,
67
- callData: CreditFacadeCalls.revertIfBalanceLessThan(token, minBalance)
68
- }
69
- }
78
+ revertIfBalanceLessThan(
79
+ token: string,
80
+ minBalance: BigNumberish
81
+ ): MultiCallStruct {
82
+ return {
83
+ target: this._address,
84
+ callData: CreditFacadeCalls.revertIfBalanceLessThan(token, minBalance)
85
+ };
86
+ }
70
87
  }