nado-protocol


Namenado-protocol JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://nado.xyz
SummaryNado Protocol SDK
upload_time2025-08-14 19:37:07
maintainerFrank Jia
docs_urlNone
authorJeury Mejia
requires_python<4.0,>=3.9
licenseNone
keywords nado protocol nado sdk nado protocol api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Nado Protocol Python SDK

This is the Python SDK for the [Nado Protocol API](TODO).

See [SDK docs](https://nadohq.github.io/nado-python-sdk/index.html) to get started.

## Requirements

- Python 3.9 or above

## Installation

You can install the SDK via pip:

```bash
pip install nado-protocol
```

## Basic usage

### Import the necessary utilities:

```python
from nado_protocol.client import create_nado_client, NadoClientMode
from nado_protocol.contracts.types import DepositCollateralParams
from nado_protocol.engine_client.types.execute import (
    OrderParams,
    PlaceOrderParams,
    SubaccountParams
)
from nado_protocol.utils.expiration import OrderType, get_expiration_timestamp
from nado_protocol.utils.math import to_pow_10, to_x18
from nado_protocol.utils.nonce import gen_order_nonce
```

### Create the NadoClient providing your private key:

```python
print("setting up nado client...")
private_key = "xxx"
client = create_nado_client(NadoClientMode.DEVNET, private_key)
```

### Perform basic operations:

```python
# Depositing collaterals
print("approving allowance...")
approve_allowance_tx_hash = client.spot.approve_allowance(0, to_pow_10(100000, 6))
print("approve allowance tx hash:", approve_allowance_tx_hash)

print("querying my allowance...")
token_allowance = client.spot.get_token_allowance(0, client.context.signer.address)
print("token allowance:", token_allowance)

print("depositing collateral...")
deposit_tx_hash = client.spot.deposit(
   DepositCollateralParams(
      subaccount_name="default", product_id=0, amount=to_pow_10(100000, 6)
   )
)
print("deposit collateral tx hash:", deposit_tx_hash)

# Placing orders
print("placing order...")
owner = client.context.engine_client.signer.address
product_id = 1
order = OrderParams(
   sender=SubaccountParams(
      subaccount_owner=owner,
      subaccount_name="default",
   ),
   priceX18=to_x18(20000),
   amount=to_pow_10(1, 17),
   expiration=get_expiration_timestamp(OrderType.POST_ONLY, int(time.time()) + 40),
   nonce=gen_order_nonce(),
)
res = client.market.place_order({"product_id": product_id, "order": order})
print("order result:", res.json(indent=2))
```

See [Getting Started](https://nadohq.github.io/nado-python-sdk/getting-started.html) for more.

## Running locally

1. Clone [github repo](https://github.com/nadohq/nado-python-sdk)

2. Install poetry

```

$ curl -sSL https://install.python-poetry.org | python3 -

```

3. Setup a virtual environment and activate it

```

$ python3 -m venv venv
$ source ./venv/bin/activate

```

4. Install dependencies via `poetry install`
5. Setup an `.env` file and set the following envvars

```shell
CLIENT_MODE='devnet'
SIGNER_PRIVATE_KEY="0x..."
LINKED_SIGNER_PRIVATE_KEY="0x..." # not required
```

### Run tests

```
$ poetry run test
```

### Run sanity checks

- `poetry run client-sanity`: runs sanity checks for the top-level client.
- `poetry run engine-sanity`: runs sanity checks for the `engine-client`.
- `poetry run indexer-sanity`: runs sanity checks for the `indexer-client`.
- `poetry run contracts-sanity`: runs sanity checks for the contracts module.

### Build Docs

To build the docs locally run:

```
$ poetry run sphinx-build docs/source docs/build
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://nado.xyz",
    "name": "nado-protocol",
    "maintainer": "Frank Jia",
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": "frank@inkfnd.com",
    "keywords": "nado protocol, nado sdk, nado protocol api",
    "author": "Jeury Mejia",
    "author_email": "jeury@inkfnd.com",
    "download_url": "https://files.pythonhosted.org/packages/a0/15/0c80d68a1d4c04e0e84e299ab0d309f3cabd5cd9b8c9f0bc6330641f0496/nado_protocol-0.1.1.tar.gz",
    "platform": null,
    "description": "# Nado Protocol Python SDK\n\nThis is the Python SDK for the [Nado Protocol API](TODO).\n\nSee [SDK docs](https://nadohq.github.io/nado-python-sdk/index.html) to get started.\n\n## Requirements\n\n- Python 3.9 or above\n\n## Installation\n\nYou can install the SDK via pip:\n\n```bash\npip install nado-protocol\n```\n\n## Basic usage\n\n### Import the necessary utilities:\n\n```python\nfrom nado_protocol.client import create_nado_client, NadoClientMode\nfrom nado_protocol.contracts.types import DepositCollateralParams\nfrom nado_protocol.engine_client.types.execute import (\n    OrderParams,\n    PlaceOrderParams,\n    SubaccountParams\n)\nfrom nado_protocol.utils.expiration import OrderType, get_expiration_timestamp\nfrom nado_protocol.utils.math import to_pow_10, to_x18\nfrom nado_protocol.utils.nonce import gen_order_nonce\n```\n\n### Create the NadoClient providing your private key:\n\n```python\nprint(\"setting up nado client...\")\nprivate_key = \"xxx\"\nclient = create_nado_client(NadoClientMode.DEVNET, private_key)\n```\n\n### Perform basic operations:\n\n```python\n# Depositing collaterals\nprint(\"approving allowance...\")\napprove_allowance_tx_hash = client.spot.approve_allowance(0, to_pow_10(100000, 6))\nprint(\"approve allowance tx hash:\", approve_allowance_tx_hash)\n\nprint(\"querying my allowance...\")\ntoken_allowance = client.spot.get_token_allowance(0, client.context.signer.address)\nprint(\"token allowance:\", token_allowance)\n\nprint(\"depositing collateral...\")\ndeposit_tx_hash = client.spot.deposit(\n   DepositCollateralParams(\n      subaccount_name=\"default\", product_id=0, amount=to_pow_10(100000, 6)\n   )\n)\nprint(\"deposit collateral tx hash:\", deposit_tx_hash)\n\n# Placing orders\nprint(\"placing order...\")\nowner = client.context.engine_client.signer.address\nproduct_id = 1\norder = OrderParams(\n   sender=SubaccountParams(\n      subaccount_owner=owner,\n      subaccount_name=\"default\",\n   ),\n   priceX18=to_x18(20000),\n   amount=to_pow_10(1, 17),\n   expiration=get_expiration_timestamp(OrderType.POST_ONLY, int(time.time()) + 40),\n   nonce=gen_order_nonce(),\n)\nres = client.market.place_order({\"product_id\": product_id, \"order\": order})\nprint(\"order result:\", res.json(indent=2))\n```\n\nSee [Getting Started](https://nadohq.github.io/nado-python-sdk/getting-started.html) for more.\n\n## Running locally\n\n1. Clone [github repo](https://github.com/nadohq/nado-python-sdk)\n\n2. Install poetry\n\n```\n\n$ curl -sSL https://install.python-poetry.org | python3 -\n\n```\n\n3. Setup a virtual environment and activate it\n\n```\n\n$ python3 -m venv venv\n$ source ./venv/bin/activate\n\n```\n\n4. Install dependencies via `poetry install`\n5. Setup an `.env` file and set the following envvars\n\n```shell\nCLIENT_MODE='devnet'\nSIGNER_PRIVATE_KEY=\"0x...\"\nLINKED_SIGNER_PRIVATE_KEY=\"0x...\" # not required\n```\n\n### Run tests\n\n```\n$ poetry run test\n```\n\n### Run sanity checks\n\n- `poetry run client-sanity`: runs sanity checks for the top-level client.\n- `poetry run engine-sanity`: runs sanity checks for the `engine-client`.\n- `poetry run indexer-sanity`: runs sanity checks for the `indexer-client`.\n- `poetry run contracts-sanity`: runs sanity checks for the contracts module.\n\n### Build Docs\n\nTo build the docs locally run:\n\n```\n$ poetry run sphinx-build docs/source docs/build\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Nado Protocol SDK",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://nadohq.github.io/nado-python-sdk/",
        "Homepage": "https://nado.xyz"
    },
    "split_keywords": [
        "nado protocol",
        " nado sdk",
        " nado protocol api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e0308a02fcc0f405af69758acc1bfda7a5e8c245aacb461e1046e3144fa79199",
                "md5": "97cbf5f95d3accbd9e4006f912bf0c46",
                "sha256": "e63f51ee5b22642f7ce43cf40e34f274eeda72bee8c35c1ea9db6fbed7d4e539"
            },
            "downloads": -1,
            "filename": "nado_protocol-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "97cbf5f95d3accbd9e4006f912bf0c46",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 91718,
            "upload_time": "2025-08-14T19:37:05",
            "upload_time_iso_8601": "2025-08-14T19:37:05.848505Z",
            "url": "https://files.pythonhosted.org/packages/e0/30/8a02fcc0f405af69758acc1bfda7a5e8c245aacb461e1046e3144fa79199/nado_protocol-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a0150c80d68a1d4c04e0e84e299ab0d309f3cabd5cd9b8c9f0bc6330641f0496",
                "md5": "e29d75e94c5f41786c0ff3d1992efdaa",
                "sha256": "8fca252dbfc96028148e705977194041b44ef15c737165293e71dc79b7c3aa2c"
            },
            "downloads": -1,
            "filename": "nado_protocol-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "e29d75e94c5f41786c0ff3d1992efdaa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 60270,
            "upload_time": "2025-08-14T19:37:07",
            "upload_time_iso_8601": "2025-08-14T19:37:07.251398Z",
            "url": "https://files.pythonhosted.org/packages/a0/15/0c80d68a1d4c04e0e84e299ab0d309f3cabd5cd9b8c9f0bc6330641f0496/nado_protocol-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-14 19:37:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "nado-protocol"
}
        
Elapsed time: 1.39405s