nastaseshot commited on
Commit
1798e29
·
verified ·
1 Parent(s): 94b71ae

Create jupiter_executor.py

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