@@ -685,6 +685,7 @@ describe('LP Pool', () => {
685685 lpPoolKey
686686 ) ) as LPPoolAccount ;
687687
688+ console . log ( lpPool . lastAum . toString ( ) ) ;
688689 assert ( lpPool . lastAum . eq ( new BN ( 1000 ) . mul ( QUOTE_PRECISION ) ) ) ;
689690
690691 // Should fail if we dont pass in the second constituent
@@ -1218,35 +1219,36 @@ describe('LP Pool', () => {
12181219 constituentVaultPublicKey
12191220 ) ;
12201221
1221- // Should have written fee pool amount owed to the amm cache and new constituent usdc balane should be 0
1222+ // Should have written fee pool amount owed to the amm cache and new constituent usdc balane should just be the quote precision to leave aum > 0
12221223 ammCache = ( await adminClient . program . account . ammCache . fetch (
12231224 getAmmCachePublicKey ( program . programId )
12241225 ) ) as AmmCache ;
12251226 // No more usdc left in the constituent vault
1226- assert ( constituent . vaultTokenBalance . eq ( ZERO ) ) ;
1227- assert ( new BN ( constituentVault . amount . toString ( ) ) . eq ( ZERO ) ) ;
1227+ assert ( constituent . vaultTokenBalance . eq ( QUOTE_PRECISION ) ) ;
1228+ assert ( new BN ( constituentVault . amount . toString ( ) ) . eq ( QUOTE_PRECISION ) ) ;
12281229
12291230 // Should have recorded the amount left over to the amm cache and increased the amount in the fee pool
12301231 assert (
12311232 ammCache . cache [ 0 ] . lastFeePoolTokenAmount . eq (
1232- new BN ( constituentUSDCBalanceBefore . toString ( ) )
1233+ new BN ( constituentUSDCBalanceBefore . toString ( ) ) . sub ( QUOTE_PRECISION )
12331234 )
12341235 ) ;
12351236 expect (
12361237 ammCache . cache [ 0 ] . quoteOwedFromLpPool . toNumber ( )
12371238 ) . to . be . approximately (
12381239 expectedTransferAmount
12391240 . sub ( new BN ( constituentUSDCBalanceBefore . toString ( ) ) )
1241+ . add ( QUOTE_PRECISION )
12401242 . toNumber ( ) ,
12411243 1
12421244 ) ;
12431245 assert (
12441246 adminClient
12451247 . getPerpMarketAccount ( 0 )
12461248 . amm . feePool . scaledBalance . eq (
1247- new BN ( constituentUSDCBalanceBefore . toString ( ) ) . mul (
1248- SPOT_MARKET_BALANCE_PRECISION . div ( QUOTE_PRECISION )
1249- )
1249+ new BN ( constituentUSDCBalanceBefore . toString ( ) )
1250+ . sub ( QUOTE_PRECISION )
1251+ . mul ( SPOT_MARKET_BALANCE_PRECISION . div ( QUOTE_PRECISION ) )
12501252 )
12511253 ) ;
12521254
@@ -1255,7 +1257,7 @@ describe('LP Pool', () => {
12551257 lpPool = ( await adminClient . program . account . lpPool . fetch (
12561258 lpPoolKey
12571259 ) ) as LPPoolAccount ;
1258- assert ( lpPool . lastAum . eq ( ZERO ) ) ;
1260+ assert ( lpPool . lastAum . eq ( QUOTE_PRECISION ) ) ;
12591261 } ) ;
12601262
12611263 it ( 'perp market will not transfer with the constituent vault if it is owed from dlp' , async ( ) => {
@@ -1303,8 +1305,8 @@ describe('LP Pool', () => {
13031305 expect (
13041306 ammCache . cache [ 0 ] . quoteOwedFromLpPool . toNumber ( )
13051307 ) . to . be . approximately ( owedAmount . divn ( 2 ) . toNumber ( ) , 1 ) ;
1306- assert ( constituent . vaultTokenBalance . eq ( ZERO ) ) ;
1307- assert ( lpPool . lastAum . eq ( ZERO ) ) ;
1308+ assert ( constituent . vaultTokenBalance . eq ( QUOTE_PRECISION ) ) ;
1309+ assert ( lpPool . lastAum . eq ( QUOTE_PRECISION ) ) ;
13081310
13091311 // Deposit here to DLP to make sure aum calc work with perp market debt
13101312 await overWriteMintAccount (
@@ -1368,7 +1370,7 @@ describe('LP Pool', () => {
13681370 const balanceBefore = constituent . vaultTokenBalance ;
13691371 const owedAmount = ammCache . cache [ 0 ] . quoteOwedFromLpPool ;
13701372
1371- // Give the perp market half of its owed amount
1373+ // Give the perp market double of its owed amount
13721374 const perpMarket = adminClient . getPerpMarketAccount ( 0 ) ;
13731375 perpMarket . amm . feePool . scaledBalance =
13741376 perpMarket . amm . feePool . scaledBalance . add (
0 commit comments