diff --git a/src/components/organisms/AssetActions/Pool/Add.tsx b/src/components/organisms/AssetActions/Pool/Add.tsx index abdec6aab..cfe9e1bea 100644 --- a/src/components/organisms/AssetActions/Pool/Add.tsx +++ b/src/components/organisms/AssetActions/Pool/Add.tsx @@ -16,17 +16,18 @@ export default function Add({ setShowAdd, poolAddress, totalPoolTokens, - totalBalance + totalBalance, + liquidityProviderFee }: { setShowAdd: (show: boolean) => void poolAddress: string totalPoolTokens: string totalBalance: Balance + liquidityProviderFee: string }): ReactElement { const { debug } = useUserPreferences() const { ocean, accountId, balance } = useOcean() const [amount, setAmount] = useState('') - const [swapFee, setSwapFee] = useState() const [txId, setTxId] = useState('') const [isLoading, setIsLoading] = useState() @@ -38,14 +39,6 @@ export default function Add({ totalBalance && ((Number(newPoolTokens) / Number(totalPoolTokens)) * 100).toFixed(2) - useEffect(() => { - async function getFee() { - const swapFee = await ocean.pool.getSwapFee(accountId, poolAddress) - setSwapFee(swapFee) - } - getFee() - }, []) - async function handleAddLiquidity() { setIsLoading(true) @@ -96,7 +89,7 @@ export default function Add({

You will earn

- + of each pool transaction
diff --git a/src/components/organisms/AssetActions/Pool/index.tsx b/src/components/organisms/AssetActions/Pool/index.tsx index f668e0786..57b753ac7 100644 --- a/src/components/organisms/AssetActions/Pool/index.tsx +++ b/src/components/organisms/AssetActions/Pool/index.tsx @@ -33,6 +33,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { const [totalBalance, setTotalBalance] = useState() const [dtSymbol, setDtSymbol] = useState() const [userBalance, setUserBalance] = useState() + const [liquidityProviderFee, setLiquidityProviderFee] = useState() const [showAdd, setShowAdd] = useState(false) const [showRemove, setShowRemove] = useState(false) @@ -103,6 +104,13 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { } setUserBalance(userBalance) + + // Get liquidity provider fee + const liquidityProviderFee = await ocean.pool.getSwapFee( + accountId, + price.address + ) + setLiquidityProviderFee(liquidityProviderFee) } catch (error) { console.error(error.message) } finally { @@ -122,6 +130,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement { poolAddress={price.address} totalPoolTokens={totalPoolTokens} totalBalance={totalBalance} + liquidityProviderFee={liquidityProviderFee} /> ) : showRemove ? ( )} +