Python package to sign on-chain self-custodial requests for orders, transfers, deposits, withdrawals and RFQs.
Project description
v2-action-signing-python
Python package to sign the following on-chain self-custodial requests:
- order
- RFQ quote
- RFQ execution
- transfer positions
Although the below actions are supported by the SDK, we recommend you use the UX developer portal (https://docs.derive.xyz/docs/onboard-via-interface):
- create subaccount
- deposit
- withdrawal
- transfer collateral
Usage
-
Install package:
pip install lyra_v2_action_signing -
Sign an order
from web3 import Web3
from lyra_v2_action_signing import SignedAction, TradeModuleData, utils
session_key_wallet = Web3().eth.account.from_key("0x2ae8be44db8a590d20bffbe3b6872df9b569147d3bf6801a35a28281a4816bbd")
action = SignedAction(
subaccount_id=30769,
owner=SMART_CONTRACT_WALLET_ADDRESS, # from Protocol Constants table in docs.lyra.finance
signer=session_key_wallet.address,
signature_expiry_sec=utils.MAX_INT_32,
nonce=utils.get_action_nonce(),
module_address=TRADE_MODULE_ADDRESS, # from Protocol Constants table in docs.lyra.finance
module_data=TradeModuleData(
asset=instrument_ticker["base_asset_address"],
sub_id=int(instrument_ticker["base_asset_sub_id"]),
limit_price=Decimal("100"),
amount=Decimal("1"),
max_fee=Decimal("1000"),
recipient_id=30769,
is_bid=True,
),
DOMAIN_SEPARATOR=DOMAIN_SEPARATOR, # from Protocol Constants table in docs.derive.xyz
ACTION_TYPEHASH=ACTION_TYPEHASH, # from Protocol Constants table in docs.derive.xyz
)
action.sign(session_key_wallet.key)
For full signing examples see examples/ in https://github.com/derivexyz/v2-action-signing-python/tree/master/examples.
Acknowledgements
Thank you 8baller for building a full Python client for the v2 API. Much of the signing logic in the repo was used to inform this package: https://github.com/8ball030/lyra_client
Developers
- Create venv and run
pip install -e ., this reflects changes in package immediately in venv - Install dev related packages with
pip install -r requirements-dev.txt
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lyra_v2_action_signing-0.0.6.tar.gz.
File metadata
- Download URL: lyra_v2_action_signing-0.0.6.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96911ce7ab918e774aece84db75c11341b4505214bd671dab96ff247511c042f
|
|
| MD5 |
ffb3645f2d7b580e539546db703310d9
|
|
| BLAKE2b-256 |
bdb9ff0c50e368808f49afdd0c20e122a7b332ee35d7f9435413e5d0bab60c0a
|
File details
Details for the file lyra_v2_action_signing-0.0.6-py3-none-any.whl.
File metadata
- Download URL: lyra_v2_action_signing-0.0.6-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4bed96ab77d502d8c312df29705056efa01b6c6c99d8ce70ad2e474da348c87
|
|
| MD5 |
e43b14dd4c7fecb8d4186f6440560f16
|
|
| BLAKE2b-256 |
21e9ac9eabb77506996c3c654873837a807c58bf3bc4710e66997521718ca7b0
|