Skip to content

Commit d88ea43

Browse files
authored
Bug: Fix market disable feature (#60)
* fix market disable features * fix nonce issues
1 parent 073c99f commit d88ea43

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

src/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name="synthetix",
5-
version="0.1.14",
5+
version="0.1.15",
66
description="Synthetix protocol SDK",
77
long_description=open("README.md").read(),
88
long_description_content_type="text/markdown",

src/synthetix/perps/constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
DISABLED_MARKETS = {
2-
8453: [6300]
2+
8453: [6300],
3+
84532: [6300],
34
}

src/synthetix/perps/perps.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, snx, default_account_id: int = None, disabled_markets=None):
5454
if disabled_markets is None and snx.network_id in DISABLED_MARKETS:
5555
self.disabled_markets = DISABLED_MARKETS[snx.network_id]
5656
else:
57-
self.disabled_markets = []
57+
self.disabled_markets = disabled_markets if disabled_markets else []
5858

5959
# check if perps is deployed on this network
6060
if "perpsFactory" in snx.contracts:

src/synthetix/synthetix.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -534,12 +534,18 @@ def approve(
534534
)
535535

536536
tx_params = self._get_tx_params()
537+
538+
# reset nonce on internal transactions
539+
self.nonce = self.web3.eth.get_transaction_count(self.address)
540+
tx_params["nonce"] = self.nonce
541+
542+
# simulate the transaction
537543
tx_params = token_contract.functions.approve(
538544
target_address, amount
539545
).build_transaction(tx_params)
540546

541547
if submit:
542-
tx_hash = self.execute_transaction(tx_params, reset_nonce=True)
548+
tx_hash = self.execute_transaction(tx_params)
543549
self.logger.info(
544550
f"Approving {target_address} to spend {amount / 1e18} {token_address} for {self.address}"
545551
)
@@ -606,12 +612,18 @@ def wrap_eth(self, amount: float, submit: bool = False) -> str:
606612
tx_args = []
607613

608614
tx_params = self._get_tx_params(value=value_wei)
615+
616+
# reset nonce on internal transactions
617+
self.nonce = self.web3.eth.get_transaction_count(self.address)
618+
tx_params["nonce"] = self.nonce
619+
620+
# simulate the transaction
609621
tx_params = weth_contract.functions[fn_name](*tx_args).build_transaction(
610622
tx_params
611623
)
612624

613625
if submit:
614-
tx_hash = self.execute_transaction(tx_params, reset_nonce=True)
626+
tx_hash = self.execute_transaction(tx_params)
615627
self.logger.info(f"Wrapping {amount} ETH for {self.address}")
616628
self.logger.info(f"wrap_eth tx: {tx_hash}")
617629
return tx_hash

0 commit comments

Comments
 (0)