# Misuse of AMM model on minting Synth (resubmit to add more detail)

Spartan Pool priced Synth minting off the same AMM curve as swaps but never reduced tokenAmount, so minting Synth was always cheaper than swapping, opening arbitrage.

- Payout: Audit contest
- Severity: high
- Program: Spartan Protocol
- Found by: jonah1005
- Disclosed: 2021-09-16
- Write-up quality: 8/10
- Original: https://github.com/code-423n4/2021-07-spartan-findings/issues/59
- Library page: https://bugbountylibrary.com/r/c4%3A2021-07-spartan%3AH-11
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:business-logic vuln:oracle-manipulation

**Target:** Pool.sol mintSynth AMM pricing
**Root cause:** mintSynth computes output with calcSwapOutput using the pool's tokenAmount, but minting Synth does not decrease tokenAmount (unlike swapTo), so the AMM price never reflects the Synth debt issued.
**Steps:**
1. Initialize Pool at 10000:10000 base:token.
2. Loop 10x: transfer 1e18 SPARTA to token_pool, call `token_pool.functions.swapTo(token.address, user).transact()`; total token out = 4744.4059.
3. Reset pool to 10000:10000.
4. Loop 10x: transfer 1e18 SPARTA to token_pool, call `token_pool.functions.mintSynth(token_synth.address, user).transact()`; total Synth out = 6223.758.
5. Observe minting yields ~31% more than swapping for identical input.
**How found:** Compared the mintSynth code path (L232) against the swapTo path (L287) and noticed both call calcSwapOutput with the same tokenAmount, but only swap decrements the pool's token balance; reasoned that minting is therefore always cheaper.
**Exploitation:** Attacker mints Synth repeatedly (or via flash loan) to capture the price discrepancy versus swapping, extracting the arbitrage spread and pushing Synth off peg; the pool's tokenAmount is never debited so the favorable price persists.
**Escalation:** Flash-loan capital could scale the arbitrage across the full price gap since the mispricing is structural, not one-shot.
**Insight:** When a protocol reuses one AMM pricing function for both swaps and issuance, check whether every path that consumes pool inventory actually debits the reserve; any issuance path that mints 'out of thin air' against an undebited reserve is systematically mispriced.

