Commit 5744ec3
Block same-timestamp Predict mint and redeem (DBU-472) (#1085)
* Block same-timestamp Predict mint and redeem
Record each position's open time (clock.timestamp_ms()) at mint and reject
a live redeem whose timestamp equals it. A single transaction reads one
Clock, so this closes the atomic mint -> oracle-update -> redeem arbitrage
that would round-trip a freshly minted order against a price the same tx
pushed. The open time is carried forward across partial-close replacements,
so seasoned positions stay closable in multiple steps.
DPU-472
Co-authored-by: Cursor <cursoragent@cursor.com>
* Unit-test the same-timestamp redeem guard
Move the open-time comparison into a factual predict_account assertion
(assert_not_opened_at, owning the open-time state) so the abort path is
covered by running unit tests instead of only the disabled flow test:
the same-timestamp abort (ESameTimestampRedeem), the missing-position
abort, and the pass case that reads back the stored open time.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Keep redeem-timestamp policy in expiry_market
predict_account is position state only: expose a position_opened_at_ms
getter and move the same-timestamp redeem assertion back into
expiry_market::redeem_live_internal (EMintRedeemSameTimestamp), where the
redeem flow owns the policy. The getter keeps its missing-position unit
coverage; the abort path is covered by the disabled flow test.
Co-authored-by: Cursor <cursoragent@cursor.com>
---------
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 542280e commit 5744ec3
4 files changed
Lines changed: 284 additions & 14 deletions
File tree
- packages/predict
- sources
- tests
- flows
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
803 | 804 | | |
804 | 805 | | |
805 | 806 | | |
| 807 | + | |
806 | 808 | | |
807 | 809 | | |
808 | 810 | | |
| |||
857 | 859 | | |
858 | 860 | | |
859 | 861 | | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
860 | 869 | | |
861 | 870 | | |
862 | 871 | | |
| |||
888 | 897 | | |
889 | 898 | | |
890 | 899 | | |
| 900 | + | |
891 | 901 | | |
892 | 902 | | |
893 | 903 | | |
| |||
967 | 977 | | |
968 | 978 | | |
969 | 979 | | |
| 980 | + | |
970 | 981 | | |
971 | 982 | | |
972 | 983 | | |
| |||
976 | 987 | | |
977 | 988 | | |
978 | 989 | | |
979 | | - | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
980 | 998 | | |
981 | 999 | | |
982 | 1000 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
38 | 49 | | |
39 | 50 | | |
40 | 51 | | |
| |||
45 | 56 | | |
46 | 57 | | |
47 | 58 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 59 | + | |
| 60 | + | |
51 | 61 | | |
52 | 62 | | |
53 | 63 | | |
| |||
146 | 156 | | |
147 | 157 | | |
148 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
149 | 172 | | |
150 | 173 | | |
| 174 | + | |
151 | 175 | | |
152 | 176 | | |
153 | 177 | | |
154 | 178 | | |
155 | 179 | | |
| 180 | + | |
156 | 181 | | |
157 | 182 | | |
158 | 183 | | |
159 | 184 | | |
160 | 185 | | |
161 | | - | |
| 186 | + | |
162 | 187 | | |
163 | 188 | | |
164 | 189 | | |
| |||
173 | 198 | | |
174 | 199 | | |
175 | 200 | | |
176 | | - | |
| 201 | + | |
177 | 202 | | |
178 | 203 | | |
179 | 204 | | |
180 | | - | |
| 205 | + | |
181 | 206 | | |
182 | 207 | | |
183 | 208 | | |
| |||
Lines changed: 157 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 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 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
0 commit comments