Skip to content

Commit

Permalink
Fix the sudden change in deposit input
Browse files Browse the repository at this point in the history
  • Loading branch information
alexharvest committed Oct 14, 2024
1 parent 4b3c22a commit ad41c4b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/AdvancedFarmComponents/Deposit/DepositBase/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const DepositBase = ({
}

if (pickedDefaultToken || portalsEstimate.succeed) {
let fromTokenUsdPrice, toTokenUsdPrice
let fromTokenUsdPrice, toTokenUsdPrice, newInputAmount
if (pickedDefaultToken) {
fromTokenUsdPrice = pickedToken.usdPrice
toTokenUsdPrice = Number(pickedToken.usdPrice) * Number(pricePerFullShare)
Expand All @@ -197,8 +197,18 @@ const DepositBase = ({
toTokenUsdPrice = toTokenDetail?.price
}

if (checkNativeToken(pickedToken)) {
newInputAmount = new BigNumber(
Math.floor(Number(balance) * 0.95 * 100000) / 100000,
).toString()
} else {
newInputAmount = new BigNumber(balance).toString()
}

const newAmount = toWei(newInputAmount, pickedToken.decimals, 0)

const quoteResult = {
fromTokenAmount: amount,
fromTokenAmount: newAmount,
fromTokenUsdPrice,
minToTokenAmount: pickedDefaultToken
? outputAmountDefault
Expand Down

0 comments on commit ad41c4b

Please sign in to comment.