From c1b3b16baaa36f373c533fecf9651aeee4e0ca14 Mon Sep 17 00:00:00 2001 From: brucedonovan Date: Tue, 26 Sep 2023 08:59:09 +0100 Subject: [PATCH] rename to transactionKeyword --- src/components/current/MessageTranslator.tsx | 2 +- .../current/widgets/uniswap/Uniswap.tsx | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/current/MessageTranslator.tsx b/src/components/current/MessageTranslator.tsx index 692d2358..bedf30cb 100644 --- a/src/components/current/MessageTranslator.tsx +++ b/src/components/current/MessageTranslator.tsx @@ -186,7 +186,7 @@ export const Widget = (props: WidgetProps) => { tokenInSymbol={parsedArgs[0]} tokenOutSymbol={parsedArgs[1]} inputAmount={parsedArgs[3]} - buyOrSellAmount={parsedArgs[2]} // BUYAMOUNT or SELLAMOUNT + transactionKeyword={parsedArgs[2]} // BUYAMOUNT or SELLAMOUNT slippage={parsedArgs[4]} /> ); diff --git a/src/components/current/widgets/uniswap/Uniswap.tsx b/src/components/current/widgets/uniswap/Uniswap.tsx index 89efd3c8..40232b84 100644 --- a/src/components/current/widgets/uniswap/Uniswap.tsx +++ b/src/components/current/widgets/uniswap/Uniswap.tsx @@ -26,13 +26,12 @@ interface UniswapProps { tokenOutSymbol: string; inputAmount: string; slippage: string; - buyOrSellAmount: 'BUYAMOUNT' | 'SELLAMOUNT'; + transactionKeyword: 'BUYAMOUNT' | 'SELLAMOUNT'; } -const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount, slippage, buyOrSellAmount }: UniswapProps) => { +const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount, slippage, transactionKeyword }: UniswapProps) => { const chainId = useChainId(); - - const isBuying = buyOrSellAmount === 'BUYAMOUNT'; + const isBuying = transactionKeyword === 'BUYAMOUNT'; const { address: recipient } = useAccount(); const { data: tokenIn, isETH: tokenInIsETH } = useToken(tokenInSymbol); @@ -40,10 +39,12 @@ const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount, slippage, buyOrSe const { data: tokenInChecked } = useToken(tokenInIsETH ? 'WETH' : tokenInSymbol); const { data: tokenOutChecked } = useToken(tokenOutIsETH ? 'WETH' : tokenOutSymbol); const input = useInput(inputAmount, tokenInChecked?.symbol!); - // const slippage_ = +slippage; // in percentage terms + + const slippage_ = +slippage || 0.5; // in percentage terms + const getSlippageAdjustedAmount = (amount: BigNumber) => BigNumber.from(amount) - .mul(10000 - +slippage * 100) + .mul(10000 - slippage_ * 100) .div(10000); // token out quote for amount in @@ -254,7 +255,7 @@ const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount, slippage, buyOrSe