From 9de72b1eb12c4c49e9a7cafaefd209a37fc10cd1 Mon Sep 17 00:00:00 2001 From: udit-gulati Date: Sat, 25 Sep 2021 16:39:23 +0530 Subject: [PATCH] Update usage in README --- README.md | 86 +++++++++++++++++++++++++++++++++++++++++++--- perppy/__init__.py | 3 -- perppy/query.py | 4 --- 3 files changed, 82 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 12f4202..4831c3e 100644 --- a/README.md +++ b/README.md @@ -8,18 +8,96 @@ Python SDK for Perpetual Protocol. pip install perp-py ``` -## Usage +## Installing from source -Export env variables: +### Running locally without installation ```bash -export INFURA_PROJECT_ID='' +git clone https://github.com/arufa-research/perp-py +cd perp-py/ + +python3 +``` + +In python interpreter: + +```python +# import the whole library +import perpy + +## import query functions +from perppy.query import * + +## import execute functions +from perppy.execute import * +``` + +### Installation + +```bash +git clone https://github.com/arufa-research/perp-py +cd perp-py/ +python3 -m venv env +source env/bin/activate +pip install -r requirements.txt +make install +``` + +### Testing + +```bash +git clone https://github.com/arufa-research/perp-py +cd perp-py/ +python3 -m venv env +source env/bin/activate +pip install -r requirements.txt +make test +``` + +## Example Usage + +### Query data + ++ Query recent positions. User can specify the network (production/staging) and add filters such as trader address, block limit and pair name. `get_position_changes()` returns a list of `Position` objects. + +```python +from perppy.query import get_position_changes + +print(get_position_changes()) +print(get_position_changes(pair='BTC/USDC')) +print(get_position_changes(pair='BTC/USDC', block_limit=10)) +print(get_position_changes(network='staging')) ``` ++ Query trader portfolio using trader address. + ```python -import perppy +from perppy.query import get_trader_portfolio + +trader_portfolio = get_trader_portfolio('') +print(trader_portfolio.layer1_balance) +print(trader_portfolio.layer2_balance) +print(trader_portfolio.portfolios['PERP/USDC']) ``` ++ Query information of all AMMs or one AMM. `get_all_amms()` returns list of `Amm` objects. `get_amm_info(pair_name)` returns the `Amm` object for given `pai_name`. + +```python +from perppy.query import get_all_amms, get_amm_info + +amm_list = get_all_amms() + +btc_amm = get_amm_info('BTC/USDC') +``` + +### Execute transactions + +### Staking + +### Faucet + ## Documentation + +Quickstart and API reference documentation is on [ReadTheDocs](). diff --git a/perppy/__init__.py b/perppy/__init__.py index f4f197a..e69de29 100644 --- a/perppy/__init__.py +++ b/perppy/__init__.py @@ -1,3 +0,0 @@ -from perppy.query import * -from perppy.execute import * - diff --git a/perppy/query.py b/perppy/query.py index 530760d..3e38262 100644 --- a/perppy/query.py +++ b/perppy/query.py @@ -87,7 +87,3 @@ def get_amm_info( network: str = 'production' ): return Amm(amm_addr, network) - - -def verify_function_data(contract_addr: str, byte_code: str): - pass