lighter-python-v1


Namelighter-python-v1 JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/elliottech/lighter-python-v1
Summarylighter Python rest api and blockchain interactions for Limit Orders
upload_time2023-01-24 11:16:39
maintainer
docs_urlNone
authorElliot
requires_python
licenseApache 2.0
keywords lighter exchange rest api defi ethereum optimism l2 eth
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Lighter

Python client for Lighter (v1).

## Installation

```bash
pip install lighter-python-v1 
```

## Getting Started

The `Client` object has two main modules;

- `Api`: allows interaction with the lighter api
- `Blockchain`: allows interaction with ligter contracts

`Client` can be created with private key or not depending on whether you are going to use the api or interract with the contracts. For more complete examples, see the [examples](./examples/) directory.

### API

Following parameters are required to use `Api` module:

- `api_auth`: You should get the key from our servers.
- `web3_provider_url`: You need a node to interact with the contract. We suggest alchemy which provides 300M free compute units monthly, You can register and get your keys [here](https://www.alchemy.com/)

```python
from lighter.lighter_client import Client
import os
from lighter.modules.blockchain import OrderSide
from lighter.constants import ORDERBOOK_WETH_USDC

api_auth = os.environ.get("API_AUTH")

# You don't need to provide private key if you only want to use the api module.

client = Client(api_auth=api_auth, web3_provider_url="ALCHEMY_URL")

# Let's get available blockchains and their details from the api module.
blockchains = client.api.get_blockchains().data
```

### Blockchain

Following parameters are required to use `Blockchain` module:

- `api_auth`: You should get the key from our servers.
- `private_key`: You need to provide your wallet private key to sign your transactions.
- `web3_provider_url`: You need a node to interact with the contract. We suggest alchemy which provides 300M free compute units monthly, You can register and get your keys [here](https://www.alchemy.com/)

```python
from lighter.lighter_client import Client
import os
from lighter.modules.blockchain import OrderSide
from lighter.constants import ORDERBOOK_WETH_USDC


private_key = os.environ.get("SOURCE_PRIVATE_KEY")
api_auth = os.environ.get("API_AUTH")


client = Client(
    private_key=private_key, api_auth=api_auth, web3_provider_url="ALCHEMY_URL"
)


x = client.blockchain  # initialize the blockchain module before using it


# Let's create a batch of limit orders

sizes = ["0.001", "0.001", "0.001"]
prices = ["1050", "1200", "1000"]
sides = [OrderSide.BUY, OrderSide.SELL, OrderSide.BUY]


tx_hash = client.blockchain.create_limit_order_batch("WETH_USDC", sizes, prices, sides)

# if you want to wait for the transaction to be mined and get order id and other details,
# you can use the following method.
# alternatively you can wait the data from websocket
result = client.blockchain.get_create_order_transaction_result(tx_hash, "WETH_USDC")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/elliottech/lighter-python-v1",
    "name": "lighter-python-v1",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "lighter exchange rest api defi ethereum optimism l2 eth",
    "author": "Elliot",
    "author_email": "ahmet@elliot.ai",
    "download_url": "https://files.pythonhosted.org/packages/1a/73/bb583977db5a93963d8403000570b514ddc5bca36f094c8bdab41c89ad4d/lighter-python-v1-1.0.0.tar.gz",
    "platform": null,
    "description": "# Lighter\n\nPython client for Lighter (v1).\n\n## Installation\n\n```bash\npip install lighter-python-v1 \n```\n\n## Getting Started\n\nThe `Client` object has two main modules;\n\n- `Api`: allows interaction with the lighter api\n- `Blockchain`: allows interaction with ligter contracts\n\n`Client` can be created with private key or not depending on whether you are going to use the api or interract with the contracts. For more complete examples, see the [examples](./examples/) directory.\n\n### API\n\nFollowing parameters are required to use `Api` module:\n\n- `api_auth`: You should get the key from our servers.\n- `web3_provider_url`: You need a node to interact with the contract. We suggest alchemy which provides 300M free compute units monthly, You can register and get your keys [here](https://www.alchemy.com/)\n\n```python\nfrom lighter.lighter_client import Client\nimport os\nfrom lighter.modules.blockchain import OrderSide\nfrom lighter.constants import ORDERBOOK_WETH_USDC\n\napi_auth = os.environ.get(\"API_AUTH\")\n\n# You don't need to provide private key if you only want to use the api module.\n\nclient = Client(api_auth=api_auth, web3_provider_url=\"ALCHEMY_URL\")\n\n# Let's get available blockchains and their details from the api module.\nblockchains = client.api.get_blockchains().data\n```\n\n### Blockchain\n\nFollowing parameters are required to use `Blockchain` module:\n\n- `api_auth`: You should get the key from our servers.\n- `private_key`: You need to provide your wallet private key to sign your transactions.\n- `web3_provider_url`: You need a node to interact with the contract. We suggest alchemy which provides 300M free compute units monthly, You can register and get your keys [here](https://www.alchemy.com/)\n\n```python\nfrom lighter.lighter_client import Client\nimport os\nfrom lighter.modules.blockchain import OrderSide\nfrom lighter.constants import ORDERBOOK_WETH_USDC\n\n\nprivate_key = os.environ.get(\"SOURCE_PRIVATE_KEY\")\napi_auth = os.environ.get(\"API_AUTH\")\n\n\nclient = Client(\n    private_key=private_key, api_auth=api_auth, web3_provider_url=\"ALCHEMY_URL\"\n)\n\n\nx = client.blockchain  # initialize the blockchain module before using it\n\n\n# Let's create a batch of limit orders\n\nsizes = [\"0.001\", \"0.001\", \"0.001\"]\nprices = [\"1050\", \"1200\", \"1000\"]\nsides = [OrderSide.BUY, OrderSide.SELL, OrderSide.BUY]\n\n\ntx_hash = client.blockchain.create_limit_order_batch(\"WETH_USDC\", sizes, prices, sides)\n\n# if you want to wait for the transaction to be mined and get order id and other details,\n# you can use the following method.\n# alternatively you can wait the data from websocket\nresult = client.blockchain.get_create_order_transaction_result(tx_hash, \"WETH_USDC\")\n```\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "lighter Python rest api and blockchain interactions for Limit Orders",
    "version": "1.0.0",
    "split_keywords": [
        "lighter",
        "exchange",
        "rest",
        "api",
        "defi",
        "ethereum",
        "optimism",
        "l2",
        "eth"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fa8643bd1b76c6b83a04de9c18b5f97809f6942a6569146259866849c4287109",
                "md5": "312984d35f116e299f8202a9a4e238b7",
                "sha256": "62396532973ac6773e2f09c7ecaffb095e60e77100c0e03b6bf5e11abf030fd8"
            },
            "downloads": -1,
            "filename": "lighter_python_v1-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "312984d35f116e299f8202a9a4e238b7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 22966,
            "upload_time": "2023-01-24T11:16:36",
            "upload_time_iso_8601": "2023-01-24T11:16:36.574353Z",
            "url": "https://files.pythonhosted.org/packages/fa/86/43bd1b76c6b83a04de9c18b5f97809f6942a6569146259866849c4287109/lighter_python_v1-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a73bb583977db5a93963d8403000570b514ddc5bca36f094c8bdab41c89ad4d",
                "md5": "cb773f22205ddfd917859f1b7a5f9936",
                "sha256": "bb3f68880b3c060e8a2e41fe42e133691d06b68bb14df7a8d56d169a9eca5c59"
            },
            "downloads": -1,
            "filename": "lighter-python-v1-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cb773f22205ddfd917859f1b7a5f9936",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 20944,
            "upload_time": "2023-01-24T11:16:39",
            "upload_time_iso_8601": "2023-01-24T11:16:39.534470Z",
            "url": "https://files.pythonhosted.org/packages/1a/73/bb583977db5a93963d8403000570b514ddc5bca36f094c8bdab41c89ad4d/lighter-python-v1-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-24 11:16:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "elliottech",
    "github_project": "lighter-python-v1",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "circle": true,
    "requirements": [],
    "tox": true,
    "lcname": "lighter-python-v1"
}
        
Elapsed time: 0.03517s