A defi swap helper package DeX SwaP
Project description
swapportunity
DXSP (DeX SwaP), A defi swap helper package . Easy peasy Swap.
Install
pip install swapportunity
2 swap execution mode are supported:
- Single SWAP via 1inch API v5 and Uniswap version 2 router
- Limit SWAP via 1inch API v3
Example
import os
from dotenv import load_dotenv
import asyncio
from web3 import Web3
import many_abis as ma
#YOUR VARIABLES
load_dotenv()
#chain ID being used refer to https://chainlist.org/
chain_id = os.getenv("CHAIN_ID", "10")
#your wallet details
wallet_address = os.getenv("WALLET_ADDRESS", "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE")
private_key = os.getenv("PRIVATE_KEY", "0x111111111117dc0aa78b770fa6a738034120c302")
#1 for 1inch and 2 for Uniswap V2
execution_mode = os.getenv("EXECUTION_MODE", "1")
#DATA from MANY_ABIS FOR RPC and EXCHANGE
chain = ma.get_chain_by_id(chain_id=int(chain_id))
network_provider_url = os.getenv("NETWORK_PROVIDER_URL", chain['rpc'][0])
dex_exchange = os.getenv("DEX_EXCHANGE", chain['dex'][0])
#Block explorer API from ETHERSCAN TYPE EXPLORER
block_explorer_api = os.getenv("BLOCK_EXPLORER_API", "1X23Q4ACZ5T3KXG67WIAH7X8C510F1972TM")
#DEX CONNECTIVITY
w3 = Web3(Web3.HTTPProvider(network_provider_url))
from dxsp import DexSwap
async def main():
#SWAP HELPER
dex = DexSwap(w3,chain_id,wallet_address,private_key,execution_mode,dex_exchange,block_explorer_api)
#get Contract Address
bitcoinaddress = await dex.get_contract_address('wBTC')
print("bitcoinaddress ", bitcoinaddress)
#getABI
bitcoinABI = await dex.get_abi(bitcoinaddress)
print("bitcoinABI ", bitcoinABI)
#INPUT for QUOTE
quote = await dex.get_quote('wBTC')
print("quote ", quote)
#INPUT for a NORMAL SWAP
# transaction_amount_out = 10
# asset_out_symbol = "USDT"
# asset_in_symbol = "ETH"
#SWAP EXECUTION
# transaction = dex.get_swap(transaction_amount_out,asset_out_symbol,asset_in_symbol)
# print("transaction ", transaction)
if __name__ == "__main__":
asyncio.run(main())
Real case
Roadmap
V1
- Single SWAP via 1inch API v5 and Uniswap version 2 router
- Limit SWAP via 1inch API v3
V2
- Uniswap V3 Support
- Ox or other API based swap or orderbook platfrom
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dxsp-0.0.1.tar.gz
(5.1 kB
view details)
Built Distribution
dxsp-0.0.1-py3-none-any.whl
(5.6 kB
view details)
File details
Details for the file dxsp-0.0.1.tar.gz
.
File metadata
- Download URL: dxsp-0.0.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da636ce3df281b3e3d216847e306cb69315ab3b81a0fff3f50310a03d42cd82b |
|
MD5 | 9badb0f7d87a927dce13c6672a92a564 |
|
BLAKE2b-256 | ea140483af42a69fda2b44090725ca0814283d71319476507f0a341e30a42950 |
File details
Details for the file dxsp-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dxsp-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 582d4a0d0076123aaf89fd4c089b8866bcce9ab962c5f6978b2de1930dafe720 |
|
MD5 | 37b08180f837d11c66b31cee3b04eac2 |
|
BLAKE2b-256 | d220d6e3d16277a5c14f2a7f19b026ecb18094f06525f3faa5d3f2cefefced96 |