diff --git a/src/language/en/en.json b/src/language/en/en.json index 44d215b..d671d47 100644 --- a/src/language/en/en.json +++ b/src/language/en/en.json @@ -67,6 +67,7 @@ "tableLabelCommunity": "Community Pools", "inputLabel": "Add / Remove", "available": "Current supply", + "balance": "Your balance", "add": "Add", "remove": "Remove", "and": "and", diff --git a/src/language/es/es.json b/src/language/es/es.json index 424fe84..d466f6f 100644 --- a/src/language/es/es.json +++ b/src/language/es/es.json @@ -68,6 +68,7 @@ "tableLabelCommunity": "Pooles comunitarios", "inputLabel": "Aportar / Retirar", "available": "Cantidad circulante", + "balance": "Tu Saldo", "add": "Agregar", "remove": "Retirar", "and": "y", diff --git a/src/language/ru/ru.json b/src/language/ru/ru.json index c3ad4f4..8522c56 100644 --- a/src/language/ru/ru.json +++ b/src/language/ru/ru.json @@ -67,6 +67,7 @@ "tableLabelCommunity": "Общественные пулы", "inputLabel": "Добавить / Удалить", "available": "Текущая поставка", + "balance": "баланс", "add": "Добавить", "remove": "Удалить", "and": "и", diff --git a/src/language/zh/zh.json b/src/language/zh/zh.json index b5488f3..4c78494 100644 --- a/src/language/zh/zh.json +++ b/src/language/zh/zh.json @@ -67,6 +67,7 @@ "tableLabelCommunity": "社区的流动性池", "inputLabel": "添加 / 移除", "available": "可用", + "balance": "平衡", "add": "添加", "remove": "移除", "and": "和", diff --git a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js index 6651140..48ec583 100644 --- a/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js +++ b/src/routes/Evodex/BackLayer/Liquidity/LiquidityBackLayer.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react' +import React, { useState, useEffect, useCallback } from 'react' import PropTypes from 'prop-types' import clsx from 'clsx' import { useTranslation } from 'react-i18next' @@ -118,6 +118,7 @@ const useStyles = makeStyles((theme) => { } }, [theme.breakpoints.up('sm')]: { + paddingTop: theme.spacing(2), flexDirection: 'row', '& button': { marginRight: theme.spacing(2), @@ -128,11 +129,9 @@ const useStyles = makeStyles((theme) => { inputBox: { ...inputBox, [theme.breakpoints.up('md')]: { - width: 800 - }, - [theme.breakpoints.up('lg')]: { - marginTop: theme.spacing(0), - paddingBottom: theme.spacing(1) + width: 800, + paddingBottom: theme.spacing(0), + marginTop: theme.spacing(0) } }, contentWrapper: { @@ -194,6 +193,7 @@ const LiquidityBackLayer = ({ const [isTourOpen, setIsTourOpen] = useState(false) const [youGive, setYouGive] = useState({}) const [loading, setLoading] = useState(false) + const [currentSupplyValue, setCurrentSupplyValue] = useState('0') const [error, setError] = useState('') const validInput = RegExp('^([0-9]+([.][0-9]*)?|[.][0-9]+)$') @@ -313,9 +313,18 @@ const LiquidityBackLayer = ({ setLoading(false) } + const getCurrentSupply = useCallback(async () => { + const currentSupply = await evolutiondex.getCurrentSupply( + youGive.selectValue + ) + + setCurrentSupplyValue(currentSupply) + }, [youGive.selectValue]) + useEffect(() => { + getCurrentSupply() setPair(pairs.find((pair) => pair.token === youGive.selectValue)) - }, [pairs, youGive.selectValue]) + }, [pairs, youGive.selectValue, getCurrentSupply]) useEffect(() => { setError('') @@ -371,11 +380,16 @@ const LiquidityBackLayer = ({ helperText={ <> {pair && ( - - {`${t('available')} ${ - pair.balance ? pair.balance.toString() : 0 - }`} - + <> + + {`${t('balance')}: ${ + pair.balance ? pair.balance.toString() : 0 + }`} + + + {`${t('available')}: ${currentSupplyValue}`} + + )} {error && ( diff --git a/src/utils/eosapi.js b/src/utils/eosapi.js new file mode 100644 index 0000000..87836d3 --- /dev/null +++ b/src/utils/eosapi.js @@ -0,0 +1,9 @@ +import EosApi from 'eosjs-api' + +const eosApi = EosApi({ + httpEndpoint: `${process.env.REACT_APP_EOS_API_PROTOCOL}://${process.env.REACT_APP_EOS_API_HOST}:${process.env.REACT_APP_EOS_API_PORT}`, + verbose: false, + fetchConfiguration: {} +}) + +export default eosApi diff --git a/src/utils/evolutiondex.js b/src/utils/evolutiondex.js index 1886e58..98d247b 100644 --- a/src/utils/evolutiondex.js +++ b/src/utils/evolutiondex.js @@ -1,11 +1,11 @@ import * as eosCommon from 'eos-common' +import { JsonRpc } from 'eosjs' import { evodexConfig } from '../config' import { getScatterError } from './getScatterError' import axiosUtil from './axios.util' - -import { JsonRpc } from 'eosjs' +import eosApi from './eosapi' const { asset, number_to_asset: numberToAsset } = eosCommon const defaultState = { pairs: [], tokens: [] } @@ -620,6 +620,24 @@ const voteFee = async (amount, pair, ual) => { } } +const getCurrentSupply = async (pool) => { + if (!pool) { + return + } + + const { rows } = await eosApi.getTableRows({ + json: true, + code: 'evolutiondex', + scope: pool, + table: 'stat', + limit: 1, + reverse: false, + show_payer: false + }) + + return rows.length ? rows[0].supply : `0 ${pool}` +} + export const evolutiondex = { getInfo, getTokensFor, @@ -633,5 +651,6 @@ export const evolutiondex = { addLiquidity, getRemoveLiquidityAssets, removeLiquidity, - voteFee + voteFee, + getCurrentSupply }