diff --git a/src/components/organisms/AssetActions/Pool/Remove.tsx b/src/components/organisms/AssetActions/Pool/Remove.tsx index fa1b1d3c8..9f50ba387 100644 --- a/src/components/organisms/AssetActions/Pool/Remove.tsx +++ b/src/components/organisms/AssetActions/Pool/Remove.tsx @@ -10,10 +10,11 @@ import { useOcean } from '@oceanprotocol/react' import Header from './Header' import { toast } from 'react-toastify' import Actions from './Actions' -import { Logger, Ocean } from '@oceanprotocol/lib' +import { Logger } from '@oceanprotocol/lib' import Token from './Token' import FormHelp from '../../../atoms/Input/Help' import Button from '../../../atoms/Button' +import { getMaxValuesRemove } from './utils' const help = { simple: @@ -22,33 +23,6 @@ const help = { 'You will get OCEAN and Datatokens equivalent to your pool share, without any limit.' } -async function getMaxValues( - ocean: Ocean, - poolAddress: string, - poolTokens: string, - amountPoolShares: string -) { - const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity( - poolAddress - ) - - const amountMaxPoolShares = await ocean.pool.getPoolSharesRequiredToRemoveOcean( - poolAddress, - amountMaxOcean - ) - - const amountMaxPercent = `${Math.floor( - (Number(amountMaxPoolShares) / Number(poolTokens)) * 100 - )}` - - const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( - poolAddress, - amountPoolShares - ) - - return { amountMaxPercent, amountOcean } -} - export default function Remove({ setShowRemove, poolAddress, @@ -125,7 +99,7 @@ export default function Remove({ setAmountOcean(tokens?.oceanAmount) setAmountDatatoken(tokens?.dtAmount) } else { - const { amountMaxPercent, amountOcean } = await getMaxValues( + const { amountMaxPercent, amountOcean } = await getMaxValuesRemove( ocean, poolAddress, poolTokens, @@ -183,7 +157,9 @@ export default function Remove({

You will receive

- {isAdvanced && } + {isAdvanced === true && ( + + )}
diff --git a/src/components/organisms/AssetActions/Pool/utils.ts b/src/components/organisms/AssetActions/Pool/utils.ts new file mode 100644 index 000000000..31dc46622 --- /dev/null +++ b/src/components/organisms/AssetActions/Pool/utils.ts @@ -0,0 +1,28 @@ +import { Ocean } from '@oceanprotocol/lib' + +export async function getMaxValuesRemove( + ocean: Ocean, + poolAddress: string, + poolTokens: string, + amountPoolShares: string +): Promise<{ amountMaxPercent: string; amountOcean: string }> { + const amountMaxOcean = await ocean.pool.getOceanMaxRemoveLiquidity( + poolAddress + ) + + const amountMaxPoolShares = await ocean.pool.getPoolSharesRequiredToRemoveOcean( + poolAddress, + amountMaxOcean + ) + + const amountMaxPercent = `${Math.floor( + (Number(amountMaxPoolShares) / Number(poolTokens)) * 100 + )}` + + const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( + poolAddress, + amountPoolShares + ) + + return { amountMaxPercent, amountOcean } +}