Skip to content

Commit

Permalink
fix: use fee asset for dust amount conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladinlight committed Nov 21, 2024
1 parent a785032 commit fbc7fc4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ export const Confirm: React.FC<ConfirmProps> = ({ accountId, onNext }) => {
toBaseUnit(fromThorBaseUnit(protocolFeeCryptoThorBaseUnit), asset.precision),
)
setDustAmountCryptoBaseUnit(
bnOrZero(toBaseUnit(fromThorBaseUnit(dust_amount), asset.precision)).toFixed(
asset.precision,
),
bnOrZero(toBaseUnit(fromThorBaseUnit(dust_amount), feeAsset.precision)).toFixed(),
)
const percentage = bnOrZero(slippage_bps).div(BASE_BPS_POINTS).times(100)
// total downside (slippage going into position) - 0.007 ETH for 5 ETH deposit
Expand All @@ -241,6 +239,7 @@ export const Confirm: React.FC<ConfirmProps> = ({ accountId, onNext }) => {
accountId,
asset,
dustAmountCryptoBaseUnit,
feeAsset,
opportunity?.apy,
opportunityData?.rewardsCryptoBaseUnit,
opportunityData?.stakedAmountCryptoBaseUnit,
Expand Down
8 changes: 7 additions & 1 deletion src/lib/utils/thorchain/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,19 @@ export const fetchHasEnoughBalanceForTxPlusFeesPlusSweep = async ({
throw new Error('Invalid type')
}
})()

const amountCryptoPrecision =
type === 'deposit'
? _amountCryptoPrecision
: fromThorBaseUnit(
(quote as ThorchainSaversWithdrawQuoteResponseSuccess).dust_amount,
).toFixed()
const amountCryptoBaseUnit = toBaseUnit(amountCryptoPrecision, asset.precision)

const amountCryptoBaseUnit = toBaseUnit(
amountCryptoPrecision,
type === 'deposit' ? asset.precision : feeAsset?.precision ?? 0,
)

const estimatedFeesQueryArgs = {
estimateFeesInput: {
amountCryptoPrecision,
Expand Down

0 comments on commit fbc7fc4

Please sign in to comment.