# Parameter misordering in fee collection function causes denial of service and fee loss

Swapped arguments in Seawater AMM's collect_protocol fee transfer pass recipient as token address, reverting every call and locking protocol fees.

- Payout: Audit contest
- Severity: high
- Program: Superposition
- Found by: mashbust
- Disclosed: 2024-10-18
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2024-08-superposition-findings/issues/84
- Library page: https://bugbountylibrary.com/r/c4%3A2024-08-superposition%3AH-05
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:rust tech:solidity technique:source-review vuln:business-logic vuln:dos

**Target:** Seawater AMM collect_protocol_7540_F_A_9_F fee collection function (Rust/Stylus)
**Root cause:** erc20::transfer_to_addr is called with (recipient, pool, amount) instead of (token, recipient, amount), so the recipient address is treated as the token contract and the transfer reverts.
**Steps:**
1. Call `collect_protocol_7540_F_A_9_F(pool, amount_0, amount_1, recipient)` as seawater_admin.
2. Function invokes `erc20::transfer_to_addr(recipient, pool, U256::from(token_0))` and `erc20::transfer_to_addr(recipient, FUSDC_ADDR, U256::from(token_1))`.
3. transfer_to_addr expects `(token, recipient, amount)`; recipient is used as token address, pool/FUSDC as recipient.
4. safe_transfer reverts; fee collection always fails.
**How found:** Source review of the fee collection function against the transfer_to_addr signature in wasm_erc20.rs revealed the argument order mismatch; confirmed via test-node trace showing revert.
**Exploitation:** No attacker action needed; any invocation of the admin-only fee collection reverts, permanently locking accrued protocol fees in the pool.
**Insight:** When auditing Rust/Stylus contracts, diff every external helper call's argument order against its declared signature — same-typed Address parameters make swapped args compile cleanly and only surface at runtime.

## Proof of concept (copied exactly from the original report)

**Buggy fee collection function with swapped transfer args**

```
pub fn collect_protocol_7540_F_A_9_F(
    &mut self,
    pool: Address,
    amount_0: u128,
    amount_1: u128,
    recipient: Address,
) -> Result<(u128, u128), Revert> {
    assert_eq_or!(
        msg::sender(),
        self.seawater_admin.get(),
        Error::SeawaterAdminOnly
    );

    let (token_0, token_1) = self
        .pools
        .setter(pool)
        .collect_protocol(amount_0, amount_1)?;

    // Incorrect transfer logic
    erc20::transfer_to_addr(recipient, pool, U256::from(token_0))?;
    erc20::transfer_to_addr(recipient, FUSDC_ADDR, U256::from(token_1))?;

    #[cfg(feature = "log-events")]
    evm::log(events::CollectProtocolFees {
        pool,
        to: recipient,
        amount0: token_0,
        amount1: token_1,
    });

    // transfer tokens
    Ok((token_0, token_1))
}
```

