Skip to main content

Official Python wrapper for the Polysynth platform

Project description

Polysynth Python SDK

The official Python client for Polysynth.

Documentation is available here.

Getting Started

This library attempts to present a clean interface to Polysynth, but in order to use it to its full potential, you must familiarize yourself with the official Polysynth documentation:

  • Installation
  • Quoting Prices
  • Making Trades
  • Managing Collaterals
  • Ratios

Installation

You can install the latest release from PyPI, or install the latest commit directly from git:

  • Install the latest release from PyPI: pip install polysynth

  • Install from git: pip install git+https://github.com/kryptolabs/polysynth-python.git

  • Clone and install with poetry:

git clone https://github.com/kryptolabs/polysynth-python.git
cd polysynth-python
poetry install

Quoting Prices

input_price

Returns the amount of ETH you get for 1 USDP

client.input_price("ETH-USDC", "BUY", 1)
output_price

Returns the amount of USDP you need to pay to get 1000 ETH

client.output_price("ETH-USDC", “BUY”, 1000)

Making Trades

open_position

Open a long position against 1000 USDP worth ETH with a leverage of 1x and slippage tolerance of 0%

client.open_position("ETH-USDC", “BUY”, 1000, 1, 0)
close_position

Closes a trader’s all positions for ETH with zero slippage tolerance

client.close_position("ETH-USDC", 0)

Managing Collaterals

add_collateral

Add 1000 USDP worth collateral in ETH AMM

client.add_collateral("ETH-USDC", 1000)
remove_collateral

Remove 500 USDP worth collateral from ETH AMM

client.remove_collateral("ETH-USDC", 500)

Ratios

fluctuation_limit_ratio

Get fluctuation limit ratio of ETH market

client.fluctuation_limit_ratio("ETH-USDC")
trade_limit_ratio

Get trade limit ratio of ETH market

client.trade_limit_ratio("ETH-USDC")
collateral_ratio

Get collateral ratio of ETH market

client.collateral_ratio("ETH-USDC")
fee_ratio

Get fee ratio of the platform

client.fee_ratio()
init_collateral_ratio

Get initial collateral ratio of the platform

client.init_collateral_ratio()
liquidation_fee_ratio

Get liquidation fee ratio of the platform

client.liquidation_fee_ratio()
maintenance_collateral_ratio

Get maintenance collateral ratio of the platform

client.maintenance_collateral_ratio()
partial_liquidation_ratio

Get partial liquidation ratio of the platform

client.partial_liquidation_ratio()

Testing

To run the full test suite, in the project directory set the PROVIDER env variable to a provider, and run:

poetry install
export PROVIDER= # URL of provider, e.g. https://mainnet.infura.io/v3/...
poetry shell
poetry run pytest

Publish to pip

To build and publish the package to pip,run:

poetry shell
poetry build
poetry publish

Authors

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

polysynth-0.6.3.tar.gz (73.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polysynth-0.6.3-py3-none-any.whl (80.8 kB view details)

Uploaded Python 3

File details

Details for the file polysynth-0.6.3.tar.gz.

File metadata

  • Download URL: polysynth-0.6.3.tar.gz
  • Upload date:
  • Size: 73.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.9 Darwin/21.0.1

File hashes

Hashes for polysynth-0.6.3.tar.gz
Algorithm Hash digest
SHA256 6762d046c694d2a9d1d339bfc0ac0d9ba99f332e2dbd652d62bd4fe97c2f479d
MD5 b7113784cc01635ff5890ed589e7e87c
BLAKE2b-256 309fc1a7321a09e2d5f8335d44b27d9b8a14d5cea13b6a966b880a0250d123d3

See more details on using hashes here.

File details

Details for the file polysynth-0.6.3-py3-none-any.whl.

File metadata

  • Download URL: polysynth-0.6.3-py3-none-any.whl
  • Upload date:
  • Size: 80.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.9 Darwin/21.0.1

File hashes

Hashes for polysynth-0.6.3-py3-none-any.whl
Algorithm Hash digest
SHA256 bb6459d29ff1db9af5967e840059987ff8455bdf71c29f2e14a26ae2ef860dff
MD5 d1d289628c3afcf6e1362afa5fc576e2
BLAKE2b-256 e612652f773a0bc1d8061e20297b0d7a40c11d8d216836b2b26d2d1a9d90c7a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page