Commit d7d37da
fix(PerpV2BasisTradingModule): External audit fixes for low-risk findings and Internal audit fixes (#232)
* Design Improvement: Cache storage slot values
* Design Improvements: Spelling and grammar
* Fix typo
* Fix revert statement
* Design improvement: Return early if no funding will be withdrawn
* Fix coverage: Add test case for when notionalFunding is zero
* Fix failing test
* Modify calculateExternalPositionUnit logic used by deposit and withdraw; Reduce bytecodesize
* Override withdraw function to track settled funding
* Fix deposit; Add check to ensure deposit unit is <= current unit; Add tests
* Refactor update external position unit logic; Add tests
* Fix tests; And skip 2 getRedemptionAdjustments tests
* Add internal audit fixes and suggestions
* Fix division by zero error
* fix(tests): Small fixes for BasisTradingModule audit changes (#243)
* Add fix for _updateExternalPositionUnit
* Add test for negative balance check in _calculateNetFeesPositionUnit
* Fix externalPositionUnit test in perpV2LeverageV2SlippageIssuance tests
* Use `tradeAndTrackFunding` everywhere in BasisTrading integration tests
* Remove .skip; Fix javadocs
Co-authored-by: cgewecke <[email protected]>1 parent 509eddf commit d7d37da
File tree
11 files changed
+526
-194
lines changed- contracts
- interfaces/external/perp-v2
- protocol
- lib
- modules/v2
- deprecated
- test
- integration
- protocol/modules/v2
- utils
- common
- deploys
11 files changed
+526
-194
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
65 | | - | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | | - | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
194 | | - | |
| 194 | + | |
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| |||
Lines changed: 109 additions & 49 deletions
Large diffs are not rendered by default.
Lines changed: 32 additions & 48 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
64 | | - | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
352 | 353 | | |
353 | 354 | | |
354 | 355 | | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
355 | 360 | | |
356 | 361 | | |
357 | 362 | | |
| |||
374 | 379 | | |
375 | 380 | | |
376 | 381 | | |
| 382 | + | |
377 | 383 | | |
378 | 384 | | |
379 | 385 | | |
| |||
385 | 391 | | |
386 | 392 | | |
387 | 393 | | |
388 | | - | |
| 394 | + | |
389 | 395 | | |
390 | 396 | | |
391 | 397 | | |
| |||
555 | 561 | | |
556 | 562 | | |
557 | 563 | | |
558 | | - | |
| 564 | + | |
559 | 565 | | |
560 | 566 | | |
561 | 567 | | |
| |||
830 | 836 | | |
831 | 837 | | |
832 | 838 | | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
| 839 | + | |
839 | 840 | | |
840 | 841 | | |
841 | 842 | | |
| |||
885 | 886 | | |
886 | 887 | | |
887 | 888 | | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
| 889 | + | |
894 | 890 | | |
895 | 891 | | |
896 | 892 | | |
| |||
1058 | 1054 | | |
1059 | 1055 | | |
1060 | 1056 | | |
1061 | | - | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1062 | 1061 | | |
1063 | | - | |
1064 | | - | |
1065 | | - | |
1066 | | - | |
1067 | | - | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
1076 | 1066 | | |
1077 | 1067 | | |
1078 | | - | |
1079 | 1068 | | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
1091 | 1074 | | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
1096 | 1081 | | |
1097 | 1082 | | |
1098 | | - | |
1099 | 1083 | | |
1100 | 1084 | | |
1101 | 1085 | | |
| |||
1107 | 1091 | | |
1108 | 1092 | | |
1109 | 1093 | | |
1110 | | - | |
| 1094 | + | |
1111 | 1095 | | |
1112 | 1096 | | |
1113 | 1097 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
| 274 | + | |
275 | 275 | | |
276 | 276 | | |
277 | 277 | | |
| |||
318 | 318 | | |
319 | 319 | | |
320 | 320 | | |
321 | | - | |
| 321 | + | |
322 | 322 | | |
323 | 323 | | |
324 | 324 | | |
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | | - | |
| 416 | + | |
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
566 | | - | |
567 | | - | |
| 566 | + | |
| 567 | + | |
568 | 568 | | |
569 | 569 | | |
570 | 570 | | |
| |||
1052 | 1052 | | |
1053 | 1053 | | |
1054 | 1054 | | |
1055 | | - | |
1056 | | - | |
| 1055 | + | |
| 1056 | + | |
1057 | 1057 | | |
1058 | 1058 | | |
1059 | 1059 | | |
| |||
1134 | 1134 | | |
1135 | 1135 | | |
1136 | 1136 | | |
1137 | | - | |
| 1137 | + | |
1138 | 1138 | | |
1139 | 1139 | | |
1140 | 1140 | | |
| |||
1236 | 1236 | | |
1237 | 1237 | | |
1238 | 1238 | | |
1239 | | - | |
| 1239 | + | |
1240 | 1240 | | |
1241 | 1241 | | |
1242 | 1242 | | |
| |||
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
| 257 | + | |
258 | 258 | | |
259 | 259 | | |
260 | 260 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
297 | 298 | | |
298 | 299 | | |
299 | 300 | | |
| |||
508 | 509 | | |
509 | 510 | | |
510 | 511 | | |
| 512 | + | |
511 | 513 | | |
512 | 514 | | |
513 | 515 | | |
| |||
542 | 544 | | |
543 | 545 | | |
544 | 546 | | |
545 | | - | |
| 547 | + | |
546 | 548 | | |
547 | 549 | | |
548 | 550 | | |
| |||
855 | 857 | | |
856 | 858 | | |
857 | 859 | | |
| 860 | + | |
858 | 861 | | |
859 | 862 | | |
860 | 863 | | |
| |||
909 | 912 | | |
910 | 913 | | |
911 | 914 | | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
912 | 919 | | |
| 920 | + | |
913 | 921 | | |
914 | 922 | | |
915 | 923 | | |
| |||
918 | 926 | | |
919 | 927 | | |
920 | 928 | | |
| 929 | + | |
921 | 930 | | |
922 | 931 | | |
923 | 932 | | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
924 | 936 | | |
925 | 937 | | |
926 | 938 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
991 | 991 | | |
992 | 992 | | |
993 | 993 | | |
994 | | - | |
| 994 | + | |
995 | 995 | | |
996 | 996 | | |
997 | 997 | | |
| |||
0 commit comments