@@ -349,18 +349,18 @@ describe("amm", () => {
349349
350350 it ( "`swap` method using 'exact in' param with mint A!" , async ( ) => {
351351 const INPUT_AMOUNT = 10_000_000 ; // 10 token
352- const SLIPPAGE_LIMIT = 0 ; // expressed in amount, no bps
352+ const MIN_OUTPUT_AMOUNT = 0 ;
353353
354354 const param : anchor . IdlTypes < Amm > [ "swapParams" ] = {
355- exactIn : { inputAmount : bn ( INPUT_AMOUNT ) } ,
355+ exactIn : { inputAmount : bn ( INPUT_AMOUNT ) , minOutputAmount : bn ( MIN_OUTPUT_AMOUNT ) } ,
356356 } ;
357357
358358 const [ prevLiquidityPool ] = await getLiquidityPoolAccount ( poolId ) ;
359359 console . log ( "A amount in vault:" , prevLiquidityPool . amountMintA ) ;
360360 console . log ( "B amount in vault:" , prevLiquidityPool . amountMintB ) ;
361361
362362 const tx = await program . methods
363- . swap ( bn ( poolId ) , param , bn ( SLIPPAGE_LIMIT ) )
363+ . swap ( bn ( poolId ) , param )
364364 . accounts ( {
365365 signer : user . publicKey ,
366366 inputMint : mintA ,
@@ -397,18 +397,18 @@ describe("amm", () => {
397397
398398 it ( "`swap` method using 'exact out' param with mint A!" , async ( ) => {
399399 const OUTPUT_AMOUNT = 20_000_000 ; // 2 token
400- const SLIPPAGE_LIMIT = 0 ; // expressed in amount, no bps
400+ const MAX_INPUT_AMOUNT = 0 ;
401401
402402 const param : anchor . IdlTypes < Amm > [ "swapParams" ] = {
403- exactOut : { outputAmount : bn ( OUTPUT_AMOUNT ) } ,
403+ exactOut : { outputAmount : bn ( OUTPUT_AMOUNT ) , maxInputAmount : bn ( MAX_INPUT_AMOUNT ) } ,
404404 } ;
405405
406406 const [ prevLiquidityPool ] = await getLiquidityPoolAccount ( poolId ) ;
407407 console . log ( "A amount in vault:" , prevLiquidityPool . amountMintA ) ;
408408 console . log ( "B amount in vault:" , prevLiquidityPool . amountMintB ) ;
409409
410410 const tx = await program . methods
411- . swap ( bn ( poolId ) , param , bn ( SLIPPAGE_LIMIT ) )
411+ . swap ( bn ( poolId ) , param )
412412 . accounts ( {
413413 signer : user . publicKey ,
414414 inputMint : mintA ,
@@ -445,18 +445,18 @@ describe("amm", () => {
445445
446446 it ( "`swap` method using 'exact in' param with mint B!" , async ( ) => {
447447 const INPUT_AMOUNT = 10_000_000 ; // 10 token
448- const SLIPPAGE_LIMIT = 0 ; // expressed in amount, no bps
448+ const MIN_OUTPUT_AMOUNT = 0 ;
449449
450450 const param : anchor . IdlTypes < Amm > [ "swapParams" ] = {
451- exactIn : { inputAmount : bn ( INPUT_AMOUNT ) } ,
451+ exactIn : { inputAmount : bn ( INPUT_AMOUNT ) , minOutputAmount : bn ( MIN_OUTPUT_AMOUNT ) } ,
452452 } ;
453453
454454 const [ prevLiquidityPool ] = await getLiquidityPoolAccount ( poolId ) ;
455455 console . log ( "A amount in vault:" , prevLiquidityPool . amountMintA ) ;
456456 console . log ( "B amount in vault:" , prevLiquidityPool . amountMintB ) ;
457457
458458 const tx = await program . methods
459- . swap ( bn ( poolId ) , param , bn ( SLIPPAGE_LIMIT ) )
459+ . swap ( bn ( poolId ) , param )
460460 . accounts ( {
461461 signer : user . publicKey ,
462462 inputMint : mintB ,
@@ -493,18 +493,18 @@ describe("amm", () => {
493493
494494 it ( "`swap` method using 'exact out' param with mint B!" , async ( ) => {
495495 const OUTPUT_AMOUNT = 2_000_000 ; // 2 token
496- const SLIPPAGE_LIMIT = 0 ; // expressed in amount, no bps
496+ const MAX_INPUT_AMOUNT = 0 ;
497497
498498 const param : anchor . IdlTypes < Amm > [ "swapParams" ] = {
499- exactOut : { outputAmount : bn ( OUTPUT_AMOUNT ) } ,
499+ exactOut : { outputAmount : bn ( OUTPUT_AMOUNT ) , maxInputAmount : bn ( MAX_INPUT_AMOUNT ) } ,
500500 } ;
501501
502502 const [ prevLiquidityPool ] = await getLiquidityPoolAccount ( poolId ) ;
503503 console . log ( "A amount in vault:" , prevLiquidityPool . amountMintA ) ;
504504 console . log ( "B amount in vault:" , prevLiquidityPool . amountMintB ) ;
505505
506506 const tx = await program . methods
507- . swap ( bn ( poolId ) , param , bn ( SLIPPAGE_LIMIT ) )
507+ . swap ( bn ( poolId ) , param )
508508 . accounts ( {
509509 signer : user . publicKey ,
510510 inputMint : mintB ,
0 commit comments