diff --git a/frontend/src/actions/dexActions.js b/frontend/src/actions/dexActions.js
index fdec9981..9691fdc7 100644
--- a/frontend/src/actions/dexActions.js
+++ b/frontend/src/actions/dexActions.js
@@ -2,7 +2,6 @@ import BigNumber from "bignumber.js";
import {
currentConnection,
ETH,
- etheriumNetwork,
moonriverNetwork,
PBR,
routerAddresses,
@@ -69,7 +68,7 @@ export const swapTokens =
const toAddress = account;
const _deadlineUnix = getUnixTime(deadline);
dispatch({
- type: SHOW_LOADING,
+ type: SHOW_DEX_LOADING,
});
dispatch({ type: START_TRANSACTION });
@@ -214,7 +213,6 @@ export const swapTokens =
await swapPromise
.on("receipt", async function (receipt) {
- console.log("UPDATE_TRANSACTION_STATUS", receipt);
dispatch({
type: UPDATE_TRANSACTION_STATUS,
payload: {
@@ -238,7 +236,7 @@ export const swapTokens =
});
}
dispatch({
- type: HIDE_LOADING,
+ type: HIDE_DEX_LOADING,
});
};
@@ -282,7 +280,7 @@ export const addLiquidity =
const _routerContract = routerContract(network);
dispatch({
- type: SHOW_LOADING,
+ type: SHOW_DEX_LOADING,
});
//input params
const token0AmountDesired = token0.amount;
@@ -343,7 +341,7 @@ export const addLiquidity =
}
dispatch({
- type: HIDE_LOADING,
+ type: HIDE_DEX_LOADING,
});
};
@@ -354,7 +352,7 @@ export const addLiquidityEth =
try {
const _routerContract = routerContract(network);
dispatch({
- type: SHOW_LOADING,
+ type: SHOW_DEX_LOADING,
});
//input params
const etherAmount = ethToken.amount;
@@ -417,7 +415,7 @@ export const addLiquidityEth =
}
dispatch({
- type: HIDE_LOADING,
+ type: HIDE_DEX_LOADING,
});
};
@@ -510,7 +508,6 @@ export const removeLiquidityEth =
const tokenAmountMin = "0";
const lpTokenAmount = lpAmount;
- console.log({ ethToken, erc20Token, lpAmount });
// deadline should be passed in minites in calculation
const _deadlineUnix = getUnixTime(deadline);
@@ -617,11 +614,39 @@ export const confirmAllowance =
const _routerContract = routerContract(network);
dispatch({
- type: SHOW_LOADING,
+ type: SHOW_DEX_LOADING,
});
await _tokenContract.methods
.approve(_routerContract._address, balance)
- .send({ from: account });
+ .send({ from: account }, function (error, transactionHash) {
+ if (error) {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: { type: "token_approve", hash: null, status: "failed" },
+ });
+ } else {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: { type: "token_approve", hash: transactionHash },
+ });
+ }
+ })
+ .on("receipt", async function (receipt) {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: {
+ type: "token_approve",
+ status: "success",
+ result: {}, // add result data for reciept
+ },
+ });
+ })
+ .on("error", async function (error) {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: { type: "token_approve", status: "failed" },
+ });
+ });
dispatch({
type: APPROVE_TOKEN,
@@ -635,7 +660,7 @@ export const confirmAllowance =
});
}
dispatch({
- type: HIDE_LOADING,
+ type: HIDE_DEX_LOADING,
});
};
@@ -693,7 +718,39 @@ export const confirmLPAllowance =
await _pairContract.methods
.approve(_routerContractAddress, balance)
- .send({ from: account });
+ .send({ from: account }, function (error, transactionHash) {
+ if (error) {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: {
+ type: "lp_token_approve",
+ hash: null,
+ status: "failed",
+ },
+ });
+ } else {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: { type: "lp_token_approve", hash: transactionHash },
+ });
+ }
+ })
+ .on("receipt", async function (receipt) {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: {
+ type: "lp_token_approve",
+ status: "success",
+ result: {}, // add result data
+ },
+ });
+ })
+ .on("error", async function (error) {
+ dispatch({
+ type: UPDATE_TRANSACTION_STATUS,
+ payload: { type: "lp_token_approve", status: "failed" },
+ });
+ });
dispatch({
type: APPROVE_LP_TOKENS,
diff --git a/frontend/src/actions/farmActions.js b/frontend/src/actions/farmActions.js
index 8469a4ed..3422b7d2 100644
--- a/frontend/src/actions/farmActions.js
+++ b/frontend/src/actions/farmActions.js
@@ -293,6 +293,7 @@ export const getFarmInfo =
poolWeight: new BigNumber(poolInfo?.allocPoint)
.div(totalAllocPoint)
.toString(),
+ lockedLp: fromWei(poolInfo?.lpAmount),
};
dispatch({
@@ -363,10 +364,11 @@ export const getLpBalanceFarm =
const balObject = {};
balObject[pairAddress] = {
lpBalance,
- poolLpTokens: new BigNumber(fromWei(totalSupply))
+ poolLpTokens: new BigNumber(fromWei(totalSupply)) // multiply this value with eth price to get correct pool total Liquidity usd value
.times(lpTokenPrice)
.toFixed(0)
.toString(),
+ lpTokenPrice, // multiply this value with eth price to get correct lp price in usd
};
dispatch({
diff --git a/frontend/src/components/common/SelectTokenDialog.js b/frontend/src/components/common/SelectTokenDialog.js
index 741d39da..9fad9377 100644
--- a/frontend/src/components/common/SelectTokenDialog.js
+++ b/frontend/src/components/common/SelectTokenDialog.js
@@ -57,7 +57,7 @@ const useStyles = makeStyles((theme) => ({
},
closeIcon: {
- color: "#f6f6f6",
+ color: theme.palette.textColors.heading,
fontSize: 24,
[theme.breakpoints.down("sm")]: {
fontSize: 20,
diff --git a/frontend/src/components/pages/AddLiquidity/AddCard.js b/frontend/src/components/pages/AddLiquidity/AddCard.js
index 70d26ac4..0d89ac9a 100644
--- a/frontend/src/components/pages/AddLiquidity/AddCard.js
+++ b/frontend/src/components/pages/AddLiquidity/AddCard.js
@@ -1,10 +1,4 @@
-import {
- Button,
- Card,
- CircularProgress,
- IconButton,
- makeStyles,
-} from "@material-ui/core";
+import { Button, Card, IconButton, makeStyles } from "@material-ui/core";
import { connect } from "react-redux";
import KeyboardBackspaceIcon from "@material-ui/icons/KeyboardBackspace";
import { useCallback, useEffect, useMemo, useState } from "react";
@@ -235,6 +229,7 @@ const AddCard = (props) => {
pairContractData,
transaction,
tokenList,
+ dexLoading,
},
addLiquidityEth,
checkAllowance,
@@ -400,7 +395,6 @@ const AddCard = (props) => {
};
const loadPairReserves = async () => {
- // console.log('loading pair reserves after add liquidity')
let _pairAddress = currentPairAddress();
if (!_pairAddress) {
@@ -746,6 +740,11 @@ const AddCard = (props) => {
};
const handleAction = () => {
+ if (dexLoading) {
+ setSwapDialog(true);
+ return;
+ }
+
if (currentTokenApprovalStatus()) {
handleAddLiquidity();
} else {
@@ -762,6 +761,11 @@ const AddCard = (props) => {
return "Please wait...";
} else if (addStatus.disabled) {
return addStatus.message;
+ } else if (
+ ["add", "token_approve"].includes(transaction.type) &&
+ transaction.status === "pending"
+ ) {
+ return "Pending Transaction...";
} else {
return !currentTokenApprovalStatus()
? currApproveBtnText()
@@ -775,13 +779,24 @@ const AddCard = (props) => {
return;
}
- if (transaction.type === "add" && transaction.status === "success") {
+ if (
+ ["add", "token_approve"].includes(transaction.type) &&
+ transaction.status === "success"
+ ) {
getAccountBalance(selectedToken0, currentNetwork);
getAccountBalance(selectedToken1, currentNetwork);
}
if (
- (transaction.type === "add" && transaction.status === "success") ||
+ ["add", "token_approve"].includes(transaction.type) &&
+ transaction.status === "pending"
+ ) {
+ setSwapDialog(true);
+ }
+
+ if (
+ (["add", "token_approve"].includes(transaction.type) &&
+ transaction.status === "success") ||
transaction.status === "failed"
) {
setSwapDialog(true);
@@ -790,10 +805,16 @@ const AddCard = (props) => {
const handleConfirmSwapClose = (value) => {
setSwapDialog(value);
- if (transaction.type === "add" && transaction.status === "success") {
+ if (
+ ["add", "token_approve"].includes(transaction.type) &&
+ transaction.status === "success"
+ ) {
store.dispatch({ type: START_TRANSACTION });
clearInputState();
- } else if (transaction.type === "add" && transaction.status === "failed") {
+ } else if (
+ ["add", "token_approve"].includes(transaction.type) &&
+ transaction.status === "failed"
+ ) {
store.dispatch({ type: START_TRANSACTION });
}
};
@@ -908,19 +929,7 @@ const AddCard = (props) => {
onClick={handleAction}
className={classes.addLiquidityButton}
>
- {!addStatus.disabled && loading ? (
-
- {transaction.status === "pending" && "Transaction Pending"}
-
-