Skip to content

Commit 662bedf

Browse files
checking fee tiers
1 parent 76ae642 commit 662bedf

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/flare_ai_defai/blockchain/sparkdex.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,36 @@ def swap_erc20_tokens_tx(self, user: UserInfo, token_in: str, token_out: str, am
568568
"amount_out_min": amount_out_min
569569
})
570570

571+
572+
573+
574+
575+
fee_tiers = [500, 3000, 10000] # 0.05%, 0.3%, 1%
576+
577+
amount_out_wei = None
578+
for fee_tier in fee_tiers:
579+
params = (
580+
token_address[token_in.lower()],
581+
token_address[token_out.lower()],
582+
fee_tier,
583+
self.wallet_store.get_address(user),
584+
deadline,
585+
amount_in_wei,
586+
1, # Minimum for estimation
587+
0
588+
)
589+
try:
590+
amount_out_wei = universal_router.functions.exactInputSingle(params).call()
591+
self.logger.debug(f"Found valid pool with fee tier {fee_tier}", extra={"amount_out_wei": amount_out_wei})
592+
break
593+
except Exception as e:
594+
self.logger.debug(f"Fee tier {fee_tier} failed: {str(e)}", extra={"params": params})
595+
596+
597+
598+
599+
600+
571601
# --- Step 1: Approve Universal Router to Spend wFLR ---
572602
approval_tx = contract_in.functions.approve(universal_router_address, amount_in_wei).build_transaction({
573603
'from': self.wallet_store.get_address(user),

0 commit comments

Comments
 (0)