| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | ETHUSDC | 999.95 | Oracle | Quantity | 10 | ||||||||||||||||||||
2 | ETHUSDC | 1000 | Spot | Debt | 6000 | ||||||||||||||||||||
3 | Flash loan fee | 0.05% | |||||||||||||||||||||||
4 | Contango fee | 0.10% | |||||||||||||||||||||||
5 | |||||||||||||||||||||||||
6 | Scenario # | Action | Cashflow | Cashflow Ccy | Desired Quantity Δ | Cashflow | Spot Cost | Debt Δ | Leverage | FL Fee | Cost | Fee | Final quantity Δ | Obs | Trader position size/collateral/leverage changes | Detailed steps | |||||||||
7 | 1 | Open | Add | Base | 10 | 4 | -6000 | 6003 | 2.501876407 | 3 | -10003 | 0.01 | 9.99 | Borrow 6k, Sell 6k for ~= 6 ETH | - flash loan 6000 USDC - swap 6000 USDC for ~6ETH - take 4 ETH from trader - take 0.01 ETH as fees - lend ~6 ETH + 3.99 ETH = ~9.99 ETH - borrow 6000 + 3 USDC - repay 6003 USDC to the flash loan | ||||||||||
8 | 2 | Open | Add | Quote | 10 | 4000 | -10000 | 6003 | 2.501876407 | 3 | -10003 | 0.01 | 9.99 | Borrow 6k, Sell 10k for ~= 10 ETH | - flash loan 6000 USDC - take 4000 USDC from trader - swap 10000 USDC for ~10 ETH - take ~0.01 ETH fees - lend ~9.99 ETH - borrow 6000 + 3 USDC - repay 6003 USDC to the flash loan | ||||||||||
9 | 3 | Increase | - | - | 4 | -4000 | 4002 | 3.501750875 | 2 | -4002 | 0.004 | 3.996 | Borrow 4k, Sell 4k for ~= 4 ETH | - increase position size - no collateral change - increase leverage | - flash loan 4000 USDC - swap 4000 USDC to ~4ETH - take 0.004 ETH as fees - lend ~3.996 ETH - borrow 4000 + 2 USDC - repay 4002 USDC to the flash loan | ||||||||||
10 | 4 | Increase | Add | Base | 4 | 3 | -1000 | 1000.5 | 2.000142867 | 0.5 | -3999.5 | 0.004 | 3.996 | Sell 1k for ~= 1 ETH | - increase position size - add collateral in base - decrease leverage | - flash loan 1000 USDC - swap 1000 USDC to ~1ETH - take 3 ETH from trader - take 0.004 ETH as fees - lend ~1ETH + 2.996 ETH = ~3.996 ETH - borrow 1000 + 0.50 USDC - repay 1000.50 USDC to the flash loan | |||||||||
11 | 5 | Increase | Add | Base | 4 | 4 | 0 | 0 | 1.75 | 0 | -3999.8 | 0.004 | 3.996 | Just lend 4 ETH, no spot trade needed | - increase position size - add collateral in base - decrease leverage | - take 4 ETH from trader - take 0.004 ETH as fees - lend 3.996 ETH | |||||||||
12 | 6 | Increase | Add | Base | 4 | 6 | -2000 | -2000 | 1.4 | 0 | -4000 | 0.004 | 3.996 | Lend 4 ETH & Sell 2 ETH, repay debt with the proceeds | - increase position size - add collateral - decrease leverage | - take 6 ETH from trader - take 0.004 ETH as fees - lend 3.996 ETH - swap 2 ETH for ~2000 USDC - use the ~2000 USDC to repay debt | |||||||||
13 | 7 | - | Add | Base | 0 | 2 | -2000 | -2000 | 1.666666667 | 0 | 0 | 0 | 0 | Sell 2 ETH, repay debt with the proceeds | - no position quantity change - add collateral in base - decrease leverage | - take 2 ETH from trader - swap 2 ETH for ~2000 USDC - use the ~2000 USDC to repay debt | |||||||||
14 | 8 | Increase | Add | Quote | 4 | 3000 | -4000 | 1000.5 | 2.000142867 | 0.5 | -3999.5 | 0.004 | 3.996 | Buy 4 ETH but only borrow what the trader's not paying for (borrow 1k) | - increase position size - add collateral in quote - decrease leverage | - flash loan 1000 USDC - take 3000 USDC from trader - swap 4000 USDC to ~4 ETH - take ~0.004 as fees - lend ~3.996 ETH - borrow 1000 + 0.50 USDC - repay 1000.50 USDC to the flash loan | |||||||||
15 | 9 | Increase | Add | Quote | 4 | 4000 | -4000 | 0 | 1.75 | 0 | -4000 | 0.004 | 3.996 | Buy 4 ETH, no changes on debt | - increase position size - add collateral in quote - decrease leverage | - get 4000 USDC from trader - swap 4000 USDC to ~4ETH - take 0.004 ETH as fees - lend ~3.996 ETH | |||||||||
16 | 10 | Increase | Add | Quote | 4 | 6000 | -4000 | -2000 | 1.4 | 0 | -4000 | 0.004 | 3.996 | Buy 4 ETH & repay debt with the excess cashflow | - increase position size - add collateral in quote - decrease leverage | - get 6000 USDC from trader - swap 4000 USDC to ~4ETH - take 0.004 ETH as fees - lend ~3.996 ETH - use remaining 2000 USDC to repay debt | |||||||||
17 | 11 | - | Add | Quote | 0 | 2000 | 0 | -2000 | 1.666666667 | 0 | 0 | 0 | 0 | Repay debt with cashflow | - no change on position size - add collateral in quote - decrease leverage | - get 2000 USDC from trader - use 2000 USDC to repay debt | |||||||||
18 | 12 | Increase | Remove | Base | 4 | -0.1 | -4100 | 4102.05 | 3.591631499 | 2.05 | -4002.05 | 0.004 | 3.996 | Buy 4.1 ETH, Lend 4, Withdraw 0.1 (take 4.1k new debt) | - increase position size - remove collateral in base - increase leverage | - flash loan 4100 USDC - swap 4100 USDC to ~4.1 ETH - give 0.1 ETH to trader - take 0.004 ETH as fees - lend ~3.996 ETH - borrow 4100 + 2.05 USDC - repay 4102.50 USDC to the flash loan | |||||||||
19 | 13 | Increase | Remove | Base | 1 | -1.1 | -2100 | 2101.05 | 3.794477311 | 1.05 | -1001 | 0.001 | 0.999 | Buy 2.1 ETH, Lend 1, Withdraw 1.1 (take 1.1k new debt) | - increase position size - remove collateral in base - increase leverage | - flash loan 2100 USDC - swap 2100 USDC for ~2.1 ETH - give 1.1 ETH to trader - take 0.001 ETH as fees - lend ~0.999 ETH - borrow 2100 + 1.05 USDC - repay 2101.05 USDC to the flash loan | |||||||||
20 | 14 | Increase | Remove | Quote | 4 | -100 | 4000 | 4102.05 | 3.591631499 | 2.05 | 4002.05 | 0.004 | 3.996 | Buy 4 ETH, Withdraw 100 (take 4.1k new debt) | - increase position size - remove collateral in quote - increase leverage | - flash loan 4100 USDC - give 100 USDC to the trader - swap 4000 USDC to ~4ETH - take 0.004 ETH as fees - lend ~3.996 ETH - borrow 4100 + 2.05 USDC - repay 4102.05 USDC to the flash loan | |||||||||
21 | 15 | Increase | Remove | Quote | 1 | -1100 | 1000 | 2101.05 | 3.794477311 | 1.05 | 1001.05 | 0.001 | 0.999 | Buy 1 ETH, Withdraw 1.1k (take 2.1k new debt) | - increase position size - remove collateral in quote - increase leverage | - flash loan 2100 USDC - give 1100 USDC to trader - swap 1000 USDC to ~1ETH - take 0.001 ETH as fees - lend ~1 ETH - borrow 2100 + 1.05 USDC - repay 2101.05 USDC to the flash loan | |||||||||
22 | 16 | Decrease | - | - | -4 | 3994 | -3994 | 1.50225338 | 0.002 | -3994.002 | 0.004 | -4 | Sell 4 ETH, repay debt with proceeds | - decrease position size - no collateral change - decrease leverage | - flash loan 4 - 0.002 - 0.004 = 3.994 ETH - swap 3.994 ETH for ~3994 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH for fees - repay 3.994 + ~0.002 = ~3.996 ETH to the flash loan | ||||||||||
23 | 17 | Decrease | Add | Base | -4 | 1 | 4993.5 | -4993.5 | 1.201562031 | 0.0025 | 3992.803598 | 0.004 | -4 | Sell 5 ETH, repay debt with proceeds | - decreasing position size - add collateral - decrease leverage | - flash loan 5 - 0.0025 - 0.004 = 4.9935 ETH - swap 4.9935 ETH for ~4993.50 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH for fees - get 1 ETH from the trader - repay 4.9935 + ~0.0025 = ~4.996 ETH to the flash loan | |||||||||
24 | 18 | Decrease | Add | Quote | -4 | 1000 | 3994 | -4994 | 1.20144173 | 0.002 | 3994 | 0.004 | -4 | Sell 4 ETH, repay debt worth 5k | - decreasing position size - adding collateral in quote - decrease leverage | - flash loan 4 - 0.002 - 0.004 = 3.994 ETH - swap 3.994 ETH for ~3994 USDC - get 1000 USDC from trader - use 1000 + ~3994 = ~4994 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH for fees - repay 3.994 + ~0.002 = ~3.996 ETH to the flash loan | |||||||||
25 | 19 | Decrease | Remove | Base | -4 | -2.5 | 1494 | -1494 | 4.016064257 | 0.002 | 3978.695073 | 0.004 | -4 | Sell 4 ETH, withdraw 2.5 ETH, repay 1.5k | - decreasing position size - remove collateral in base - increase leverage | - flash loan 4 - 0.002 - 0.004 = 3.994 ETH - transfer 2.5 ETH to the trader - swap 1.494 ETH for ~1494 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH for the fees - repay 3.994 + ~0.002 = ~3.996 ETH to the flash loan | |||||||||
26 | 20 | Decrease | Remove | Base | -1 | -2 | 1000 | 1000 | 4.5 | 0 | -1000 | 0.001 | -1 | Borrow 1k, Sell 1k, withdraw approx 2 ETH | - decreasing position size - remove collateral in base - increasing leverage | - unlend 1 ETH - keep 0.001 ETH fee - borrow 1000 USDC and swap for ~1 ETH - give ~1 + 0.999 = ~1.999 ETH to trader | |||||||||
27 | 21 | Decrease | Remove | Quote | -4 | -2500 | 3994 | -1494 | 4.016064257 | 0.002 | 3994 | 0.004 | -4 | Sell 4 ETH, repay 1.5k debt, withdraw 2.5k | - decrease position size - remove collateral in quote - increase leverage | - flash loan 4 - 0.002 - 0.004 = 3.994 ETH - swap 3.994 ETH for ~3994 USDC - transfer 2500 USDC to trader - use ~1494 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH fee - repay 3.994 + ~0.002 = ~3.996 ETH to the flash loan | |||||||||
28 | 22 | Decrease | Remove | Quote | -1 | -2000 | 998.5 | 1001.5 | 4.503377533 | 0.0005 | 998.5 | 0.001 | -1 | Sell 1 ETH, take 1k debt, withdraw 2k | - decrease position size - remove collateral in quote - increase leverage | - flash loan 1 - 0.0005 - 0.001 = 0.9985 ETH - swap 0.9985 ETH for ~998.50 USDC - borrow the difference between what you need (2000 USDC) and what you get (~998.50 USDC), which is ~1001.50 USDC - transfer 2000 USDC to the trader - unlend 1 ETH - keep 0.001 ETH fee - repay 0.9985 + ~0.0005 = 0.999 ETH to the flash loan | |||||||||
29 | 23 | Close | Remove | Base | -10 | -4 | 6000 | -6000 | 0.003 | 9995.002499 | 0.01 | -10 | Sell 6 ETH, repay 6k, withdraw 4 ETH | fully close and get base | - overshoot amount needed for the swap. e.g. slippage tolerance of 0.1%, then swap 6.006 ETH for ~6006 USDC (WE NEED TO ENSURE WE HAVE 6k FOR THE DEBT, NO MATTER THE SLIPPAGE) - flash loan 6 + 0.006 ETH = 6.006 ETH - swap 6.006 ETH for ~6006 USDC - use 6000 USDC to repay debt - unlend 10 ETH (unlend the full lending position, more money could be unlent depending on the interest on the lending position) - keep 0.01 ETH fee - repay 6.006 + 0.003003 = 6.009003 ETH to the flash loan - transfer 10 - 6.009003 - 0.01 = 3.980997 ETH and ~6 USDC to the trader | ||||||||||
30 | 24 | Close | Remove | Quote | -10 | -4000 | 9985 | -6000 | 0.005 | 9985 | 0.01 | -10 | Sell 10 ETH, repay 6k, withdraw 4k | fully close and get quote | - flash loan 10 - 0.005 = 9.995 ETH - unlend 10 ETH (unlend full lending position, more money could be unlent depending on the interest on the lending position) - keep 0.01 ETH fee - repay 10 + 0.005 = 10.005 ETH to the flash loan - swap 9.985 ETH for ~9985 USDC - use 6000 USDC to repay debt - transfer ~9985 - 6000 = ~3985 USDC to the trader | ||||||||||
31 | 25 | - | Remove | Base | 0 | -1 | 1000 | 1000 | 3.333333333 | 0 | 0 | 0 | 0 | Borrow 1k, Buy 1 ETH, withdraw 1 ETH | - no change in position size - remove collateral in base - increase leverage | - borrow 1000 USDC - swap to ~1 ETH - transfer ~1 ETH to the trader | |||||||||
32 | 26 | - | Remove | Quote | 0 | -1000 | 0 | 1000 | 3.333333333 | 0 | 0 | 0 | 0 | Borrow 1k, withdraw 1k | - no change in position size - remove collateral in quote - increase leverage | - borrow 1000 USDC - give the 1000 USDC to the trader | |||||||||
33 | 27 | Decrease | Remove | Base | -1 | -1 | 0 | 0 | 3 | 0 | -999.95 | 0.001 | -1 | Just withdraw 1 ETH, no spot trade needed | - decrease position size - remove collateral in base - increase leverage | - unlend 1 ETH - take 0.001 ETH fee - transfer 0.999 ETH to the trader | |||||||||
34 | 28 | Increase | Add | Base | 5 | 1 | -4000 | 4002 | 3.00120048 | 2 | -4998 | 0.005 | 4.995 | Sell 4k for ~= 4 ETH | - increase position size - add collateral in base - increase leverage | - flash loan 4000 USDC - swap 4000 USDC to ~4ETH - take 1 ETH from trader - take 0.004 ETH as fees - lend ~4ETH + 0.996 ETH = ~4.996 ETH - borrow 4000 + 2 USDC - repay 4002 USDC to the flash loan | |||||||||
35 | 29 | Increase | Add | Quote | 5 | 1000 | -5000 | 4002 | 3.00120048 | 2 | -4998 | 0.005 | 4.995 | Buy 5 ETH but only borrow what the trader's not paying for (borrow 4k) | - increase position size - add collateral in quote - increase leverage | - flash loan 4000 USDC - take 1000 USDC from trader - swap 5000 USDC to ~5 ETH - take ~0.005 as fees - lend ~4.995 ETH - borrow 4000 + 2 USDC - repay 4002 USDC to the flash loan | |||||||||
36 | 30 | Decrease | Remove | Base | -4 | -1 | 2994 | -2994 | 2.004008016 | 0.002 | 3989.34044 | 0.004 | -4 | Sell 3 ETH, withdraw 1 ETH, repay 3k | - decreasing position size - remove collateral in base - decrease leverage | - flash loan 4 - 0.002 - 0.004 = 3.994 ETH - transfer 1 ETH to the trader - swap 2.994 ETH for ~2994 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH for the fees - repay 3.994 + ~0.002 = ~3.996 ETH to the flash loan | |||||||||
37 | 31 | Decrease | Remove | Quote | -4 | -1000 | 3994 | 2994 | -2.004008016 | 0.002 | 3994 | 0.004 | -4 | Sell 4 ETH, repay 3k debt, withdraw 1k | - decrease position size - remove collateral in quote - decrease leverage | - flash loan 4 - 0.002 - 0.004 = 3.994 ETH - swap 3.994 ETH for ~3994 USDC - transfer 1000 USDC to trader - use ~2994 USDC to repay debt - unlend 4 ETH - keep 0.004 ETH fee - repay 3.994 + ~0.002 = ~3.996 ETH to the flash loan | |||||||||
38 | |||||||||||||||||||||||||
39 | |||||||||||||||||||||||||
40 | |||||||||||||||||||||||||
41 | |||||||||||||||||||||||||
42 | |||||||||||||||||||||||||
43 | |||||||||||||||||||||||||
44 | |||||||||||||||||||||||||
45 | |||||||||||||||||||||||||
46 | |||||||||||||||||||||||||
47 | |||||||||||||||||||||||||
48 | |||||||||||||||||||||||||
49 | |||||||||||||||||||||||||
50 | |||||||||||||||||||||||||
51 | |||||||||||||||||||||||||
52 | |||||||||||||||||||||||||
53 | |||||||||||||||||||||||||
54 | |||||||||||||||||||||||||
55 | |||||||||||||||||||||||||
56 | |||||||||||||||||||||||||
57 | |||||||||||||||||||||||||
58 | |||||||||||||||||||||||||
59 | |||||||||||||||||||||||||
60 | |||||||||||||||||||||||||
61 | |||||||||||||||||||||||||
62 | |||||||||||||||||||||||||
63 | |||||||||||||||||||||||||
64 | |||||||||||||||||||||||||
65 | |||||||||||||||||||||||||
66 | |||||||||||||||||||||||||
67 | |||||||||||||||||||||||||
68 | |||||||||||||||||||||||||
69 | |||||||||||||||||||||||||
70 | |||||||||||||||||||||||||
71 | |||||||||||||||||||||||||
72 | |||||||||||||||||||||||||
73 | |||||||||||||||||||||||||
74 | |||||||||||||||||||||||||
75 | |||||||||||||||||||||||||
76 | |||||||||||||||||||||||||
77 | |||||||||||||||||||||||||
78 | |||||||||||||||||||||||||
79 | |||||||||||||||||||||||||
80 | |||||||||||||||||||||||||
81 | |||||||||||||||||||||||||
82 | |||||||||||||||||||||||||
83 | |||||||||||||||||||||||||
84 | |||||||||||||||||||||||||
85 | |||||||||||||||||||||||||
86 | |||||||||||||||||||||||||
87 | |||||||||||||||||||||||||
88 | |||||||||||||||||||||||||
89 | |||||||||||||||||||||||||
90 | |||||||||||||||||||||||||
91 | |||||||||||||||||||||||||
92 | |||||||||||||||||||||||||
93 | |||||||||||||||||||||||||
94 | |||||||||||||||||||||||||
95 | |||||||||||||||||||||||||
96 | |||||||||||||||||||||||||
97 | |||||||||||||||||||||||||
98 | |||||||||||||||||||||||||
99 | |||||||||||||||||||||||||
100 |