Skip to content

Commit

Permalink
Bug: Fix market disable feature (#60)
Browse files Browse the repository at this point in the history
* fix market disable features

* fix nonce issues
  • Loading branch information
Tburm authored Aug 8, 2024
1 parent 073c99f commit d88ea43
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="synthetix",
version="0.1.14",
version="0.1.15",
description="Synthetix protocol SDK",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
Expand Down
3 changes: 2 additions & 1 deletion src/synthetix/perps/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
DISABLED_MARKETS = {
8453: [6300]
8453: [6300],
84532: [6300],
}
2 changes: 1 addition & 1 deletion src/synthetix/perps/perps.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self, snx, default_account_id: int = None, disabled_markets=None):
if disabled_markets is None and snx.network_id in DISABLED_MARKETS:
self.disabled_markets = DISABLED_MARKETS[snx.network_id]
else:
self.disabled_markets = []
self.disabled_markets = disabled_markets if disabled_markets else []

# check if perps is deployed on this network
if "perpsFactory" in snx.contracts:
Expand Down
16 changes: 14 additions & 2 deletions src/synthetix/synthetix.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,18 @@ def approve(
)

tx_params = self._get_tx_params()

# reset nonce on internal transactions
self.nonce = self.web3.eth.get_transaction_count(self.address)
tx_params["nonce"] = self.nonce

# simulate the transaction
tx_params = token_contract.functions.approve(
target_address, amount
).build_transaction(tx_params)

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

tx_params = self._get_tx_params(value=value_wei)

# reset nonce on internal transactions
self.nonce = self.web3.eth.get_transaction_count(self.address)
tx_params["nonce"] = self.nonce

# simulate the transaction
tx_params = weth_contract.functions[fn_name](*tx_args).build_transaction(
tx_params
)

if submit:
tx_hash = self.execute_transaction(tx_params, reset_nonce=True)
tx_hash = self.execute_transaction(tx_params)
self.logger.info(f"Wrapping {amount} ETH for {self.address}")
self.logger.info(f"wrap_eth tx: {tx_hash}")
return tx_hash
Expand Down

0 comments on commit d88ea43

Please sign in to comment.