1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
Matthias Kretschmann eabb696f49
Remove slider quick wins (#222)
* make max display into max button

* effect refactor, get amountOcean as early as possible

* fix slider styles in Chrome

* max button fixes

* fix debounce

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* remove console.log

* lower threshold

Co-authored-by: mihaisc <mihai.scarlat@smartcontrol.ro>
2020-11-10 09:50:05 +01:00

26 lines
592 B
TypeScript

import { Ocean } from '@oceanprotocol/lib'
export async function getMaxPercentRemove(
ocean: Ocean,
poolAddress: string,
poolTokens: string
): Promise<string> {
const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity(
poolAddress
)
const amountMaxPoolShares = await ocean.pool.getPoolSharesRequiredToRemoveOcean(
poolAddress,
amountMaxOcean
)
let amountMaxPercent = `${Math.floor(
(Number(amountMaxPoolShares) / Number(poolTokens)) * 100
)}`
if (Number(amountMaxPercent) > 100) {
amountMaxPercent = '100'
}
return amountMaxPercent
}