|
16 | 16 | DERIVATIVE_ORDER_CREATION_GAS_LIMIT = 70_000 |
17 | 17 | SPOT_ORDER_CANCELATION_GAS_LIMIT = 50_000 |
18 | 18 | DERIVATIVE_ORDER_CANCELATION_GAS_LIMIT = 60_000 |
19 | | -# POST ONLY orders take around 50% more gas to create than normal orders, due to the validations |
20 | | -POST_ONLY_ORDER_MULTIPLIER = 0.5 |
| 19 | +# POST ONLY orders take around 60% (for spot) and 50% (for derivative) more gas to create than normal orders |
| 20 | +# due to the required validations |
| 21 | +SPOT_POST_ONLY_ORDER_MULTIPLIER = 0.6 |
| 22 | +DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER = 0.5 |
21 | 23 |
|
22 | 24 |
|
23 | 25 | class GasLimitEstimator(ABC): |
@@ -109,7 +111,7 @@ def gas_limit(self) -> int: |
109 | 111 | total = 0 |
110 | 112 | total += self.GENERAL_MESSAGE_GAS_LIMIT |
111 | 113 | total += len(self._message.orders) * SPOT_ORDER_CREATION_GAS_LIMIT |
112 | | - total += math.ceil(len(post_only_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER) |
| 114 | + total += math.ceil(len(post_only_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * SPOT_POST_ONLY_ORDER_MULTIPLIER) |
113 | 115 |
|
114 | 116 | return total |
115 | 117 |
|
@@ -150,7 +152,9 @@ def gas_limit(self) -> int: |
150 | 152 | total = 0 |
151 | 153 | total += self.GENERAL_MESSAGE_GAS_LIMIT |
152 | 154 | total += len(self._message.orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT |
153 | | - total += math.ceil(len(post_only_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER) |
| 155 | + total += math.ceil( |
| 156 | + len(post_only_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER |
| 157 | + ) |
154 | 158 |
|
155 | 159 | return total |
156 | 160 |
|
@@ -204,12 +208,16 @@ def gas_limit(self) -> int: |
204 | 208 | total += len(self._message.derivative_orders_to_create) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT |
205 | 209 | total += len(self._message.binary_options_orders_to_create) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT |
206 | 210 |
|
207 | | - total += math.ceil(len(post_only_spot_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER) |
| 211 | + total += math.ceil(len(post_only_spot_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * SPOT_POST_ONLY_ORDER_MULTIPLIER) |
208 | 212 | total += math.ceil( |
209 | | - len(post_only_derivative_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER |
| 213 | + len(post_only_derivative_orders) |
| 214 | + * DERIVATIVE_ORDER_CREATION_GAS_LIMIT |
| 215 | + * DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER |
210 | 216 | ) |
211 | 217 | total += math.ceil( |
212 | | - len(post_only_binary_options_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER |
| 218 | + len(post_only_binary_options_orders) |
| 219 | + * DERIVATIVE_ORDER_CREATION_GAS_LIMIT |
| 220 | + * DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER |
213 | 221 | ) |
214 | 222 |
|
215 | 223 | total += len(self._message.spot_orders_to_cancel) * SPOT_ORDER_CANCELATION_GAS_LIMIT |
|
0 commit comments