Skip to content

Commit 20100c3

Browse files
more bug fixes
1 parent af9a984 commit 20100c3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/flare_ai_defai/blockchain/explorer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def _get(self, params: dict) -> dict:
3131
self.logger.debug("Response JSON:", extra={"json_response": json_response})
3232
except ValueError:
3333
# If the response is not JSON, log the raw content
34-
#self.logger.error("Response is not in JSON format, raw content:", extra={"response_text": response.text})
34+
self.logger.error("Response is not in JSON format, raw content:", extra={"response_text": response.text})
3535
#with open('invalid_response.json', 'w') as f:
3636
# f.write(response.text)
3737

src/flare_ai_defai/blockchain/sparkdex.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
523523
fee_tier = 500 # Assuming 0.05% pool fee
524524
amount_out_min = 0 # Fetch dynamically for slippage protection
525525
deadline = self.w3.eth.get_block("latest")["timestamp"] + 300 # 5 minutes from now
526+
526527

527528
# ---- Step 0.5: calculate amount_out_min
528529
params = (
@@ -559,7 +560,16 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
559560
self.logger.debug(f"Approval transaction: {approval_tx}")
560561

561562
# --- Step 3: Execute the swap ---
562-
563+
params = (
564+
token_in_address, # tokenIn
565+
token_out_address, # tokenOut
566+
fee_tier, # fee (e.g., 500 = 0.05%)
567+
self.wallet_store.get_address(user), # recipient (your address)
568+
int(self.w3.eth.get_block("latest")["timestamp"]) + 300, # deadline (5 min)
569+
amount_in, # amountIn
570+
amount_out_min, # amountOutMinimum (set to 0 for estimation)
571+
0 # sqrtPriceLimitX96 (no limit)
572+
)
563573

564574
swap_tx = universal_router.functions.exactInputSingle(params).build_transaction({
565575
'from': self.wallet_store.get_address(user),

0 commit comments

Comments
 (0)