fix exchangeToNativeDecimal function

This commit is contained in:
lomonoshka
2023-11-03 18:34:43 +04:00
parent 8263258226
commit ad40b10f78
2 changed files with 2 additions and 2 deletions

View File

@@ -99,5 +99,5 @@ export async function toNativeDecimals(token: AddressLike, amount: BigNumberish,
const contract = ERC20__factory.connect(token, provider)
decimals = BigInt(await contract.decimals())
}
return BigInt(amount) * (BigInt(10) ** decimals) / (BigInt(10) ** 8n)
return BigInt(amount) * (BigInt(10) ** decimals)
}

View File

@@ -77,7 +77,7 @@ export async function generateSwapCalldataWithUnit({
amount,
minReturnAmount,
receiverAddress,
useContractBalance: walletBalance < BigInt(amount),
useContractBalance: walletBalance < await exchangeToNativeDecimals(path.first().assetIn, amount, unit.provider),
path,
wethAddress,
curveRegistryAddress,