diff --git a/src/modules/fungibleTrading/quoter.ts b/src/modules/fungibleTrading/quoter.ts index 2a646ac..404b045 100644 --- a/src/modules/fungibleTrading/quoter.ts +++ b/src/modules/fungibleTrading/quoter.ts @@ -1,5 +1,5 @@ import { IQuoterContract, ProviderOrSigner, TheaNetwork, UniswapPoolFee } from "../../types"; -import { consts, ContractWrapper, validateAddress } from "../../utils"; +import { amountShouldBeGTZero, consts, ContractWrapper, validateAddress } from "../../utils"; import Quoter_ABI from "../../abi/Quoter_ABI.json"; import { BigNumber, BigNumberish } from "@ethersproject/bignumber"; @@ -22,6 +22,7 @@ export class Quoter extends ContractWrapper { ): Promise<{ amountOut: BigNumber | 0; fee: number }> { validateAddress(tokenIn); validateAddress(tokenOut); + amountShouldBeGTZero(amount); const fees = Object.values(UniswapPoolFee); diff --git a/src/modules/fungibleTrading/swapRouter.ts b/src/modules/fungibleTrading/swapRouter.ts index 50bf8fb..822d0c0 100644 --- a/src/modules/fungibleTrading/swapRouter.ts +++ b/src/modules/fungibleTrading/swapRouter.ts @@ -1,5 +1,5 @@ import { ExactInputSingleParams, ProviderOrSigner, ISwapRouterContract, SwapTokens, TheaNetwork } from "../../types"; -import { consts, ContractWrapper, signerRequired, validateAddress } from "../../utils"; +import { amountShouldBeGTZero, consts, ContractWrapper, signerRequired, validateAddress } from "../../utils"; import SwapRouter_ABI from "../../abi/SwapRouter_ABI.json"; import { ContractReceipt } from "@ethersproject/contracts"; import { approve, checkBalance, execute } from "../shared"; @@ -24,6 +24,7 @@ export class SwapRouter extends ContractWrapper { */ async swap(params: ExactInputSingleParams, tokenIn: SwapTokens): Promise { signerRequired(this.providerOrSigner); + amountShouldBeGTZero(params.amountIn); [params.tokenIn, params.tokenOut, params.recipient].forEach((address) => validateAddress(address)); // Check balance of token in