@@ -315,6 +315,102 @@ describe('WAMPL:withdrawTo', () => {
315
315
} )
316
316
} )
317
317
318
+ describe ( 'WAMPL:withdrawAll' , ( ) => {
319
+ beforeEach ( 'setup WAMPL contract' , setupContracts )
320
+
321
+ let r : any , amplesDeposited : BigNumber , wamplesMinted : BigNumber
322
+ beforeEach ( async function ( ) {
323
+ // 2% of AMPL total supply
324
+ amplesDeposited = toAMPLFixedPt ( '1000000' )
325
+
326
+ // 2 % of MAX_WAMPL_SUPPLY
327
+ wamplesMinted = await wAMPL . underlyingToWrapper ( amplesDeposited )
328
+
329
+ await ampl . connect ( deployer ) . approve ( wAMPL . address , amplesDeposited )
330
+ await wAMPL . connect ( deployer ) . deposit ( amplesDeposited )
331
+
332
+ expect ( await wAMPL . wrapperToUnderlying ( wamplesMinted ) ) . to . eq (
333
+ amplesDeposited ,
334
+ )
335
+ expect ( await wAMPL . connect ( deployer ) . callStatic . withdrawAll ( ) ) . to . eq (
336
+ wamplesMinted ,
337
+ )
338
+
339
+ r = wAMPL . connect ( deployer ) . withdrawAll ( )
340
+ await r
341
+ } )
342
+
343
+ it ( 'should burn wamples' , async function ( ) {
344
+ expect ( await ampl . balanceOf ( wAMPL . address ) ) . to . eq ( '0' )
345
+ expect ( await wAMPL . totalUnderlying ( ) ) . to . eq ( '0' )
346
+ expect ( await wAMPL . balanceOfUnderlying ( deployerAddress ) ) . to . eq ( '0' )
347
+
348
+ expect ( await wAMPL . totalSupply ( ) ) . to . eq ( '0' )
349
+ expect ( await wAMPL . balanceOf ( deployerAddress ) ) . to . eq ( '0' )
350
+ } )
351
+
352
+ it ( 'should log transfer' , async function ( ) {
353
+ await expect ( r )
354
+ . to . emit ( ampl , 'Transfer' )
355
+ . withArgs ( wAMPL . address , deployerAddress , amplesDeposited )
356
+ } )
357
+
358
+ it ( 'should log burn' , async function ( ) {
359
+ await expect ( r )
360
+ . to . emit ( wAMPL , 'Transfer' )
361
+ . withArgs ( deployerAddress , ethers . constants . AddressZero , wamplesMinted )
362
+ } )
363
+ } )
364
+
365
+ describe ( 'WAMPL:withdrawAllTo' , ( ) => {
366
+ beforeEach ( 'setup WAMPL contract' , setupContracts )
367
+
368
+ let r : any , amplesDeposited : BigNumber , wamplesMinted : BigNumber
369
+ beforeEach ( async function ( ) {
370
+ // 2% of AMPL total supply
371
+ amplesDeposited = toAMPLFixedPt ( '1000000' )
372
+
373
+ // 2 % of MAX_WAMPL_SUPPLY
374
+ wamplesMinted = await wAMPL . underlyingToWrapper ( amplesDeposited )
375
+
376
+ await ampl . connect ( deployer ) . approve ( wAMPL . address , amplesDeposited )
377
+ await wAMPL . connect ( deployer ) . deposit ( amplesDeposited )
378
+
379
+ expect ( await wAMPL . wrapperToUnderlying ( wamplesMinted ) ) . to . eq (
380
+ amplesDeposited ,
381
+ )
382
+ expect (
383
+ await wAMPL . connect ( deployer ) . callStatic . withdrawAllTo ( userBAddress ) ,
384
+ ) . to . eq ( wamplesMinted )
385
+
386
+ r = wAMPL . connect ( deployer ) . withdrawAllTo ( userBAddress )
387
+ await r
388
+ } )
389
+
390
+ it ( 'should burn wamples' , async function ( ) {
391
+ expect ( await ampl . balanceOf ( wAMPL . address ) ) . to . eq ( '0' )
392
+ expect ( await wAMPL . totalUnderlying ( ) ) . to . eq ( '0' )
393
+ expect ( await wAMPL . balanceOfUnderlying ( userBAddress ) ) . to . eq ( '0' )
394
+ expect ( await wAMPL . balanceOfUnderlying ( deployerAddress ) ) . to . eq ( '0' )
395
+
396
+ expect ( await wAMPL . totalSupply ( ) ) . to . eq ( '0' )
397
+ expect ( await wAMPL . balanceOf ( userBAddress ) ) . to . eq ( '0' )
398
+ expect ( await wAMPL . balanceOf ( deployerAddress ) ) . to . eq ( '0' )
399
+ } )
400
+
401
+ it ( 'should log transfer' , async function ( ) {
402
+ await expect ( r )
403
+ . to . emit ( ampl , 'Transfer' )
404
+ . withArgs ( wAMPL . address , userBAddress , amplesDeposited )
405
+ } )
406
+
407
+ it ( 'should log burn' , async function ( ) {
408
+ await expect ( r )
409
+ . to . emit ( wAMPL , 'Transfer' )
410
+ . withArgs ( deployerAddress , ethers . constants . AddressZero , wamplesMinted )
411
+ } )
412
+ } )
413
+
318
414
describe ( 'WAMPL:mint' , ( ) => {
319
415
beforeEach ( 'setup WAMPL contract' , setupContracts )
320
416
@@ -541,7 +637,7 @@ describe('WAMPL:burnTo', () => {
541
637
} )
542
638
} )
543
639
544
- describe ( 'WAMPL:withdrawAll ' , ( ) => {
640
+ describe ( 'WAMPL:burnAll ' , ( ) => {
545
641
beforeEach ( 'setup WAMPL contract' , setupContracts )
546
642
547
643
let r : any , amplesDeposited : BigNumber , wamplesMinted : BigNumber
@@ -558,11 +654,11 @@ describe('WAMPL:withdrawAll', () => {
558
654
expect ( await wAMPL . wrapperToUnderlying ( wamplesMinted ) ) . to . eq (
559
655
amplesDeposited ,
560
656
)
561
- expect ( await wAMPL . connect ( deployer ) . callStatic . withdrawAll ( ) ) . to . eq (
562
- wamplesMinted ,
657
+ expect ( await wAMPL . connect ( deployer ) . callStatic . burnAll ( ) ) . to . eq (
658
+ amplesDeposited ,
563
659
)
564
660
565
- r = wAMPL . connect ( deployer ) . withdrawAll ( )
661
+ r = wAMPL . connect ( deployer ) . burnAll ( )
566
662
await r
567
663
} )
568
664
@@ -588,7 +684,7 @@ describe('WAMPL:withdrawAll', () => {
588
684
} )
589
685
} )
590
686
591
- describe ( 'WAMPL:withdrawAllTo ' , ( ) => {
687
+ describe ( 'WAMPL:burnAllTo ' , ( ) => {
592
688
beforeEach ( 'setup WAMPL contract' , setupContracts )
593
689
594
690
let r : any , amplesDeposited : BigNumber , wamplesMinted : BigNumber
@@ -606,8 +702,8 @@ describe('WAMPL:withdrawAllTo', () => {
606
702
amplesDeposited ,
607
703
)
608
704
expect (
609
- await wAMPL . connect ( deployer ) . callStatic . withdrawAllTo ( userBAddress ) ,
610
- ) . to . eq ( wamplesMinted )
705
+ await wAMPL . connect ( deployer ) . callStatic . burnAllTo ( userBAddress ) ,
706
+ ) . to . eq ( amplesDeposited )
611
707
612
708
r = wAMPL . connect ( deployer ) . withdrawAllTo ( userBAddress )
613
709
await r
0 commit comments