Tapioca-DAO / tap-token

24 stars 14 forks source link

Wrong variable assignment makes `TOB::exitPosition()` never check for expiry #247

Open 0xRektora opened 2 months ago

0xRektora commented 2 months ago

Context In TOB::exitPosition() we check for the time of expiry using

            if (!isSGLInRescueMode) {
                if (block.timestamp < lock.lockTime + lock.lockDuration) {
                    revert LockNotExpired();
                }
            }

However, on the V2 change, we added a new check on the user's BB debt

        // Check if debt ratio is below threshold, if so bypass lock expiration
        if (tOLP.canLockWithDebt(oTAP.ownerOf(_oTAPTokenID), uint256(lock.sglAssetID), uint256(lock.ybShares))) {
            // If SGL is in rescue, bypass the lock expiration
            isSGLInRescueMode = true;
            if (!isSGLInRescueMode) {
                if (block.timestamp < lock.lockTime + lock.lockDuration) {
                    revert LockNotExpired();
                }
            }
        }

The new addition

+             isSGLInRescueMode = true;

makes so the expiry check is never reached, and it should be removed.

0xRektora commented 2 months ago

@carrotsmuggler @maarcweiss