Skip to main content

DXSP (DeX SwaP), A defi swap helper package. Easy peasy Swap.

Project description

dxsp

DXSP (DeX SwaP), A defi swap helper package. Easy peasy Swap.

Pypi Version

Install

pip install dxsp

2 swap execution mode are supported:

  • Single SWAP via 1inch API v5 and Uniswap version 2 router DEX type
  • Limit SWAP via 1inch API v3

Example

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
protocol = os.getenv("PROTOCOL", "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,protocol,dex_exchange,block_explorer_api)


	#get Contract Address
	bitcoinaddress = await dex.get_contract_address('wBTC')
	print("bitcoinaddress ", bitcoinaddress)
	#

	# #get Contract Address
	bitcoinaddress2 = await dex.get_address('wBTC')
	print("bitcoinaddress2 ", bitcoinaddress2)
	#

	#getABI
	bitcoinABI = await dex.get_abi(bitcoinaddress)
	print("bitcoinABI ", bitcoinABI)
	# ABI

	#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 = await dex.get_swap(transaction_amount_out,asset_out_symbol,asset_in_symbol)
	print("transaction ", transaction)
	# 

if __name__ == "__main__":
    asyncio.run(main())

Real case

TalkyTrader, submit trading order to CEX & DEX with messaging platform (Telegram, Matrix and Discord)

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.24.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

dxsp-0.0.24-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file dxsp-0.0.24.tar.gz.

File metadata

  • Download URL: dxsp-0.0.24.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for dxsp-0.0.24.tar.gz
Algorithm Hash digest
SHA256 e62b74dd6e4ebcb795e5636a4096d1e0597badec46f64d7742eb057f9faacd43
MD5 7ade882d07fbb2f2b5ef813e47c9521d
BLAKE2b-256 f56218c53621cdfd08ba4960552c7b76a13c3f3926746690623a5dc5f522d0d8

See more details on using hashes here.

File details

Details for the file dxsp-0.0.24-py3-none-any.whl.

File metadata

  • Download URL: dxsp-0.0.24-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for dxsp-0.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 20add2b409c9bd285384f0b77fa7d27e93d5109f9b40b3b2e557a1ba4efc8a85
MD5 40a07380dcff2553291387ba7bd15595
BLAKE2b-256 580e427e5c5c814a2b985b8f2d31bfcc2cb8b04654bfb18b77f7c6846886fe51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page