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
Metadata
Release files for lyra-v2-action-signing 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lyra_v2_action_signing-0.0.7.tar.gz | 8.7 kB | Without provenance | Details for lyra_v2_action_signing-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lyra_v2_action_signing-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for lyra_v2_action_signing-0.0.7-py3-none-any.whl |
Total release size: 18.6 kB
Release files / lyra_v2_action_signing-0.0.7.tar.gz
| Download URL | lyra_v2_action_signing-0.0.7.tar.gz |
|---|---|
| Size | 8.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eb477aa9a7d9956d87e3f46da3132ce58df49f762efce95ed8a70f864cf911e3
|
|
BLAKE2b-256 checksum How to use checksums |
a55ffee8315c9267344207b74c61ee005ead56a170f56976ad1549b8164b5fc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Release files / lyra_v2_action_signing-0.0.7-py3-none-any.whl
| Download URL | lyra_v2_action_signing-0.0.7-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d909dfe53101b3a5cc283498c6ce34a66d269c4c809b070d492f85afccd85c23
|
|
BLAKE2b-256 checksum How to use checksums |
0d8dad1d45e6a35595d902b6046a733e96f5c6a2e942656d393347e23b9129bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/5.1.1 CPython/3.12.7
|
Security for lyra-v2-action-signing 0.0.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.