@@ -254,7 +254,7 @@ export const ZapContextProvider = ({
254254 listAmountsIn [ index ] === "0" ||
255255 ! parseFloat ( listAmountsIn [ index ] )
256256 ) ;
257- if ( listTokenEmptyAmount . length )
257+ if ( tokensIn . length === listTokenEmptyAmount . length )
258258 return (
259259 ERROR_MESSAGE . ENTER_AMOUNT +
260260 " " +
@@ -274,7 +274,6 @@ export const ZapContextProvider = ({
274274 } catch ( e ) {
275275 return ERROR_MESSAGE . INVALID_INPUT_AMOUNTT ;
276276 }
277-
278277 if ( zapApiError ) return zapApiError ;
279278 return "" ;
280279 } , [
@@ -383,21 +382,40 @@ export const ZapContextProvider = ({
383382 error === ERROR_MESSAGE . INSUFFICIENT_BALANCE ||
384383 error === ERROR_MESSAGE . WRONG_NETWORK )
385384 ) {
386- let formattedAmountsInWeis = "" ;
387385 const listAmountsIn = amountsIn . split ( "," ) ;
386+ let tokensInParam = "" ;
387+ let formattedAmountsInWeis = "" ;
388388
389389 try {
390- formattedAmountsInWeis = tokensIn
391- . map ( ( token : Token , index : number ) =>
392- parseUnits ( listAmountsIn [ index ] || "0" , token . decimals ) . toString ( )
393- )
390+ const tokenAmountPairs = tokensIn
391+ . map ( ( token : Token , index : number ) => {
392+ const amountInWei = parseUnits (
393+ listAmountsIn [ index ] || "0" ,
394+ token . decimals
395+ ) ;
396+
397+ if ( amountInWei === 0n ) return null ;
398+
399+ return {
400+ address : token . address as string ,
401+ amountWei : amountInWei . toString ( ) ,
402+ } ;
403+ } )
404+ . filter ( ( item ) : item is { address : string ; amountWei : string } => {
405+ return ! ! item ?. address && ! ! item . amountWei ;
406+ } ) ;
407+
408+ tokensInParam = tokenAmountPairs . map ( ( item ) => item . address ) . join ( "," ) ;
409+
410+ formattedAmountsInWeis = tokenAmountPairs
411+ . map ( ( item ) => item . amountWei )
394412 . join ( "," ) ;
395413 } catch ( error ) {
396414 console . log ( error ) ;
397415 }
398416
399417 if (
400- ! tokensInAddress ||
418+ ! tokensInParam ||
401419 ! formattedAmountsInWeis ||
402420 ! formattedAmountsInWeis . length ||
403421 ! formattedAmountsInWeis [ 0 ] ||
@@ -416,7 +434,7 @@ export const ZapContextProvider = ({
416434 "pool.fee" : pool . fee ,
417435 "position.tickUpper" : debounceTickUpper ,
418436 "position.tickLower" : debounceTickLower ,
419- tokensIn : tokensInAddress ,
437+ tokensIn : tokensInParam ,
420438 amountsIn : formattedAmountsInWeis ,
421439 slippage,
422440 ...( positionId ? { "position.id" : positionId } : { } ) ,
0 commit comments