Skip to content

Commit a760aed

Browse files
more gas
1 parent c7865d1 commit a760aed

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

AI_research/check_sparkdex_pool.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,14 @@
137137
"maxPriorityFeePerGas": w3.eth.max_priority_fee,
138138
'chainId': 14,
139139
"type": 2,
140-
})
140+
})
141+
142+
143+
144+
145+
146+
147+
148+
149+
150+

src/flare_ai_defai/blockchain/kinetic_market.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,17 @@ def swapFLRtoSFLR(self, user: UserInfo, amount: float):
223223
# Fetch current nonce
224224
current_nonce = self.w3.eth.get_transaction_count(self.wallet_store.get_address(user))
225225

226+
estimated_gas = self.w3.eth.estimate_gas({
227+
"from": self.wallet_store.get_address(user),
228+
"to": self.SFLR_ADDRESS,
229+
"data": self.SFLR_ABI,
230+
"value": amount_wei,
231+
})
232+
gas_limit = int(estimated_gas * 1.2) # Adding a 20% buffer
233+
226234
# Create submit transaction with value
227235
tx1 = self.flare_provider.create_contract_function_tx(user,
228-
contract, "submit", 0, value=amount_wei
236+
contract, "submit", 0, value=amount_wei, gas=gas_limit
229237
)
230238

231239
return [tx1]

src/flare_ai_defai/blockchain/sparkdex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,8 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
623623
approval_tx = contract_in.functions.approve(universal_router_address, amount_in_wei).build_transaction({
624624
'from': self.wallet_store.get_address(user),
625625
'nonce': self.get_nonce(),
626-
"maxFeePerGas": 10*(base_fee + priority_fee),
627-
"maxPriorityFeePerGas": 10*(priority_fee),
626+
"maxFeePerGas": (base_fee + priority_fee),
627+
"maxPriorityFeePerGas": (priority_fee),
628628
'chainId': self.w3.eth.chain_id,
629629
"type": 2,
630630
})
@@ -647,8 +647,8 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
647647
swap_tx = universal_router.functions.exactInputSingle(params).build_transaction({
648648
'from': self.wallet_store.get_address(user),
649649
'nonce': self.get_nonce(),
650-
"maxFeePerGas": base_fee + priority_fee, #self.w3.eth.gas_price,
651-
"maxPriorityFeePerGas": priority_fee, #self.w3.eth.max_priority_fee,
650+
"maxFeePerGas": 10*(base_fee + priority_fee), #self.w3.eth.gas_price,
651+
"maxPriorityFeePerGas": 10*(priority_fee), #self.w3.eth.max_priority_fee,
652652
'chainId': self.w3.eth.chain_id,
653653
"type": 2,
654654
})

0 commit comments

Comments
 (0)