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..5193015 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,19 @@ const LiquidityBackLayer = ({ setLoading(false) } + const getCurrentSupply = useCallback(async () => { + const currentSupply = await evolutiondex.getCurrentSupply( + ual, + youGive.selectValue + ) + + setCurrentSupplyValue(currentSupply) + }, [ual, youGive.selectValue]) + useEffect(() => { + getCurrentSupply() setPair(pairs.find((pair) => pair.token === youGive.selectValue)) - }, [pairs, youGive.selectValue]) + }, [pairs, youGive.selectValue, getCurrentSupply]) useEffect(() => { setError('') @@ -371,11 +381,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/evolutiondex.js b/src/utils/evolutiondex.js index 1886e58..063cb3d 100644 --- a/src/utils/evolutiondex.js +++ b/src/utils/evolutiondex.js @@ -620,6 +620,26 @@ const voteFee = async (amount, pair, ual) => { } } +const getCurrentSupply = async (ual, pool) => { + if (!ual.activeUser || !pool) { + return + } + + const rpc = getRpc(ual) + + const { rows } = await rpc.get_table_rows({ + 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 +653,6 @@ export const evolutiondex = { addLiquidity, getRemoveLiquidityAssets, removeLiquidity, - voteFee + voteFee, + getCurrentSupply }