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
Although the below actions are supported by the SDK, we recommend you use the UX developer portal (https://docs.lyra.finance/docs/onboard-via-interface):
- create subaccount
- deposit
- withdrawal
- transfer
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.lyra.finance
ACTION_TYPEHASH=ACTION_TYPEHASH, # from Protocol Constants table in docs.lyra.finance
)
action.sign(session_key_wallet.key)
For full signing examples see examples/
in https://github.com/lyra-finance/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
Release history Release notifications | RSS feed
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
Hashes for lyra_v2_action_signing-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50c1b0d0121c891343d255e03fe47bebe842ce9ace650551dd24b7987dcda75d |
|
MD5 | 8f1ee99e7b9863c037f1da7c0aea7b5c |
|
BLAKE2b-256 | f05a2afd4fe66f19df66e6a9f6ab7bce7d77b277ac79dafc1b2862cf3f93473c |
Hashes for lyra_v2_action_signing-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7c858bf99aa03534af68d16034a148d3a7b8d05a4995d8ec2245c04435d35d3 |
|
MD5 | 885a86c7bbce6b6c077af276f9a9f224 |
|
BLAKE2b-256 | a027715bb26880b9848a4751a9c39b811260532e2b5a515f6776f21301ddfe6b |