# Pendle Uses Wrong Return Value For swapExactTokensForTokens()

Pendle lend() reads index 0 (input amount) instead of index 1 (output) from swapExactTokensForTokens, minting wrong PT amounts to msg.sender.

- Payout: Contest reward
- Severity: high
- Program: Illuminate
- Credited: kirk-baird
- Disclosed: 2022-08-23
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2022-06-illuminate-findings/issues/94
- Library page: https://bugbountylibrary.com/r/c4%3A2022-06-illuminate%3AH-03
- Tags: domain:web3 impact:integrity kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error

**Target:** Pendle integration lend() in Illuminate
**Root cause:** swapExactTokensForTokens returns [inputAmount, outputAmount...]; the code indexes [0] (input) instead of [1] (principal output) when computing returned PT amount.
**Steps:**
1. Call Pendle lend() which builds path [u, principal] and invokes swapExactTokensForTokens(a - fee, r, path, address(this), d)
2. Observe returned = ...[0], which is the input amount a - fee, not the principal received
3. PTs minted to msg.sender are computed from this wrong value, over/under-stating the minted amount depending on exchange rate
**How found:** Code review of the Pendle integration: noticed the swap return array was indexed at [0], recalling that index 0 is the input amount and outputs start at index 1.
**Exploitation:** Attacker calls lend() when exchange rate makes input amount exceed actual principal output, receiving inflated PT tokens; or is shortchanged otherwise. No capital/sequence detail beyond the misindexing.
**Insight:** When integrating AMM routers, verify which index of the returned amounts array is the output; index 0 is always the input amount, so [0] silently yields the wrong mint/burn quantity.
