Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcede174

Browse files
author
Roman Shterenzon
authored
feat: estimate gas using RPC (#190)
This will allow using it on Arbitrum (see#177).
1 parent3cf179b commitcede174

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

‎uniswap/uniswap.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,8 @@ def _build_and_send_tx(
10851085
ifnottx_params:
10861086
tx_params=self._get_tx_params()
10871087
transaction=function.buildTransaction(tx_params)
1088+
# Uniswap3 uses 20% margin for transactions
1089+
transaction["gas"]=Wei(int(self.w3.eth.estimate_gas(transaction)*1.2))
10881090
signed_txn=self.w3.eth.account.sign_transaction(
10891091
transaction,private_key=self.private_key
10901092
)
@@ -1096,12 +1098,11 @@ def _build_and_send_tx(
10961098
logger.debug(f"nonce:{tx_params['nonce']}")
10971099
self.last_nonce=Nonce(tx_params["nonce"]+1)
10981100

1099-
def_get_tx_params(self,value:Wei=Wei(0),gas:Wei=Wei(250000))->TxParams:
1101+
def_get_tx_params(self,value:Wei=Wei(0))->TxParams:
11001102
"""Get generic transaction parameters."""
11011103
return {
11021104
"from":_addr_to_str(self.address),
11031105
"value":value,
1104-
"gas":gas,
11051106
"nonce":max(
11061107
self.last_nonce,self.w3.eth.get_transaction_count(self.address)
11071108
),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp