diff --git a/packages/react-app/src/components/Exchange.js b/packages/react-app/src/components/Exchange.js index 07da0ba..7c5c4f7 100644 --- a/packages/react-app/src/components/Exchange.js +++ b/packages/react-app/src/components/Exchange.js @@ -5,12 +5,84 @@ import { ERC20, useContractFunction, useEthers, useTokenAllowance, useTokenBalan import { ethers } from "ethers"; import { parseUnits } from "ethers/lib/utils"; +import { getAvailableTokens, getCounterpartTokens, findPoolByTokens, isOperationPending, getFailureMessage, getSuccessMessage } from '../utils'; import { ROUTER_ADDRESS } from "../config"; +import AmountIn from "./"; +import AmountOut from "./"; +import Balance from "./"; +import styles from "../styles"; const Exchange = ({ pools }) => { + const isApproving = isOperationPending(swapApproveState); + const isSwapping = isOperationPending(swapExecuteState); + + const successMessage = getSuccessMessage(swapApproveState, swapExecuteState); + const failureMessage = getFailureMessage(swapApproveState, swapExecuteState); + return ( -
Exchange
- ) +
+
+ + +
+ +
+ + +
+ + {approvedNeeded && !isSwapping ? ( + + ) : ( + + )} + + {failureMessage && !resetState ? ( +

{failureMessage}

+ ) : successMessage ? ( +

{successMessage}

+ ) : ( + "" + )} +
+ ); } export default Exchange; \ No newline at end of file