From 5030b346e1e44b90c88aefc5e84d3994abaaa0b5 Mon Sep 17 00:00:00 2001 From: Bogdan Fazakas Date: Mon, 2 May 2022 18:46:32 +0300 Subject: [PATCH] partial fix for asset with pool fees, algo not working yet --- .../Compute/FormComputeDataset.tsx | 1 - .../Asset/AssetActions/Compute/index.tsx | 22 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx index c0257a235..45c5d743d 100644 --- a/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx +++ b/src/components/Asset/AssetActions/Compute/FormComputeDataset.tsx @@ -146,7 +146,6 @@ export default function FormStartCompute({ .plus(priceAlgo) .toDecimalPlaces(MAX_DECIMALS) .toString() - console.log(totalPrice) setTotalPrice(totalPrice) }, [ asset?.accessDetails, diff --git a/src/components/Asset/AssetActions/Compute/index.tsx b/src/components/Asset/AssetActions/Compute/index.tsx index e77848f91..0a70cbde0 100644 --- a/src/components/Asset/AssetActions/Compute/index.tsx +++ b/src/components/Asset/AssetActions/Compute/index.tsx @@ -45,6 +45,8 @@ import { buyDtFromPool } from '@utils/pool' import { order, reuseOrder } from '@utils/order' import { AssetExtended } from 'src/@types/AssetExtended' import { getComputeFeedback } from '@utils/feedback' +import { usePool } from '@context/Pool' +import { useMarketMetadata } from '@context/MarketMetadata' export default function Compute({ asset, @@ -81,6 +83,8 @@ export default function Compute({ const hasDatatoken = Number(dtBalance) >= 1 const isMounted = useIsMounted() + const { getOpcFeeForToken } = useMarketMetadata() + const { poolData } = usePool() const newCancelToken = useCancelToken() const [isConsumablePrice, setIsConsumablePrice] = useState(true) const [isAlgoConsumablePrice, setIsAlgoConsumablePrice] = useState(true) @@ -145,10 +149,26 @@ export default function Compute({ asset.metadata.type )[0] ) + const poolParams = + asset?.accessDetails?.type === 'dynamic' + ? { + tokenInLiquidity: poolData?.baseTokenLiquidity, + tokenOutLiquidity: poolData?.datatokenLiquidity, + tokenOutAmount: '1', + opcFee: getOpcFeeForToken( + asset?.accessDetails?.baseToken.address, + asset?.chainId + ), + lpSwapFee: poolData?.liquidityProviderSwapFee, + publishMarketSwapFee: + asset?.accessDetails?.publisherMarketOrderFee, + consumeMarketSwapFee: '0' + } + : null const datasetPriceAndFees = await getOrderPriceAndFees( asset, ZERO_ADDRESS, - null, + poolParams, computeEnv?.id, validUntil )