diff --git a/package.json b/package.json index 36df1dbc9..1011cb6a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "app-v2", - "version": "2.1.10", + "version": "2.1.11", "private": true, "dependencies": { "@multiavatar/multiavatar": "^1.0.6", diff --git a/src/hooks/actionHooks/useRepayDebt.ts b/src/hooks/actionHooks/useRepayDebt.ts index fe7d2a760..3b448040d 100644 --- a/src/hooks/actionHooks/useRepayDebt.ts +++ b/src/hooks/actionHooks/useRepayDebt.ts @@ -83,6 +83,7 @@ export const useRepayDebt = () => { const inputGreaterThanDebt: boolean = ethers.BigNumber.from(_inputAsFyToken).gte(vault.accruedArt); const inputGreaterThanMaxBaseIn = _input.gt(_MaxBaseIn); + const _inputforClose = (vault.accruedArt.gt(ZERO_BN) && vault.accruedArt.lte(_input)) ? vault.accruedArt : _input; /* if requested, and all debt will be repaid, automatically remove collateral */ @@ -104,13 +105,20 @@ export const useRepayDebt = () => { reclaimToAddress = ladleAddress; } - const alreadyApproved = ( + const alreadyApproved = !series.seriesIsMature && ( await base.getAllowance( account!, - series.seriesIsMature || inputGreaterThanMaxBaseIn ? base.joinAddress : ladleAddress + inputGreaterThanMaxBaseIn ? base.joinAddress : ladleAddress ) ).gte(_input); + const alreadyApprovedPostMaturity = series.seriesIsMature && ( + await base.getAllowance( + account!, + base.joinAddress + ) + ).gte(_inputforClose.mul(2)); + const permits: ICallData[] = await sign( [ { @@ -132,7 +140,7 @@ export const useRepayDebt = () => { target: base, spender: base.joinAddress, amount: MAX_256, - ignoreIf: !series.seriesIsMature || alreadyApproved === true, + ignoreIf: !series.seriesIsMature || alreadyApprovedPostMaturity === true, }, ], txCode