Calculation guide
Single swap with a proportional input fee. Benchmark the average fill against the pretrade reserve ratio. Report the curve impact separately from the all-in shortfall including fees.
Inputs
Input-token reserve
Example entry 1000.
Output-token reserve
Example entry 2000.
Input tokens tendered
Example entry 100.
Input fee
Example entry 1 %. Allowed range 0 to 100.
Worked example
| Input | Value |
|---|---|
| Input-token reserve | 1,000 |
| Output-token reserve | 2,000 |
| Input tokens tendered | 100 |
| Input fee | 1% |
| Result | Value |
|---|---|
| Output tokens received | 180.163785 |
| Curve impact excluding fee | 9.008189% |
| All-in shortfall against spot | 9.918107% |
Calculation steps
Output tokens received = ((Output-token reserve × (Input tokens tendered × (1 − (Input fee ÷ 100)))) ÷ (Input-token reserve + (Input tokens tendered × (1 − (Input fee ÷ 100)))))
((2,000 × (100 × (1 − (1 ÷ 100)))) ÷ (1,000 + (100 × (1 − (1 ÷ 100))))) = 180.163785
Curve impact excluding fee = (((100 × Input tokens tendered) × (1 − (Input fee ÷ 100))) ÷ (Input-token reserve + (Input tokens tendered × (1 − (Input fee ÷ 100)))))
(((100 × 100) × (1 − (1 ÷ 100))) ÷ (1,000 + (100 × (1 − (1 ÷ 100))))) = 9.008189%
All-in shortfall against spot = (100 × (1 − (Output tokens received ÷ ((Input tokens tendered × Output-token reserve) ÷ Input-token reserve))))
(100 × (1 − (180.163785 ÷ ((100 × 2,000) ÷ 1,000)))) = 9.918107%
How each input affects this example
Each row starts from the worked example and changes one input.
| Input | Original input | New input | Affected result | Original result | New result |
|---|---|---|---|---|---|
| Input-token reserve | 1,000 | 1,100 | Output tokens received | 180.163785 | 165.137615 |
| Output-token reserve | 2,000 | 2,200 | Output tokens received | 180.163785 | 198.180164 |
| Input tokens tendered | 100 | 110 | Output tokens received | 180.163785 | 196.410858 |
| Input fee | 1% | 2% | Output tokens received | 180.163785 | 178.506375 |
