From bfdf7e1b2427c4cc02a18837a5e991260b8c09e1 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Mon, 24 Jan 2022 15:35:34 +0000 Subject: [PATCH] prepare to use getAmountInExactOut --- .../Asset/AssetActions/Pool/Add/index.tsx | 1 - .../Asset/AssetActions/Pool/Remove.tsx | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/components/Asset/AssetActions/Pool/Add/index.tsx b/src/components/Asset/AssetActions/Pool/Add/index.tsx index 3226cb1cf..935123cb3 100644 --- a/src/components/Asset/AssetActions/Pool/Add/index.tsx +++ b/src/components/Asset/AssetActions/Pool/Add/index.tsx @@ -14,7 +14,6 @@ import { useWeb3 } from '@context/Web3' import { useAsset } from '@context/Asset' import content from '../../../../../../content/price.json' import { LoggerInstance, Pool } from '@oceanprotocol/lib' -import { getOceanConfig } from '@utils/ocean' export interface FormAddLiquidity { amount: number diff --git a/src/components/Asset/AssetActions/Pool/Remove.tsx b/src/components/Asset/AssetActions/Pool/Remove.tsx index d6fa05348..27429b15d 100644 --- a/src/components/Asset/AssetActions/Pool/Remove.tsx +++ b/src/components/Asset/AssetActions/Pool/Remove.tsx @@ -53,12 +53,12 @@ export default function Remove({ const [minOceanAmount, setMinOceanAmount] = useState('0') Decimal.set({ toExpNeg: -18, precision: 18, rounding: 1 }) + const poolInstance = new Pool(web3, LoggerInstance) async function handleRemoveLiquidity() { setIsLoading(true) try { - const poolInstance = new Pool(web3, LoggerInstance) const result = await poolInstance.exitswapPoolAmountIn( accountId, poolAddress, @@ -89,11 +89,19 @@ export default function Remove({ const getValues = useRef( debounce(async (newAmountPoolShares) => { - // const amountOcean = await ocean.pool.getOceanRemovedforPoolShares( + // TODO: check based on pool tokens sent in, what I get out in baseToken. + // Seems to be not possible with getAmountInExactOut(). + // const tokenIn = newAmountPoolShares // TODO: this needs to pool shares? + // const swapMarketFee = '' // TODO: which is it? Swap fee or market fee? + // const baseTokenAmount = '' // TODO: this is what I want to know, why do I need to pass as param then? + // const newAmountOcean = await poolInstance.getAmountInExactOut( // poolAddress, - // newAmountPoolShares + // tokenIn, + // baseTokenAddress, + // baseTokenAmount, + // swapMarketFee // ) - // setAmountOcean(amountOcean) + // setAmountOcean(newAmountOcean) }, 150) ) // Check and set outputs when amountPoolShares changes