# Wrong token allocation computation for token decimals != 18 if floor price not reached

Trader Joe LaunchEvent scaled token allocation by token.decimals() instead of 1e18, zeroing allocation for non-18-decimal tokens when floor price missed.

- Payout: Audit contest
- Severity: high
- Program: Trader Joe
- Found by: cmichel
- Disclosed: 2022-03-07
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-01-trader-joe-findings/issues/193
- Library page: https://bugbountylibrary.com/r/c4%3A2022-01-trader-joe%3AH-02
- Tags: domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error vuln:precision-loss

**Target:** LaunchEvent.createPair token allocation logic (Solidity)
**Root cause:** tokenAllocated = (wavaxReserve * 10**token.decimals()) / floorPrice uses token decimals, but floorPrice is scaled to 1e18, so the units mismatch for tokens with decimals != 18.
**Steps:**
1. Sell 1.0 wBTC (8 decimals) at floorPrice 2000e18 AVAX/token => floorPrice = 2e31.
2. Launch raises only 1000e18 AVAX (half), so floorPrice > wavaxReserve*1e18/tokenAllocated triggers reduction.
3. Compute tokenAllocated = 1000e18 * 1e8 / 2e31 = 0 (truncates to zero).
4. Observe no tokens allocated instead of expected 0.5e8 wBTC.
5. Fix: tokenAllocated = wavaxReserve * 1e18 / floorPrice.
**How found:** Code review of createPair: noticed floorPrice documented as 1e18-scaled but tokenAllocated multiplied by 10**token.decimals(), then tested with an 8-decimal token example showing truncation to zero.
**Insight:** When a price/rate is documented as scaled to 1e18, audit every multiplication/division against it for unit consistency; non-18-decimal tokens (wBTC, USDC) expose decimal-mismatch truncation that silently zeroes amounts.
