Spaces:
No application file
No application file
File size: 781 Bytes
1798e29 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # jupiter_executor.py
import requests
def get_best_jupiter_route(input_token, output_token, amount_in):
"""
Get best route for swapping tokens via Jupiter aggregator.
"""
url = f"https://quote-api.jup.ag/v1/quote?inputMint={input_token}&outputMint={output_token}&amount={amount_in}&slippage=0.5"
try:
response = requests.get(url)
route = response.json()["data"][0]
return route
except Exception as e:
print(f"[JupiterExecutor] Error fetching route: {e}")
return None
def execute_jupiter_swap(wallet, route_info):
"""
Placeholder for sending swap transactions using route_info.
"""
print(f"[JupiterExecutor] Executing swap: {route_info['marketInfos'][0]['amm']}")
return "DummyJupiterSwapTxHash"
|