# Balance check for swapToken in ShortLongSpell#_deposit is incorrect and will result in nonfunctional contract

ShortLongSpell._deposit computes strTokenAmt as swapToken balance minus borrowed amount, but swapToken equals borrowToken, so the subtraction underflows and reverts on every swap.

- Payout: Contest reward
- Severity: high
- Program: Blueberry
- Credited: 0x52
- Disclosed: 2023-04-07
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/133
- Library page: https://bugbountylibrary.com/r/sherlock%3A2023-04-blueberry%3AH-10
- Tags: domain:web3 impact:dos kind:contest platform:sherlock sev:high tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** ShortLongSpell.sol _deposit swap accounting
**Root cause:** swapToken is always vault.uToken which equals borrowToken, so after swapping the swapToken balance decreases; subtracting the original strTokenAmt underflows and reverts.
**Steps:**
1. Call ShortLongSpell._deposit with borrowToken = vault.uToken and a swapData that swaps borrowed token to strategy token.
2. Observe strTokenAmt = _doBorrow(...) records borrowed amount.
3. swapToken = ISoftVault(strategy.vault).uToken() equals borrowToken.
4. PSwapLib.megaSwap executes, reducing swapToken balance below strTokenAmt.
5. Line `strTokenAmt = swapToken.balanceOf(address(this)) - strTokenAmt` underflows and reverts.
**How found:** Code reading: noticed swapToken is defined as vault.uToken and borrowToken is required to be vault.uToken, so they are identical; reasoned the post-swap balance subtraction must underflow.
**Insight:** When a contract aliases two token variables (swapToken = vault.uToken, borrowToken = vault.uToken), check whether the 'swap' actually changes the balance before subtracting the pre-swap amount; identical tokens make the delta negative.
