Skip to main content

Install Packages

pip install hashflow-python

Example Usage

Initialize the client

from hashflow.client import Client

# create a new client with a private key (string or bytearray)
hflow = Client(
    private_key='0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d',
    network_id = 1,
    node='https://mainnet.infura.io/v3/00000000000000000000000000000000'
)

Interacting with the protocol

# set eip 1559 gas fees. in options. Nonce is optional and only needed if resubmitting a tx.
options = { 'maxFeePerGas' : 500000000000, 'maxPriorityFeePerGas': 5000000000, 'nonce': 11}
# create a new hashflow pool
  hflow.main.factory.create_pool(name='hash42', signer=signer, admin=admin, options=options)

# fetch pool addresses deployed using operations key
  hflow.main.factory.pools(operations, options)

# set hashflow allowance
hflow.main.erc20.set_maximum_allowance(token, options)

# check allowance
hflow.main.erc20.allowance(token, owner,spender, options)

# To add Eth liquidity set token address to zero address 
hflow.main.router.add_liquidity_private_pool(pool, token, amount, options)
hflow.main.router.add_liquidity_public_pool(pool, token, amount, options)

# Optionally pass binance account address to transfer funds directly
hflow.main.router.remove_liquidity_private_pool(pool, token, amount, recipient=binance, options)
# To remove liquidity from public pools LPs must burn native h-tokens
hflow.main.router.remove_liquidity_public_pool(pool, token, burn_amount, options)

# Transfer assets to CeFi venues to rebalance
hflow.main.pool.transfer_assets(pool, token, recipient, amount, options)


# generate quote 
quote = utils.Quote(pool,eoa, trader, effective_trader, base_token_address, quote_token_address, base_token_amount, quote_token_amount, fees, expiry, flag, txid, k_value, trade_eoa)

# hash quote 
quote_digest = hflow.main.hash_quote(quote)

# hash quote for EOA
quote_digest = hflow.main.hash_quote_eoa(quote)

# sign quote
signed_quote = utils.sign_digest(quote_digest, signer_private_key)

# trade 
#effective_base_token_amount is optional arg if you wanna do routing.
hflow.main.router.trade_single_hop(quote, signed_quote, effective_base_token_amount, options)

Release files for hashflow-python 10.7.0

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

Source distribution (sdist)

Source distribution for hashflow-python 10.7.0
File Size Uploaded
hashflow-python-10.7.0.tar.gz 24.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hashflow-python 10.7.0
File Interpreter ABI Platform
hashflow_python-10.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 55.8 kB

Release files / hashflow-python-10.7.0.tar.gz

Download URL hashflow-python-10.7.0.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
935321fdb4757f1d36432c16cea63c04ec4375f3b8a75d0826bcda9903259cf8
BLAKE2b-256 checksum
How to use checksums
f93ded081bebfbce13a1759fee3189fef448b6c51588b5da137759a7cdb44621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / hashflow_python-10.7.0-py3-none-any.whl

Download URL hashflow_python-10.7.0-py3-none-any.whl
Size 31.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37ba49c5071fcb6699fe7dc367bda229f26e8bc8126fe808f105f4c0a85cbdc0
BLAKE2b-256 checksum
How to use checksums
31aee2b622f5f787b56ae4de1958b7e9f8a365bd1764887d42108934df9a2678
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release history Release notifications | RSS feed

This release

10.7.0 This release

2 release files

10.6.1

2 release files

10.6.0

2 release files

10.5.0

2 release files

10.4.0

2 release files

10.3.0

2 release files

10.2.0

2 release files

10.1.0

2 release files

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