Spaces:
No application file
No application file
| # 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" | |