Skip to main content

Translated to python from JS, source: https://github.com/minswap/blockfrost-adapter/blob/main/README.md?plain=1

Modified to work with Oura and mongoDB

  • Get current pair price
  • Get historical pair price

Minswap Blockfrost Adapter

Features

  • Get current pair price
  • Get historical pair price
  • Calculate trade price and price impact
  • Create orders and submit to Blockfrost

Install

  • Pypi: pip install minswap

Examples

Example 1: Get current price of MIN/ADA pool

from minswap import BlockfrostAdapter, NetworkId

adapter = BlockfrostAdapter(
  projectId="<your_project_id>",
  networkId=NetworkId.MAINNET,
)

page = 1
while True:
    pools = adapter.getPools(page=page)

    if len(pools) == 0:
        # last page
        break

    minAdaPool = next((pool for pool in pools if pool.assetA == "lovelace" and pool.assetB=="29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e"), None)

    if minAdaPool:
        min, ada = adapter.getPoolPrice(pool=minAdaPool)
        print(f'ADA/MIN price: {min}; MIN/ADA price: {ada}')
        print(f'ADA/MIN pool ID: {minAdaPool.id}')
        break

Example 2: Get historical prices of MIN/ADA pool

from minswap import BlockfrostAdapter, NetworkId

adapter = BlockfrostAdapter(
  projectId="<your_project_id>",
  networkId=NetworkId.MAINNET,
)

MIN_ADA_POOL_ID = "6aa2153e1ae896a95539c9d62f76cedcdabdcdf144e564b8955f609d660cf6a2"

history = adapter.getPoolHistory(id=MIN_ADA_POOL_ID)

for historyPoint in history:
    pool = adapter.getPoolInTx(txHash=historyPoint.txHash)
    if not pool:
        raise Exception("pool not found")
    
    price0, price1 = adapter.getPoolPrice(
        pool,
        decimalsA=6,
        decimalsB=6,
    )
    print(f'{historyPoint.time}: {price0} ADA/MIN, {price1} MIN/ADA`)

Metadata

Release files for minswap-oura 0.1.4

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-oura 0.1.4
File Size Uploaded Provenance Actions
minswap_oura-0.1.4.tar.gz 7.8 kB Without provenance Details for minswap_oura-0.1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for minswap-oura 0.1.4
File Interpreter ABI Platform Actions
minswap_oura-0.1.4-py3-none-any.whl Python 3 none any Details for minswap_oura-0.1.4-py3-none-any.whl

Total release size: 17.4 kB

Release files / minswap_oura-0.1.4.tar.gz

Download URL minswap_oura-0.1.4.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
27075335a8e527cad4f727b9e9fe0e02a31b9845ca70368f421a849ba93603cc
BLAKE2b-256 checksum
How to use checksums
d633df5fe8b346b1a93797c7542d129b051cfe55832b8b161dc6dfb2b46cae4e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-110-generic

Release files / minswap_oura-0.1.4-py3-none-any.whl

Download URL minswap_oura-0.1.4-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7cfdb32c5991601ab49e77540b19adf4cec144d2fce40dc0baaa3e3f8dbb4c3c
BLAKE2b-256 checksum
How to use checksums
82b9749150c47dc8095becd0ca970ddd7ffbe25e656869b457dbfa9c6495a8af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-110-generic

Security for minswap-oura 0.1.4

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