Skip to content

Commit

Permalink
Update usage in README
Browse files Browse the repository at this point in the history
  • Loading branch information
udit-gulati committed Sep 25, 2021
1 parent 997721a commit 9de72b1
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 11 deletions.
86 changes: 82 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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='<key>'
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]().
3 changes: 0 additions & 3 deletions perppy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from perppy.query import *
from perppy.execute import *

4 changes: 0 additions & 4 deletions perppy/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9de72b1

Please sign in to comment.