@@ -263,13 +263,26 @@ contract("BErc20", async (accounts) => {
263
263
expect ( await bETH . balanceOf ( a . user1 ) ) . to . be . bignumber . equal ( cETHBalance ) ;
264
264
expect ( await bBAT . balanceOf ( a . user1 ) ) . to . be . bignumber . equal ( cBATBalance ) ;
265
265
266
+ const avatar1 = await bProtocol . registry . getAvatar . call ( a . user1 ) ;
267
+ const assetsIn = await comptroller . getAssetsIn ( avatar1 ) ;
268
+
269
+ expect ( assetsIn . includes ( cZRX . address ) ) . to . be . equal ( true ) ;
270
+ expect ( assetsIn . includes ( cETH . address ) ) . to . be . equal ( true ) ;
271
+ expect ( assetsIn . includes ( cBAT . address ) ) . to . be . equal ( true ) ;
272
+
266
273
if ( checkDebtAfter ) {
267
274
console . log ( "checking debt after" ) ;
268
275
expect ( await bBAT . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal ( HUNDRED_BAT ) ;
269
276
expect ( await bUSDT . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal (
270
277
FIVE_HUNDRED_USDT ,
271
278
) ;
272
- } else console . log ( "skipping checking debt after" ) ;
279
+
280
+ expect ( assetsIn . length ) . to . be . equal ( 4 ) ;
281
+ expect ( assetsIn . includes ( cUSDT . address ) ) . to . be . equal ( true ) ;
282
+ } else {
283
+ expect ( assetsIn . length ) . to . be . equal ( 3 ) ;
284
+ console . log ( "skipping checking debt after" ) ;
285
+ }
273
286
274
287
console . log ( "checking delegate was revoked" ) ;
275
288
const avatar = await bProtocol . registry . getAvatar . call ( a . user1 ) ;
@@ -387,6 +400,45 @@ contract("BErc20", async (accounts) => {
387
400
checkDebtAfter = false ;
388
401
} ) ;
389
402
403
+ it ( "user should import without fees and with no debt without flashloan" , async ( ) => {
404
+ // repay the bat and usdt debt
405
+ await BAT . approve ( cBAT . address , HUNDRED_BAT , { from : a . user1 } ) ;
406
+ await cBAT . repayBorrow ( HUNDRED_BAT , { from : a . user1 } ) ;
407
+ await USDT . approve ( cUSDT . address , HUNDRED_BAT , { from : a . user1 } ) ;
408
+ await cUSDT . repayBorrow ( FIVE_HUNDRED_USDT , { from : a . user1 } ) ;
409
+
410
+ // make sure borrow balance was reset
411
+ expect ( await cBAT . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal ( ZERO ) ;
412
+ expect ( await cUSDT . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal ( ZERO ) ;
413
+
414
+ const avatar1 = await bProtocol . registry . getAvatar . call ( a . user1 ) ;
415
+ await cZRX . approve ( avatar1 , new BN ( 2 ) . pow ( new BN ( 255 ) ) , { from : a . user1 } ) ;
416
+ await cETH . approve ( avatar1 , new BN ( 2 ) . pow ( new BN ( 255 ) ) , { from : a . user1 } ) ;
417
+ await cBAT . approve ( avatar1 , new BN ( 2 ) . pow ( new BN ( 255 ) ) , { from : a . user1 } ) ;
418
+
419
+ // call flash import
420
+ const data = await bImport . contract . methods
421
+ . importCollateral (
422
+ [ cZRX . address , cETH . address , cBAT . address ]
423
+ )
424
+ . encodeABI ( ) ;
425
+
426
+ const tx = await bProtocol . registry . delegateAndExecuteOnce (
427
+ bImport . address ,
428
+ bImport . address ,
429
+ data ,
430
+ { from : a . user1 } ,
431
+ ) ;
432
+ console . log ( tx . receipt . gasUsed ) ;
433
+
434
+ // check balance
435
+ expect ( await bETH . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal ( ZERO ) ;
436
+ expect ( await bBAT . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal ( ZERO ) ;
437
+ expect ( await bUSDT . borrowBalanceCurrent . call ( a . user1 ) ) . to . be . bignumber . equal ( ZERO ) ;
438
+
439
+ checkDebtAfter = false ;
440
+ } ) ;
441
+
390
442
it ( "user should import with fees" , async ( ) => {
391
443
const avatar1 = await bProtocol . registry . getAvatar . call ( a . user1 ) ;
392
444
await cZRX . approve ( avatar1 , new BN ( 2 ) . pow ( new BN ( 255 ) ) , { from : a . user1 } ) ;
0 commit comments