@@ -317,235 +317,6 @@ const makeLP = async (
317
317
return me ;
318
318
} ;
319
319
320
- test . skip ( 'LP borrow - TODO: move to exo test' , async t => {
321
- const common = await commonSetup ( t ) ;
322
- const {
323
- brands : { usdc } ,
324
- utils,
325
- } = common ;
326
-
327
- const { instance, creatorFacet, zoe, metricsSub, terms } =
328
- await startContract ( common ) ;
329
-
330
- const usdcPurse = purseOf ( terms . issuers . USDC , utils ) ;
331
- const lps = {
332
- alice : makeLP ( 'Alice' , usdcPurse ( 100n ) , zoe , instance ) ,
333
- } ;
334
- // seed pool with funds
335
- await E ( lps . alice ) . deposit ( t , 100n ) ;
336
-
337
- const { value } = await E ( metricsSub ) . getUpdateSince ( ) ;
338
- const { shareWorth, encumberedBalance } = value ;
339
- const poolSeatAllocation = subtract (
340
- subtract ( shareWorth . numerator , encumberedBalance ) ,
341
- usdc . make ( 1n ) ,
342
- ) ;
343
- t . log ( 'Attempting to borrow entire pool seat allocation' , poolSeatAllocation ) ;
344
- await t . throwsAsync (
345
- E ( creatorFacet ) . testBorrow ( { USDC : poolSeatAllocation } ) ,
346
- {
347
- message : / C a n n o t b o r r o w / ,
348
- } ,
349
- 'borrow fails when requested equals pool seat allocation' ,
350
- ) ;
351
-
352
- await t . throwsAsync (
353
- E ( creatorFacet ) . testBorrow ( { USDC : usdc . make ( 200n ) } ) ,
354
- {
355
- message : / C a n n o t b o r r o w / ,
356
- } ,
357
- 'borrow fails when requested exceeds pool seat allocation' ,
358
- ) ;
359
-
360
- await t . throwsAsync ( E ( creatorFacet ) . testBorrow ( { USDC : usdc . make ( 0n ) } ) , {
361
- message : / a r g 1 : U S D C : v a l u e : " \[ 0 n \] " - M u s t b e > = " \[ 1 n \] " / ,
362
- } ) ;
363
-
364
- await t . throwsAsync (
365
- E ( creatorFacet ) . testBorrow (
366
- // @ts -expect-error intentionally incorrect KW
367
- { Fee : usdc . make ( 1n ) } ,
368
- ) ,
369
- {
370
- message : / M u s t h a v e m i s s i n g p r o p e r t i e s \[ " U S D C " \] / ,
371
- } ,
372
- ) ;
373
-
374
- // LPs can still withdraw (contract did not shutdown)
375
- await E ( lps . alice ) . withdraw ( t , 0.5 ) ;
376
-
377
- const amt = await E ( creatorFacet ) . testBorrow ( { USDC : usdc . make ( 30n ) } ) ;
378
- t . deepEqual ( amt , { USDC : usdc . make ( 30n ) } , 'borrow succeeds' ) ;
379
-
380
- await eventLoopIteration ( ) ;
381
- t . like ( await E ( metricsSub ) . getUpdateSince ( ) , {
382
- value : {
383
- encumberedBalance : {
384
- value : 30n ,
385
- } ,
386
- totalBorrows : {
387
- value : 30n ,
388
- } ,
389
- totalRepays : {
390
- value : 0n ,
391
- } ,
392
- } ,
393
- } ) ;
394
- } ) ;
395
-
396
- test . skip ( 'LP repay - TODO: move to exo test' , async t => {
397
- const common = await commonSetup ( t ) ;
398
- const {
399
- commonPrivateArgs,
400
- brands : { usdc } ,
401
- utils,
402
- } = common ;
403
-
404
- const { instance, creatorFacet, zoe, metricsSub, terms } =
405
- await startContract ( common ) ;
406
- const usdcPurse = purseOf ( terms . issuers . USDC , utils ) ;
407
- const lps = {
408
- alice : makeLP ( 'Alice' , usdcPurse ( 100n ) , zoe , instance ) ,
409
- } ;
410
- // seed pool with funds
411
- await E ( lps . alice ) . deposit ( t , 100n ) ;
412
-
413
- // borrow funds from pool to increase encumbered balance
414
- await E ( creatorFacet ) . testBorrow ( { USDC : usdc . make ( 50n ) } ) ;
415
- const feeTools = makeFeeTools ( commonPrivateArgs . feeConfig ) ;
416
- {
417
- t . log ( 'cannot repay more than encumbered balance' ) ;
418
- const repayAmounts = feeTools . calculateSplit ( usdc . make ( 100n ) ) ;
419
- const repayPayments = await deeplyFulfilledObject (
420
- objectMap ( repayAmounts , utils . pourPayment ) ,
421
- ) ;
422
- await t . throwsAsync (
423
- E ( creatorFacet ) . testRepay ( repayAmounts , repayPayments ) ,
424
- {
425
- message : / C a n n o t r e p a y . P r i n c i p a l .* e x c e e d s e n c u m b e r e d B a l a n c e / ,
426
- } ,
427
- ) ;
428
- }
429
-
430
- {
431
- const pmt = utils . pourPayment ( usdc . make ( 50n ) ) ;
432
- await t . throwsAsync (
433
- E ( creatorFacet ) . testRepay (
434
- // @ts -expect-error intentionally incorrect KWR
435
- { USDC : usdc . make ( 50n ) } ,
436
- { USDC : pmt } ,
437
- ) ,
438
- {
439
- message :
440
- / M u s t h a v e m i s s i n g p r o p e r t i e s \[ " P r i n c i p a l " , " P o o l F e e " , " C o n t r a c t F e e " \] / ,
441
- } ,
442
- ) ;
443
- }
444
- {
445
- const pmt = utils . pourPayment ( usdc . make ( 50n ) ) ;
446
- await t . throwsAsync (
447
- E ( creatorFacet ) . testRepay (
448
- // @ts -expect-error intentionally incorrect KWR
449
- { Principal : usdc . make ( 50n ) } ,
450
- { Principal : pmt } ,
451
- ) ,
452
- {
453
- message : / M u s t h a v e m i s s i n g p r o p e r t i e s \[ " P o o l F e e " , " C o n t r a c t F e e " \] / ,
454
- } ,
455
- ) ;
456
- }
457
- {
458
- const amts = {
459
- Principal : usdc . make ( 0n ) ,
460
- ContractFee : usdc . make ( 0n ) ,
461
- PoolFee : usdc . make ( 0n ) ,
462
- } ;
463
- const pmts = await deeplyFulfilledObject (
464
- objectMap ( amts , utils . pourPayment ) ,
465
- ) ;
466
- await t . throwsAsync ( E ( creatorFacet ) . testRepay ( amts , pmts ) , {
467
- message : / a r g 1 : P r i n c i p a l : v a l u e : " \[ 0 n \] " - M u s t b e > = " \[ 1 n \] " / ,
468
- } ) ;
469
- }
470
-
471
- {
472
- t . log ( 'repay fails when amounts do not match seat allocation' ) ;
473
- const amts = {
474
- Principal : usdc . make ( 25n ) ,
475
- ContractFee : usdc . make ( 1n ) ,
476
- PoolFee : usdc . make ( 2n ) ,
477
- } ;
478
- const pmts = await deeplyFulfilledObject (
479
- harden ( {
480
- Principal : utils . pourPayment ( usdc . make ( 24n ) ) ,
481
- ContractFee : utils . pourPayment ( usdc . make ( 1n ) ) ,
482
- PoolFee : utils . pourPayment ( usdc . make ( 2n ) ) ,
483
- } ) ,
484
- ) ;
485
- await t . throwsAsync ( E ( creatorFacet ) . testRepay ( amts , pmts ) , {
486
- message : / C a n n o t r e p a y . F r o m s e a t a l l o c a t i o n .* d o e s n o t e q u a l a m o u n t s / ,
487
- } ) ;
488
- }
489
-
490
- {
491
- t . log ( 'repay succeeds with no Pool or Contract Fee' ) ;
492
- const amts = {
493
- Principal : usdc . make ( 25n ) ,
494
- ContractFee : usdc . make ( 0n ) ,
495
- PoolFee : usdc . make ( 0n ) ,
496
- } ;
497
- const pmts = await deeplyFulfilledObject (
498
- objectMap ( amts , utils . pourPayment ) ,
499
- ) ;
500
- const repayResult = await E ( creatorFacet ) . testRepay ( amts , pmts ) ;
501
-
502
- for ( const r of Object . values ( repayResult ) ) {
503
- t . is ( r . value , 0n , 'testRepay consumes all payments' ) ;
504
- }
505
- }
506
-
507
- const amts = {
508
- Principal : usdc . make ( 25n ) ,
509
- ContractFee : usdc . make ( 1n ) ,
510
- PoolFee : usdc . make ( 2n ) ,
511
- } ;
512
- const pmts = await deeplyFulfilledObject ( objectMap ( amts , utils . pourPayment ) ) ;
513
- const repayResult = await E ( creatorFacet ) . testRepay ( amts , pmts ) ;
514
-
515
- for ( const r of Object . values ( repayResult ) ) {
516
- t . is ( r . value , 0n , 'testRepay consumes all payments' ) ;
517
- }
518
-
519
- await eventLoopIteration ( ) ;
520
- t . like ( await E ( metricsSub ) . getUpdateSince ( ) , {
521
- value : {
522
- encumberedBalance : {
523
- value : 0n ,
524
- } ,
525
- totalBorrows : {
526
- value : 50n ,
527
- } ,
528
- totalRepays : {
529
- value : 50n ,
530
- } ,
531
- totalContractFees : {
532
- value : 1n ,
533
- } ,
534
- totalPoolFees : {
535
- value : 2n ,
536
- } ,
537
- shareWorth : {
538
- numerator : {
539
- value : 103n , // 100n (alice lp) + 1n (dust) + 2n (pool fees)
540
- } ,
541
- } ,
542
- } ,
543
- } ) ;
544
-
545
- // LPs can still withdraw (contract did not shutdown)
546
- await E ( lps . alice ) . withdraw ( t , 1 ) ;
547
- } ) ;
548
-
549
320
const makeEVM = ( template = MockCctpTxEvidences . AGORIC_PLUS_OSMO ( ) ) => {
550
321
const [ settleAddr ] = template . aux . recipientAddress . split ( '?' ) ;
551
322
let nonce = 0 ;
0 commit comments