1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-11-15 09:44:53 +01:00

remove liquidity in OCEAN only

This commit is contained in:
Matthias Kretschmann 2020-10-14 10:26:00 +02:00
parent 36d1289a8e
commit 1a71f0f66f
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 4 additions and 12 deletions

View File

@ -10,19 +10,16 @@ import Token from './Token'
export default function Remove({ export default function Remove({
setShowRemove, setShowRemove,
poolAddress, poolAddress,
poolTokens, poolTokens
dtSymbol
}: { }: {
setShowRemove: (show: boolean) => void setShowRemove: (show: boolean) => void
poolAddress: string poolAddress: string
poolTokens: string poolTokens: string
dtSymbol: string
}): ReactElement { }): ReactElement {
const { ocean, accountId } = useOcean() const { ocean, accountId } = useOcean()
const [amountPercent, setAmountPercent] = useState('0') const [amountPercent, setAmountPercent] = useState('0')
const [amountPoolShares, setAmountPoolShares] = useState('0') const [amountPoolShares, setAmountPoolShares] = useState('0')
const [amountOcean, setAmountOcean] = useState<string>() const [amountOcean, setAmountOcean] = useState<string>()
const [amountDatatoken, setAmountDatatoken] = useState<string>()
const [isLoading, setIsLoading] = useState<boolean>() const [isLoading, setIsLoading] = useState<boolean>()
const [txId, setTxId] = useState<string>() const [txId, setTxId] = useState<string>()
@ -52,6 +49,9 @@ export default function Remove({
useEffect(() => { useEffect(() => {
if (!ocean || !poolTokens) return if (!ocean || !poolTokens) return
// TODO: check max amount to be able to remove
// getOceanMaxRemoveLiquidity()
async function getValues() { async function getValues() {
const amountPoolShares = const amountPoolShares =
(Number(amountPercent) / 100) * Number(poolTokens) (Number(amountPercent) / 100) * Number(poolTokens)
@ -62,12 +62,6 @@ export default function Remove({
`${amountPoolShares}` `${amountPoolShares}`
) )
setAmountOcean(amountOcean) setAmountOcean(amountOcean)
const amountDatatoken = await ocean.pool.getDTRemovedforPoolShares(
poolAddress,
`${amountPoolShares}`
)
setAmountDatatoken(amountDatatoken)
} }
getValues() getValues()
}, [amountPercent, ocean, poolTokens, poolAddress]) }, [amountPercent, ocean, poolTokens, poolAddress])
@ -100,7 +94,6 @@ export default function Remove({
<p>You will receive</p> <p>You will receive</p>
<Token symbol="OCEAN" balance={amountOcean} /> <Token symbol="OCEAN" balance={amountOcean} />
<Token symbol={dtSymbol} balance={amountDatatoken} />
<Actions <Actions
isLoading={isLoading} isLoading={isLoading}

View File

@ -129,7 +129,6 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
setShowRemove={setShowRemove} setShowRemove={setShowRemove}
poolAddress={price.address} poolAddress={price.address}
poolTokens={poolTokens} poolTokens={poolTokens}
dtSymbol={dtSymbol}
/> />
) : ( ) : (
<> <>