Skip to main content

No project description provided

Project description

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`)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

minswap_oura-0.1.1.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

minswap_oura-0.1.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file minswap_oura-0.1.1.tar.gz.

File metadata

  • Download URL: minswap_oura-0.1.1.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-109-generic

File hashes

Hashes for minswap_oura-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cfdf76083f2684204838ce5baaa1c66aa038d08737dc572f26b6efb9fa714729
MD5 1f5ed5e315f1bfa57ef06bf3309a03be
BLAKE2b-256 fbe0f93710866c5481ae2ce030115e3c7ed1e21ccc9b8dfb899303655ec4040e

See more details on using hashes here.

File details

Details for the file minswap_oura-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: minswap_oura-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.4.0-109-generic

File hashes

Hashes for minswap_oura-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 085100b0fe59d0ad29b0917708d9242e4dd12e6bf530a0c8bedf6ab0e019bdc4
MD5 7421e1f5e41e04225687814ba99b8313
BLAKE2b-256 8615a889c9168737ea03a2fc934f3145b34abf4a9e14a2087e3ae1226f39457a

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