File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -252,13 +252,19 @@ contract CometSupplyMultipleAssetsAndBorrow {
252
252
}
253
253
254
254
for (uint256 i = 0 ; i < assets.length ;) {
255
- IERC20 (assets[i]).forceApprove (comet, amounts[i]);
256
- IComet (comet).supply (assets[i], amounts[i]);
255
+ if (amounts[i] > 0 ) {
256
+ IERC20 (assets[i]).forceApprove (comet, amounts[i]);
257
+ IComet (comet).supply (assets[i], amounts[i]);
258
+ }
259
+
257
260
unchecked {
258
261
++ i;
259
262
}
260
263
}
261
- IComet (comet).withdraw (baseAsset, borrow);
264
+
265
+ if (borrow > 0 ) {
266
+ IComet (comet).withdraw (baseAsset, borrow);
267
+ }
262
268
}
263
269
}
264
270
@@ -273,10 +279,16 @@ contract CometRepayAndWithdrawMultipleAssets {
273
279
revert DeFiScriptErrors.InvalidInput ();
274
280
}
275
281
276
- IERC20 (baseAsset).forceApprove (comet, repay);
277
- IComet (comet).supply (baseAsset, repay);
282
+ if (repay > 0 ) {
283
+ IERC20 (baseAsset).forceApprove (comet, repay);
284
+ IComet (comet).supply (baseAsset, repay);
285
+ }
286
+
278
287
for (uint256 i = 0 ; i < assets.length ;) {
279
- IComet (comet).withdraw (assets[i], amounts[i]);
288
+ if (amounts[i] > 0 ) {
289
+ IComet (comet).withdraw (assets[i], amounts[i]);
290
+ }
291
+
280
292
unchecked {
281
293
++ i;
282
294
}
You can’t perform that action at this time.
0 commit comments