API Reference
Dive into several methods of Polysynth Class for all types of use cases.

Polysynth Class

class polysynth.Polysynth(address: Optional[Union[Address, ChecksumAddress, str]], private_key: Optional[str], gas_estimate_custom: Optional [Callable] = None, provider: Optional[str] = None, web3: Optional[web3.main.Web3] = None, version: int = 1, default_slippage: float = 0.01, stable_token_contract_addr: Optional[str] = None, manager_contract_addr: Optional[str] = None, amm_reader_contract_addr: Optional[str] = None)
Parameters:
  • address – The public address of the wallet to be used
  • private_key – The private key of the wallet to be used
  • gas_estimate_custom – Can be optionally set to a custom gas strategy function
  • provider – Can be optionally set to a Web3 provider URL. If none set, will fall back to the PROVIDER environment variable, or web3 if set
  • web3 – Can be optionally set to a custom Web3 instance
  • version – Which version of the Polysynth contracts to use
  • default_slippage – Default slippage for a trade, as a float (0.01 is 1%)
  • stable_token_contract_addr – Can be optionally set to override the address of the stable token contract
  • manager_contract_addr – Can be optionally set to override the address of the manager contract
  • amm_reader_contract_addr – Can be optionally set to override the address of the amm contract

Gas Estimate Custom:

  • While initialisation gas estimate custom function can be optionally passed [only the name of the function needs to be passed, example: gas_custom_strategy without calling the function]
  • This function will be called each time gas estimate needs to be fetched for any of the trading operations
  • The function should return the output in the following format: {"maxPriorityFee": ,"maxFee": } where the unit is gwei

Account

This section covers all account management methods on Polysynth. You can fetch wallet balance, add/remove margin, etc using these methods.

Markets

This section covers all market data related methods on Polysynth. You can fetch price, funding rate, index price, etc using these methods.

Trade

This section covers all trade management-related methods on Polysynth. You can place orders, manage positions using these methods.

Status Codes

Code
Message
200
Successful
400
Bad Request
408
Request Time Out
429
Too Many Requests
500
Failed Transaction
3000
Missing Required Args
3001
Invalid Arg Type
3002
Execution Reverted
3003
Invalid Provider
3004
Invalid Address
3005
Invalid Side
3006
Invalid Amount
3007
Invalid Leverage
3008
Invalid Slippage
3009
Fluctuation Limit Exceeded
3010
Insufficient Wallet Balance
3011
Zero Collateral
3012
Collateral Not Enough
​
Last modified 3mo ago