1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

refactor token checks

* requires https://github.com/oceanprotocol/ocean.js/pull/361
This commit is contained in:
Matthias Kretschmann 2020-10-14 12:58:10 +02:00
parent 207b61933a
commit 0a248b36a1
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 47 additions and 24 deletions

View File

@ -31,3 +31,19 @@
margin-top: calc(var(--spacer) / 4);
margin-bottom: 0;
}
.output {
composes: output from './Add.module.css';
}
.output [class*='token'] {
white-space: nowrap;
}
.output [class*='token'] > figure {
display: inline-block;
}
.output figure[class*='pool shares'] {
display: none;
}

View File

@ -82,30 +82,34 @@ export default function Remove({
useEffect(() => {
if (!ocean || !poolTokens) return
// TODO: check max amount to be able to remove
// getOceanMaxRemoveLiquidity()
async function getValues() {
const amountPoolShares =
(Number(amountPercent) / 100) * Number(poolTokens)
setAmountPoolShares(`${amountPoolShares}`)
const amountOcean = await ocean.pool.getOceanRemovedforPoolShares(
poolAddress,
`${amountPoolShares}`
)
setAmountOcean(amountOcean)
if (isAdvanced === true) {
const tokens = await ocean.pool.getTokensRemovedforPoolShares(
poolAddress,
`${amountPoolShares}`
)
setAmountOcean(tokens?.oceanAmount)
setAmountDatatoken(tokens?.dtAmount)
} else {
// TODO: check max amount to be able to remove
const maxOcean = await ocean.pool.getOceanMaxRemoveLiquidity(
poolAddress
)
console.log(maxOcean)
if (!isAdvanced) return
const amountDatatoken = await ocean.pool.getDTRemovedforPoolShares(
poolAddress,
`${amountPoolShares}`
)
setAmountDatatoken(amountDatatoken)
const amountOcean = await ocean.pool.getOceanRemovedforPoolShares(
poolAddress,
`${amountPoolShares}`
)
setAmountOcean(amountOcean)
}
}
getValues()
}, [amountPercent, ocean, poolTokens, poolAddress, isAdvanced])
}, [amountPercent, isAdvanced, ocean, poolTokens, poolAddress])
return (
<div className={styles.remove}>
@ -136,14 +140,17 @@ export default function Remove({
</div>
</form>
<p>You will spend</p>
<Token symbol="pool shares" balance={amountPoolShares} noIcon />
<p>You will receive</p>
<Token symbol="OCEAN" balance={amountOcean} />
{isAdvanced && <Token symbol={dtSymbol} balance={amountDatatoken} />}
<div className={styles.output}>
<div>
<p>You will spend</p>
<Token symbol="pool shares" balance={amountPoolShares} noIcon />
</div>
<div>
<p>You will receive</p>
<Token symbol="OCEAN" balance={amountOcean} />
{isAdvanced && <Token symbol={dtSymbol} balance={amountDatatoken} />}
</div>
</div>
<Actions
isLoading={isLoading}