Skip to content

Commit

Permalink
Merge branch 'develop' into new-splash
Browse files Browse the repository at this point in the history
  • Loading branch information
NeOMakinG authored Sep 25, 2024
2 parents f6c0fcd + 22877d9 commit 2549d8a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
10 changes: 9 additions & 1 deletion src/pages/Lending/hooks/useAllLendingPositionsData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,30 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
[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(() => {
Expand Down Expand Up @@ -842,11 +863,6 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
poolAssetFeeAsset?.precision,
)

const poolAssetFeeAssetDustAmountCryptoPrecision = fromBaseUnit(
poolAssetFeeAssetDustAmountCryptoBaseUnit,
poolAssetFeeAsset?.precision,
)

return bnOrZero(poolAssetTxFeeCryptoPrecision)
.plus(poolAssetFeeAssetDustAmountCryptoPrecision)
.lte(poolAssetFeeAssetBalanceCryptoPrecision)
Expand All @@ -855,8 +871,8 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
withdrawType,
poolAssetFeeAsset,
poolAssetFeeAssetBalanceCryptoBaseUnit,
poolAssetFeeAssetDustAmountCryptoBaseUnit,
poolAssetTxFeeCryptoPrecision,
poolAssetFeeAssetDustAmountCryptoPrecision,
])

const hasEnoughRuneBalanceForTx = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 2549d8a

Please sign in to comment.