Skip to main content

DeDust SDK for Python

Analogue of DeDust SDK for Python.

Description

You can swap tokens, deposit liquidity and many more.

Getting Started

Dependencies

  • httpx
  • tonsdk

Installing

pip install dedust

Using

Example of buying $SCALE using SDK.

from dedust import Asset, Factory, PoolType, SwapParams, VaultNative
from dedust.api import Provider
import asyncio
import time
from tonsdk.utils import Address, bytes_to_b64str
from tonsdk.contract.wallet import Wallets, WalletVersionEnum

mnemonics = ["your", "mnemonics", "here"]

mnemonics, pub_k, priv_k, wallet = Wallets.from_mnemonics(mnemonics=mnemonics, version=WalletVersionEnum.v4r2,
                                                          workchain=0)
async def main():
    provider = Provider()

    SCALE_ADDRESS = Address("EQBlqsm144Dq6SjbPI4jjZvA1hqTIP3CvHovbIfW_t-SCALE")

    TON = Asset.native()
    SCALE = Asset.jetton(SCALE_ADDRESS)


    pool = await Factory.get_pool(pool_type=PoolType.VOLATILE,
                                  assets=[TON, SCALE],
                                  provider=provider)
                                  
    swap_params = SwapParams(deadline=int(time.time() + 60 * 5),
                             recipient_address=wallet.address)
    swap_amount = float(input("Enter swap TON amount: ")) * 1e9


    swap = VaultNative.create_swap_payload(amount=swap_amount,
                                           pool_address=pool.address,
                                           swap_params=swap_params)

    swap_amount = int(swap_amount + (0.25 * 1e9)) # 0.25 = gas_value

    seqno = await provider.runGetMethod(address=wallet.address, method="seqno")
    query = wallet.create_transfer_message(to_addr=Address("EQDa4VOnTYlLvDJ0gZjNYm5PXfSmmtL6Vs6A_CZEtXCNICq_"),
                                           amount=swap_amount,
                                           seqno=seqno[0]["value"],
                                           payload=swap)

    boc = bytes_to_b64str(query["message"].to_boc(False))
    await provider.sendBoc(boc)

    # or:
    # print(f"https://app.tonkeeper.com/transfer/EQDa4VOnTYlLvDJ0gZjNYm5PXfSmmtL6Vs6A_CZEtXCNICq_?amount={swap_amount}&bin={bytes_to_b64str(swap.to_boc(False))}")

asyncio.run(main())

Authors

@shibdev @VladPavly

Version History

  • 1.0.5
    • Changes
  • 1.0.4
    • Bug fix
  • 1.0.3
    • Fixes
  • 1.0.2
    • Fixes and changes
  • 1.0.1
    • Small fix
  • 1.0.0
    • Remake to DeDust SDK analogue
  • 0.0.5
    • License change
  • 0.0.4
    • Dependecies fix
  • 0.0.3
    • Examples fix
  • 0.0.2
    • LP token address getting
  • 0.0.1
    • Initial Beta

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Donate

If you like the library, I will be glad to accept donations.

  • TON: EQCgphx8rTI0PukwmgpVqiPgqguTujhQscg2h7jgc4U0t347

Acknowledgments

Metadata

Release files for dedust-tonsdk 1.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dedust-tonsdk 1.0.5
File Size Uploaded Provenance Actions
dedust_tonsdk-1.0.5.tar.gz 10.2 kB Without provenance Details for dedust_tonsdk-1.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dedust-tonsdk 1.0.5
File Interpreter ABI Platform Actions
dedust_tonsdk-1.0.5-py2.py3-none-any.whl Python 2, Python 3 none any Details for dedust_tonsdk-1.0.5-py2.py3-none-any.whl

Total release size: 26.7 kB

Release files / dedust_tonsdk-1.0.5.tar.gz

Download URL dedust_tonsdk-1.0.5.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
03f7bc51b281223cf9af7ad145be8fec8285b48e27e9d979093e2fd9dab5ba2e
BLAKE2b-256 checksum
How to use checksums
641e6ed6132cba9c7c90183d3570e85f5575cdb4f4ee9aaf33684d60710db56f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Release files / dedust_tonsdk-1.0.5-py2.py3-none-any.whl

Download URL dedust_tonsdk-1.0.5-py2.py3-none-any.whl
Size 16.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e7f3f2c9c610d75d5535a8d77775979dc052e9410f73e1930e13c2c4a4282eae
BLAKE2b-256 checksum
How to use checksums
3eb72afe2543aae639afdc6eecec29d8a5023759a8787fe216ff8d4577d5f612
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.31.0

Security for dedust-tonsdk 1.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.5 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page