From 1c40ac91132b6ecef14faae1f88e9e8b3e9fe936 Mon Sep 17 00:00:00 2001 From: brucedonovan Date: Mon, 8 Nov 2021 09:29:03 +0000 Subject: [PATCH] bugfix: approve collInput on borrow --- src/hooks/actionHooks/useBorrow.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/hooks/actionHooks/useBorrow.ts b/src/hooks/actionHooks/useBorrow.ts index 8d99fd280..b642ef724 100644 --- a/src/hooks/actionHooks/useBorrow.ts +++ b/src/hooks/actionHooks/useBorrow.ts @@ -4,7 +4,7 @@ import { SettingsContext } from '../../contexts/SettingsContext'; import { UserContext } from '../../contexts/UserContext'; import { ICallData, IVault, ActionCodes, LadleActions, ISeries } from '../../types'; import { cleanValue, getTxCode } from '../../utils/appUtils'; -import { ETH_BASED_ASSETS, BLANK_VAULT } from '../../utils/constants'; +import { ETH_BASED_ASSETS, BLANK_VAULT, MAX_256 } from '../../utils/constants'; import { buyBase, calculateSlippage } from '../../utils/yieldMath'; import { useChain } from '../useChain'; import { useAddCollateral } from './useAddCollateral'; @@ -50,7 +50,7 @@ export const useBorrow = () => { /* if approveMAx, check if signature is required */ const alreadyApproved = approveMax - ? (await ilk.baseContract.allowance(account, ilk.joinAddress)).gt(_input) + ? (await ilk.baseContract.allowance(account, ilk.joinAddress)).gt(_collInput) : false; /* Gather all the required signatures - sign() processes them and returns them as ICallData types */ @@ -60,7 +60,7 @@ export const useBorrow = () => { target: ilk, spender: ilk.joinAddress, message: `Allow Yield Protocol to move ${ilk.symbol}`, - amount: _input, + amount: _collInput, ignoreIf: alreadyApproved || ETH_BASED_ASSETS.includes(selectedIlkId) || _collInput.eq(ethers.constants.Zero), }, ],