Skip to content

Commit

Permalink
4x outbound fee and toFixed(0)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaladinlight committed Nov 22, 2024
1 parent 966ef7b commit 31bda9c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,8 @@ export const Confirm: React.FC<ConfirmProps> = ({ accountId, onNext }) => {
}, [onNext])

const missingBalanceForGasCryptoPrecision = useMemo(() => {
if (isTokenWithdraw) {
return fromBaseUnit(
bnOrZero(feeAssetBalanceCryptoBaseUnit)
.minus(bnOrZero(state?.withdraw.estimatedGasCryptoBaseUnit))
.minus(bnOrZero(dustAmountCryptoBaseUnit))
.times(-1),
feeAsset.precision,
)
}
return fromBaseUnit(
bnOrZero(assetBalanceBaseUnit)
bnOrZero(isTokenWithdraw ? feeAssetBalanceCryptoBaseUnit : assetBalanceBaseUnit)
.minus(bnOrZero(state?.withdraw.estimatedGasCryptoBaseUnit))
.minus(bnOrZero(dustAmountCryptoBaseUnit))
.times(-1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ export const Withdraw: React.FC<WithdrawProps> = ({ accountId, fromAddress, onNe
return toBaseUnit(outboundFeeInAssetCryptoPrecision, asset.precision)
}, [outboundFeeCryptoBaseUnit, assetPriceInFeeAsset, asset, feeAsset])

// https://gitlab.com/thorchain/thornode/-/blob/develop/x/thorchain/querier_quotes.go#L467
const safeOutboundFeeInAssetCryptoBaseUnit = useMemo(() => {
if (!outboundFeeInAssetCryptoBaseUnit) return
// Add 5% as as a safety factor since the dust threshold fee is not necessarily going to cut it
return bnOrZero(outboundFeeInAssetCryptoBaseUnit).times(1.05).toFixed(0)
return bnOrZero(outboundFeeInAssetCryptoBaseUnit).times(4).toFixed(0)
}, [outboundFeeInAssetCryptoBaseUnit])

const _validateCryptoAmount = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const thorchainSaversStakingOpportunitiesUserDataResolver = async ({
) // to actual asset precision base unit

const rewardsAmountsCryptoBaseUnit: [string] = [
stakedAmountCryptoBaseUnitIncludeRewards.minus(stakedAmountCryptoBaseUnit).toFixed(),
stakedAmountCryptoBaseUnitIncludeRewards.minus(stakedAmountCryptoBaseUnit).toFixed(0),
]

const dateUnlocked = await (async () => {
Expand Down Expand Up @@ -388,7 +388,7 @@ export const thorchainSaversStakingOpportunitiesUserDataResolver = async ({
stakingOpportunitiesUserDataByUserStakingId[userStakingId] = {
isLoaded: true,
userStakingId,
stakedAmountCryptoBaseUnit: stakedAmountCryptoBaseUnit.toFixed(),
stakedAmountCryptoBaseUnit: stakedAmountCryptoBaseUnit.toFixed(0),
rewardsCryptoBaseUnit: { amounts: rewardsAmountsCryptoBaseUnit, claimable: false },
dateUnlocked,
}
Expand Down

0 comments on commit 31bda9c

Please sign in to comment.