@@ -289,8 +289,9 @@ describe('User Tests', () => {
289
289
mockUser . getMaxLeverageForPerp ( 0 ) . toString ( )
290
290
) ;
291
291
assert ( mockUser . getMaxLeverageForPerp ( 0 ) . eq ( new BN ( '50000' ) ) ) ; // 5x
292
- assert ( mockUser . getMaxLeverageForPerp ( 0 , 'Maintenance' ) . eq ( new BN ( '100000' ) ) ) ; // 10x
293
-
292
+ assert (
293
+ mockUser . getMaxLeverageForPerp ( 0 , 'Maintenance' ) . eq ( new BN ( '100000' ) )
294
+ ) ; // 10x
294
295
} ) ;
295
296
296
297
it ( 'worst case token amount' , async ( ) => {
@@ -399,8 +400,7 @@ describe('User Tests', () => {
399
400
) ; // -$2k
400
401
} ) ;
401
402
402
-
403
- it ( 'custom margin ratio (sol spot)' , async ( ) => {
403
+ it ( 'custom margin ratio (sol spot)' , async ( ) => {
404
404
const myMockUserAccount = _ . cloneDeep ( mockUserAccount ) ;
405
405
406
406
const solMarket = Object . assign ( { } , _ . cloneDeep ( mockSpotMarkets [ 1 ] ) , {
@@ -427,12 +427,10 @@ describe('User Tests', () => {
427
427
) ;
428
428
429
429
console . log ( worstCase ) ;
430
- assert ( worstCase . weight . eq ( new BN ( 8000 ) ) ) ;
431
-
430
+ assert ( worstCase . weight . eq ( new BN ( 8000 ) ) ) ;
432
431
433
432
myMockUserAccount . maxMarginRatio = MARGIN_PRECISION . toNumber ( ) ; // max 1x pls
434
433
435
-
436
434
const worstCaseAfter = getWorstCaseTokenAmounts (
437
435
spotPosition ,
438
436
solMarket ,
@@ -443,10 +441,9 @@ describe('User Tests', () => {
443
441
444
442
console . log ( worstCaseAfter ) ;
445
443
assert ( worstCaseAfter . weight . eq ( new BN ( 0 ) ) ) ; // not allowed to increase exposure
446
-
447
444
} ) ;
448
445
449
- it ( 'custom margin ratio (sol perp)' , async ( ) => {
446
+ it ( 'custom margin ratio (sol perp)' , async ( ) => {
450
447
const myMockPerpMarkets = _ . cloneDeep ( mockPerpMarkets ) ;
451
448
const myMockSpotMarkets = _ . cloneDeep ( mockSpotMarkets ) ;
452
449
const myMockUserAccount = _ . cloneDeep ( mockUserAccount ) ;
@@ -469,7 +466,6 @@ describe('User Tests', () => {
469
466
[ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ]
470
467
) ;
471
468
472
-
473
469
assert ( mockUser . getTokenAmount ( 0 ) . eq ( new BN ( '10000000000' ) ) ) ;
474
470
assert ( mockUser . getNetSpotMarketValue ( ) . eq ( new BN ( '10000000000' ) ) ) ;
475
471
assert (
@@ -486,7 +482,9 @@ describe('User Tests', () => {
486
482
assert ( iLev == 5000 ) ;
487
483
assert ( mLev == 10000 ) ;
488
484
489
- myMockUserAccount . maxMarginRatio = MARGIN_PRECISION . div ( new BN ( 2 ) ) . toNumber ( ) ; // 2x max pls
485
+ myMockUserAccount . maxMarginRatio = MARGIN_PRECISION . div (
486
+ new BN ( 2 )
487
+ ) . toNumber ( ) ; // 2x max pls
490
488
491
489
const mockUser2 : User = await makeMockUser (
492
490
myMockPerpMarkets ,
@@ -498,9 +496,8 @@ describe('User Tests', () => {
498
496
iLev = mockUser2 . getMaxLeverageForPerp ( 0 , 'Initial' ) . toNumber ( ) ;
499
497
mLev = mockUser2 . getMaxLeverageForPerp ( 0 , 'Maintenance' ) . toNumber ( ) ;
500
498
console . log ( iLev , mLev ) ;
501
-
499
+
502
500
assert ( iLev == 2000 ) ;
503
501
assert ( mLev == 10000 ) ;
504
-
505
502
} ) ;
506
503
} ) ;
0 commit comments