From 2f94c0207bdebee618c8c57c7678748b97e3d9ce Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:01:51 +0800 Subject: [PATCH 1/3] fix: fiat amount lps gas fee maths (#7787) --- .../RemoveLiquidity/RemoveLiquidityInput.tsx | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx b/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx index e22c1232665..95302aa7966 100644 --- a/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx +++ b/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx @@ -449,9 +449,30 @@ export const RemoveLiquidityInput: React.FC = ({ [estimatedPoolAssetFeesData?.txFeeCryptoBaseUnit, poolAssetFeeAsset?.precision], ) + const poolAssetFeeAssetDustAmountCryptoPrecision = useMemo(() => { + if (!poolAssetFeeAsset) return 0 + + return fromBaseUnit(poolAssetFeeAssetDustAmountCryptoBaseUnit, poolAssetFeeAsset?.precision) + }, [poolAssetFeeAssetDustAmountCryptoBaseUnit, poolAssetFeeAsset]) + + const poolAssetFeeAssetDustAmountFiatUserCurrency = useMemo(() => { + return bnOrZero(poolAssetFeeAssetDustAmountCryptoPrecision).times( + poolAssetFeeAssetMarketData.price, + ) + }, [poolAssetFeeAssetMarketData.price, poolAssetFeeAssetDustAmountCryptoPrecision]) + + // We also include the dust amount in the gas fee as it's deducted in the input validation + // This will result in displaying gas fees and dust amounts as a single value in the UI const poolAssetGasFeeFiatUserCurrency = useMemo( - () => bnOrZero(poolAssetTxFeeCryptoPrecision).times(poolAssetFeeAssetMarketData.price), - [poolAssetFeeAssetMarketData.price, poolAssetTxFeeCryptoPrecision], + () => + bnOrZero(poolAssetTxFeeCryptoPrecision) + .times(poolAssetFeeAssetMarketData.price) + .plus(poolAssetFeeAssetDustAmountFiatUserCurrency), + [ + poolAssetFeeAssetMarketData.price, + poolAssetTxFeeCryptoPrecision, + poolAssetFeeAssetDustAmountFiatUserCurrency, + ], ) const runeProtocolFeeCryptoPrecision = useMemo(() => { @@ -842,11 +863,6 @@ export const RemoveLiquidityInput: React.FC = ({ poolAssetFeeAsset?.precision, ) - const poolAssetFeeAssetDustAmountCryptoPrecision = fromBaseUnit( - poolAssetFeeAssetDustAmountCryptoBaseUnit, - poolAssetFeeAsset?.precision, - ) - return bnOrZero(poolAssetTxFeeCryptoPrecision) .plus(poolAssetFeeAssetDustAmountCryptoPrecision) .lte(poolAssetFeeAssetBalanceCryptoPrecision) @@ -855,8 +871,8 @@ export const RemoveLiquidityInput: React.FC = ({ withdrawType, poolAssetFeeAsset, poolAssetFeeAssetBalanceCryptoBaseUnit, - poolAssetFeeAssetDustAmountCryptoBaseUnit, poolAssetTxFeeCryptoPrecision, + poolAssetFeeAssetDustAmountCryptoPrecision, ]) const hasEnoughRuneBalanceForTx = useMemo(() => { From f585c316def27e0e5c7ca111ad0e34c09e17d77d Mon Sep 17 00:00:00 2001 From: Apotheosis <0xapotheosis@gmail.com> Date: Tue, 24 Sep 2024 18:30:44 +1000 Subject: [PATCH 2/3] fix: empty loan state (#7792) --- src/pages/Lending/hooks/useAllLendingPositionsData.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/Lending/hooks/useAllLendingPositionsData.tsx b/src/pages/Lending/hooks/useAllLendingPositionsData.tsx index 28a82cebc96..5f481818033 100644 --- a/src/pages/Lending/hooks/useAllLendingPositionsData.tsx +++ b/src/pages/Lending/hooks/useAllLendingPositionsData.tsx @@ -115,7 +115,15 @@ export const useAllLendingPositionsData = ({ assetId }: UseAllLendingPositionsDa ) const isLoading = useMemo(() => positions.some(position => position.isLoading), [positions]) - const isActive = useMemo(() => positions.some(position => position.data), [positions]) + + const isActive = useMemo(() => { + return positions.some(position => { + const data = position.data + if (!data) return false + const { collateralBalanceCryptoPrecision } = data + return collateralBalanceCryptoPrecision && parseFloat(collateralBalanceCryptoPrecision) > 0 + }) + }, [positions]) return { debtValueUserCurrency, From 22877d9136655283b76776eb558b1c776c6505ec Mon Sep 17 00:00:00 2001 From: NeOMakinG <14963751+NeOMakinG@users.noreply.github.com> Date: Tue, 24 Sep 2024 22:36:55 +0800 Subject: [PATCH 3/3] fix: lower btc dust threshold as thor docs (#7788) --- .../opportunitiesSlice/resolvers/thorchainsavers/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state/slices/opportunitiesSlice/resolvers/thorchainsavers/utils.ts b/src/state/slices/opportunitiesSlice/resolvers/thorchainsavers/utils.ts index 01aa66eb8b3..5418fa05931 100644 --- a/src/state/slices/opportunitiesSlice/resolvers/thorchainsavers/utils.ts +++ b/src/state/slices/opportunitiesSlice/resolvers/thorchainsavers/utils.ts @@ -48,7 +48,7 @@ const usdtEthereumAssetId: AssetId = 'eip155:1/erc20:0xdac17f958d2ee523a22062069 // The minimum amount to be sent both for deposit and withdraws // else it will be considered a dust attack and gifted to the network export const THORCHAIN_SAVERS_DUST_THRESHOLDS_CRYPTO_BASE_UNIT = { - [btcAssetId]: '30000', + [btcAssetId]: '10000', [bchAssetId]: '10000', [ltcAssetId]: '10000', [dogeAssetId]: '100000000',