mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
correct pool shares
Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>
This commit is contained in:
parent
2b6759c3a2
commit
93d141f91f
@ -158,13 +158,28 @@ export default function Add({
|
|||||||
submitForm,
|
submitForm,
|
||||||
handleChange
|
handleChange
|
||||||
}) => {
|
}) => {
|
||||||
const newPoolTokens =
|
const [newPoolTokens, setNewPoolTokens] = useState('0')
|
||||||
totalBalance &&
|
const [newPoolShare, setNewPoolShare] = useState('0')
|
||||||
((values.amount / Number(totalBalance.ocean)) * 100).toFixed(2)
|
useEffect(() => {
|
||||||
|
async function calculatePoolShares() {
|
||||||
const newPoolShare =
|
if (!values.amount) return
|
||||||
totalBalance &&
|
if (Number(values.amount) > Number(amountMax)) return
|
||||||
((Number(newPoolTokens) / Number(totalPoolTokens)) * 100).toFixed(2)
|
const poolTokens = await ocean.pool.calcPoolOutGivenSingleIn(
|
||||||
|
poolAddress,
|
||||||
|
ocean.pool.oceanAddress,
|
||||||
|
values.amount.toString()
|
||||||
|
)
|
||||||
|
setNewPoolTokens(poolTokens)
|
||||||
|
setNewPoolShare(
|
||||||
|
totalBalance &&
|
||||||
|
(
|
||||||
|
(Number(poolTokens) / Number(totalPoolTokens)) *
|
||||||
|
100
|
||||||
|
).toFixed(2)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
calculatePoolShares()
|
||||||
|
}, [values.amount])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user