Skip to content

Commit

Permalink
Merge branch 'develop' into fix-past-loan-state
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre authored Sep 24, 2024
2 parents 02a1ff3 + 2f94c02 commit 6baa04a
Showing 1 changed file with 24 additions and 8 deletions.
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

0 comments on commit 6baa04a

Please sign in to comment.