From 53496cf11adfb438f96bb0373280e7e25060c66c Mon Sep 17 00:00:00 2001 From: abel Date: Wed, 24 Jan 2024 11:48:04 -0300 Subject: [PATCH] (fix) Configured different extra gas cost for spot and derivative post only orders --- pyinjective/core/gas_limit_estimator.py | 22 +++++++++++++++------- pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pyinjective/core/gas_limit_estimator.py b/pyinjective/core/gas_limit_estimator.py index 7de11d63..c3f65760 100644 --- a/pyinjective/core/gas_limit_estimator.py +++ b/pyinjective/core/gas_limit_estimator.py @@ -16,8 +16,10 @@ DERIVATIVE_ORDER_CREATION_GAS_LIMIT = 70_000 SPOT_ORDER_CANCELATION_GAS_LIMIT = 50_000 DERIVATIVE_ORDER_CANCELATION_GAS_LIMIT = 60_000 -# POST ONLY orders take around 50% more gas to create than normal orders, due to the validations -POST_ONLY_ORDER_MULTIPLIER = 0.5 +# POST ONLY orders take around 60% (for spot) and 50% (for derivative) more gas to create than normal orders +# due to the required validations +SPOT_POST_ONLY_ORDER_MULTIPLIER = 0.6 +DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER = 0.5 class GasLimitEstimator(ABC): @@ -109,7 +111,7 @@ def gas_limit(self) -> int: total = 0 total += self.GENERAL_MESSAGE_GAS_LIMIT total += len(self._message.orders) * SPOT_ORDER_CREATION_GAS_LIMIT - total += math.ceil(len(post_only_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER) + total += math.ceil(len(post_only_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * SPOT_POST_ONLY_ORDER_MULTIPLIER) return total @@ -150,7 +152,9 @@ def gas_limit(self) -> int: total = 0 total += self.GENERAL_MESSAGE_GAS_LIMIT total += len(self._message.orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT - total += math.ceil(len(post_only_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER) + total += math.ceil( + len(post_only_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER + ) return total @@ -204,12 +208,16 @@ def gas_limit(self) -> int: total += len(self._message.derivative_orders_to_create) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT total += len(self._message.binary_options_orders_to_create) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT - total += math.ceil(len(post_only_spot_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER) + total += math.ceil(len(post_only_spot_orders) * SPOT_ORDER_CREATION_GAS_LIMIT * SPOT_POST_ONLY_ORDER_MULTIPLIER) total += math.ceil( - len(post_only_derivative_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER + len(post_only_derivative_orders) + * DERIVATIVE_ORDER_CREATION_GAS_LIMIT + * DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER ) total += math.ceil( - len(post_only_binary_options_orders) * DERIVATIVE_ORDER_CREATION_GAS_LIMIT * POST_ONLY_ORDER_MULTIPLIER + len(post_only_binary_options_orders) + * DERIVATIVE_ORDER_CREATION_GAS_LIMIT + * DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER ) total += len(self._message.spot_orders_to_cancel) * SPOT_ORDER_CANCELATION_GAS_LIMIT diff --git a/pyproject.toml b/pyproject.toml index 7c315858..3e2aaa19 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "injective-py" -version = "1.2.0-rc2" +version = "1.2.0-rc3" description = "Injective Python SDK, with Exchange API Client" authors = ["Injective Labs "] license = "Apache-2.0"