From 281537976814b5aaeea1ea7df3b1a93908a6fe3f Mon Sep 17 00:00:00 2001 From: Pham Tu Date: Mon, 27 Feb 2023 16:06:46 +0700 Subject: [PATCH] fix checking allowance --- src/pages/Pools/LiquidityModal/LiquidityModal.tsx | 4 ++-- src/rest/api.ts | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pages/Pools/LiquidityModal/LiquidityModal.tsx b/src/pages/Pools/LiquidityModal/LiquidityModal.tsx index 52c88943d..b96fda9d3 100644 --- a/src/pages/Pools/LiquidityModal/LiquidityModal.tsx +++ b/src/pages/Pools/LiquidityModal/LiquidityModal.tsx @@ -211,7 +211,7 @@ const LiquidityModal: FC = ({ displayToast(TToastType.TX_BROADCASTING); try { - if (!!token1AllowanceToPair && +token1AllowanceToPair < amount1) { + if (!!token1AllowanceToPair && token1AllowanceToPair < BigInt(amount1)) { await increaseAllowance( '9'.repeat(30), token1InfoData!.contractAddress!, @@ -219,7 +219,7 @@ const LiquidityModal: FC = ({ ); refetchToken1Allowance(); } - if (!!token2AllowanceToPair && +token2AllowanceToPair < amount2) { + if (!!token2AllowanceToPair && token2AllowanceToPair < BigInt(amount2)) { await increaseAllowance( '9'.repeat(30), token2InfoData!.contractAddress!, diff --git a/src/rest/api.ts b/src/rest/api.ts index fb718b93c..0b6aa915e 100644 --- a/src/rest/api.ts +++ b/src/rest/api.ts @@ -183,14 +183,15 @@ async function fetchTokenAllowance( tokenAddr: string, walletAddr: string, spender: string -) { - // hard code with token orai - // if (!tokenAddr) return '999999999999999999999999999999'; +): Promise { + // hard code with native token + if (!tokenAddr) return BigInt('999999999999999999999999999999'); + const data = await Contract.token(tokenAddr).allowance({ owner: walletAddr, spender }); - return data.allowance; + return BigInt(data.allowance); } async function fetchRewardInfo(