Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fiat amount lps gas fee maths #7787

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,28 @@ 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])

const poolAssetGasFeeFiatUserCurrency = useMemo(
NeOMakinG marked this conversation as resolved.
Show resolved Hide resolved
() => 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 +861,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 +869,8 @@ export const RemoveLiquidityInput: React.FC<RemoveLiquidityInputProps> = ({
withdrawType,
poolAssetFeeAsset,
poolAssetFeeAssetBalanceCryptoBaseUnit,
poolAssetFeeAssetDustAmountCryptoBaseUnit,
poolAssetTxFeeCryptoPrecision,
poolAssetFeeAssetDustAmountCryptoPrecision,
])

const hasEnoughRuneBalanceForTx = useMemo(() => {
Expand Down
Loading