Skip to main content

minswap-py (v0.3.5)

Code style: black

minswap-py is a tool to interact with Minswap. The current version has feature parity with the minswap blockfrost-adapter, except for the ability to remove liquidity.

Documentation and additional features coming soon.

Changelog

Be sure to check out the CHANGELOG.md for a complete history of changes. This section only contains patch updates for the current minor version and patches.

0.3.5

  • Fixed a bug for non-ADA pools that was improperly ordering assets in the pool.

0.3.3

  • Fixed a bug in how the NFT policy IDs were being checked when restoring a PoolState from JSON.

0.3.2

  • Small change to fetching pool data, removing hard coded pool addresses and how pool addresses are fetched by finding addresses that contain the Minswap DEX NFT.
  • Small change to how swap exact in/out are calculated, where fees are now a PoolState property.

0.3.1

  • Modified PoolState initialization so that PoolDatum is not automatically queried from blockfrost. This was causing a large number of calls to be generated to Blockfrost when using pools.get_pools() (one for each of the 3,000+ pools). Now, the lp_total and root_k_last are only retrieved from Blockfrost when requested.

0.3.0

Improvements:

  1. Added wallet support, including easy methods to create a collateral, send funds, and consolidate UTxOs.
  2. Swap transactions.
  3. Cancel transactions.
  4. Deposit liquidity (including zap in), but should be updated in the future. The Minswap team has not responded to requests for details on how to better estimate expected LP based on amount of token deposited. https://github.com/minswap/sdk/pull/7#discussion_r1279439474

Changes:

  1. There was an inconsistency in how time values were being cached. See the examples/rename_time.py for a way to translate previously cached data to the new standard.
  2. Changed the way some of the underlying classes were managing amounts to use the Assets class. This makes combining assets from different UTxOs easier.

Installation

In order to use this package:

  1. Install with pip install minswap-py
  2. Sign up for blockfrost and get an API key.
  3. In your working directory, create a .env file. The .env should have the following fields:
# The blockfrost project id
PROJECT_ID=

# The maximum number of calls allowed to Blockfrost within a session.
MAX_CALLS=45000

# Must be one of mainnet or preprod
NETWORK=mainnet
  1. Browse the examples folder for use cases.

Setup your wallet

To use a wallet with minswap-py, you will need to supply a mnemonic in a file on your hard drive. By default, the Wallet class will create a brand new wallet and store it in .wallet/{chain}_mnemonic.txt. Then, this wallet will be used every time a new Wallet object is created. The chain in the file name must either be mainnet or preprod depending on what NETWORK you want to operate on (i.e. mainnet_mnemonic.txt or preprod_mnemonic.txt).

If you want to supply your own wallet, you can either replace the mnemonic in .wallets/{chain}_mnemonic.txt if it exists, or create it. You can also pass the mnemonic directly into the Wallet. Alternatively, you can create your own txt file with the mnemonic in it anywhere on disk, and pass that file to the Wallet constructor.

Examples:

from minswap.wallets import Wallet

# Initialize with a path to a file containing a mnemonic
wallet = Wallet(path="path/to/mnemonic.txt")

# Initialize with a mnemonic
wallet = Wallet(mnemonic="bert says buy flac")

Have a question?

Reach out to me on the Minswap discord. You can usually find me on#technical, and I'm happy to respond to questions there.

https://discord.com/channels/829060079248343090/845208119729979402

Support

If you find this project useful, please consider supporting the project by buying me a beer in the form of ADA or MIN:

addr1q9hw8fuex09vr3rqwtn4fzh9qxjlzjzh8aww684ln0rv0cfu3f0de6qkmh7c7yysfz808978wwe6ll30wu8l3cgvgdjqa7egnl

Use Cases

This tool was recently used to help generate data for the Minswap DAO Emissions and Treasury report. You can read the report here:

https://minswap.org/storage/2023/06/31-3-2023_Emissions_and_Treasury_Report.pdf

Contributors

A special thanks to Farmer, creator of Farmbot, for assisting me working through the details of swaps and cancel orders. If you would like to learn more about Farmbot, check out their discord:

https://discord.gg/zQHyJKrA7K

Metadata

Release files for minswap-py 0.3.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 minswap-py 0.3.5
File Size Uploaded Provenance Actions
minswap_py-0.3.5.tar.gz 52.4 kB Without provenance Details for minswap_py-0.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minswap-py 0.3.5
File Interpreter ABI Platform Actions
minswap_py-0.3.5-py3-none-any.whl Python 3 none any Details for minswap_py-0.3.5-py3-none-any.whl

Total release size: 108.2 kB

Release files / minswap_py-0.3.5.tar.gz

Download URL minswap_py-0.3.5.tar.gz
Size 52.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b717e42dc2717f09ff1defd1b48ea8fe79531235927de92081d7e24c4f6b5472
BLAKE2b-256 checksum
How to use checksums
17eea232022984ad6dbb7d792b533f665f5ecc3f65bf181e084ccbc8fbe5cc13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.11 Windows/10

Release files / minswap_py-0.3.5-py3-none-any.whl

Download URL minswap_py-0.3.5-py3-none-any.whl
Size 55.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6094f40774f3d79918b7ff69480099ac798b87e86e3cdda65de9eea9a18ba4b3
BLAKE2b-256 checksum
How to use checksums
90f2e06e7c7259a20c69a0c3a3620d15aa21e4ed06c1fc72a860fe09bdbe5fe6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.11 Windows/10

Security for minswap-py 0.3.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.

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