@gearbox-protocol/sdk 0.0.102 → 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.
- package/.eslintignore +4 -0
- package/.eslintrc.js +52 -0
- package/.husky/pre-push +4 -0
- package/lib/apy/convexAPY.js +3 -5
- package/lib/apy/lidoAPY.js +8 -9
- package/lib/contracts/contracts.d.ts +3 -3
- package/lib/contracts/contracts.js +2 -2
- package/lib/core/constants.d.ts +1 -1
- package/lib/core/constants.js +2 -2
- package/lib/core/creditAccount.js +7 -5
- package/lib/core/creditManager.d.ts +1 -1
- package/lib/core/creditManager.js +1 -7
- package/lib/core/creditSession.js +14 -3
- package/lib/core/eventOrTx.d.ts +1 -1
- package/lib/core/events.d.ts +19 -19
- package/lib/core/events.js +23 -21
- package/lib/core/pool.d.ts +1 -1
- package/lib/core/pool.js +1 -7
- package/lib/core/price.js +6 -1
- package/lib/core/strategy.d.ts +1 -3
- package/lib/core/strategy.js +14 -13
- package/lib/core/tokenDistributor.js +1 -1
- package/lib/core/transactions.d.ts +18 -3
- package/lib/core/transactions.js +39 -3
- package/lib/index.d.ts +1 -2
- package/lib/index.js +1 -1
- package/lib/oracles/priceFeeds.js +1 -1
- package/lib/pathfinder/convexLP.d.ts +1 -1
- package/lib/pathfinder/convexLP.js +26 -29
- package/lib/pathfinder/curveLP.d.ts +1 -1
- package/lib/pathfinder/curveLP.js +5 -7
- package/lib/pathfinder/path.d.ts +1 -1
- package/lib/pathfinder/path.js +38 -42
- package/lib/pathfinder/trade.d.ts +1 -2
- package/lib/pathfinder/tradeTypes.d.ts +5 -5
- package/lib/pathfinder/yVault.d.ts +2 -2
- package/lib/pathfinder/yVault.js +18 -15
- package/lib/strategies/curve.d.ts +6 -60
- package/lib/strategies/curve.js +6 -0
- package/lib/strategies/uniswapV2.js +3 -19
- package/lib/strategies/uniswapV3.js +1 -1
- package/lib/strategies/yearn.js +15 -11
- package/lib/tokens/convex.d.ts +3 -3
- package/lib/tokens/curveLP.d.ts +2 -2
- package/lib/tokens/curveLP.js +1 -1
- package/lib/tokens/gear.d.ts +2 -2
- package/lib/tokens/gear.js +1 -1
- package/lib/tokens/normal.d.ts +1 -1
- package/lib/tokens/token.js +4 -4
- package/lib/tokens/tokenData.d.ts +3 -1
- package/lib/tokens/tokenData.js +10 -8
- package/lib/tokens/yearn.d.ts +3 -3
- package/lib/utils/errors.d.ts +6 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/formatter.d.ts +1 -1
- package/lib/utils/formatter.js +17 -14
- package/lib/utils/loading.d.ts +2 -1
- package/lib/utils/loading.js +9 -13
- package/lib/utils/mappers.js +2 -2
- package/lib/utils/network.js +2 -2
- package/lib/utils/repeater.js +12 -24
- package/lib/utils/validate.js +1 -1
- package/package.json +26 -8
- package/src/apy/convexAPY.ts +6 -6
- package/src/apy/lidoAPY.ts +12 -11
- package/src/contracts/contracts.ts +8 -7
- package/src/core/constants.ts +1 -1
- package/src/core/creditAccount.ts +28 -5
- package/src/core/creditManager.ts +29 -4
- package/src/core/creditOperation.ts +7 -7
- package/src/core/creditSession.ts +25 -5
- package/src/core/errors.ts +1 -0
- package/src/core/eventOrTx.ts +8 -5
- package/src/core/events.ts +85 -24
- package/src/core/history.ts +46 -46
- package/src/core/operations.ts +6 -0
- package/src/core/pool.ts +16 -4
- package/src/core/price.ts +7 -3
- package/src/core/strategy.ts +27 -23
- package/src/core/tokenDistributor.ts +2 -2
- package/src/core/transactions.ts +427 -350
- package/src/index.ts +1 -3
- package/src/oracles/priceFeeds.ts +523 -523
- package/src/pathfinder/contracts.ts +15 -13
- package/src/pathfinder/convexLP.ts +29 -25
- package/src/pathfinder/curveLP.ts +57 -53
- package/src/pathfinder/path.ts +17 -9
- package/src/pathfinder/priority.ts +11 -11
- package/src/pathfinder/trade.ts +84 -77
- package/src/pathfinder/tradeTypes.ts +98 -94
- package/src/pathfinder/yVault.ts +26 -11
- package/src/payload/token.ts +3 -3
- package/src/strategies/convex.ts +217 -210
- package/src/strategies/creditFacade.ts +70 -53
- package/src/strategies/curve.ts +263 -194
- package/src/strategies/lido.ts +33 -37
- package/src/strategies/uniswapV2.ts +90 -112
- package/src/strategies/uniswapV3.ts +114 -91
- package/src/strategies/yearn.ts +58 -62
- package/src/tokens/connectors.ts +6 -6
- package/src/tokens/convex.ts +297 -296
- package/src/tokens/curveLP.ts +170 -165
- package/src/tokens/gear.ts +47 -45
- package/src/tokens/normal.ts +801 -802
- package/src/tokens/token.ts +9 -5
- package/src/tokens/tokenData.ts +19 -9
- package/src/tokens/tokenType.ts +11 -11
- package/src/tokens/yearn.ts +126 -124
- package/src/utils/errors.ts +11 -0
- package/src/utils/formatter.ts +22 -18
- package/src/utils/loading.ts +14 -6
- package/src/utils/mappers.ts +8 -6
- package/src/utils/multicall.ts +2 -0
- package/src/utils/network.ts +21 -21
- package/src/utils/repeater.ts +2 -2
- package/src/utils/validate.ts +1 -1
- package/lib/utils/events.d.ts +0 -2
- package/lib/utils/events.js +0 -13
- package/src/utils/events.ts +0 -10
package/src/strategies/convex.ts
CHANGED
|
@@ -1,233 +1,240 @@
|
|
|
1
1
|
import { BigNumberish } from "ethers";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
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
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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 {
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
public static increaseDebt(amount: BigNumberish) {
|
|
22
|
+
return ICreditFacade__factory.createInterface().encodeFunctionData(
|
|
23
|
+
"increaseDebt",
|
|
24
|
+
[amount]
|
|
25
|
+
);
|
|
26
|
+
}
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
public static decreaseDebt(amount: BigNumberish) {
|
|
29
|
+
return ICreditFacade__factory.createInterface().encodeFunctionData(
|
|
30
|
+
"decreaseDebt",
|
|
31
|
+
[amount]
|
|
32
|
+
);
|
|
33
|
+
}
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
47
|
+
private readonly _address: string;
|
|
38
48
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
49
|
+
constructor(address: string) {
|
|
50
|
+
this._address = address;
|
|
51
|
+
}
|
|
42
52
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
increaseDebt(amount: BigNumberish): MultiCallStruct {
|
|
65
|
+
return {
|
|
66
|
+
target: this._address,
|
|
67
|
+
callData: CreditFacadeCalls.increaseDebt(amount)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
56
70
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
decreaseDebt(amount: BigNumberish): MultiCallStruct {
|
|
72
|
+
return {
|
|
73
|
+
target: this._address,
|
|
74
|
+
callData: CreditFacadeCalls.decreaseDebt(amount)
|
|
75
|
+
};
|
|
76
|
+
}
|
|
63
77
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
}
|