Kwenta SDK
Kwenta Python SDK
Python SDK to interact with Kwenta's smart contracts, subgraphs, and Synthetix perps.
Installation
Install the SDK using pip:
For more information on usage, see the Usage section and the sample scripts.
Development
Create a python virtual environment, activate it and install libraries:
This method will install the local version of the module in editable mode. You can make changes to the SDK and test them without reinstalling the module.
Usage
To configure an instance of the Kwenta SDK, you need to specify some parameters. At minimum you need to specify the network_id
and provider_rpc
to read data from the contracts. If you specify a wallet_address
and private_key
you can also submit transactions or create transaction data using the SDK.:
VERSIONS
SDK Versions below 1.6.0 will only support Kwenta V1 isolated margin. Please use the current version to utilize Smart Margin functionality.
Queries / Subgraphs:
Queries will default to Kwenta's public Hosted Service endpoints for The Graph.
To fetch perps data specify endpoint
gql_endpoint_perps
: defaults to Optimism-perps subgraphTo fetch rates specify endpoint
gql_endpoint_perps
: defaults to Optimism-perps subgraph
Pyth:
Specify the endpoint of a Pyth price service as
price_service_endpoint
defaults to the public Pyth price service. This should be updated for any production applications to use a private Pyth price service.
Telegram:
Search telegram for bot named "@botfather"
Message the bot with and type "/newbot"
Input bot name (This will become channel name)
Specify API token as
telegram_token
Specify channel name as
telegram_channel_name
Features
kwenta
:
Fetch market info
Fetch position info
Open positions
Close positions
Modify open positions
Transfer margin
Execute and cancel orders
Limit and stop limit orders
kwenta.queries
:
Fetch historical trades
Fetch historical positions
kwenta.pyth
:
Fetch price update data from Pyth price feed
Initialization Parameters
Last updated