Skip to content

Commit

Permalink
(fix) Changed gas cost of spot orders in general, to solve out of gas…
Browse files Browse the repository at this point in the history
… issues when using the estimator
  • Loading branch information
abel committed Jan 24, 2024
1 parent 53496cf commit e315110
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions pyinjective/core/gas_limit_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
tx_pb2 as injective_exchange_tx_pb,
)

SPOT_ORDER_CREATION_GAS_LIMIT = 45_000
SPOT_ORDER_CREATION_GAS_LIMIT = 50_000
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 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
# POST ONLY orders take around 50% more gas to create than normal orders due to the required validations
SPOT_POST_ONLY_ORDER_MULTIPLIER = 0.5
DERIVATIVE_POST_ONLY_ORDER_MULTIPLIER = 0.5


Expand Down
6 changes: 3 additions & 3 deletions tests/core/test_gas_limit_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_estimation_for_batch_create_spot_limit_orders(self):
message = composer.MsgBatchCreateSpotLimitOrders(sender="sender", orders=orders)
estimator = GasLimitEstimator.for_message(message=message)

expected_order_gas_limit = 45000
expected_order_gas_limit = 50000
expected_message_gas_limit = 15000

assert (expected_order_gas_limit * 2) + expected_message_gas_limit == estimator.gas_limit()
Expand Down Expand Up @@ -172,7 +172,7 @@ def test_estimation_for_batch_update_orders_to_create_spot_orders(self):
)
estimator = GasLimitEstimator.for_message(message=message)

expected_order_gas_limit = 45_000
expected_order_gas_limit = 50_000
expected_message_gas_limit = 15_000

assert (expected_order_gas_limit * 2) + expected_message_gas_limit == estimator.gas_limit()
Expand Down Expand Up @@ -462,7 +462,7 @@ def test_estimation_for_exec_message(self):

estimator = GasLimitEstimator.for_message(message=message)

expected_order_gas_limit = 45_000
expected_order_gas_limit = 50_000
expected_inner_message_gas_limit = 15_000
expected_exec_message_gas_limit = 8_000

Expand Down

0 comments on commit e315110

Please sign in to comment.