Skip to content

Commit

Permalink
rename to transactionKeyword
Browse files Browse the repository at this point in the history
  • Loading branch information
brucedonovan committed Sep 26, 2023
1 parent 8d68030 commit c1b3b16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/current/MessageTranslator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]}
/>
);
Expand Down
15 changes: 8 additions & 7 deletions src/components/current/widgets/uniswap/Uniswap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,25 @@ 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);
const { isETH: tokenOutIsETH } = useToken(tokenOutSymbol);
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
Expand Down Expand Up @@ -254,7 +255,7 @@ const Uniswap = ({ tokenInSymbol, tokenOutSymbol, inputAmount, slippage, buyOrSe
<ListResponse
title="Breakdown"
data={[
['Slippage', `${slippage}%`],
['Slippage', `${slippage_}%`],
['Minimum swap', cleanValue(amountOutMinimum_, 2)],
['Route', `${tokenInSymbol}-${tokenOutSymbol}`],
]}
Expand Down

0 comments on commit c1b3b16

Please sign in to comment.