Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
77e9d72
Update README.md
0xTaoDev Dec 12, 2023
5d00c63
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Dec 20, 2023
7d344fd
[+] Images
0xTaoDev Dec 20, 2023
1ecc967
[+] Added keywords
0xTaoDev Dec 20, 2023
b9b17bd
[+] Banner test
0xTaoDev Dec 20, 2023
0873da0
[+] Banner
0xTaoDev Dec 20, 2023
931540e
Banner
0xTaoDev Dec 20, 2023
f31fba6
[+] Title and image banner
0xTaoDev Dec 20, 2023
90cf319
Update README.md
0xTaoDev Dec 20, 2023
f32334a
[+] Update README.md, add details in functions
0xTaoDev Dec 20, 2023
3603ae4
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Dec 20, 2023
303e67f
Update README.md
0xTaoDev Dec 20, 2023
a380159
[+] README.md to /src/
0xTaoDev Dec 20, 2023
dfb7a51
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Dec 20, 2023
a2668e8
[+] packages required
0xTaoDev Dec 20, 2023
81acb54
[+] Package
0xTaoDev Dec 20, 2023
470ec11
Update README.md
0xTaoDev Dec 20, 2023
55fcb82
[+] TO-DO
0xTaoDev Dec 21, 2023
28593ba
[+] Fix get_all_swap_pairs() documentation
0xTaoDev Dec 21, 2023
9145022
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Dec 21, 2023
ba0e63f
[+] Fix get_indexed_route_map() documentation
0xTaoDev Dec 21, 2023
b314d22
Update README.md
0xTaoDev Dec 21, 2023
18de0a0
[+] Fix swap()
0xTaoDev Dec 21, 2023
db34177
Update README.md
0xTaoDev Dec 21, 2023
13805d4
[+] Updated package
0xTaoDev Dec 21, 2023
5365eac
[+] Fix package installation (wrong readme.md)
0xTaoDev Dec 23, 2023
7c0f277
fix: package
0xTaoDev Dec 23, 2023
fb9cb53
Update README.md
0xTaoDev Dec 25, 2023
2492f47
Update README.md
0xTaoDev Dec 25, 2023
c7f949e
Update README.md
0xTaoDev Dec 25, 2023
47d6fbc
[+] fix: docstring swap & open_order
0xTaoDev Dec 25, 2023
6b4cbde
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Dec 25, 2023
a5d7896
[+] package
0xTaoDev Dec 25, 2023
958d206
[+] fix: install_requires
0xTaoDev Dec 26, 2023
ed4660c
Update README.md
0xTaoDev Dec 26, 2023
b12a9e3
Update README.md
0xTaoDev Jan 4, 2024
2a5f4ce
add: instructions to send transaction
0xTaoDev Jan 9, 2024
d6667e4
Update README.md
0xTaoDev Jan 9, 2024
91897c0
Update README.md
0xTaoDev Jan 9, 2024
c0b8628
Update README.md
0xTaoDev Jan 9, 2024
6417687
Update README.md
0xTaoDev Jan 19, 2024
05de2be
Update README.md
0xTaoDev Jan 19, 2024
d7fc247
Create requirements.txt
0xTaoDev Jan 19, 2024
7de2516
Update requirements.txt
0xTaoDev Jan 19, 2024
5bb7371
fix: wrapUnwrapSol
0xTaoDev Jan 24, 2024
25f2bbb
test
0xTaoDev Jan 24, 2024
01751c3
test
0xTaoDev Jan 24, 2024
a6c80e1
fix: wrapAndUnwrapSol
0xTaoDev Jan 24, 2024
d4e9e48
add: base58 requirements
0xTaoDev Jan 24, 2024
2070ee4
change package version
0xTaoDev Jan 24, 2024
0048037
Delete src/jupiter_python_sdk.egg-info directory
0xTaoDev Jan 24, 2024
ae9b18d
Delete src/dist directory
0xTaoDev Jan 24, 2024
490fef2
fix: version
0xTaoDev Jan 24, 2024
bf99549
[+] Ability to change SWAP,QUOTE,... endpoints
0xTaoDev Feb 10, 2024
e80cead
[+] Display error when imposible to execute a swap
0xTaoDev Feb 10, 2024
9e0c0ed
Update README.md
0xTaoDev Feb 14, 2024
2e1531c
test
0xTaoDev Feb 15, 2024
b13a81c
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Feb 15, 2024
73c0735
Update README.md
0xTaoDev Feb 16, 2024
39ad975
Update README.md
0xTaoDev Feb 18, 2024
9881354
Update readme private_key to keypair
Thomasvanderlinden Mar 9, 2024
f6d8498
Merge pull request #10 from Thomasvanderlinden/update-readme
0xTaoDev Mar 10, 2024
ced7739
Update README.md
0xTaoDev Mar 10, 2024
db69562
[+] Priority fee
0xTaoDev Apr 8, 2024
5872910
Merge branch 'main' of https://github.com/0xTaoDev/jupiter-sdk-python
0xTaoDev Apr 8, 2024
86dc5fb
[+] Priority Fee
0xTaoDev Apr 8, 2024
7306a78
[+] Priority Fee, Platform Fee, Old Quote, Library Versions
0xTaoDev Apr 8, 2024
3574ae5
Make dynamic compute limit configurable
Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 177 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,179 @@
venv/
__pycache__/
main.py
main.py

# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 0xtaodev

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
190 changes: 189 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,189 @@
### JUPITER SDK PYTHON
<div align="center">
<h1>🐍 JUPITER PYTHON SDK 🪐</h1>
<img src="https://github.com/0xTaoDev/jupiter-python-sdk/blob/main/images/jupiter-python-sdk-banner.png?raw=true" width="75%" height="75%">
</div>

---

<p align="center">
<img src="https://img.shields.io/github/stars/0xtaodev/jupiter-python-sdk">
<img src="https://img.shields.io/github/forks/0xtaodev/jupiter-python-sdk">
<br>
<img src="https://img.shields.io/github/issues/0xtaodev/jupiter-python-sdk">
<img src="https://img.shields.io/github/issues-closed/0xtaodev/jupiter-python-sdk">
<br>
<img src="https://img.shields.io/github/languages/top/0xtaodev/jupiter-python-sdk">
<img src="https://img.shields.io/github/last-commit/0xtaodev/jupiter-python-sdk">
<br>
</p>

# 📖 Introduction
**Jupiter Python SDK** is a Python library that allows you to use most of **[Jupiter](https://jup.ag/) features**.<br>
It enables executing swaps, limit orders, DCA, swap pairs, tokens prices, fetching wallet infos, stats, data and more!<br>
This library is using packages like: [solana-py](https://github.com/michaelhly/solana-py), [solders](https://github.com/kevinheavey/solders), [anchorpy](https://github.com/kevinheavey/anchorpy).<br>
There is documentation inside each function, however, you can access to the [official Jupiter API](https://docs.jup.ag/docs) for more information.

# ⚠️ Disclaimer
**Please note that I'm not responsible for any loss of funds, damages, or other libailities resulting from the use of this software or any associated services.<br>
This tool is provided for educational purposes only and should not be used as financial advice, it is still in expiremental phase so use it at your own risk.**

# ✨ Quickstart

### 🛠️ Installation

```sh
pip install jupiter-python-sdk
```

### 📃 General Usage
**Providing the private key and RPC client is not mandatory if you only intend to execute functions for retrieving data.<br>
Otherwise, this is required, for instance, to open a DCA account or to close one.**

**You can set custom URLs for any self-hosted Jupiter APIs. Like the [V6 Swap API](https://station.jup.ag/docs/apis/self-hosted) or [QuickNode's Metis API](https://marketplace.quicknode.com/add-on/metis-jupiter-v6-swap-api).**

If you encounter ```ImportError: cannot import name 'sync_native' from 'spl.token.instructions``` error when trying to import Jupiter, Jupiter_DCA from jupiter_python_sdk.jupiter, follow these steps:
1. Go to https://github.com/michaelhly/solana-py/tree/master/src/spl/token and download ```instructions.py```
2. In your packages folder, replace ```spl/token/instructions.py``` with the one you just downloaded.

### Here is a code snippet on how to use the SDK
```py
import base58
import base64
import json

from solders import message
from solders.pubkey import Pubkey
from solders.keypair import Keypair
from solders.transaction import VersionedTransaction

from solana.rpc.types import TxOpts
from solana.rpc.async_api import AsyncClient
from solana.rpc.commitment import Processed

from jupiter_python_sdk.jupiter import Jupiter, Jupiter_DCA


private_key = Keypair.from_bytes(base58.b58decode(os.getenv("PRIVATE-KEY"))) # Replace PRIVATE-KEY with your private key as string
async_client = AsyncClient("SOLANA-RPC-ENDPOINT-URL") # Replace SOLANA-RPC-ENDPOINT-URL with your Solana RPC Endpoint URL
jupiter = Jupiter(
async_client=async_client,
keypair=private_key,
quote_api_url="https://quote-api.jup.ag/v6/quote?",
swap_api_url="https://quote-api.jup.ag/v6/swap",
open_order_api_url="https://jup.ag/api/limit/v1/createOrder",
cancel_orders_api_url="https://jup.ag/api/limit/v1/cancelOrders",
query_open_orders_api_url="https://jup.ag/api/limit/v1/openOrders?wallet=",
query_order_history_api_url="https://jup.ag/api/limit/v1/orderHistory",
query_trade_history_api_url="https://jup.ag/api/limit/v1/tradeHistory"
)


"""
EXECUTE A SWAP
"""
transaction_data = await jupiter.swap(
input_mint="So11111111111111111111111111111111111111112",
output_mint="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount=5_000_000,
slippage_bps=1,
)
# Returns str: serialized transactions to execute the swap.

raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(transaction_data))
signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message))
signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature])
opts = TxOpts(skip_preflight=False, preflight_commitment=Processed)
result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)
transaction_id = json.loads(result.to_json())['result']
print(f"Transaction sent: https://explorer.solana.com/tx/{transaction_id}")


"""
OPEN LIMIT ORDER
"""
transaction_data = await jupiter.open_order(
input_mint=So11111111111111111111111111111111111111112",
output_mint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
in_amount=5_000_000,
out_amount=100_000,
)
# Returns dict: {'transaction_data': serialized transactions to create the limit order, 'signature2': signature of the account that will be opened}

raw_transaction = VersionedTransaction.from_bytes(base64.b64decode(transaction_data['transaction_data']))
signature = private_key.sign_message(message.to_bytes_versioned(raw_transaction.message))
signed_txn = VersionedTransaction.populate(raw_transaction.message, [signature, transaction_data['signature2']])
opts = TxOpts(skip_preflight=False, preflight_commitment=Processed)
result = await async_client.send_raw_transaction(txn=bytes(signed_txn), opts=opts)
transaction_id = json.loads(result.to_json())['result']
print(f"Transaction sent: https://explorer.solana.com/tx/{transaction_id}")


"""
CREATE DCA ACCOUNT
"""
create_dca_account = await jupiter.dca.create_dca(
input_mint=Pubkey.from_string("So11111111111111111111111111111111111111112"),
output_mint=Pubkey.from_string("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"),
total_in_amount=5_000_000,
in_amount_per_cycle=100_000,
cycle_frequency=60,
min_out_amount_per_cycle=0,
max_out_amount_per_cycle=0,
start=0
)
# Returns DCA Account Pubkey and transaction hash.


"""
CLOSE DCA ACCOUNT
"""
close_dca_account = await jupiter.dca.close_dca(
dca_pubkey=Pubkey.from_string("45iYdjmFUHSJCQHnNpWNFF9AjvzRcsQUP9FDBvJCiNS1")
)
# Returns transaction hash.
```

### 📜 All available features
```py
- quote
- swap
- open_order
- cancel_orders
- create_dca
- close_dca
- fetch_user_dca_accounts
- fetch_dca_account_fills_history
- get_available_dca_tokens
- fetch_dca_data
- query_open_orders
- query_orders_history
- query_trades_history
- get_jupiter_stats
- get_token_price
- get_indexed_route_map
- get_tokens_list
- get_all_tickers
- get_all_swap_pairs
- get_swap_pairs
- get_token_stats_by_date
- program_id_to_label
```

# 📝 TO-DO
- [ ] Bridge 🌉
- [ ] Perpetual 💸
- [ ] Price API
- [ ] Wallet Transactions History

# 🤝 Contributions
If you are interesting in contributing, fork the repository and submit a pull request in order to merge your improvements into the main repository.<br>
Contact me for any inquiry, I will reach you as soon as possible.<br>
[![Discord](https://img.shields.io/badge/Discord-%237289DA.svg?logo=discord&logoColor=white)](https://discord.gg/QxwPGcXDp7)
[![Twitter](https://img.shields.io/badge/Twitter-%231DA1F2.svg?logo=Twitter&logoColor=white)](https://twitter.com/_TaoDev_)

# 👑 Donations
This project doesn't include platform fees. If you find value in it and would like to support its development, your donations are greatly appreciated.<br>
**SOLANA ADDRESS**
```sh
AyWu89SjZBW1MzkxiREmgtyMKxSkS1zVy8Uo23RyLphX
```
Binary file added images/jupiter-python-sdk-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/jupiter-python-sdk-logo-transparent.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/jupiter-python-sdk-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading