Commit f1841f0
Protocol fee switch-over timestamp (cowprotocol#3907)
# Description
cowprotocol#3900 introduced a way to show the volume fees to users in advance via
quotes. Autopilot should start applying the same policies simultaneously
to avoid situations where the user receives an incorrect quote. This PR
introduces timestamp-based configs in both orderbook and autopilot
crates that control when the volume fee should start applying.
For the orderbook, it is pretty straightforward, which adds an optional
timestamp param to the existing volume fee factor config, and each time
the service tries to apply volume fees, it checks for the current time.
If the timestamp config is None, it means volume fees are applied
unconditionally, which should be useful once switched to a long-lasting
config.
The autopilot config is a bit more sophisticated. It introduces a
separate "upcoming" fee policies config with the effective "from"
timestamp. ~~So, if another order's creation timestamp is after the
configured upcoming fee policy timestamp, the service starts using this
fee policy.~~ Based on [this
discussion](cowprotocol#3907 (comment)),
the volume fee gets applied only based on the current time. This is
useful because the volume fee factor affects price improvement and
surplus fee policy caps, so each time the volume fee factor is updated,
other fee policy configs need to be adjusted accordingly, so we need to
switch to the new fee policies set altogether. The config is also
optional and can be easily switched to permanent.
The major disadvantage of this approach is that orderbook and autopilot
use configs from different sources. A more correct approach would be to
use a shared config via a DB or similar, but this would require many
more changes, and we should probably avoid any mistakes by making deeper
reviews.
## How to test
New e2e tests.
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 37de01d commit f1841f0
File tree
10 files changed
+425
-74
lines changed- crates
- autopilot/src
- domain/fee
- e2e
- src/setup
- tests/e2e
- orderbook/src
10 files changed
+425
-74
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
194 | 195 | | |
195 | 196 | | |
196 | 197 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 198 | + | |
| 199 | + | |
204 | 200 | | |
205 | 201 | | |
206 | 202 | | |
| |||
389 | 385 | | |
390 | 386 | | |
391 | 387 | | |
392 | | - | |
393 | | - | |
| 388 | + | |
394 | 389 | | |
395 | 390 | | |
396 | 391 | | |
| |||
448 | 443 | | |
449 | 444 | | |
450 | 445 | | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
| 446 | + | |
456 | 447 | | |
457 | 448 | | |
458 | 449 | | |
| |||
585 | 576 | | |
586 | 577 | | |
587 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
588 | 595 | | |
589 | 596 | | |
590 | 597 | | |
| |||
604 | 611 | | |
605 | 612 | | |
606 | 613 | | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
607 | 632 | | |
608 | 633 | | |
609 | 634 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
56 | 79 | | |
57 | 80 | | |
58 | 81 | | |
59 | 82 | | |
60 | 83 | | |
| 84 | + | |
61 | 85 | | |
62 | 86 | | |
63 | 87 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 88 | + | |
68 | 89 | | |
69 | | - | |
| 90 | + | |
| 91 | + | |
70 | 92 | | |
71 | 93 | | |
72 | 94 | | |
73 | 95 | | |
74 | | - | |
| 96 | + | |
| 97 | + | |
75 | 98 | | |
76 | 99 | | |
77 | 100 | | |
| |||
230 | 253 | | |
231 | 254 | | |
232 | 255 | | |
233 | | - | |
234 | | - | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
235 | 265 | | |
236 | 266 | | |
237 | 267 | | |
238 | 268 | | |
239 | 269 | | |
| 270 | + | |
240 | 271 | | |
241 | 272 | | |
242 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
541 | | - | |
| 541 | + | |
542 | 542 | | |
543 | 543 | | |
544 | 544 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
2 | 14 | | |
3 | 15 | | |
4 | 16 | | |
| |||
57 | 69 | | |
58 | 70 | | |
59 | 71 | | |
60 | | - | |
61 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
62 | 75 | | |
63 | | - | |
| 76 | + | |
64 | 77 | | |
65 | 78 | | |
66 | 79 | | |
67 | 80 | | |
68 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
69 | 98 | | |
70 | 99 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
1074 | 1077 | | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1081 | 1084 | | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
1086 | 1089 | | |
1087 | 1090 | | |
1088 | 1091 | | |
1089 | 1092 | | |
1090 | 1093 | | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
1095 | 1099 | | |
1096 | 1100 | | |
1097 | 1101 | | |
| |||
0 commit comments