# Incorrect implementation of arctan in the contract FairSideFormula

FairSideFormula's _arctan omitted abs() calls, producing wrong results for negative inputs and miscomputing FSD mint/burn amounts in calculateDeltaOfFSD.

- Payout: Audit contest
- Severity: high
- Program: FairSide
- Disclosed: 2021-07-07
- Write-up quality: 6/10
- Original: https://github.com/code-423n4/2021-05-fairside-findings/issues/73
- Library page: https://bugbountylibrary.com/r/c4%3A2021-05-fairside%3AH-08
- Tags: area:web3 domain:web3 impact:funds-loss kind:contest platform:code4rena sev:high tech:solidity technique:source-review vuln:accounting-error

**Target:** FairSideFormula Solidity contract (_arctan/arctan/arcs)
**Root cause:** _arctan uses `a` directly instead of `a.abs()` in the polynomial term, so the approximation diverges from the referenced paper when `a` is negative.
**Steps:**
1. Note `arcs` calls `arctan(ONE.sub(arcInner))` where `arcInner = MULTIPLIER_INNER_ARCTAN.mul(x).div(fS3_4)` and `x` is the capital pool, so the argument can be negative.
2. Observe `_arctan` computes `a.mul(a.abs().sub(ONE)).mul(APPROX_A.add(APPROX_B.mul(a.abs())))` without abs on the leading `a`.
3. Fix by using `a.abs()` in place of `a` in that term, matching the paper's formula.
4. Impact propagates to `calculateDeltaOfFSD`, changing FSD tokens minted or burned.
**How found:** Compared the contract's `_arctan` implementation against the referenced paper's formula and noticed the missing `abs` on `a`, then traced callers to confirm negative inputs are reachable.
**Insight:** When a contract ports a published math formula, diff each term against the paper symbol-by-symbol; sign handling (abs) is a common omission, and tracing callers for reachable negative inputs turns a math nit into a fund-impacting bug.

