Skip to main content

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

Metadata

Release files for polysynth 0.7.2

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

Source distribution (sdist)

Source distribution for polysynth 0.7.2
File Size Uploaded
polysynth-0.7.2.tar.gz 75.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polysynth 0.7.2
File Interpreter ABI Platform
polysynth-0.7.2-py3-none-any.whl Python 3 none any Details

Total release size: 159.6 kB

Release files / polysynth-0.7.2.tar.gz

Download URL polysynth-0.7.2.tar.gz
Size 75.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d3e6dbb9c06129dfcee6e83f7bc230de0f105a9a2f775bd3121fd5635d09052f
BLAKE2b-256 checksum
How to use checksums
10d49a080104922fac39c57775faa490dffce6c91f31a6a86612498bb02a107a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.9 Darwin/21.0.1

Release files / polysynth-0.7.2-py3-none-any.whl

Download URL polysynth-0.7.2-py3-none-any.whl
Size 83.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c11c11b93291201140543f8d7eb93350e17d6b1e4b8874aee19d6d0726626428
BLAKE2b-256 checksum
How to use checksums
2798b710a6dd86b84fba05e1d4316ca72779a758bd7ee548fcc8ed564dfea246
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.13 CPython/3.8.9 Darwin/21.0.1

Release history Release notifications | RSS feed

This release

0.7.2 This release

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.6

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.5.9

2 release files

0.5.8

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.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