diff --git a/.gitignore b/.gitignore index ba10070..30e5089 100644 --- a/.gitignore +++ b/.gitignore @@ -63,3 +63,6 @@ target/ #Ipython Notebook .ipynb_checkpoints openapi-generator-cli.jar + + +.idea \ No newline at end of file diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 6f8645b..1559712 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,9 +1,3 @@ -.github/workflows/python.yml -.gitignore -.gitlab-ci.yml -.openapi-generator-ignore -.travis.yml -README.md docs/Account.md docs/AccountApi.md docs/AccountApiKeys.md @@ -24,6 +18,7 @@ docs/Candlesticks.md docs/ContractAddress.md docs/CurrentHeight.md docs/Cursor.md +docs/DailyReturn.md docs/DepositHistory.md docs/DepositHistoryItem.md docs/DetailedAccount.md @@ -52,7 +47,6 @@ docs/OrderBookStats.md docs/OrderBooks.md docs/Orders.md docs/PnLEntry.md -docs/PositionFunding.md docs/PriceLevel.md docs/PublicPool.md docs/PublicPoolInfo.md @@ -107,8 +101,6 @@ docs/WithdrawHistory.md docs/WithdrawHistoryCursor.md docs/WithdrawHistoryItem.md docs/ZkLighterInfo.md -git_push.sh -lighter/__init__.py lighter/api/__init__.py lighter/api/account_api.py lighter/api/block_api.py @@ -124,40 +116,28 @@ lighter/exceptions.py lighter/models/__init__.py lighter/models/account.py lighter/models/account_api_keys.py -lighter/models/account_market_stats.py -lighter/models/account_metadata.py lighter/models/account_pn_l.py lighter/models/account_position.py -lighter/models/account_stats.py -lighter/models/accounts.py lighter/models/api_key.py lighter/models/block.py lighter/models/blocks.py -lighter/models/bridge_supported_network.py lighter/models/candlestick.py lighter/models/candlesticks.py -lighter/models/contract_address.py lighter/models/current_height.py -lighter/models/cursor.py +lighter/models/daily_return.py lighter/models/deposit_history.py lighter/models/deposit_history_item.py lighter/models/detailed_account.py lighter/models/detailed_accounts.py -lighter/models/detailed_candlestick.py lighter/models/enriched_tx.py lighter/models/exchange_stats.py lighter/models/fee_bucket.py lighter/models/funding.py lighter/models/fundings.py -lighter/models/is_whitelisted.py -lighter/models/l1_provider_info.py lighter/models/layer2_basic_info.py -lighter/models/liquidation.py -lighter/models/market_info.py lighter/models/next_nonce.py lighter/models/order.py lighter/models/order_book.py -lighter/models/order_book_depth.py lighter/models/order_book_detail.py lighter/models/order_book_details.py lighter/models/order_book_orders.py @@ -165,168 +145,21 @@ lighter/models/order_book_stats.py lighter/models/order_books.py lighter/models/orders.py lighter/models/pn_l_entry.py -lighter/models/position_funding.py -lighter/models/price_level.py lighter/models/public_pool.py lighter/models/public_pool_info.py lighter/models/public_pool_share.py lighter/models/public_pools.py -lighter/models/req_get_account.py -lighter/models/req_get_account_active_orders.py -lighter/models/req_get_account_api_keys.py -lighter/models/req_get_account_by_l1_address.py -lighter/models/req_get_account_inactive_orders.py -lighter/models/req_get_account_orders.py -lighter/models/req_get_account_pending_txs.py -lighter/models/req_get_account_pn_l.py -lighter/models/req_get_account_txs.py -lighter/models/req_get_block.py -lighter/models/req_get_block_txs.py -lighter/models/req_get_by_account.py -lighter/models/req_get_candlesticks.py -lighter/models/req_get_deposit_history.py -lighter/models/req_get_fee_bucket.py -lighter/models/req_get_fundings.py -lighter/models/req_get_l1_tx.py -lighter/models/req_get_latest_deposit.py -lighter/models/req_get_next_nonce.py -lighter/models/req_get_order_book_details.py -lighter/models/req_get_order_book_orders.py -lighter/models/req_get_order_books.py -lighter/models/req_get_public_pools.py -lighter/models/req_get_range_with_cursor.py -lighter/models/req_get_range_with_index.py -lighter/models/req_get_range_with_index_sortable.py -lighter/models/req_get_recent_trades.py -lighter/models/req_get_trades.py -lighter/models/req_get_tx.py -lighter/models/req_get_withdraw_history.py -lighter/models/req_is_whitelisted.py -lighter/models/result_code.py lighter/models/simple_order.py lighter/models/status.py lighter/models/sub_accounts.py -lighter/models/ticker.py lighter/models/trade.py lighter/models/trades.py lighter/models/tx.py lighter/models/tx_hash.py lighter/models/tx_hashes.py lighter/models/txs.py -lighter/models/validator_info.py lighter/models/withdraw_history.py -lighter/models/withdraw_history_cursor.py lighter/models/withdraw_history_item.py lighter/models/zk_lighter_info.py lighter/py.typed lighter/rest.py -pyproject.toml -requirements.txt -setup.cfg -setup.py -test-requirements.txt -test/__init__.py -test/test_account.py -test/test_account_api.py -test/test_account_api_keys.py -test/test_account_market_stats.py -test/test_account_metadata.py -test/test_account_pn_l.py -test/test_account_position.py -test/test_account_stats.py -test/test_accounts.py -test/test_api_key.py -test/test_block.py -test/test_block_api.py -test/test_blocks.py -test/test_bridge_supported_network.py -test/test_candlestick.py -test/test_candlestick_api.py -test/test_candlesticks.py -test/test_contract_address.py -test/test_current_height.py -test/test_cursor.py -test/test_deposit_history.py -test/test_deposit_history_item.py -test/test_detailed_account.py -test/test_detailed_accounts.py -test/test_detailed_candlestick.py -test/test_enriched_tx.py -test/test_exchange_stats.py -test/test_fee_bucket.py -test/test_funding.py -test/test_fundings.py -test/test_info_api.py -test/test_is_whitelisted.py -test/test_l1_provider_info.py -test/test_layer2_basic_info.py -test/test_liquidation.py -test/test_market_info.py -test/test_next_nonce.py -test/test_order.py -test/test_order_api.py -test/test_order_book.py -test/test_order_book_depth.py -test/test_order_book_detail.py -test/test_order_book_details.py -test/test_order_book_orders.py -test/test_order_book_stats.py -test/test_order_books.py -test/test_orders.py -test/test_pn_l_entry.py -test/test_position_funding.py -test/test_price_level.py -test/test_public_pool.py -test/test_public_pool_info.py -test/test_public_pool_share.py -test/test_public_pools.py -test/test_req_get_account.py -test/test_req_get_account_active_orders.py -test/test_req_get_account_api_keys.py -test/test_req_get_account_by_l1_address.py -test/test_req_get_account_inactive_orders.py -test/test_req_get_account_orders.py -test/test_req_get_account_pending_txs.py -test/test_req_get_account_pn_l.py -test/test_req_get_account_txs.py -test/test_req_get_block.py -test/test_req_get_block_txs.py -test/test_req_get_by_account.py -test/test_req_get_candlesticks.py -test/test_req_get_deposit_history.py -test/test_req_get_fee_bucket.py -test/test_req_get_fundings.py -test/test_req_get_l1_tx.py -test/test_req_get_latest_deposit.py -test/test_req_get_next_nonce.py -test/test_req_get_order_book_details.py -test/test_req_get_order_book_orders.py -test/test_req_get_order_books.py -test/test_req_get_public_pools.py -test/test_req_get_range_with_cursor.py -test/test_req_get_range_with_index.py -test/test_req_get_range_with_index_sortable.py -test/test_req_get_recent_trades.py -test/test_req_get_trades.py -test/test_req_get_tx.py -test/test_req_get_withdraw_history.py -test/test_req_is_whitelisted.py -test/test_result_code.py -test/test_root_api.py -test/test_simple_order.py -test/test_status.py -test/test_sub_accounts.py -test/test_ticker.py -test/test_trade.py -test/test_trades.py -test/test_transaction_api.py -test/test_tx.py -test/test_tx_hash.py -test/test_tx_hashes.py -test/test_txs.py -test/test_validator_info.py -test/test_withdraw_history.py -test/test_withdraw_history_cursor.py -test/test_withdraw_history_item.py -test/test_zk_lighter_info.py -tox.ini diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..b506b7c --- /dev/null +++ b/examples/README.md @@ -0,0 +1,24 @@ +## Setup steps for testnet +- Go to https://testnet.app.lighter.xyz/ and connect a wallet to receive $500 +- run `system_setup.py` with the correct ETH Private key configured + - set an API key index which is not 0, so you won't override the one used by [app.lighter.xyz](https://app.lighter.xyz/) + - this will require you to enter your Ethereum private key + - the eth private key will only be used in the Py SDK to sign a message + - the eth private key is not required in order to trade on the platform + - the eth private key is not passed to the binary + - copy the output of the script and post it into `create_cancel_order.py` + - the output should look like +``` +BASE_URL = 'https://testnet.zklighter.elliot.ai' +API_KEY_PRIVATE_KEY = '0xea5d2eca5be67eca056752eaf27b173518b8a5550117c09d2b58c7ea7d306cc4426f913ccf27ab19' +ACCOUNT_INDEX = 595 +API_KEY_INDEX = 1 +``` +- start trading using + - `create_cancel_order.py` has an example which created an order on testnet & cancels it + - you'll need to set up both your account index, api key index & API Key private key + +## Setup steps for mainnet +- deposit money on Lighter to create an account first +- change the URL to `mainnet.zklighter.elliot.ai` +- repeat setup step \ No newline at end of file diff --git a/examples/create_cancel_order.py b/examples/create_cancel_order.py index 94b5c2a..485a029 100644 --- a/examples/create_cancel_order.py +++ b/examples/create_cancel_order.py @@ -1,15 +1,15 @@ import asyncio import logging -import time -from lighter import SignerClient import lighter -import lighter.configuration logging.basicConfig(level=logging.DEBUG) - +# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. +# It was generated using the setup_system.py script, and servers as an example. BASE_URL = "https://testnet.zklighter.elliot.ai" -PRIVATE_KEY = "WALLET_PRIVATE_KEY" +API_KEY_PRIVATE_KEY = "0xc0a06468a5bbc9a7b785065a8b227a37fdfa18e2b81d51b018cb03ddd99bfbef4b7551f0f0765639" +ACCOUNT_INDEX = 595 +API_KEY_INDEX = 1 def trim_exception(e: Exception) -> str: @@ -17,42 +17,40 @@ def trim_exception(e: Exception) -> str: async def main(): - api_client = lighter.ApiClient( - configuration=lighter.Configuration(host=BASE_URL) + api_client = lighter.ApiClient(configuration=lighter.Configuration(host=BASE_URL)) + + client = lighter.SignerClient( + url=BASE_URL, + private_key=API_KEY_PRIVATE_KEY, + account_index=ACCOUNT_INDEX, + api_key_index=API_KEY_INDEX, ) - # assuring that client is created - account_created = False - new_account = False - while not account_created: - try: - client = SignerClient(url=BASE_URL, private_key=PRIVATE_KEY) - await client.set_account_index() - account_created = True - if new_account: - time.sleep(10) - except Exception as e: - new_account = True - print("Account not created yet", trim_exception(e)) - time.sleep(2) - - print("Account Index: ", client.account_index) - - tx = await client.create_order( + err = client.check_client() + if err is not None: + print(f"CheckClient error: {trim_exception(err)}") + return + + # create order + tx, tx_hash, err = await client.create_order( market_index=0, - client_order_index=0, - base_amount=10000, - price=250000, - is_ask=False, + client_order_index=123, + base_amount=100000, + price=200000, + is_ask=True, order_type=lighter.SignerClient.ORDER_TYPE_LIMIT, time_in_force=lighter.SignerClient.ORDER_TIME_IN_FORCE_GOOD_TILL_TIME, reduce_only=0, trigger_price=0, ) - print("Create Order Tx:", tx) + print(f"Create Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) - auth = client.create_auth_token_with_expiry(SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY) - print("Auth:", auth) + auth, err = client.create_auth_token_with_expiry(lighter.SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY) + print(f"{auth=}") + if err is not None: + raise Exception(err) active_orders = await lighter.OrderApi(api_client).account_active_orders( account_index=client.account_index, market_id=0, auth=auth @@ -61,16 +59,16 @@ async def main(): print("No active orders") return - print("Active Orders:", active_orders.orders) + print(f"{active_orders.orders=}") - last_order_index = active_orders.orders[0].order_index - - tx, response = await client.cancel_order( - market_index=0, order_index=last_order_index - ) - print( - f"code: {response.code} msg: {response.message} l2Hash: {response.tx_hash} tx: {tx.to_json()}" + # cancel order + tx, tx_hash, err = await client.cancel_order( + market_index=0, + order_index=123, ) + print(f"Cancel Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) await client.close() await api_client.close() diff --git a/examples/create_market_order.py b/examples/create_market_order.py new file mode 100644 index 0000000..1dcea08 --- /dev/null +++ b/examples/create_market_order.py @@ -0,0 +1,39 @@ +import asyncio +import logging +import lighter + +logging.basicConfig(level=logging.DEBUG) + +# The API_KEY_PRIVATE_KEY provided belongs to a dummy account registered on Testnet. +# It was generated using the setup_system.py script, and servers as an example. +BASE_URL = "https://testnet.zklighter.elliot.ai" +API_KEY_PRIVATE_KEY = "0xc0a06468a5bbc9a7b785065a8b227a37fdfa18e2b81d51b018cb03ddd99bfbef4b7551f0f0765639" +ACCOUNT_INDEX = 595 +API_KEY_INDEX = 1 + + +def trim_exception(e: Exception) -> str: + return str(e).strip().split("\n")[-1] + + +async def main(): + client = lighter.SignerClient( + url=BASE_URL, + private_key=API_KEY_PRIVATE_KEY, + account_index=ACCOUNT_INDEX, + api_key_index=API_KEY_INDEX, + ) + + tx = await client.create_market_order( + market_index=0, + client_order_index=0, + base_amount=1000, # 0.1 ETH + avg_execution_price=170000, # $1700 + is_ask=True, + ) + print("Create Order Tx:", tx) + await client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/get_info.py b/examples/get_info.py index 0572e71..bd16072 100644 --- a/examples/get_info.py +++ b/examples/get_info.py @@ -6,8 +6,10 @@ logging.basicConfig(level=logging.INFO) -L1_ADDRESS = "WALLET_L1_ADDRESS" -account_index = 0 +# The address provided belongs to a dummy account registered on Testnet. +L1_ADDRESS = "0x8D7f03FdE1A626223364E592740a233b72395235" +ACCOUNT_INDEX = 595 + async def print_api(method, *args, **kwargs): logging.info(f"{method.__name__}: {await method(*args, **kwargs)}") @@ -16,25 +18,15 @@ async def print_api(method, *args, **kwargs): async def account_apis(client: lighter.ApiClient): logging.info("ACCOUNT APIS") account_instance = lighter.AccountApi(client) - res = await account_instance.account(by="l1_address", value=L1_ADDRESS) - global account_index - if res.accounts: - account_index = res.accounts[0].index - else: - print("NO ACCOUNT FOUND") - exit(0) - await print_api(account_instance.account, by="index", value=str(account_index)) - await print_api(account_instance.accounts, index=0, limit=2, sort="asc") - await print_api( - account_instance.accounts_by_l1_address, - l1_address=L1_ADDRESS, - ) - await print_api(account_instance.apikeys, account_index=3, api_key_index=255) - await print_api(account_instance.fee_bucket, account_index=3) + await print_api(account_instance.account, by="l1_address", value=L1_ADDRESS) + await print_api(account_instance.account, by="index", value=str(ACCOUNT_INDEX)) + await print_api(account_instance.accounts_by_l1_address, l1_address=L1_ADDRESS) + await print_api(account_instance.apikeys, account_index=ACCOUNT_INDEX, api_key_index=1) + await print_api(account_instance.fee_bucket, account_index=ACCOUNT_INDEX) await print_api( account_instance.pnl, by="index", - value=str(account_index), + value=str(ACCOUNT_INDEX), resolution="1h", start_timestamp=int(datetime.datetime.now().timestamp() - 60 * 60 * 24), end_timestamp=int(datetime.datetime.now().timestamp()), @@ -93,24 +85,25 @@ async def transaction_apis(client: lighter.ApiClient): logging.info("TRANSACTION APIS") transaction_instance = lighter.TransactionApi(client) await print_api(transaction_instance.block_txs, by="block_height", value="1") - await print_api(transaction_instance.next_nonce, account_index=int(account_index), api_key_index=0) + await print_api( + transaction_instance.next_nonce, + account_index=int(ACCOUNT_INDEX), + api_key_index=0, + ) # use with a valid sequence index # await print_api(transaction_instance.tx, by="sequence_index", value="5") await print_api(transaction_instance.txs, index=0, limit=2) async def main(): - client = lighter.ApiClient( - configuration=lighter.Configuration( - host="https://testnet.zklighter.elliot.ai" - ) - ) + client = lighter.ApiClient(configuration=lighter.Configuration(host="https://testnet.zklighter.elliot.ai")) await account_apis(client) await block_apis(client) await candlestick_apis(client) await info_apis(client) await order_apis(client) await transaction_apis(client) + await client.close() if __name__ == "__main__": diff --git a/examples/system_setup.py b/examples/system_setup.py new file mode 100644 index 0000000..0c047a5 --- /dev/null +++ b/examples/system_setup.py @@ -0,0 +1,82 @@ +import asyncio +import logging +import time +import eth_account +import lighter + +logging.basicConfig(level=logging.DEBUG) + +# this is a dummy private key which is registered on Testnet. +# It serves as a good example +BASE_URL = "https://testnet.zklighter.elliot.ai" +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +API_KEY_INDEX = 1 + + +async def main(): + # verify that the account exists & fetch account index + api_client = lighter.ApiClient(configuration=lighter.Configuration(host=BASE_URL)) + eth_acc = eth_account.Account.from_key(ETH_PRIVATE_KEY) + eth_address = eth_acc.address + + try: + response = await lighter.AccountApi(api_client).accounts_by_l1_address(l1_address=eth_address) + except lighter.ApiException as e: + if e.data.message == "account not found": + print(f"error: account not found for {eth_address}") + return + else: + raise e + + if len(response.sub_accounts) > 1: + for sub_account in response.sub_accounts: + print(f"found accountIndex: {sub_account.index}") + raise Exception(f"found found multiple account indexes: {len(response.sub_accounts)}") + else: + account_index = response.sub_accounts[0].index + + # create a private/public key pair for the new API key + # pass any string to be used as seed for create_api_key like + # create_api_key("Hello world random seed to make things more secure") + private_key, public_key, err = lighter.create_api_key() + if err is not None: + raise Exception(err) + + tx_client = lighter.SignerClient( + url=BASE_URL, + private_key=private_key, + account_index=account_index, + api_key_index=API_KEY_INDEX, + ) + + # change the API key + response, err = await tx_client.change_api_key( + eth_private_key=ETH_PRIVATE_KEY, + new_pubkey=public_key, + ) + if err is not None: + raise Exception(err) + + # wait some time so that we receive the new API key in the response + time.sleep(10) + + # check that the API key changed on the server + err = tx_client.check_client() + if err is not None: + raise Exception(err) + + print( + f""" +BASE_URL = '{BASE_URL}' +API_KEY_PRIVATE_KEY = '{private_key}' +ACCOUNT_INDEX = {account_index} +API_KEY_INDEX = {API_KEY_INDEX} + """ + ) + + await tx_client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/ws.py b/examples/ws.py index bfa62c9..8fc6445 100644 --- a/examples/ws.py +++ b/examples/ws.py @@ -1,6 +1,6 @@ import json import logging -from lighter import WsClient +import lighter logging.basicConfig(level=logging.INFO) @@ -13,7 +13,7 @@ def on_account_update(account_id, account): logging.info(f"Account {account_id}:\n{json.dumps(account, indent=2)}") -client = WsClient( +client = lighter.WsClient( order_book_ids=[0, 1], account_ids=[1, 2], on_order_book_update=on_order_book_update, diff --git a/examples/ws_async.py b/examples/ws_async.py index 3be7989..3262192 100644 --- a/examples/ws_async.py +++ b/examples/ws_async.py @@ -1,8 +1,7 @@ import json import logging import asyncio - -from lighter import WsClient +import lighter logging.basicConfig(level=logging.INFO) @@ -15,7 +14,7 @@ def on_account_update(account_id, account): logging.info(f"Account {account_id}:\n{json.dumps(account, indent=2)}") -client = WsClient( +client = lighter.WsClient( order_book_ids=[0, 1], account_ids=[1, 2], on_order_book_update=on_order_book_update, diff --git a/lighter/__init__.py b/lighter/__init__.py index 0195a09..0801e32 100644 --- a/lighter/__init__.py +++ b/lighter/__init__.py @@ -3,11 +3,11 @@ # flake8: noqa """ - + zkLighter API - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + Public APIs for Lighter - The version of the OpenAPI document: + The version of the OpenAPI document: 1.0 Generated by OpenAPI Generator (https://openapi-generator.tech) Do not edit the class manually. @@ -39,40 +39,27 @@ # import models into sdk package from lighter.models.account import Account from lighter.models.account_api_keys import AccountApiKeys -from lighter.models.account_market_stats import AccountMarketStats -from lighter.models.account_metadata import AccountMetadata from lighter.models.account_pn_l import AccountPnL from lighter.models.account_position import AccountPosition -from lighter.models.account_stats import AccountStats -from lighter.models.account_trade_stats import AccountTradeStats -from lighter.models.accounts import Accounts from lighter.models.api_key import ApiKey from lighter.models.block import Block from lighter.models.blocks import Blocks -from lighter.models.bridge_supported_network import BridgeSupportedNetwork from lighter.models.candlestick import Candlestick from lighter.models.candlesticks import Candlesticks -from lighter.models.contract_address import ContractAddress from lighter.models.current_height import CurrentHeight -from lighter.models.cursor import Cursor +from lighter.models.daily_return import DailyReturn from lighter.models.deposit_history import DepositHistory from lighter.models.deposit_history_item import DepositHistoryItem from lighter.models.detailed_account import DetailedAccount from lighter.models.detailed_accounts import DetailedAccounts -from lighter.models.detailed_candlestick import DetailedCandlestick from lighter.models.enriched_tx import EnrichedTx from lighter.models.exchange_stats import ExchangeStats from lighter.models.fee_bucket import FeeBucket from lighter.models.funding import Funding from lighter.models.fundings import Fundings -from lighter.models.l1_provider_info import L1ProviderInfo -from lighter.models.layer2_basic_info import Layer2BasicInfo -from lighter.models.liquidation import Liquidation -from lighter.models.market_info import MarketInfo from lighter.models.next_nonce import NextNonce from lighter.models.order import Order from lighter.models.order_book import OrderBook -from lighter.models.order_book_depth import OrderBookDepth from lighter.models.order_book_detail import OrderBookDetail from lighter.models.order_book_details import OrderBookDetails from lighter.models.order_book_orders import OrderBookOrders @@ -80,57 +67,22 @@ from lighter.models.order_books import OrderBooks from lighter.models.orders import Orders from lighter.models.pn_l_entry import PnLEntry -from lighter.models.position_funding import PositionFunding -from lighter.models.price_level import PriceLevel from lighter.models.public_pool import PublicPool from lighter.models.public_pool_info import PublicPoolInfo from lighter.models.public_pool_share import PublicPoolShare from lighter.models.public_pools import PublicPools -from lighter.models.req_get_account import ReqGetAccount -from lighter.models.req_get_account_active_orders import ReqGetAccountActiveOrders -from lighter.models.req_get_account_api_keys import ReqGetAccountApiKeys -from lighter.models.req_get_account_by_l1_address import ReqGetAccountByL1Address -from lighter.models.req_get_account_inactive_orders import ReqGetAccountInactiveOrders -from lighter.models.req_get_account_orders import ReqGetAccountOrders -from lighter.models.req_get_account_pending_txs import ReqGetAccountPendingTxs -from lighter.models.req_get_account_pn_l import ReqGetAccountPnL -from lighter.models.req_get_account_txs import ReqGetAccountTxs -from lighter.models.req_get_block import ReqGetBlock -from lighter.models.req_get_block_txs import ReqGetBlockTxs -from lighter.models.req_get_by_account import ReqGetByAccount -from lighter.models.req_get_candlesticks import ReqGetCandlesticks -from lighter.models.req_get_deposit_history import ReqGetDepositHistory -from lighter.models.req_get_fee_bucket import ReqGetFeeBucket -from lighter.models.req_get_fundings import ReqGetFundings -from lighter.models.req_get_l1_tx import ReqGetL1Tx -from lighter.models.req_get_latest_deposit import ReqGetLatestDeposit -from lighter.models.req_get_next_nonce import ReqGetNextNonce -from lighter.models.req_get_order_book_details import ReqGetOrderBookDetails -from lighter.models.req_get_order_book_orders import ReqGetOrderBookOrders -from lighter.models.req_get_order_books import ReqGetOrderBooks -from lighter.models.req_get_public_pools import ReqGetPublicPools -from lighter.models.req_get_range_with_cursor import ReqGetRangeWithCursor -from lighter.models.req_get_range_with_index import ReqGetRangeWithIndex -from lighter.models.req_get_range_with_index_sortable import ReqGetRangeWithIndexSortable -from lighter.models.req_get_recent_trades import ReqGetRecentTrades -from lighter.models.req_get_trades import ReqGetTrades -from lighter.models.req_get_tx import ReqGetTx -from lighter.models.req_get_withdraw_history import ReqGetWithdrawHistory -from lighter.models.result_code import ResultCode from lighter.models.simple_order import SimpleOrder from lighter.models.status import Status from lighter.models.sub_accounts import SubAccounts -from lighter.models.ticker import Ticker from lighter.models.trade import Trade from lighter.models.trades import Trades from lighter.models.tx import Tx from lighter.models.tx_hash import TxHash from lighter.models.tx_hashes import TxHashes from lighter.models.txs import Txs -from lighter.models.validator_info import ValidatorInfo from lighter.models.withdraw_history import WithdrawHistory from lighter.models.withdraw_history_item import WithdrawHistoryItem from lighter.models.zk_lighter_info import ZkLighterInfo from lighter.ws_client import WsClient -from lighter.signer_client import SignerClient +from lighter.signer_client import SignerClient, create_api_key diff --git a/lighter/api/__init__.py b/lighter/api/__init__.py index eb70861..2903967 100644 --- a/lighter/api/__init__.py +++ b/lighter/api/__init__.py @@ -4,7 +4,6 @@ from lighter.api.account_api import AccountApi from lighter.api.block_api import BlockApi from lighter.api.candlestick_api import CandlestickApi -from lighter.api.info_api import InfoApi from lighter.api.order_api import OrderApi from lighter.api.root_api import RootApi from lighter.api.transaction_api import TransactionApi diff --git a/lighter/api/account_api.py b/lighter/api/account_api.py index aece5b2..2d7efcb 100644 --- a/lighter/api/account_api.py +++ b/lighter/api/account_api.py @@ -21,7 +21,6 @@ from typing_extensions import Annotated from lighter.models.account_api_keys import AccountApiKeys from lighter.models.account_pn_l import AccountPnL -from lighter.models.accounts import Accounts from lighter.models.detailed_accounts import DetailedAccounts from lighter.models.fee_bucket import FeeBucket from lighter.models.public_pools import PublicPools @@ -325,303 +324,6 @@ def _account_serialize( - @validate_call - async def accounts( - self, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], - index: Optional[StrictInt] = None, - sort: Optional[StrictStr] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, - _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, - _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> Accounts: - """accounts - - Get accounts returns accounts by account index - - :param limit: (required) - :type limit: int - :param index: - :type index: int - :param sort: - :type sort: str - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :type _request_timeout: int, tuple(int, int), optional - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the - authentication in the spec for a single request. - :type _request_auth: dict, optional - :param _content_type: force content-type for the request. - :type _content_type: str, Optional - :param _headers: set to override the headers for a single - request; this effectively ignores the headers - in the spec for a single request. - :type _headers: dict, optional - :param _host_index: set to override the host_index for a single - request; this effectively ignores the host_index - in the spec for a single request. - :type _host_index: int, optional - :return: Returns the result object. - """ # noqa: E501 - - _param = self._accounts_serialize( - limit=limit, - index=index, - sort=sort, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index - ) - - _response_types_map: Dict[str, Optional[str]] = { - '200': "Accounts", - '400': "ResultCode", - } - response_data = await self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) - await response_data.read() - return self.api_client.response_deserialize( - response_data=response_data, - response_types_map=_response_types_map, - ).data - - - @validate_call - async def accounts_with_http_info( - self, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], - index: Optional[StrictInt] = None, - sort: Optional[StrictStr] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, - _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, - _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[Accounts]: - """accounts - - Get accounts returns accounts by account index - - :param limit: (required) - :type limit: int - :param index: - :type index: int - :param sort: - :type sort: str - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :type _request_timeout: int, tuple(int, int), optional - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the - authentication in the spec for a single request. - :type _request_auth: dict, optional - :param _content_type: force content-type for the request. - :type _content_type: str, Optional - :param _headers: set to override the headers for a single - request; this effectively ignores the headers - in the spec for a single request. - :type _headers: dict, optional - :param _host_index: set to override the host_index for a single - request; this effectively ignores the host_index - in the spec for a single request. - :type _host_index: int, optional - :return: Returns the result object. - """ # noqa: E501 - - _param = self._accounts_serialize( - limit=limit, - index=index, - sort=sort, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index - ) - - _response_types_map: Dict[str, Optional[str]] = { - '200': "Accounts", - '400': "ResultCode", - } - response_data = await self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) - await response_data.read() - return self.api_client.response_deserialize( - response_data=response_data, - response_types_map=_response_types_map, - ) - - - @validate_call - async def accounts_without_preload_content( - self, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], - index: Optional[StrictInt] = None, - sort: Optional[StrictStr] = None, - _request_timeout: Union[ - None, - Annotated[StrictFloat, Field(gt=0)], - Tuple[ - Annotated[StrictFloat, Field(gt=0)], - Annotated[StrictFloat, Field(gt=0)] - ] - ] = None, - _request_auth: Optional[Dict[StrictStr, Any]] = None, - _content_type: Optional[StrictStr] = None, - _headers: Optional[Dict[StrictStr, Any]] = None, - _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> RESTResponseType: - """accounts - - Get accounts returns accounts by account index - - :param limit: (required) - :type limit: int - :param index: - :type index: int - :param sort: - :type sort: str - :param _request_timeout: timeout setting for this request. If one - number provided, it will be total request - timeout. It can also be a pair (tuple) of - (connection, read) timeouts. - :type _request_timeout: int, tuple(int, int), optional - :param _request_auth: set to override the auth_settings for an a single - request; this effectively ignores the - authentication in the spec for a single request. - :type _request_auth: dict, optional - :param _content_type: force content-type for the request. - :type _content_type: str, Optional - :param _headers: set to override the headers for a single - request; this effectively ignores the headers - in the spec for a single request. - :type _headers: dict, optional - :param _host_index: set to override the host_index for a single - request; this effectively ignores the host_index - in the spec for a single request. - :type _host_index: int, optional - :return: Returns the result object. - """ # noqa: E501 - - _param = self._accounts_serialize( - limit=limit, - index=index, - sort=sort, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index - ) - - _response_types_map: Dict[str, Optional[str]] = { - '200': "Accounts", - '400': "ResultCode", - } - response_data = await self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) - return response_data.response - - - def _accounts_serialize( - self, - limit, - index, - sort, - _request_auth, - _content_type, - _headers, - _host_index, - ) -> RequestSerialized: - - _host = None - - _collection_formats: Dict[str, str] = { - } - - _path_params: Dict[str, str] = {} - _query_params: List[Tuple[str, str]] = [] - _header_params: Dict[str, Optional[str]] = _headers or {} - _form_params: List[Tuple[str, str]] = [] - _files: Dict[str, Union[str, bytes]] = {} - _body_params: Optional[bytes] = None - - # process the path parameters - # process the query parameters - if index is not None: - - _query_params.append(('index', index)) - - if limit is not None: - - _query_params.append(('limit', limit)) - - if sort is not None: - - _query_params.append(('sort', sort)) - - # process the header parameters - # process the form parameters - # process the body parameter - - - # set the HTTP header `Accept` - if 'Accept' not in _header_params: - _header_params['Accept'] = self.api_client.select_header_accept( - [ - 'application/json' - ] - ) - - - # authentication setting - _auth_settings: List[str] = [ - ] - - return self.api_client.param_serialize( - method='GET', - resource_path='/api/v1/accounts', - path_params=_path_params, - query_params=_query_params, - header_params=_header_params, - body=_body_params, - post_params=_form_params, - files=_files, - auth_settings=_auth_settings, - collection_formats=_collection_formats, - _host=_host, - _request_auth=_request_auth - ) - - - - @validate_call async def accounts_by_l1_address( self, @@ -889,7 +591,7 @@ def _accounts_by_l1_address_serialize( async def apikeys( self, account_index: StrictInt, - api_key_index: StrictInt, + api_key_index: Optional[StrictInt] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -909,7 +611,7 @@ async def apikeys( :param account_index: (required) :type account_index: int - :param api_key_index: (required) + :param api_key_index: :type api_key_index: int :param _request_timeout: timeout setting for this request. If one number provided, it will be total request @@ -961,7 +663,7 @@ async def apikeys( async def apikeys_with_http_info( self, account_index: StrictInt, - api_key_index: StrictInt, + api_key_index: Optional[StrictInt] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -981,7 +683,7 @@ async def apikeys_with_http_info( :param account_index: (required) :type account_index: int - :param api_key_index: (required) + :param api_key_index: :type api_key_index: int :param _request_timeout: timeout setting for this request. If one number provided, it will be total request @@ -1033,7 +735,7 @@ async def apikeys_with_http_info( async def apikeys_without_preload_content( self, account_index: StrictInt, - api_key_index: StrictInt, + api_key_index: Optional[StrictInt] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1053,7 +755,7 @@ async def apikeys_without_preload_content( :param account_index: (required) :type account_index: int - :param api_key_index: (required) + :param api_key_index: :type api_key_index: int :param _request_timeout: timeout setting for this request. If one number provided, it will be total request @@ -1434,9 +1136,10 @@ async def pnl( by: StrictStr, value: StrictStr, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, + auth: Optional[StrictStr] = None, ignore_transfers: Optional[StrictBool] = None, _request_timeout: Union[ None, @@ -1467,6 +1170,8 @@ async def pnl( :type end_timestamp: int :param count_back: (required) :type count_back: int + :param auth: + :type auth: str :param ignore_transfers: :type ignore_transfers: bool :param _request_timeout: timeout setting for this request. If one @@ -1498,6 +1203,7 @@ async def pnl( start_timestamp=start_timestamp, end_timestamp=end_timestamp, count_back=count_back, + auth=auth, ignore_transfers=ignore_transfers, _request_auth=_request_auth, _content_type=_content_type, @@ -1526,9 +1232,10 @@ async def pnl_with_http_info( by: StrictStr, value: StrictStr, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, + auth: Optional[StrictStr] = None, ignore_transfers: Optional[StrictBool] = None, _request_timeout: Union[ None, @@ -1559,6 +1266,8 @@ async def pnl_with_http_info( :type end_timestamp: int :param count_back: (required) :type count_back: int + :param auth: + :type auth: str :param ignore_transfers: :type ignore_transfers: bool :param _request_timeout: timeout setting for this request. If one @@ -1590,6 +1299,7 @@ async def pnl_with_http_info( start_timestamp=start_timestamp, end_timestamp=end_timestamp, count_back=count_back, + auth=auth, ignore_transfers=ignore_transfers, _request_auth=_request_auth, _content_type=_content_type, @@ -1618,9 +1328,10 @@ async def pnl_without_preload_content( by: StrictStr, value: StrictStr, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, + auth: Optional[StrictStr] = None, ignore_transfers: Optional[StrictBool] = None, _request_timeout: Union[ None, @@ -1651,6 +1362,8 @@ async def pnl_without_preload_content( :type end_timestamp: int :param count_back: (required) :type count_back: int + :param auth: + :type auth: str :param ignore_transfers: :type ignore_transfers: bool :param _request_timeout: timeout setting for this request. If one @@ -1682,6 +1395,7 @@ async def pnl_without_preload_content( start_timestamp=start_timestamp, end_timestamp=end_timestamp, count_back=count_back, + auth=auth, ignore_transfers=ignore_transfers, _request_auth=_request_auth, _content_type=_content_type, @@ -1708,6 +1422,7 @@ def _pnl_serialize( start_timestamp, end_timestamp, count_back, + auth, ignore_transfers, _request_auth, _content_type, @@ -1729,6 +1444,10 @@ def _pnl_serialize( # process the path parameters # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + if by is not None: _query_params.append(('by', by)) @@ -1791,13 +1510,12 @@ def _pnl_serialize( ) - - @validate_call async def public_pools( self, index: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], + auth: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, account_index: Optional[StrictInt] = None, _request_timeout: Union[ @@ -1821,6 +1539,8 @@ async def public_pools( :type index: int :param limit: (required) :type limit: int + :param auth: + :type auth: str :param filter: :type filter: str :param account_index: @@ -1850,6 +1570,7 @@ async def public_pools( _param = self._public_pools_serialize( index=index, limit=limit, + auth=auth, filter=filter, account_index=account_index, _request_auth=_request_auth, @@ -1878,6 +1599,7 @@ async def public_pools_with_http_info( self, index: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], + auth: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, account_index: Optional[StrictInt] = None, _request_timeout: Union[ @@ -1901,6 +1623,8 @@ async def public_pools_with_http_info( :type index: int :param limit: (required) :type limit: int + :param auth: + :type auth: str :param filter: :type filter: str :param account_index: @@ -1930,6 +1654,7 @@ async def public_pools_with_http_info( _param = self._public_pools_serialize( index=index, limit=limit, + auth=auth, filter=filter, account_index=account_index, _request_auth=_request_auth, @@ -1958,6 +1683,7 @@ async def public_pools_without_preload_content( self, index: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], + auth: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, account_index: Optional[StrictInt] = None, _request_timeout: Union[ @@ -1981,6 +1707,8 @@ async def public_pools_without_preload_content( :type index: int :param limit: (required) :type limit: int + :param auth: + :type auth: str :param filter: :type filter: str :param account_index: @@ -2010,6 +1738,7 @@ async def public_pools_without_preload_content( _param = self._public_pools_serialize( index=index, limit=limit, + auth=auth, filter=filter, account_index=account_index, _request_auth=_request_auth, @@ -2033,6 +1762,7 @@ def _public_pools_serialize( self, index, limit, + auth, filter, account_index, _request_auth, @@ -2055,6 +1785,10 @@ def _public_pools_serialize( # process the path parameters # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + if filter is not None: _query_params.append(('filter', filter)) diff --git a/lighter/api/candlestick_api.py b/lighter/api/candlestick_api.py index 4ebfa02..c964c30 100644 --- a/lighter/api/candlestick_api.py +++ b/lighter/api/candlestick_api.py @@ -16,8 +16,9 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from pydantic import StrictBool, StrictInt, StrictStr, field_validator +from pydantic import Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Optional +from typing_extensions import Annotated from lighter.models.candlesticks import Candlesticks from lighter.models.fundings import Fundings @@ -44,8 +45,8 @@ async def candlesticks( self, market_id: StrictInt, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, set_timestamp_to_end: Optional[StrictBool] = None, _request_timeout: Union[ @@ -132,8 +133,8 @@ async def candlesticks_with_http_info( self, market_id: StrictInt, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, set_timestamp_to_end: Optional[StrictBool] = None, _request_timeout: Union[ @@ -220,8 +221,8 @@ async def candlesticks_without_preload_content( self, market_id: StrictInt, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, set_timestamp_to_end: Optional[StrictBool] = None, _request_timeout: Union[ @@ -392,8 +393,8 @@ async def fundings( self, market_id: StrictInt, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, _request_timeout: Union[ None, @@ -476,8 +477,8 @@ async def fundings_with_http_info( self, market_id: StrictInt, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, _request_timeout: Union[ None, @@ -560,8 +561,8 @@ async def fundings_without_preload_content( self, market_id: StrictInt, resolution: StrictStr, - start_timestamp: StrictInt, - end_timestamp: StrictInt, + start_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], + end_timestamp: Annotated[int, Field(le=5000000000000, strict=True, ge=0)], count_back: StrictInt, _request_timeout: Union[ None, diff --git a/lighter/api/order_api.py b/lighter/api/order_api.py index dc9579c..fa247cb 100644 --- a/lighter/api/order_api.py +++ b/lighter/api/order_api.py @@ -344,6 +344,7 @@ def _account_active_orders_serialize( @validate_call async def account_inactive_orders( self, + auth: StrictStr, account_index: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], market_id: Optional[StrictInt] = None, @@ -367,6 +368,8 @@ async def account_inactive_orders( Get account inactive orders + :param auth: (required) + :type auth: str :param account_index: (required) :type account_index: int :param limit: (required) @@ -402,6 +405,7 @@ async def account_inactive_orders( """ # noqa: E501 _param = self._account_inactive_orders_serialize( + auth=auth, account_index=account_index, limit=limit, market_id=market_id, @@ -432,6 +436,7 @@ async def account_inactive_orders( @validate_call async def account_inactive_orders_with_http_info( self, + auth: StrictStr, account_index: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], market_id: Optional[StrictInt] = None, @@ -455,6 +460,8 @@ async def account_inactive_orders_with_http_info( Get account inactive orders + :param auth: (required) + :type auth: str :param account_index: (required) :type account_index: int :param limit: (required) @@ -490,6 +497,7 @@ async def account_inactive_orders_with_http_info( """ # noqa: E501 _param = self._account_inactive_orders_serialize( + auth=auth, account_index=account_index, limit=limit, market_id=market_id, @@ -520,6 +528,7 @@ async def account_inactive_orders_with_http_info( @validate_call async def account_inactive_orders_without_preload_content( self, + auth: StrictStr, account_index: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], market_id: Optional[StrictInt] = None, @@ -543,6 +552,8 @@ async def account_inactive_orders_without_preload_content( Get account inactive orders + :param auth: (required) + :type auth: str :param account_index: (required) :type account_index: int :param limit: (required) @@ -578,6 +589,7 @@ async def account_inactive_orders_without_preload_content( """ # noqa: E501 _param = self._account_inactive_orders_serialize( + auth=auth, account_index=account_index, limit=limit, market_id=market_id, @@ -603,6 +615,7 @@ async def account_inactive_orders_without_preload_content( def _account_inactive_orders_serialize( self, + auth, account_index, limit, market_id, @@ -629,6 +642,10 @@ def _account_inactive_orders_serialize( # process the path parameters # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + if account_index is not None: _query_params.append(('account_index', account_index)) @@ -692,6 +709,7 @@ def _account_inactive_orders_serialize( @validate_call async def account_orders( self, + auth: StrictStr, account_index: StrictInt, market_id: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], @@ -713,6 +731,8 @@ async def account_orders( Get account orders + :param auth: (required) + :type auth: str :param account_index: (required) :type account_index: int :param market_id: (required) @@ -744,6 +764,7 @@ async def account_orders( """ # noqa: E501 _param = self._account_orders_serialize( + auth=auth, account_index=account_index, market_id=market_id, limit=limit, @@ -772,6 +793,7 @@ async def account_orders( @validate_call async def account_orders_with_http_info( self, + auth: StrictStr, account_index: StrictInt, market_id: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], @@ -793,6 +815,8 @@ async def account_orders_with_http_info( Get account orders + :param auth: (required) + :type auth: str :param account_index: (required) :type account_index: int :param market_id: (required) @@ -824,6 +848,7 @@ async def account_orders_with_http_info( """ # noqa: E501 _param = self._account_orders_serialize( + auth=auth, account_index=account_index, market_id=market_id, limit=limit, @@ -852,6 +877,7 @@ async def account_orders_with_http_info( @validate_call async def account_orders_without_preload_content( self, + auth: StrictStr, account_index: StrictInt, market_id: StrictInt, limit: Annotated[int, Field(le=100, strict=True, ge=1)], @@ -873,6 +899,8 @@ async def account_orders_without_preload_content( Get account orders + :param auth: (required) + :type auth: str :param account_index: (required) :type account_index: int :param market_id: (required) @@ -904,6 +932,7 @@ async def account_orders_without_preload_content( """ # noqa: E501 _param = self._account_orders_serialize( + auth=auth, account_index=account_index, market_id=market_id, limit=limit, @@ -927,6 +956,7 @@ async def account_orders_without_preload_content( def _account_orders_serialize( self, + auth, account_index, market_id, limit, @@ -951,6 +981,10 @@ def _account_orders_serialize( # process the path parameters # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + if account_index is not None: _query_params.append(('account_index', account_index)) @@ -2340,6 +2374,7 @@ async def trades( self, sort_by: StrictStr, limit: Annotated[int, Field(le=100, strict=True, ge=1)], + auth: Optional[StrictStr] = None, market_id: Optional[StrictInt] = None, account_index: Optional[StrictInt] = None, order_index: Optional[StrictInt] = None, @@ -2368,6 +2403,8 @@ async def trades( :type sort_by: str :param limit: (required) :type limit: int + :param auth: + :type auth: str :param market_id: :type market_id: int :param account_index: @@ -2407,6 +2444,7 @@ async def trades( _param = self._trades_serialize( sort_by=sort_by, limit=limit, + auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, @@ -2440,6 +2478,7 @@ async def trades_with_http_info( self, sort_by: StrictStr, limit: Annotated[int, Field(le=100, strict=True, ge=1)], + auth: Optional[StrictStr] = None, market_id: Optional[StrictInt] = None, account_index: Optional[StrictInt] = None, order_index: Optional[StrictInt] = None, @@ -2468,6 +2507,8 @@ async def trades_with_http_info( :type sort_by: str :param limit: (required) :type limit: int + :param auth: + :type auth: str :param market_id: :type market_id: int :param account_index: @@ -2507,6 +2548,7 @@ async def trades_with_http_info( _param = self._trades_serialize( sort_by=sort_by, limit=limit, + auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, @@ -2540,6 +2582,7 @@ async def trades_without_preload_content( self, sort_by: StrictStr, limit: Annotated[int, Field(le=100, strict=True, ge=1)], + auth: Optional[StrictStr] = None, market_id: Optional[StrictInt] = None, account_index: Optional[StrictInt] = None, order_index: Optional[StrictInt] = None, @@ -2568,6 +2611,8 @@ async def trades_without_preload_content( :type sort_by: str :param limit: (required) :type limit: int + :param auth: + :type auth: str :param market_id: :type market_id: int :param account_index: @@ -2607,6 +2652,7 @@ async def trades_without_preload_content( _param = self._trades_serialize( sort_by=sort_by, limit=limit, + auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, @@ -2635,6 +2681,7 @@ def _trades_serialize( self, sort_by, limit, + auth, market_id, account_index, order_index, @@ -2662,6 +2709,10 @@ def _trades_serialize( # process the path parameters # process the query parameters + if auth is not None: + + _query_params.append(('auth', auth)) + if market_id is not None: _query_params.append(('market_id', market_id)) diff --git a/lighter/api/transaction_api.py b/lighter/api/transaction_api.py index 3e0f526..d146305 100644 --- a/lighter/api/transaction_api.py +++ b/lighter/api/transaction_api.py @@ -660,6 +660,8 @@ def _block_txs_serialize( @validate_call async def deposit_history( self, + account_index: StrictInt, + auth: StrictStr, l1_address: StrictStr, cursor: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, @@ -680,6 +682,10 @@ async def deposit_history( Get deposit history + :param account_index: (required) + :type account_index: int + :param auth: (required) + :type auth: str :param l1_address: (required) :type l1_address: str :param cursor: @@ -709,6 +715,8 @@ async def deposit_history( """ # noqa: E501 _param = self._deposit_history_serialize( + account_index=account_index, + auth=auth, l1_address=l1_address, cursor=cursor, filter=filter, @@ -736,6 +744,8 @@ async def deposit_history( @validate_call async def deposit_history_with_http_info( self, + account_index: StrictInt, + auth: StrictStr, l1_address: StrictStr, cursor: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, @@ -756,6 +766,10 @@ async def deposit_history_with_http_info( Get deposit history + :param account_index: (required) + :type account_index: int + :param auth: (required) + :type auth: str :param l1_address: (required) :type l1_address: str :param cursor: @@ -785,6 +799,8 @@ async def deposit_history_with_http_info( """ # noqa: E501 _param = self._deposit_history_serialize( + account_index=account_index, + auth=auth, l1_address=l1_address, cursor=cursor, filter=filter, @@ -812,6 +828,8 @@ async def deposit_history_with_http_info( @validate_call async def deposit_history_without_preload_content( self, + account_index: StrictInt, + auth: StrictStr, l1_address: StrictStr, cursor: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, @@ -832,6 +850,10 @@ async def deposit_history_without_preload_content( Get deposit history + :param account_index: (required) + :type account_index: int + :param auth: (required) + :type auth: str :param l1_address: (required) :type l1_address: str :param cursor: @@ -861,6 +883,8 @@ async def deposit_history_without_preload_content( """ # noqa: E501 _param = self._deposit_history_serialize( + account_index=account_index, + auth=auth, l1_address=l1_address, cursor=cursor, filter=filter, @@ -883,6 +907,8 @@ async def deposit_history_without_preload_content( def _deposit_history_serialize( self, + account_index, + auth, l1_address, cursor, filter, @@ -906,6 +932,14 @@ def _deposit_history_serialize( # process the path parameters # process the query parameters + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + if auth is not None: + + _query_params.append(('auth', auth)) + if l1_address is not None: _query_params.append(('l1_address', l1_address)) @@ -2654,6 +2688,7 @@ def _txs_serialize( async def withdraw_history( self, account_index: StrictInt, + auth: StrictStr, cursor: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, _request_timeout: Union[ @@ -2675,6 +2710,8 @@ async def withdraw_history( :param account_index: (required) :type account_index: int + :param auth: (required) + :type auth: str :param cursor: :type cursor: str :param filter: @@ -2703,6 +2740,7 @@ async def withdraw_history( _param = self._withdraw_history_serialize( account_index=account_index, + auth=auth, cursor=cursor, filter=filter, _request_auth=_request_auth, @@ -2730,6 +2768,7 @@ async def withdraw_history( async def withdraw_history_with_http_info( self, account_index: StrictInt, + auth: StrictStr, cursor: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, _request_timeout: Union[ @@ -2751,6 +2790,8 @@ async def withdraw_history_with_http_info( :param account_index: (required) :type account_index: int + :param auth: (required) + :type auth: str :param cursor: :type cursor: str :param filter: @@ -2779,6 +2820,7 @@ async def withdraw_history_with_http_info( _param = self._withdraw_history_serialize( account_index=account_index, + auth=auth, cursor=cursor, filter=filter, _request_auth=_request_auth, @@ -2806,6 +2848,7 @@ async def withdraw_history_with_http_info( async def withdraw_history_without_preload_content( self, account_index: StrictInt, + auth: StrictStr, cursor: Optional[StrictStr] = None, filter: Optional[StrictStr] = None, _request_timeout: Union[ @@ -2827,6 +2870,8 @@ async def withdraw_history_without_preload_content( :param account_index: (required) :type account_index: int + :param auth: (required) + :type auth: str :param cursor: :type cursor: str :param filter: @@ -2855,6 +2900,7 @@ async def withdraw_history_without_preload_content( _param = self._withdraw_history_serialize( account_index=account_index, + auth=auth, cursor=cursor, filter=filter, _request_auth=_request_auth, @@ -2877,6 +2923,7 @@ async def withdraw_history_without_preload_content( def _withdraw_history_serialize( self, account_index, + auth, cursor, filter, _request_auth, @@ -2903,6 +2950,10 @@ def _withdraw_history_serialize( _query_params.append(('account_index', account_index)) + if auth is not None: + + _query_params.append(('auth', auth)) + if cursor is not None: _query_params.append(('cursor', cursor)) diff --git a/lighter/models/__init__.py b/lighter/models/__init__.py index 1a5bc23..19c157c 100644 --- a/lighter/models/__init__.py +++ b/lighter/models/__init__.py @@ -16,40 +16,28 @@ # import models into model package from lighter.models.account import Account from lighter.models.account_api_keys import AccountApiKeys -from lighter.models.account_market_stats import AccountMarketStats -from lighter.models.account_metadata import AccountMetadata from lighter.models.account_pn_l import AccountPnL from lighter.models.account_position import AccountPosition -from lighter.models.account_stats import AccountStats -from lighter.models.account_trade_stats import AccountTradeStats -from lighter.models.accounts import Accounts from lighter.models.api_key import ApiKey from lighter.models.block import Block from lighter.models.blocks import Blocks -from lighter.models.bridge_supported_network import BridgeSupportedNetwork from lighter.models.candlestick import Candlestick from lighter.models.candlesticks import Candlesticks -from lighter.models.contract_address import ContractAddress from lighter.models.current_height import CurrentHeight -from lighter.models.cursor import Cursor +from lighter.models.daily_return import DailyReturn from lighter.models.deposit_history import DepositHistory from lighter.models.deposit_history_item import DepositHistoryItem from lighter.models.detailed_account import DetailedAccount from lighter.models.detailed_accounts import DetailedAccounts -from lighter.models.detailed_candlestick import DetailedCandlestick from lighter.models.enriched_tx import EnrichedTx from lighter.models.exchange_stats import ExchangeStats from lighter.models.fee_bucket import FeeBucket from lighter.models.funding import Funding from lighter.models.fundings import Fundings -from lighter.models.l1_provider_info import L1ProviderInfo from lighter.models.layer2_basic_info import Layer2BasicInfo -from lighter.models.liquidation import Liquidation -from lighter.models.market_info import MarketInfo from lighter.models.next_nonce import NextNonce from lighter.models.order import Order from lighter.models.order_book import OrderBook -from lighter.models.order_book_depth import OrderBookDepth from lighter.models.order_book_detail import OrderBookDetail from lighter.models.order_book_details import OrderBookDetails from lighter.models.order_book_orders import OrderBookOrders @@ -57,54 +45,19 @@ from lighter.models.order_books import OrderBooks from lighter.models.orders import Orders from lighter.models.pn_l_entry import PnLEntry -from lighter.models.position_funding import PositionFunding -from lighter.models.price_level import PriceLevel from lighter.models.public_pool import PublicPool from lighter.models.public_pool_info import PublicPoolInfo from lighter.models.public_pool_share import PublicPoolShare from lighter.models.public_pools import PublicPools -from lighter.models.req_get_account import ReqGetAccount -from lighter.models.req_get_account_active_orders import ReqGetAccountActiveOrders -from lighter.models.req_get_account_api_keys import ReqGetAccountApiKeys -from lighter.models.req_get_account_by_l1_address import ReqGetAccountByL1Address -from lighter.models.req_get_account_inactive_orders import ReqGetAccountInactiveOrders -from lighter.models.req_get_account_orders import ReqGetAccountOrders -from lighter.models.req_get_account_pending_txs import ReqGetAccountPendingTxs -from lighter.models.req_get_account_pn_l import ReqGetAccountPnL -from lighter.models.req_get_account_txs import ReqGetAccountTxs -from lighter.models.req_get_block import ReqGetBlock -from lighter.models.req_get_block_txs import ReqGetBlockTxs -from lighter.models.req_get_by_account import ReqGetByAccount -from lighter.models.req_get_candlesticks import ReqGetCandlesticks -from lighter.models.req_get_deposit_history import ReqGetDepositHistory -from lighter.models.req_get_fee_bucket import ReqGetFeeBucket -from lighter.models.req_get_fundings import ReqGetFundings -from lighter.models.req_get_l1_tx import ReqGetL1Tx -from lighter.models.req_get_latest_deposit import ReqGetLatestDeposit -from lighter.models.req_get_next_nonce import ReqGetNextNonce -from lighter.models.req_get_order_book_details import ReqGetOrderBookDetails -from lighter.models.req_get_order_book_orders import ReqGetOrderBookOrders -from lighter.models.req_get_order_books import ReqGetOrderBooks -from lighter.models.req_get_public_pools import ReqGetPublicPools -from lighter.models.req_get_range_with_cursor import ReqGetRangeWithCursor -from lighter.models.req_get_range_with_index import ReqGetRangeWithIndex -from lighter.models.req_get_range_with_index_sortable import ReqGetRangeWithIndexSortable -from lighter.models.req_get_recent_trades import ReqGetRecentTrades -from lighter.models.req_get_trades import ReqGetTrades -from lighter.models.req_get_tx import ReqGetTx -from lighter.models.req_get_withdraw_history import ReqGetWithdrawHistory -from lighter.models.result_code import ResultCode from lighter.models.simple_order import SimpleOrder from lighter.models.status import Status from lighter.models.sub_accounts import SubAccounts -from lighter.models.ticker import Ticker from lighter.models.trade import Trade from lighter.models.trades import Trades from lighter.models.tx import Tx from lighter.models.tx_hash import TxHash from lighter.models.tx_hashes import TxHashes from lighter.models.txs import Txs -from lighter.models.validator_info import ValidatorInfo from lighter.models.withdraw_history import WithdrawHistory from lighter.models.withdraw_history_item import WithdrawHistoryItem from lighter.models.zk_lighter_info import ZkLighterInfo diff --git a/lighter/models/account_market_stats.py b/lighter/models/account_market_stats.py deleted file mode 100644 index ea24c4b..0000000 --- a/lighter/models/account_market_stats.py +++ /dev/null @@ -1,112 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Union -from typing import Optional, Set -from typing_extensions import Self - -class AccountMarketStats(BaseModel): - """ - AccountMarketStats - """ # noqa: E501 - market_id: StrictInt - daily_trades_count: StrictInt - daily_base_token_volume: Union[StrictFloat, StrictInt] - daily_quote_token_volume: Union[StrictFloat, StrictInt] - total_trades_count: StrictInt - total_base_token_volume: Union[StrictFloat, StrictInt] - total_quote_token_volume: Union[StrictFloat, StrictInt] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "total_trades_count", "total_base_token_volume", "total_quote_token_volume"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AccountMarketStats from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AccountMarketStats from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "daily_trades_count": obj.get("daily_trades_count"), - "daily_base_token_volume": obj.get("daily_base_token_volume"), - "daily_quote_token_volume": obj.get("daily_quote_token_volume"), - "total_trades_count": obj.get("total_trades_count"), - "total_base_token_volume": obj.get("total_base_token_volume"), - "total_quote_token_volume": obj.get("total_quote_token_volume") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/account_metadata.py b/lighter/models/account_metadata.py deleted file mode 100644 index 1b68877..0000000 --- a/lighter/models/account_metadata.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class AccountMetadata(BaseModel): - """ - AccountMetadata - """ # noqa: E501 - name: StrictStr - description: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["name", "description"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AccountMetadata from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AccountMetadata from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "description": obj.get("description") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/account_position.py b/lighter/models/account_position.py index 3bc6b28..c0e590f 100644 --- a/lighter/models/account_position.py +++ b/lighter/models/account_position.py @@ -18,7 +18,7 @@ import json from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List +from typing import Any, ClassVar, Dict, List, Optional from typing import Optional, Set from typing_extensions import Self @@ -31,14 +31,16 @@ class AccountPosition(BaseModel): initial_margin_fraction: StrictStr open_order_count: StrictInt pending_order_count: StrictInt + position_tied_order_count: StrictInt sign: StrictInt position: StrictStr avg_entry_price: StrictStr position_value: StrictStr unrealized_pnl: StrictStr realized_pnl: StrictStr + total_funding_paid_out: Optional[StrictStr] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "symbol", "initial_margin_fraction", "open_order_count", "pending_order_count", "sign", "position", "avg_entry_price", "position_value", "unrealized_pnl", "realized_pnl"] + __properties: ClassVar[List[str]] = ["market_id", "symbol", "initial_margin_fraction", "open_order_count", "pending_order_count", "position_tied_order_count", "sign", "position", "avg_entry_price", "position_value", "unrealized_pnl", "realized_pnl", "total_funding_paid_out"] model_config = ConfigDict( populate_by_name=True, @@ -103,12 +105,14 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "initial_margin_fraction": obj.get("initial_margin_fraction"), "open_order_count": obj.get("open_order_count"), "pending_order_count": obj.get("pending_order_count"), + "position_tied_order_count": obj.get("position_tied_order_count"), "sign": obj.get("sign"), "position": obj.get("position"), "avg_entry_price": obj.get("avg_entry_price"), "position_value": obj.get("position_value"), "unrealized_pnl": obj.get("unrealized_pnl"), - "realized_pnl": obj.get("realized_pnl") + "realized_pnl": obj.get("realized_pnl"), + "total_funding_paid_out": obj.get("total_funding_paid_out") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/account_stats.py b/lighter/models/account_stats.py deleted file mode 100644 index 85e14c2..0000000 --- a/lighter/models/account_stats.py +++ /dev/null @@ -1,110 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class AccountStats(BaseModel): - """ - AccountStats - """ # noqa: E501 - collateral: StrictStr - portfolio_value: StrictStr - leverage: StrictStr - available_balance: StrictStr - margin_usage: StrictStr - buying_power: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["collateral", "portfolio_value", "leverage", "available_balance", "margin_usage", "buying_power"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AccountStats from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AccountStats from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "collateral": obj.get("collateral"), - "portfolio_value": obj.get("portfolio_value"), - "leverage": obj.get("leverage"), - "available_balance": obj.get("available_balance"), - "margin_usage": obj.get("margin_usage"), - "buying_power": obj.get("buying_power") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/account_trade_stats.py b/lighter/models/account_trade_stats.py deleted file mode 100644 index 9ea3bdb..0000000 --- a/lighter/models/account_trade_stats.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Union -from typing import Optional, Set -from typing_extensions import Self - -class AccountTradeStats(BaseModel): - """ - AccountTradeStats - """ # noqa: E501 - total_trades_count: StrictInt - total_volume: Union[StrictFloat, StrictInt] - daily_trades_count: StrictInt - daily_volume: Union[StrictFloat, StrictInt] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["total_trades_count", "total_volume", "daily_trades_count", "daily_volume"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of AccountTradeStats from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of AccountTradeStats from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "total_trades_count": obj.get("total_trades_count"), - "total_volume": obj.get("total_volume"), - "daily_trades_count": obj.get("daily_trades_count"), - "daily_volume": obj.get("daily_volume") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/accounts.py b/lighter/models/accounts.py deleted file mode 100644 index c3b2e2c..0000000 --- a/lighter/models/accounts.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from lighter.models.account import Account -from typing import Optional, Set -from typing_extensions import Self - -class Accounts(BaseModel): - """ - Accounts - """ # noqa: E501 - code: StrictInt - message: Optional[StrictStr] = None - total: StrictInt - accounts: List[Account] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "total", "accounts"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Accounts from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in accounts (list) - _items = [] - if self.accounts: - for _item in self.accounts: - if _item: - _items.append(_item.to_dict()) - _dict['accounts'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Accounts from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "message": obj.get("message"), - "total": obj.get("total"), - "accounts": [Account.from_dict(_item) for _item in obj["accounts"]] if obj.get("accounts") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/bridge_supported_network.py b/lighter/models/bridge_supported_network.py deleted file mode 100644 index 4e3533a..0000000 --- a/lighter/models/bridge_supported_network.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class BridgeSupportedNetwork(BaseModel): - """ - BridgeSupportedNetwork - """ # noqa: E501 - name: StrictStr - chain_id: StrictStr - explorer: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["name", "chain_id", "explorer"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of BridgeSupportedNetwork from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of BridgeSupportedNetwork from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "chain_id": obj.get("chain_id"), - "explorer": obj.get("explorer") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/contract_address.py b/lighter/models/contract_address.py deleted file mode 100644 index 768652e..0000000 --- a/lighter/models/contract_address.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ContractAddress(BaseModel): - """ - ContractAddress - """ # noqa: E501 - name: StrictStr - address: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["name", "address"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ContractAddress from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ContractAddress from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "name": obj.get("name"), - "address": obj.get("address") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/cursor.py b/lighter/models/cursor.py deleted file mode 100644 index a1ca1ef..0000000 --- a/lighter/models/cursor.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class Cursor(BaseModel): - """ - Cursor - """ # noqa: E501 - next_cursor: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["next_cursor"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Cursor from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Cursor from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "next_cursor": obj.get("next_cursor") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/price_level.py b/lighter/models/daily_return.py similarity index 83% rename from lighter/models/price_level.py rename to lighter/models/daily_return.py index dc5b081..0453381 100644 --- a/lighter/models/price_level.py +++ b/lighter/models/daily_return.py @@ -17,19 +17,19 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt +from typing import Any, ClassVar, Dict, List, Union from typing import Optional, Set from typing_extensions import Self -class PriceLevel(BaseModel): +class DailyReturn(BaseModel): """ - PriceLevel + DailyReturn """ # noqa: E501 - price: StrictStr - size: StrictStr + timestamp: StrictInt + daily_return: Union[StrictFloat, StrictInt] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["price", "size"] + __properties: ClassVar[List[str]] = ["timestamp", "daily_return"] model_config = ConfigDict( populate_by_name=True, @@ -49,7 +49,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PriceLevel from a JSON string""" + """Create an instance of DailyReturn from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -81,7 +81,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PriceLevel from a dict""" + """Create an instance of DailyReturn from a dict""" if obj is None: return None @@ -89,8 +89,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "price": obj.get("price"), - "size": obj.get("size") + "timestamp": obj.get("timestamp"), + "daily_return": obj.get("daily_return") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/detailed_account.py b/lighter/models/detailed_account.py index b74113c..aa1d9bb 100644 --- a/lighter/models/detailed_account.py +++ b/lighter/models/detailed_account.py @@ -17,9 +17,8 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from lighter.models.account_market_stats import AccountMarketStats from lighter.models.account_position import AccountPosition from lighter.models.public_pool_info import PublicPoolInfo from lighter.models.public_pool_share import PublicPoolShare @@ -42,13 +41,15 @@ class DetailedAccount(BaseModel): collateral: StrictStr name: StrictStr description: StrictStr + can_invite: StrictBool + referral_points_percentage: StrictStr + max_referral_usage_limit: StrictInt positions: List[AccountPosition] total_asset_value: StrictStr - market_stats: List[AccountMarketStats] pool_info: PublicPoolInfo shares: List[PublicPoolShare] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "status", "collateral", "name", "description", "positions", "total_asset_value", "market_stats", "pool_info", "shares"] + __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "status", "collateral", "name", "description", "can_invite", "referral_points_percentage", "max_referral_usage_limit", "positions", "total_asset_value", "pool_info", "shares"] model_config = ConfigDict( populate_by_name=True, @@ -98,13 +99,6 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict['positions'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in market_stats (list) - _items = [] - if self.market_stats: - for _item in self.market_stats: - if _item: - _items.append(_item.to_dict()) - _dict['market_stats'] = _items # override the default output from pydantic by calling `to_dict()` of pool_info if self.pool_info: _dict['pool_info'] = self.pool_info.to_dict() @@ -144,9 +138,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "collateral": obj.get("collateral"), "name": obj.get("name"), "description": obj.get("description"), + "can_invite": obj.get("can_invite"), + "referral_points_percentage": obj.get("referral_points_percentage"), + "max_referral_usage_limit": obj.get("max_referral_usage_limit"), "positions": [AccountPosition.from_dict(_item) for _item in obj["positions"]] if obj.get("positions") is not None else None, "total_asset_value": obj.get("total_asset_value"), - "market_stats": [AccountMarketStats.from_dict(_item) for _item in obj["market_stats"]] if obj.get("market_stats") is not None else None, "pool_info": PublicPoolInfo.from_dict(obj["pool_info"]) if obj.get("pool_info") is not None else None, "shares": [PublicPoolShare.from_dict(_item) for _item in obj["shares"]] if obj.get("shares") is not None else None }) diff --git a/lighter/models/detailed_candlestick.py b/lighter/models/detailed_candlestick.py deleted file mode 100644 index 36a84ca..0000000 --- a/lighter/models/detailed_candlestick.py +++ /dev/null @@ -1,116 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt -from typing import Any, ClassVar, Dict, List, Union -from typing import Optional, Set -from typing_extensions import Self - -class DetailedCandlestick(BaseModel): - """ - DetailedCandlestick - """ # noqa: E501 - timestamp: StrictInt - open: Union[StrictFloat, StrictInt] - high: Union[StrictFloat, StrictInt] - low: Union[StrictFloat, StrictInt] - close: Union[StrictFloat, StrictInt] - volume0: Union[StrictFloat, StrictInt] - volume1: Union[StrictFloat, StrictInt] - last_trade_id: StrictInt - trade_count: StrictInt - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["timestamp", "open", "high", "low", "close", "volume0", "volume1", "last_trade_id", "trade_count"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of DetailedCandlestick from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of DetailedCandlestick from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "timestamp": obj.get("timestamp"), - "open": obj.get("open"), - "high": obj.get("high"), - "low": obj.get("low"), - "close": obj.get("close"), - "volume0": obj.get("volume0"), - "volume1": obj.get("volume1"), - "last_trade_id": obj.get("last_trade_id"), - "trade_count": obj.get("trade_count") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/l1_provider_info.py b/lighter/models/l1_provider_info.py deleted file mode 100644 index 9620bfb..0000000 --- a/lighter/models/l1_provider_info.py +++ /dev/null @@ -1,106 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class L1ProviderInfo(BaseModel): - """ - L1ProviderInfo - """ # noqa: E501 - chain_id: StrictInt = Field(alias="chainId") - network_id: StrictInt = Field(alias="networkId") - latest_block_number: StrictInt = Field(alias="latestBlockNumber") - network_rpc: StrictStr = Field(alias="NetworkRpc") - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["chainId", "networkId", "latestBlockNumber", "NetworkRpc"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of L1ProviderInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of L1ProviderInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "chainId": obj.get("chainId"), - "networkId": obj.get("networkId"), - "latestBlockNumber": obj.get("latestBlockNumber"), - "NetworkRpc": obj.get("NetworkRpc") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/liquidation.py b/lighter/models/liquidation.py deleted file mode 100644 index 96ed5e2..0000000 --- a/lighter/models/liquidation.py +++ /dev/null @@ -1,108 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class Liquidation(BaseModel): - """ - Liquidation - """ # noqa: E501 - liquidation_id: StrictInt - account_index: StrictInt - liquidation_type: StrictInt - portfolio_value: StrictStr - margin_requirement: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["liquidation_id", "account_index", "liquidation_type", "portfolio_value", "margin_requirement"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Liquidation from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Liquidation from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "liquidation_id": obj.get("liquidation_id"), - "account_index": obj.get("account_index"), - "liquidation_type": obj.get("liquidation_type"), - "portfolio_value": obj.get("portfolio_value"), - "margin_requirement": obj.get("margin_requirement") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/market_info.py b/lighter/models/market_info.py deleted file mode 100644 index c836971..0000000 --- a/lighter/models/market_info.py +++ /dev/null @@ -1,124 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Union -from typing import Optional, Set -from typing_extensions import Self - -class MarketInfo(BaseModel): - """ - MarketInfo - """ # noqa: E501 - market_id: StrictInt - index_price: StrictStr - mark_price: StrictStr - open_interest: StrictStr - last_trade_price: StrictStr - current_funding_rate: StrictStr - funding_rate: StrictStr - funding_timestamp: StrictInt - daily_base_token_volume: Union[StrictFloat, StrictInt] - daily_quote_token_volume: Union[StrictFloat, StrictInt] - daily_price_low: Union[StrictFloat, StrictInt] - daily_price_high: Union[StrictFloat, StrictInt] - daily_price_change: Union[StrictFloat, StrictInt] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "index_price", "mark_price", "open_interest", "last_trade_price", "current_funding_rate", "funding_rate", "funding_timestamp", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MarketInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MarketInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "index_price": obj.get("index_price"), - "mark_price": obj.get("mark_price"), - "open_interest": obj.get("open_interest"), - "last_trade_price": obj.get("last_trade_price"), - "current_funding_rate": obj.get("current_funding_rate"), - "funding_rate": obj.get("funding_rate"), - "funding_timestamp": obj.get("funding_timestamp"), - "daily_base_token_volume": obj.get("daily_base_token_volume"), - "daily_quote_token_volume": obj.get("daily_quote_token_volume"), - "daily_price_low": obj.get("daily_price_low"), - "daily_price_high": obj.get("daily_price_high"), - "daily_price_change": obj.get("daily_price_change") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/order.py b/lighter/models/order.py index 0b8e187..91d7885 100644 --- a/lighter/models/order.py +++ b/lighter/models/order.py @@ -28,6 +28,8 @@ class Order(BaseModel): """ # noqa: E501 order_index: StrictInt client_order_index: StrictInt + order_id: StrictStr + client_order_id: StrictStr market_index: StrictInt owner_account_index: StrictInt initial_base_amount: StrictStr @@ -46,12 +48,17 @@ class Order(BaseModel): trigger_price: StrictStr order_expiry: StrictInt status: StrictStr + trigger_status: StrictStr trigger_time: StrictInt parent_order_index: StrictInt + parent_order_id: StrictStr + to_trigger_order_id_0: StrictStr + to_trigger_order_id_1: StrictStr + to_cancel_order_id_0: StrictStr block_height: StrictInt timestamp: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["order_index", "client_order_index", "market_index", "owner_account_index", "initial_base_amount", "price", "nonce", "remaining_base_amount", "is_ask", "base_size", "base_price", "filled_base_amount", "filled_quote_amount", "side", "type", "time_in_force", "reduce_only", "trigger_price", "order_expiry", "status", "trigger_time", "parent_order_index", "block_height", "timestamp"] + __properties: ClassVar[List[str]] = ["order_index", "client_order_index", "order_id", "client_order_id", "market_index", "owner_account_index", "initial_base_amount", "price", "nonce", "remaining_base_amount", "is_ask", "base_size", "base_price", "filled_base_amount", "filled_quote_amount", "side", "type", "time_in_force", "reduce_only", "trigger_price", "order_expiry", "status", "trigger_status", "trigger_time", "parent_order_index", "parent_order_id", "to_trigger_order_id_0", "to_trigger_order_id_1", "to_cancel_order_id_0", "block_height", "timestamp"] @field_validator('type') def type_validate_enum(cls, value): @@ -70,8 +77,15 @@ def time_in_force_validate_enum(cls, value): @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" - if value not in set(['in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired']): - raise ValueError("must be one of enum values ('in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired')") + if value not in set(['in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired', 'canceled-oco', 'canceled-child']): + raise ValueError("must be one of enum values ('in-progress', 'pending', 'open', 'filled', 'canceled', 'canceled-post-only', 'canceled-reduce-only', 'canceled-position-not-allowed', 'canceled-margin-not-allowed', 'canceled-too-much-slippage', 'canceled-not-enough-liquidity', 'canceled-self-trade', 'canceled-expired', 'canceled-oco', 'canceled-child')") + return value + + @field_validator('trigger_status') + def trigger_status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['na', 'ready', 'mark-price', 'twap', 'parent-order']): + raise ValueError("must be one of enum values ('na', 'ready', 'mark-price', 'twap', 'parent-order')") return value model_config = ConfigDict( @@ -134,6 +148,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "order_index": obj.get("order_index"), "client_order_index": obj.get("client_order_index"), + "order_id": obj.get("order_id"), + "client_order_id": obj.get("client_order_id"), "market_index": obj.get("market_index"), "owner_account_index": obj.get("owner_account_index"), "initial_base_amount": obj.get("initial_base_amount"), @@ -152,8 +168,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "trigger_price": obj.get("trigger_price"), "order_expiry": obj.get("order_expiry"), "status": obj.get("status"), + "trigger_status": obj.get("trigger_status"), "trigger_time": obj.get("trigger_time"), "parent_order_index": obj.get("parent_order_index"), + "parent_order_id": obj.get("parent_order_id"), + "to_trigger_order_id_0": obj.get("to_trigger_order_id_0"), + "to_trigger_order_id_1": obj.get("to_trigger_order_id_1"), + "to_cancel_order_id_0": obj.get("to_cancel_order_id_0"), "block_height": obj.get("block_height"), "timestamp": obj.get("timestamp") }) diff --git a/lighter/models/order_book_depth.py b/lighter/models/order_book_depth.py deleted file mode 100644 index 214d798..0000000 --- a/lighter/models/order_book_depth.py +++ /dev/null @@ -1,123 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from lighter.models.price_level import PriceLevel -from typing import Optional, Set -from typing_extensions import Self - -class OrderBookDepth(BaseModel): - """ - OrderBookDepth - """ # noqa: E501 - code: StrictInt - message: Optional[StrictStr] = None - asks: List[PriceLevel] - bids: List[PriceLevel] - offset: StrictInt - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "asks", "bids", "offset"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OrderBookDepth from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of each item in asks (list) - _items = [] - if self.asks: - for _item in self.asks: - if _item: - _items.append(_item.to_dict()) - _dict['asks'] = _items - # override the default output from pydantic by calling `to_dict()` of each item in bids (list) - _items = [] - if self.bids: - for _item in self.bids: - if _item: - _items.append(_item.to_dict()) - _dict['bids'] = _items - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OrderBookDepth from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "message": obj.get("message"), - "asks": [PriceLevel.from_dict(_item) for _item in obj["asks"]] if obj.get("asks") is not None else None, - "bids": [PriceLevel.from_dict(_item) for _item in obj["bids"]] if obj.get("bids") is not None else None, - "offset": obj.get("offset") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/pn_l_entry.py b/lighter/models/pn_l_entry.py index 1a8e292..e0b53fc 100644 --- a/lighter/models/pn_l_entry.py +++ b/lighter/models/pn_l_entry.py @@ -28,8 +28,12 @@ class PnLEntry(BaseModel): """ # noqa: E501 timestamp: StrictInt value: Union[StrictFloat, StrictInt] + trade_pnl: Union[StrictFloat, StrictInt] + pool_pnl: Union[StrictFloat, StrictInt] + inflow: Union[StrictFloat, StrictInt] + outflow: Union[StrictFloat, StrictInt] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["timestamp", "value"] + __properties: ClassVar[List[str]] = ["timestamp", "value", "trade_pnl", "pool_pnl", "inflow", "outflow"] model_config = ConfigDict( populate_by_name=True, @@ -90,7 +94,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "timestamp": obj.get("timestamp"), - "value": obj.get("value") + "value": obj.get("value"), + "trade_pnl": obj.get("trade_pnl"), + "pool_pnl": obj.get("pool_pnl"), + "inflow": obj.get("inflow"), + "outflow": obj.get("outflow") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/position_funding.py b/lighter/models/position_funding.py deleted file mode 100644 index 1fee27f..0000000 --- a/lighter/models/position_funding.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class PositionFunding(BaseModel): - """ - PositionFunding - """ # noqa: E501 - timestamp: StrictInt - market_id: StrictInt - funding_id: StrictInt - change: StrictStr - rate: StrictStr - position_size: StrictStr - position_side: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["timestamp", "market_id", "funding_id", "change", "rate", "position_size", "position_side"] - - @field_validator('position_side') - def position_side_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['long', 'short']): - raise ValueError("must be one of enum values ('long', 'short')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PositionFunding from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PositionFunding from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "timestamp": obj.get("timestamp"), - "market_id": obj.get("market_id"), - "funding_id": obj.get("funding_id"), - "change": obj.get("change"), - "rate": obj.get("rate"), - "position_size": obj.get("position_size"), - "position_side": obj.get("position_side") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/public_pool.py b/lighter/models/public_pool.py index 210aee3..16f611d 100644 --- a/lighter/models/public_pool.py +++ b/lighter/models/public_pool.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr +from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional from lighter.models.public_pool_info import PublicPoolInfo from lighter.models.public_pool_share import PublicPoolShare @@ -40,11 +40,14 @@ class PublicPool(BaseModel): collateral: StrictStr name: StrictStr description: StrictStr + can_invite: StrictBool + referral_points_percentage: StrictStr + max_referral_usage_limit: StrictInt total_asset_value: StrictStr pool_info: PublicPoolInfo - account_share: PublicPoolShare + account_share: Optional[PublicPoolShare] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "status", "collateral", "name", "description", "total_asset_value", "pool_info", "account_share"] + __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "status", "collateral", "name", "description", "can_invite", "referral_points_percentage", "max_referral_usage_limit", "total_asset_value", "pool_info", "account_share"] model_config = ConfigDict( populate_by_name=True, @@ -122,6 +125,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "collateral": obj.get("collateral"), "name": obj.get("name"), "description": obj.get("description"), + "can_invite": obj.get("can_invite"), + "referral_points_percentage": obj.get("referral_points_percentage"), + "max_referral_usage_limit": obj.get("max_referral_usage_limit"), "total_asset_value": obj.get("total_asset_value"), "pool_info": PublicPoolInfo.from_dict(obj["pool_info"]) if obj.get("pool_info") is not None else None, "account_share": PublicPoolShare.from_dict(obj["account_share"]) if obj.get("account_share") is not None else None diff --git a/lighter/models/public_pool_info.py b/lighter/models/public_pool_info.py index b327707..9566848 100644 --- a/lighter/models/public_pool_info.py +++ b/lighter/models/public_pool_info.py @@ -17,8 +17,9 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List +from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List, Union +from lighter.models.daily_return import DailyReturn from typing import Optional, Set from typing_extensions import Self @@ -31,8 +32,13 @@ class PublicPoolInfo(BaseModel): min_operator_share_rate: StrictStr total_shares: StrictInt operator_shares: StrictInt + share_price_1d: Union[StrictFloat, StrictInt] + share_price_7d: Union[StrictFloat, StrictInt] + share_price_30d: Union[StrictFloat, StrictInt] + annual_percentage_yield: Union[StrictFloat, StrictInt] + daily_returns: List[DailyReturn] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["status", "operator_fee", "min_operator_share_rate", "total_shares", "operator_shares"] + __properties: ClassVar[List[str]] = ["status", "operator_fee", "min_operator_share_rate", "total_shares", "operator_shares", "share_price_1d", "share_price_7d", "share_price_30d", "annual_percentage_yield", "daily_returns"] model_config = ConfigDict( populate_by_name=True, @@ -75,6 +81,13 @@ def to_dict(self) -> Dict[str, Any]: exclude=excluded_fields, exclude_none=True, ) + # override the default output from pydantic by calling `to_dict()` of each item in daily_returns (list) + _items = [] + if self.daily_returns: + for _item in self.daily_returns: + if _item: + _items.append(_item.to_dict()) + _dict['daily_returns'] = _items # puts key-value pairs in additional_properties in the top level if self.additional_properties is not None: for _key, _value in self.additional_properties.items(): @@ -96,7 +109,12 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "operator_fee": obj.get("operator_fee"), "min_operator_share_rate": obj.get("min_operator_share_rate"), "total_shares": obj.get("total_shares"), - "operator_shares": obj.get("operator_shares") + "operator_shares": obj.get("operator_shares"), + "share_price_1d": obj.get("share_price_1d"), + "share_price_7d": obj.get("share_price_7d"), + "share_price_30d": obj.get("share_price_30d"), + "annual_percentage_yield": obj.get("annual_percentage_yield"), + "daily_returns": [DailyReturn.from_dict(_item) for _item in obj["daily_returns"]] if obj.get("daily_returns") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/req_get_account.py b/lighter/models/req_get_account.py deleted file mode 100644 index c6108e6..0000000 --- a/lighter/models/req_get_account.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccount(BaseModel): - """ - ReqGetAccount - """ # noqa: E501 - by: StrictStr - value: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['index', 'l1_address']): - raise ValueError("must be one of enum values ('index', 'l1_address')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccount from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccount from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_active_orders.py b/lighter/models/req_get_account_active_orders.py deleted file mode 100644 index d1193bb..0000000 --- a/lighter/models/req_get_account_active_orders.py +++ /dev/null @@ -1,104 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountActiveOrders(BaseModel): - """ - ReqGetAccountActiveOrders - """ # noqa: E501 - account_index: StrictInt - market_id: StrictInt - auth: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index", "market_id", "auth"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountActiveOrders from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountActiveOrders from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index"), - "market_id": obj.get("market_id"), - "auth": obj.get("auth") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_api_keys.py b/lighter/models/req_get_account_api_keys.py deleted file mode 100644 index a9c462e..0000000 --- a/lighter/models/req_get_account_api_keys.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountApiKeys(BaseModel): - """ - ReqGetAccountApiKeys - """ # noqa: E501 - account_index: StrictInt - api_key_index: StrictInt - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index", "api_key_index"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountApiKeys from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountApiKeys from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index"), - "api_key_index": obj.get("api_key_index") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_by_l1_address.py b/lighter/models/req_get_account_by_l1_address.py deleted file mode 100644 index a0b86eb..0000000 --- a/lighter/models/req_get_account_by_l1_address.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountByL1Address(BaseModel): - """ - ReqGetAccountByL1Address - """ # noqa: E501 - l1_address: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["l1_address"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountByL1Address from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountByL1Address from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "l1_address": obj.get("l1_address") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_inactive_orders.py b/lighter/models/req_get_account_inactive_orders.py deleted file mode 100644 index 4577704..0000000 --- a/lighter/models/req_get_account_inactive_orders.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountInactiveOrders(BaseModel): - """ - ReqGetAccountInactiveOrders - """ # noqa: E501 - account_index: StrictInt - market_id: Optional[StrictInt] = None - ask_filter: Optional[StrictInt] = None - between_timestamps: Optional[StrictStr] = None - cursor: Optional[StrictStr] = None - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index", "market_id", "ask_filter", "between_timestamps", "cursor", "limit"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountInactiveOrders from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountInactiveOrders from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index"), - "market_id": obj.get("market_id"), - "ask_filter": obj.get("ask_filter"), - "between_timestamps": obj.get("between_timestamps"), - "cursor": obj.get("cursor"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_orders.py b/lighter/models/req_get_account_orders.py deleted file mode 100644 index 82052d2..0000000 --- a/lighter/models/req_get_account_orders.py +++ /dev/null @@ -1,107 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountOrders(BaseModel): - """ - ReqGetAccountOrders - """ # noqa: E501 - account_index: StrictInt - market_id: StrictInt - cursor: Optional[StrictStr] = None - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index", "market_id", "cursor", "limit"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountOrders from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountOrders from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index"), - "market_id": obj.get("market_id"), - "cursor": obj.get("cursor"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_pending_txs.py b/lighter/models/req_get_account_pending_txs.py deleted file mode 100644 index 9f0f878..0000000 --- a/lighter/models/req_get_account_pending_txs.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountPendingTxs(BaseModel): - """ - ReqGetAccountPendingTxs - """ # noqa: E501 - by: Optional[StrictStr] = None - value: Optional[StrictStr] = None - types: Optional[List[StrictInt]] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value", "types"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['account_index']): - raise ValueError("must be one of enum values ('account_index')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountPendingTxs from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountPendingTxs from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value"), - "types": obj.get("types") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_pn_l.py b/lighter/models/req_get_account_pn_l.py deleted file mode 100644 index c4e5b8f..0000000 --- a/lighter/models/req_get_account_pn_l.py +++ /dev/null @@ -1,126 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountPnL(BaseModel): - """ - ReqGetAccountPnL - """ # noqa: E501 - by: StrictStr - value: StrictStr - resolution: StrictStr - start_timestamp: StrictInt - end_timestamp: StrictInt - count_back: StrictInt - ignore_transfers: Optional[StrictBool] = False - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value", "resolution", "start_timestamp", "end_timestamp", "count_back", "ignore_transfers"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['index']): - raise ValueError("must be one of enum values ('index')") - return value - - @field_validator('resolution') - def resolution_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['1m', '5m', '15m', '1h', '4h', '1d']): - raise ValueError("must be one of enum values ('1m', '5m', '15m', '1h', '4h', '1d')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountPnL from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountPnL from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value"), - "resolution": obj.get("resolution"), - "start_timestamp": obj.get("start_timestamp"), - "end_timestamp": obj.get("end_timestamp"), - "count_back": obj.get("count_back"), - "ignore_transfers": obj.get("ignore_transfers") if obj.get("ignore_transfers") is not None else False - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_account_txs.py b/lighter/models/req_get_account_txs.py deleted file mode 100644 index c83d7ae..0000000 --- a/lighter/models/req_get_account_txs.py +++ /dev/null @@ -1,119 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetAccountTxs(BaseModel): - """ - ReqGetAccountTxs - """ # noqa: E501 - index: Optional[StrictInt] = None - limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None - by: Optional[StrictStr] = None - value: Optional[StrictStr] = None - types: Optional[List[StrictInt]] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["index", "limit", "by", "value", "types"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['account_index']): - raise ValueError("must be one of enum values ('account_index')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetAccountTxs from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetAccountTxs from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "index": obj.get("index"), - "limit": obj.get("limit"), - "by": obj.get("by"), - "value": obj.get("value"), - "types": obj.get("types") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_block.py b/lighter/models/req_get_block.py deleted file mode 100644 index 574e2c7..0000000 --- a/lighter/models/req_get_block.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetBlock(BaseModel): - """ - ReqGetBlock - """ # noqa: E501 - by: StrictStr - value: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['commitment', 'height']): - raise ValueError("must be one of enum values ('commitment', 'height')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetBlock from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetBlock from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_block_txs.py b/lighter/models/req_get_block_txs.py deleted file mode 100644 index b040c5e..0000000 --- a/lighter/models/req_get_block_txs.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetBlockTxs(BaseModel): - """ - ReqGetBlockTxs - """ # noqa: E501 - by: StrictStr - value: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['block_height', 'block_commitment']): - raise ValueError("must be one of enum values ('block_height', 'block_commitment')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetBlockTxs from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetBlockTxs from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_by_account.py b/lighter/models/req_get_by_account.py deleted file mode 100644 index 9e52c14..0000000 --- a/lighter/models/req_get_by_account.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetByAccount(BaseModel): - """ - ReqGetByAccount - """ # noqa: E501 - by: StrictStr - value: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['account_index']): - raise ValueError("must be one of enum values ('account_index')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetByAccount from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetByAccount from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_candlesticks.py b/lighter/models/req_get_candlesticks.py deleted file mode 100644 index 2b8861b..0000000 --- a/lighter/models/req_get_candlesticks.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictBool, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetCandlesticks(BaseModel): - """ - ReqGetCandlesticks - """ # noqa: E501 - market_id: StrictInt - resolution: StrictStr - start_timestamp: StrictInt - end_timestamp: StrictInt - count_back: StrictInt - set_timestamp_to_end: Optional[StrictBool] = False - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "resolution", "start_timestamp", "end_timestamp", "count_back", "set_timestamp_to_end"] - - @field_validator('resolution') - def resolution_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['1m', '5m', '15m', '1h', '4h', '1d']): - raise ValueError("must be one of enum values ('1m', '5m', '15m', '1h', '4h', '1d')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetCandlesticks from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetCandlesticks from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "resolution": obj.get("resolution"), - "start_timestamp": obj.get("start_timestamp"), - "end_timestamp": obj.get("end_timestamp"), - "count_back": obj.get("count_back"), - "set_timestamp_to_end": obj.get("set_timestamp_to_end") if obj.get("set_timestamp_to_end") is not None else False - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_deposit_history.py b/lighter/models/req_get_deposit_history.py deleted file mode 100644 index 1511f92..0000000 --- a/lighter/models/req_get_deposit_history.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetDepositHistory(BaseModel): - """ - ReqGetDepositHistory - """ # noqa: E501 - l1_address: StrictStr - cursor: Optional[StrictStr] = None - filter: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["l1_address", "cursor", "filter"] - - @field_validator('filter') - def filter_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['all', 'pending', 'claimable']): - raise ValueError("must be one of enum values ('all', 'pending', 'claimable')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetDepositHistory from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetDepositHistory from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "l1_address": obj.get("l1_address"), - "cursor": obj.get("cursor"), - "filter": obj.get("filter") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_fee_bucket.py b/lighter/models/req_get_fee_bucket.py deleted file mode 100644 index 17bb262..0000000 --- a/lighter/models/req_get_fee_bucket.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetFeeBucket(BaseModel): - """ - ReqGetFeeBucket - """ # noqa: E501 - account_index: StrictInt - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetFeeBucket from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetFeeBucket from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_fundings.py b/lighter/models/req_get_fundings.py deleted file mode 100644 index af9a20a..0000000 --- a/lighter/models/req_get_fundings.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetFundings(BaseModel): - """ - ReqGetFundings - """ # noqa: E501 - market_id: StrictInt - resolution: StrictStr - start_timestamp: StrictInt - end_timestamp: StrictInt - count_back: StrictInt - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "resolution", "start_timestamp", "end_timestamp", "count_back"] - - @field_validator('resolution') - def resolution_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['1h']): - raise ValueError("must be one of enum values ('1h')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetFundings from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetFundings from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "resolution": obj.get("resolution"), - "start_timestamp": obj.get("start_timestamp"), - "end_timestamp": obj.get("end_timestamp"), - "count_back": obj.get("count_back") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_l1_tx.py b/lighter/models/req_get_l1_tx.py deleted file mode 100644 index dda8501..0000000 --- a/lighter/models/req_get_l1_tx.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetL1Tx(BaseModel): - """ - ReqGetL1Tx - """ # noqa: E501 - hash: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["hash"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetL1Tx from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetL1Tx from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "hash": obj.get("hash") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_latest_deposit.py b/lighter/models/req_get_latest_deposit.py deleted file mode 100644 index 6ce2506..0000000 --- a/lighter/models/req_get_latest_deposit.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetLatestDeposit(BaseModel): - """ - ReqGetLatestDeposit - """ # noqa: E501 - l1_address: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["l1_address"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetLatestDeposit from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetLatestDeposit from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "l1_address": obj.get("l1_address") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_next_nonce.py b/lighter/models/req_get_next_nonce.py deleted file mode 100644 index 90920a0..0000000 --- a/lighter/models/req_get_next_nonce.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetNextNonce(BaseModel): - """ - ReqGetNextNonce - """ # noqa: E501 - account_index: StrictInt - api_key_index: StrictInt - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index", "api_key_index"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetNextNonce from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetNextNonce from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index"), - "api_key_index": obj.get("api_key_index") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_order_book_details.py b/lighter/models/req_get_order_book_details.py deleted file mode 100644 index e38a012..0000000 --- a/lighter/models/req_get_order_book_details.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetOrderBookDetails(BaseModel): - """ - ReqGetOrderBookDetails - """ # noqa: E501 - market_id: Optional[StrictInt] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetOrderBookDetails from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetOrderBookDetails from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_order_book_orders.py b/lighter/models/req_get_order_book_orders.py deleted file mode 100644 index 52c008f..0000000 --- a/lighter/models/req_get_order_book_orders.py +++ /dev/null @@ -1,103 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetOrderBookOrders(BaseModel): - """ - ReqGetOrderBookOrders - """ # noqa: E501 - market_id: StrictInt - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "limit"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetOrderBookOrders from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetOrderBookOrders from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_order_books.py b/lighter/models/req_get_order_books.py deleted file mode 100644 index 9608c4b..0000000 --- a/lighter/models/req_get_order_books.py +++ /dev/null @@ -1,100 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetOrderBooks(BaseModel): - """ - ReqGetOrderBooks - """ # noqa: E501 - market_id: Optional[StrictInt] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetOrderBooks from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetOrderBooks from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_public_pools.py b/lighter/models/req_get_public_pools.py deleted file mode 100644 index cac0b25..0000000 --- a/lighter/models/req_get_public_pools.py +++ /dev/null @@ -1,117 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetPublicPools(BaseModel): - """ - ReqGetPublicPools - """ # noqa: E501 - filter: Optional[StrictStr] = None - index: StrictInt - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - account_index: Optional[StrictInt] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["filter", "index", "limit", "account_index"] - - @field_validator('filter') - def filter_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['all', 'user', 'protocol', 'account_index']): - raise ValueError("must be one of enum values ('all', 'user', 'protocol', 'account_index')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetPublicPools from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetPublicPools from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "filter": obj.get("filter"), - "index": obj.get("index"), - "limit": obj.get("limit"), - "account_index": obj.get("account_index") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_range_with_cursor.py b/lighter/models/req_get_range_with_cursor.py deleted file mode 100644 index dc7821e..0000000 --- a/lighter/models/req_get_range_with_cursor.py +++ /dev/null @@ -1,103 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetRangeWithCursor(BaseModel): - """ - ReqGetRangeWithCursor - """ # noqa: E501 - cursor: Optional[StrictStr] = None - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["cursor", "limit"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetRangeWithCursor from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetRangeWithCursor from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "cursor": obj.get("cursor"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_range_with_index.py b/lighter/models/req_get_range_with_index.py deleted file mode 100644 index e589449..0000000 --- a/lighter/models/req_get_range_with_index.py +++ /dev/null @@ -1,103 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetRangeWithIndex(BaseModel): - """ - ReqGetRangeWithIndex - """ # noqa: E501 - index: Optional[StrictInt] = None - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["index", "limit"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetRangeWithIndex from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetRangeWithIndex from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "index": obj.get("index"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_range_with_index_sortable.py b/lighter/models/req_get_range_with_index_sortable.py deleted file mode 100644 index d22bbb2..0000000 --- a/lighter/models/req_get_range_with_index_sortable.py +++ /dev/null @@ -1,115 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetRangeWithIndexSortable(BaseModel): - """ - ReqGetRangeWithIndexSortable - """ # noqa: E501 - index: Optional[StrictInt] = None - limit: Optional[Annotated[int, Field(le=100, strict=True, ge=1)]] = None - sort: Optional[StrictStr] = 'asc' - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["index", "limit", "sort"] - - @field_validator('sort') - def sort_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['asc', 'desc']): - raise ValueError("must be one of enum values ('asc', 'desc')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetRangeWithIndexSortable from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetRangeWithIndexSortable from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "index": obj.get("index"), - "limit": obj.get("limit"), - "sort": obj.get("sort") if obj.get("sort") is not None else 'asc' - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_recent_trades.py b/lighter/models/req_get_recent_trades.py deleted file mode 100644 index 96dba79..0000000 --- a/lighter/models/req_get_recent_trades.py +++ /dev/null @@ -1,103 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt -from typing import Any, ClassVar, Dict, List -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetRecentTrades(BaseModel): - """ - ReqGetRecentTrades - """ # noqa: E501 - market_id: StrictInt - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "limit"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetRecentTrades from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetRecentTrades from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_trades.py b/lighter/models/req_get_trades.py deleted file mode 100644 index 16f5ed8..0000000 --- a/lighter/models/req_get_trades.py +++ /dev/null @@ -1,134 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetTrades(BaseModel): - """ - ReqGetTrades - """ # noqa: E501 - market_id: Optional[StrictInt] = None - account_index: Optional[StrictInt] = -1 - order_index: Optional[StrictInt] = None - sort_by: StrictStr - sort_dir: Optional[StrictStr] = 'asc' - cursor: Optional[StrictStr] = None - var_from: Optional[StrictInt] = Field(default=-1, alias="from") - ask_filter: Optional[StrictInt] = None - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id", "account_index", "order_index", "sort_by", "sort_dir", "cursor", "from", "ask_filter", "limit"] - - @field_validator('sort_by') - def sort_by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['block_height', 'timestamp', 'trade_id']): - raise ValueError("must be one of enum values ('block_height', 'timestamp', 'trade_id')") - return value - - @field_validator('sort_dir') - def sort_dir_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['asc', 'desc']): - raise ValueError("must be one of enum values ('asc', 'desc')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetTrades from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetTrades from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "market_id": obj.get("market_id"), - "account_index": obj.get("account_index") if obj.get("account_index") is not None else -1, - "order_index": obj.get("order_index"), - "sort_by": obj.get("sort_by"), - "sort_dir": obj.get("sort_dir") if obj.get("sort_dir") is not None else 'asc', - "cursor": obj.get("cursor"), - "from": obj.get("from") if obj.get("from") is not None else -1, - "ask_filter": obj.get("ask_filter"), - "limit": obj.get("limit") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_tx.py b/lighter/models/req_get_tx.py deleted file mode 100644 index 275c4ff..0000000 --- a/lighter/models/req_get_tx.py +++ /dev/null @@ -1,109 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetTx(BaseModel): - """ - ReqGetTx - """ # noqa: E501 - by: StrictStr - value: StrictStr - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["by", "value"] - - @field_validator('by') - def by_validate_enum(cls, value): - """Validates the enum""" - if value not in set(['hash', 'sequence_index']): - raise ValueError("must be one of enum values ('hash', 'sequence_index')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetTx from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetTx from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "by": obj.get("by"), - "value": obj.get("value") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/req_get_withdraw_history.py b/lighter/models/req_get_withdraw_history.py deleted file mode 100644 index 38ca57c..0000000 --- a/lighter/models/req_get_withdraw_history.py +++ /dev/null @@ -1,114 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, field_validator -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ReqGetWithdrawHistory(BaseModel): - """ - ReqGetWithdrawHistory - """ # noqa: E501 - account_index: StrictInt - cursor: Optional[StrictStr] = None - filter: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["account_index", "cursor", "filter"] - - @field_validator('filter') - def filter_validate_enum(cls, value): - """Validates the enum""" - if value is None: - return value - - if value not in set(['all', 'pending', 'claimable']): - raise ValueError("must be one of enum values ('all', 'pending', 'claimable')") - return value - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetWithdrawHistory from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetWithdrawHistory from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "account_index": obj.get("account_index"), - "cursor": obj.get("cursor"), - "filter": obj.get("filter") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/result_code.py b/lighter/models/result_code.py deleted file mode 100644 index a29a276..0000000 --- a/lighter/models/result_code.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr -from typing import Any, ClassVar, Dict, List, Optional -from typing import Optional, Set -from typing_extensions import Self - -class ResultCode(BaseModel): - """ - ResultCode - """ # noqa: E501 - code: StrictInt - message: Optional[StrictStr] = None - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ResultCode from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ResultCode from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "code": obj.get("code"), - "message": obj.get("message") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/simple_order.py b/lighter/models/simple_order.py index d5cd8b5..a10be5d 100644 --- a/lighter/models/simple_order.py +++ b/lighter/models/simple_order.py @@ -27,13 +27,14 @@ class SimpleOrder(BaseModel): SimpleOrder """ # noqa: E501 order_index: StrictInt + order_id: StrictStr owner_account_index: StrictInt initial_base_amount: StrictStr remaining_base_amount: StrictStr price: StrictStr order_expiry: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["order_index", "owner_account_index", "initial_base_amount", "remaining_base_amount", "price", "order_expiry"] + __properties: ClassVar[List[str]] = ["order_index", "order_id", "owner_account_index", "initial_base_amount", "remaining_base_amount", "price", "order_expiry"] model_config = ConfigDict( populate_by_name=True, @@ -94,6 +95,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "order_index": obj.get("order_index"), + "order_id": obj.get("order_id"), "owner_account_index": obj.get("owner_account_index"), "initial_base_amount": obj.get("initial_base_amount"), "remaining_base_amount": obj.get("remaining_base_amount"), diff --git a/lighter/models/status.py b/lighter/models/status.py index 2db4004..d2026f0 100644 --- a/lighter/models/status.py +++ b/lighter/models/status.py @@ -28,8 +28,9 @@ class Status(BaseModel): """ # noqa: E501 status: StrictInt network_id: StrictInt + timestamp: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["status", "network_id"] + __properties: ClassVar[List[str]] = ["status", "network_id", "timestamp"] model_config = ConfigDict( populate_by_name=True, @@ -90,7 +91,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "status": obj.get("status"), - "network_id": obj.get("network_id") + "network_id": obj.get("network_id"), + "timestamp": obj.get("timestamp") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/ticker.py b/lighter/models/ticker.py deleted file mode 100644 index 96a5cd4..0000000 --- a/lighter/models/ticker.py +++ /dev/null @@ -1,111 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictStr -from typing import Any, ClassVar, Dict, List -from lighter.models.price_level import PriceLevel -from typing import Optional, Set -from typing_extensions import Self - -class Ticker(BaseModel): - """ - Ticker - """ # noqa: E501 - s: StrictStr - a: PriceLevel - b: PriceLevel - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["s", "a", "b"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of Ticker from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # override the default output from pydantic by calling `to_dict()` of a - if self.a: - _dict['a'] = self.a.to_dict() - # override the default output from pydantic by calling `to_dict()` of b - if self.b: - _dict['b'] = self.b.to_dict() - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of Ticker from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "s": obj.get("s"), - "a": PriceLevel.from_dict(obj["a"]) if obj.get("a") is not None else None, - "b": PriceLevel.from_dict(obj["b"]) if obj.get("b") is not None else None - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/models/validator_info.py b/lighter/models/validator_info.py deleted file mode 100644 index ca08bdf..0000000 --- a/lighter/models/validator_info.py +++ /dev/null @@ -1,102 +0,0 @@ -# coding: utf-8 - -""" - - - No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - - The version of the OpenAPI document: - Generated by OpenAPI Generator (https://openapi-generator.tech) - - Do not edit the class manually. -""" # noqa: E501 - - -from __future__ import annotations -import pprint -import re # noqa: F401 -import json - -from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr -from typing import Any, ClassVar, Dict, List -from typing import Optional, Set -from typing_extensions import Self - -class ValidatorInfo(BaseModel): - """ - ValidatorInfo - """ # noqa: E501 - address: StrictStr - is_active: StrictBool - additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["address", "is_active"] - - model_config = ConfigDict( - populate_by_name=True, - validate_assignment=True, - protected_namespaces=(), - ) - - - def to_str(self) -> str: - """Returns the string representation of the model using alias""" - return pprint.pformat(self.model_dump(by_alias=True)) - - def to_json(self) -> str: - """Returns the JSON representation of the model using alias""" - # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead - return json.dumps(self.to_dict()) - - @classmethod - def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ValidatorInfo from a JSON string""" - return cls.from_dict(json.loads(json_str)) - - def to_dict(self) -> Dict[str, Any]: - """Return the dictionary representation of the model using alias. - - This has the following differences from calling pydantic's - `self.model_dump(by_alias=True)`: - - * `None` is only added to the output dict for nullable fields that - were set at model initialization. Other fields with value `None` - are ignored. - * Fields in `self.additional_properties` are added to the output dict. - """ - excluded_fields: Set[str] = set([ - "additional_properties", - ]) - - _dict = self.model_dump( - by_alias=True, - exclude=excluded_fields, - exclude_none=True, - ) - # puts key-value pairs in additional_properties in the top level - if self.additional_properties is not None: - for _key, _value in self.additional_properties.items(): - _dict[_key] = _value - - return _dict - - @classmethod - def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ValidatorInfo from a dict""" - if obj is None: - return None - - if not isinstance(obj, dict): - return cls.model_validate(obj) - - _obj = cls.model_validate({ - "address": obj.get("address"), - "is_active": obj.get("is_active") - }) - # store additional fields in additional_properties - for _key in obj.keys(): - if _key not in cls.__properties: - _obj.additional_properties[_key] = obj.get(_key) - - return _obj - - diff --git a/lighter/signer_client.py b/lighter/signer_client.py index be65e97..6ebdc6b 100644 --- a/lighter/signer_client.py +++ b/lighter/signer_client.py @@ -1,10 +1,13 @@ import ctypes +import json import platform import logging import os import time from eth_account import Account +from eth_account.messages import encode_defunct +from pydantic import StrictInt import lighter from lighter.configuration import Configuration from lighter.models import TxHash @@ -13,9 +16,54 @@ logging.basicConfig(level=logging.DEBUG) +class ApiKeyResponse(ctypes.Structure): + _fields_ = [("privateKey", ctypes.c_char_p), ("publicKey", ctypes.c_char_p), ("err", ctypes.c_char_p)] + + +class StrOrErr(ctypes.Structure): + _fields_ = [("str", ctypes.c_char_p), ("err", ctypes.c_char_p)] + + +def _initialize_signer(): + is_linux = platform.system() == "Linux" + is_mac = platform.system() == "Darwin" + is_x64 = platform.machine().lower() in ("amd64", "x86_64") + is_arm = platform.machine().lower() == "arm64" + + current_file_directory = os.path.dirname(os.path.abspath(__file__)) + path_to_signer_folders = os.path.join(current_file_directory, "signers") + + if is_arm and is_mac: + logging.debug("Detected ARM architecture on macOS.") + return ctypes.CDLL(os.path.join(path_to_signer_folders, "signer-arm64.dylib")) + elif is_linux and is_x64: + logging.debug("Detected x64/amd architecture on Linux.") + return ctypes.CDLL(os.path.join(path_to_signer_folders, "signer-amd64.so")) + else: + raise Exception( + f"Unsupported platform/architecture: {platform.system()}/{platform.machine()} only supports Linux(x86) and Darwin(arm64)" + ) + + +def create_api_key(seed=""): + signer = _initialize_signer() + signer.GenerateAPIKey.argtypes = [ + ctypes.c_char_p, + ] + signer.GenerateAPIKey.restype = ApiKeyResponse + result = signer.GenerateAPIKey(ctypes.c_char_p(seed.encode("utf-8"))) + + private_key_str = result.privateKey.decode("utf-8") if result.privateKey else None + public_key_str = result.publicKey.decode("utf-8") if result.publicKey else None + error = result.err.decode("utf-8") if result.err else None + + return private_key_str, public_key_str, error + + class SignerClient: USDC_TICKER_SCALE = 1e6 + TX_TYPE_CHANGE_PUB_KEY = 8 TX_TYPE_CREATE_SUB_ACCOUNT = 9 TX_TYPE_CREATE_PUBLIC_POOL = 10 TX_TYPE_UPDATE_PUBLIC_POOL = 11 @@ -42,12 +90,14 @@ class SignerClient: NIL_TRIGGER_PRICE = 0 DEFAULT_28_DAY_ORDER_EXPIRY = -1 + DEFAULT_IOC_EXPIRY = 0 DEFAULT_10_MIN_AUTH_EXPIRY = -1 MINUTE = 60 - def __init__( - self, url, private_key, chain_id=300, api_key_index=0, account_index=-1 - ): + def __init__(self, url, private_key, api_key_index, account_index): + chain_id = 304 if "mainnet" in url else 300 + + # api_key_index=0 is generally used by frontend if private_key.startswith("0x"): private_key = private_key[2:] self.url = url @@ -55,46 +105,10 @@ def __init__( self.chain_id = chain_id self.api_key_index = api_key_index self.account_index = account_index - self.signer = self._initialize_signer() + self.signer = _initialize_signer() self.api_client = lighter.ApiClient(configuration=Configuration(host=url)) self.tx_api = lighter.TransactionApi(self.api_client) self.create_client() - self.l1_address = Account.from_key(private_key).address - - def _initialize_signer(self): - is_linux = platform.system() == "Linux" - is_mac = platform.system() == "Darwin" - is_x64 = platform.machine().lower() in ("amd64", "x86_64") - is_arm = platform.machine().lower() == "arm64" - - current_file_directory = os.path.dirname(os.path.abspath(__file__)) - path_to_signer_folders = os.path.join(current_file_directory, "signers") - - if is_arm and is_mac: - logging.debug("Detected ARM architecture on macOS.") - return ctypes.CDLL( - os.path.join(path_to_signer_folders, "signer-arm64.dylib") - ) - elif is_linux and is_x64: - logging.debug("Detected x64/amd architecture on Linux.") - return ctypes.CDLL(os.path.join(path_to_signer_folders, "signer-amd64.so")) - else: - raise Exception( - f"Unsupported platform/architecture: {platform.system()}/{platform.machine()} only supports Linux(x86) and Darwin(arm64)" - ) - - async def set_account_index(self) -> int: - if self.account_index != -1: - return self.account_index - - accounts = await lighter.AccountApi(self.api_client).accounts_by_l1_address( - l1_address=self.l1_address - ) - if len(accounts.sub_accounts) > 0: - self.account_index = min(acc.index for acc in accounts.sub_accounts) - return self.account_index - - return -1 def create_client(self): self.signer.CreateClient.argtypes = [ @@ -104,8 +118,8 @@ def create_client(self): ctypes.c_int, ctypes.c_longlong, ] - self.signer.CreateClient.restype = ctypes.c_void_p - self.signer.CreateClient( + self.signer.CreateClient.restype = ctypes.c_char_p + err = self.signer.CreateClient( self.url.encode("utf-8"), self.private_key.encode("utf-8"), self.chain_id, @@ -113,6 +127,61 @@ def create_client(self): self.account_index, ) + if err is None: + return + + err_str = err.decode("utf-8") + raise Exception(err_str) + + # check_client verifies that the given API key associated with (api_key_index, account_index) matches the one on Lighter + def check_client(self): + self.signer.CheckClient.argtypes = [ + ctypes.c_int, + ctypes.c_longlong, + ] + self.signer.CheckClient.restype = ctypes.c_char_p + + result = self.signer.CheckClient(self.api_key_index, self.account_index) + return result.decode("utf-8") if result else None + + def create_api_key(self, seed=""): + self.signer.GenerateAPIKey.argtypes = [ + ctypes.c_char_p, + ] + self.signer.GenerateAPIKey.restype = ApiKeyResponse + result = self.signer.GenerateAPIKey(ctypes.c_char_p(seed.encode("utf-8"))) + + private_key_str = result.str.decode("utf-8") if result.privateKey else None + public_key_str = result.str.decode("utf-8") if result.publicKey else None + error = result.err.decode("utf-8") if result.err else None + + return private_key_str, public_key_str, error + + def sign_change_api_key(self, eth_private_key, new_pubkey: str, nonce: int): + self.signer.SignChangePubKey.argtypes = [ + ctypes.c_char_p, + ctypes.c_longlong, + ] + self.signer.SignChangePubKey.restype = StrOrErr + result = self.signer.SignChangePubKey(ctypes.c_char_p(new_pubkey.encode("utf-8")), nonce) + + tx_info_str = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + if error is not None: + return None, error + + # fetch message to sign + tx_info = json.loads(tx_info_str) + msg_to_sign = tx_info["MessageToSign"] + del tx_info["MessageToSign"] + + # sign the message + acct = Account.from_key(eth_private_key) + message = encode_defunct(text=msg_to_sign) + signature = acct.sign_message(message) + tx_info["L1Sig"] = signature.signature.to_0x_hex() + return json.dumps(tx_info), None + def sign_create_order( self, market_index, @@ -140,8 +209,9 @@ def sign_create_order( ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignCreateOrder.restype = ctypes.c_char_p - return self.signer.SignCreateOrder( + self.signer.SignCreateOrder.restype = StrOrErr + + result = self.signer.SignCreateOrder( market_index, client_order_index, base_amount, @@ -153,7 +223,12 @@ def sign_create_order( trigger_price, order_expiry, nonce, - ).decode("utf-8") + ) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_cancel_order(self, market_index, order_index, nonce=-1): self.signer.SignCancelOrder.argtypes = [ @@ -161,20 +236,36 @@ def sign_cancel_order(self, market_index, order_index, nonce=-1): ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignCancelOrder.restype = ctypes.c_char_p - return self.signer.SignCancelOrder(market_index, order_index, nonce).decode( - "utf-8" - ) + self.signer.SignCancelOrder.restype = StrOrErr + + result = self.signer.SignCancelOrder(market_index, order_index, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_withdraw(self, usdc_amount, nonce=-1): self.signer.SignWithdraw.argtypes = [ctypes.c_longlong, ctypes.c_longlong] - self.signer.SignWithdraw.restype = ctypes.c_char_p - return self.signer.SignWithdraw(usdc_amount, nonce).decode("utf-8") + self.signer.SignWithdraw.restype = StrOrErr + + result = self.signer.SignWithdraw(usdc_amount, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_create_sub_account(self, nonce=-1): self.signer.SignCreateSubAccount.argtypes = [ctypes.c_longlong] - self.signer.SignCreateSubAccount.restype = ctypes.c_char_p - return self.signer.SignCreateSubAccount(nonce).decode("utf-8") + self.signer.SignCreateSubAccount.restype = StrOrErr + + result = self.signer.SignCreateSubAccount(nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_cancel_all_orders(self, time_in_force, time, nonce=-1): self.signer.SignCancelAllOrders.argtypes = [ @@ -182,14 +273,16 @@ def sign_cancel_all_orders(self, time_in_force, time, nonce=-1): ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignCancelAllOrders.restype = ctypes.c_char_p - return self.signer.SignCancelAllOrders(time_in_force, time, nonce).decode( - "utf-8" - ) + self.signer.SignCancelAllOrders.restype = StrOrErr - def sign_modify_order( - self, market_index, order_index, base_amount, price, trigger_price, nonce=-1 - ): + result = self.signer.SignCancelAllOrders(time_in_force, time, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error + + def sign_modify_order(self, market_index, order_index, base_amount, price, trigger_price, nonce=-1): self.signer.SignModifyOrder.argtypes = [ ctypes.c_int, ctypes.c_longlong, @@ -198,10 +291,14 @@ def sign_modify_order( ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignModifyOrder.restype = ctypes.c_char_p - return self.signer.SignModifyOrder( - market_index, order_index, base_amount, price, trigger_price, nonce - ).decode("utf-8") + self.signer.SignModifyOrder.restype = StrOrErr + + result = self.signer.SignModifyOrder(market_index, order_index, base_amount, price, trigger_price, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_transfer(self, to_account_index, usdc_amount, nonce=-1): self.signer.SignTransfer.argtypes = [ @@ -209,28 +306,32 @@ def sign_transfer(self, to_account_index, usdc_amount, nonce=-1): ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignTransfer.restype = ctypes.c_char_p - return self.signer.SignTransfer(to_account_index, usdc_amount, nonce).decode( - "utf-8" - ) + self.signer.SignTransfer.restype = StrOrErr - def sign_create_public_pool( - self, operator_fee, initial_total_shares, min_operator_share_rate, nonce=-1 - ): + result = self.signer.SignTransfer(to_account_index, usdc_amount, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error + + def sign_create_public_pool(self, operator_fee, initial_total_shares, min_operator_share_rate, nonce=-1): self.signer.SignCreatePublicPool.argtypes = [ ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignCreatePublicPool.restype = ctypes.c_char_p - return self.signer.SignCreatePublicPool( - operator_fee, initial_total_shares, min_operator_share_rate, nonce - ).decode("utf-8") + self.signer.SignCreatePublicPool.restype = StrOrErr - def sign_update_public_pool( - self, public_pool_index, status, operator_fee, min_operator_share_rate, nonce=-1 - ): + result = self.signer.SignCreatePublicPool(operator_fee, initial_total_shares, min_operator_share_rate, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error + + def sign_update_public_pool(self, public_pool_index, status, operator_fee, min_operator_share_rate, nonce=-1): self.signer.SignUpdatePublicPool.argtypes = [ ctypes.c_longlong, ctypes.c_int, @@ -238,10 +339,16 @@ def sign_update_public_pool( ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignUpdatePublicPool.restype = ctypes.c_char_p - return self.signer.SignUpdatePublicPool( + self.signer.SignUpdatePublicPool.restype = StrOrErr + + result = self.signer.SignUpdatePublicPool( public_pool_index, status, operator_fee, min_operator_share_rate, nonce - ).decode("utf-8") + ) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_mint_shares(self, public_pool_index, share_amount, nonce=-1): self.signer.SignMintShares.argtypes = [ @@ -249,10 +356,14 @@ def sign_mint_shares(self, public_pool_index, share_amount, nonce=-1): ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignMintShares.restype = ctypes.c_char_p - return self.signer.SignMintShares( - public_pool_index, share_amount, nonce - ).decode("utf-8") + self.signer.SignMintShares.restype = StrOrErr + + result = self.signer.SignMintShares(public_pool_index, share_amount, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_burn_shares(self, public_pool_index, share_amount, nonce=-1): self.signer.SignBurnShares.argtypes = [ @@ -260,10 +371,14 @@ def sign_burn_shares(self, public_pool_index, share_amount, nonce=-1): ctypes.c_longlong, ctypes.c_longlong, ] - self.signer.SignBurnShares.restype = ctypes.c_char_p - return self.signer.SignBurnShares( - public_pool_index, share_amount, nonce - ).decode("utf-8") + self.signer.SignBurnShares.restype = StrOrErr + + result = self.signer.SignBurnShares(public_pool_index, share_amount, nonce) + + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error def sign_update_leverage(self, market_index, leverage, nonce=-1): self.signer.SignUpdateLeverage.argtypes = [ @@ -271,17 +386,38 @@ def sign_update_leverage(self, market_index, leverage, nonce=-1): ctypes.c_int, ctypes.c_longlong, ] - self.signer.SignUpdateLeverage.restype = ctypes.c_char_p - return self.signer.SignUpdateLeverage(market_index, leverage, nonce).decode( - "utf-8" - ) + self.signer.SignUpdateLeverage.restype = StrOrErr + + result = self.signer.SignUpdateLeverage(market_index, leverage, nonce) - def create_auth_token_with_expiry(self, deadline: int=DEFAULT_10_MIN_AUTH_EXPIRY): + tx_info = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return tx_info, error + + def create_auth_token_with_expiry(self, deadline: int = DEFAULT_10_MIN_AUTH_EXPIRY): if deadline == SignerClient.DEFAULT_10_MIN_AUTH_EXPIRY: deadline = int(time.time() + 10 * SignerClient.MINUTE) self.signer.CreateAuthToken.argtypes = [ctypes.c_longlong] - self.signer.CreateAuthToken.restype = ctypes.c_char_p - return self.signer.CreateAuthToken(deadline).decode("utf-8") + self.signer.CreateAuthToken.restype = StrOrErr + + result = self.signer.CreateAuthToken(deadline) + + auth = result.str.decode("utf-8") if result.str else None + error = result.err.decode("utf-8") if result.err else None + + return auth, error + + async def change_api_key(self, eth_private_key: str, new_pubkey: str, nonce=-1): + tx_info, error = self.sign_change_api_key(eth_private_key, new_pubkey, nonce) + if error is not None: + return None, error + + logging.debug(f"Change Pub Key Tx Info: {tx_info}") + + api_response = await self.send_tx(tx_type=self.TX_TYPE_CHANGE_PUB_KEY, tx_info=tx_info) + logging.debug(f"Change Pub Key Send Tx Response: {api_response}") + return api_response, None async def create_order( self, @@ -296,8 +432,8 @@ async def create_order( trigger_price=NIL_TRIGGER_PRICE, order_expiry=-1, nonce=-1, - ) -> (CreateOrder, TxHash): - tx_info = self.sign_create_order( + ) -> (CreateOrder, TxHash, str): + tx_info, error = self.sign_create_order( market_index, client_order_index, base_amount, @@ -310,131 +446,141 @@ async def create_order( order_expiry, nonce, ) + if error is not None: + return None, None, error logging.debug(f"Create Order Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_CREATE_ORDER, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_CREATE_ORDER, tx_info=tx_info) logging.debug(f"Create Order Send Tx Response: {api_response}") - return CreateOrder.from_json(tx_info), api_response + return CreateOrder.from_json(tx_info), api_response, None - async def cancel_order( - self, market_index, order_index, nonce=-1 - ) -> (CancelOrder, TxHash): - tx_info = self.sign_cancel_order(market_index, order_index, nonce) + async def create_market_order( + self, market_index, client_order_index, base_amount, avg_execution_price, is_ask, reduce_only: bool = False + ) -> (CreateOrder, TxHash, str): + return await self.create_order( + market_index, + client_order_index, + base_amount, + avg_execution_price, + is_ask, + order_type=self.ORDER_TYPE_MARKET, + time_in_force=self.ORDER_TIME_IN_FORCE_IMMEDIATE_OR_CANCEL, + order_expiry=self.DEFAULT_IOC_EXPIRY, + reduce_only=reduce_only, + ) + + async def cancel_order(self, market_index, order_index, nonce=-1) -> (CancelOrder, TxHash, str): + tx_info, error = self.sign_cancel_order(market_index, order_index, nonce) + if error is not None: + return None, None, error logging.debug(f"Cancel Order Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_CANCEL_ORDER, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_CANCEL_ORDER, tx_info=tx_info) logging.debug(f"Cancel Order Send Tx Response: {api_response}") - return CancelOrder.from_json(tx_info), api_response + return CancelOrder.from_json(tx_info), api_response, None async def withdraw(self, usdc_amount, nonce=-1) -> (Withdraw, TxHash): usdc_amount = int(usdc_amount * self.USDC_TICKER_SCALE) - tx_info = self.sign_withdraw(usdc_amount, nonce) + tx_info, error = self.sign_withdraw(usdc_amount, nonce) + if error is not None: + return None, None, error logging.debug(f"Withdraw Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_WITHDRAW, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_WITHDRAW, tx_info=tx_info) logging.debug(f"Withdraw Send Tx Response: {api_response}") - return Withdraw.from_json(tx_info), api_response + return Withdraw.from_json(tx_info), api_response, None async def create_sub_account(self, nonce=-1): - tx_info = self.sign_create_sub_account(nonce) + tx_info, error = self.sign_create_sub_account(nonce) + if error is not None: + return None, error logging.debug(f"Create Sub Account Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_CREATE_SUB_ACCOUNT, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_CREATE_SUB_ACCOUNT, tx_info=tx_info) logging.debug(f"Create Sub Account Send Tx Response: {api_response}") - return api_response + return api_response, None async def cancel_all_orders(self, time_in_force, time, nonce=-1): - tx_info = self.sign_cancel_all_orders(time_in_force, time, nonce) + tx_info, error = self.sign_cancel_all_orders(time_in_force, time, nonce) + if error is not None: + return None, error logging.debug(f"Cancel All Orders Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_CANCEL_ALL_ORDERS, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_CANCEL_ALL_ORDERS, tx_info=tx_info) logging.debug(f"Cancel All Orders Send Tx Response: {api_response}") - return api_response + return api_response, None - async def modify_order( - self, market_index, order_index, base_amount, price, trigger_price, nonce=-1 - ): - tx_info = self.sign_modify_order( - market_index, order_index, base_amount, price, trigger_price, nonce - ) + async def modify_order(self, market_index, order_index, base_amount, price, trigger_price, nonce=-1): + tx_info, error = self.sign_modify_order(market_index, order_index, base_amount, price, trigger_price, nonce) + if error is not None: + return None, error logging.debug(f"Modify Order Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_MODIFY_ORDER, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_MODIFY_ORDER, tx_info=tx_info) logging.debug(f"Modify Order Send Tx Response: {api_response}") - return api_response + return api_response, None async def transfer(self, to_account_index, usdc_amount, nonce=-1): usdc_amount = int(usdc_amount * self.USDC_TICKER_SCALE) - tx_info = self.sign_transfer(to_account_index, usdc_amount, nonce) + tx_info, error = self.sign_transfer(to_account_index, usdc_amount, nonce) + if error is not None: + return None, error logging.debug(f"Transfer Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_TRANSFER, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_TRANSFER, tx_info=tx_info) logging.debug(f"Transfer Send Tx Response: {api_response}") - return api_response + return api_response, None - async def create_public_pool( - self, operator_fee, initial_total_shares, min_operator_share_rate, nonce=-1 - ): - tx_info = self.sign_create_public_pool( + async def create_public_pool(self, operator_fee, initial_total_shares, min_operator_share_rate, nonce=-1): + tx_info, error = self.sign_create_public_pool( operator_fee, initial_total_shares, min_operator_share_rate, nonce ) + if error is not None: + return None, error logging.debug(f"Create Public Pool Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_CREATE_PUBLIC_POOL, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_CREATE_PUBLIC_POOL, tx_info=tx_info) logging.debug(f"Create Public Pool Send Tx Response: {api_response}") - return api_response + return api_response, None - async def update_public_pool( - self, public_pool_index, status, operator_fee, min_operator_share_rate, nonce=-1 - ): - tx_info = self.sign_update_public_pool( + async def update_public_pool(self, public_pool_index, status, operator_fee, min_operator_share_rate, nonce=-1): + tx_info, error = self.sign_update_public_pool( public_pool_index, status, operator_fee, min_operator_share_rate, nonce ) + if error is not None: + return None, error logging.debug(f"Update Public Pool Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_UPDATE_PUBLIC_POOL, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_UPDATE_PUBLIC_POOL, tx_info=tx_info) logging.debug(f"Update Public Pool Send Tx Response: {api_response}") - return api_response + return api_response, None async def mint_shares(self, public_pool_index, share_amount, nonce=-1): - tx_info = self.sign_mint_shares(public_pool_index, share_amount, nonce) + tx_info, error = self.sign_mint_shares(public_pool_index, share_amount, nonce) + if error is not None: + return None, error logging.debug(f"Mint Shares Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_MINT_SHARES, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_MINT_SHARES, tx_info=tx_info) logging.debug(f"Mint Shares Send Tx Response: {api_response}") - return api_response + return api_response, None async def burn_shares(self, public_pool_index, share_amount, nonce=-1): - tx_info = self.sign_burn_shares(public_pool_index, share_amount, nonce) + tx_info, error = self.sign_burn_shares(public_pool_index, share_amount, nonce) + if error is not None: + return None, error logging.debug(f"Burn Shares Tx Info: {tx_info}") - api_response = await self.tx_api.send_tx( - tx_type=self.TX_TYPE_BURN_SHARES, tx_info=tx_info - ) + api_response = await self.send_tx(tx_type=self.TX_TYPE_BURN_SHARES, tx_info=tx_info) logging.debug(f"Burn Shares Send Tx Response: {api_response}") - return api_response + return api_response, None + + async def send_tx(self, tx_type: StrictInt, tx_info: str) -> TxHash: + if tx_info[0] != "{": + raise Exception(tx_info) + return await self.tx_api.send_tx(tx_type=tx_type, tx_info=tx_info) async def close(self): await self.api_client.close() diff --git a/lighter/signers/README.md b/lighter/signers/README.md new file mode 100644 index 0000000..c1e3962 --- /dev/null +++ b/lighter/signers/README.md @@ -0,0 +1 @@ +Check the [go-sdk](https://github.com/elliottech/lighter-go) to see the source code for the binaries or to generate them youself. \ No newline at end of file diff --git a/lighter/signers/signer-amd64.so b/lighter/signers/signer-amd64.so index b98128e..85b688e 100644 Binary files a/lighter/signers/signer-amd64.so and b/lighter/signers/signer-amd64.so differ diff --git a/lighter/signers/signer-arm64.dylib b/lighter/signers/signer-arm64.dylib index d0176fa..bf526f7 100644 Binary files a/lighter/signers/signer-arm64.dylib and b/lighter/signers/signer-arm64.dylib differ diff --git a/openapi.json b/openapi.json index 8f6cbe6..870d264 100644 --- a/openapi.json +++ b/openapi.json @@ -130,7 +130,7 @@ "consumes": [ "multipart/form-data" ], - "description": "Get account active orders" + "description": "Get account active orders. `auth` can be generated using the SDK." } }, "/api/v1/accountInactiveOrders": { @@ -152,6 +152,12 @@ } }, "parameters": [ + { + "name": "auth", + "in": "query", + "required": true, + "type": "string" + }, { "name": "account_index", "in": "query", @@ -203,7 +209,7 @@ "consumes": [ "multipart/form-data" ], - "description": "Get account active orders" + "description": "Get account inactive orders" } }, "/api/v1/accountOrders": { @@ -225,6 +231,12 @@ } }, "parameters": [ + { + "name": "auth", + "in": "query", + "required": true, + "type": "string" + }, { "name": "account_index", "in": "query", @@ -264,60 +276,6 @@ "description": "Get account orders" } }, - "/api/v1/accountPendingTxs": { - "get": { - "summary": "accountPendingTxs", - "operationId": "accountPendingTxs", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/Txs" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/ResultCode" - } - } - }, - "parameters": [ - { - "name": "by", - "in": "query", - "required": true, - "type": "string", - "enum": [ - "account_index" - ] - }, - { - "name": "value", - "in": "query", - "required": true, - "type": "string" - }, - { - "name": "types", - "in": "query", - "required": false, - "type": "array", - "items": { - "type": "integer", - "format": "uint8" - } - } - ], - "tags": [ - "transaction" - ], - "consumes": [ - "multipart/form-data" - ], - "description": "Get pending transactions of a specific account" - } - }, "/api/v1/accountTxs": { "get": { "summary": "accountTxs", @@ -388,62 +346,6 @@ "description": "Get transactions of a specific account" } }, - "/api/v1/accounts": { - "get": { - "summary": "accounts", - "operationId": "accounts", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/Accounts" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/ResultCode" - } - } - }, - "parameters": [ - { - "name": "index", - "in": "query", - "required": false, - "type": "integer", - "format": "int64" - }, - { - "name": "limit", - "in": "query", - "required": true, - "type": "integer", - "format": "int64", - "minimum": 1, - "maximum": 100 - }, - { - "name": "sort", - "in": "query", - "required": false, - "type": "string", - "enum": [ - "asc", - "desc" - ], - "default": "asc" - } - ], - "tags": [ - "account" - ], - "consumes": [ - "multipart/form-data" - ], - "description": "Get accounts returns accounts by account index" - } - }, "/api/v1/accountsByL1Address": { "get": { "summary": "accountsByL1Address", @@ -508,7 +410,7 @@ { "name": "api_key_index", "in": "query", - "required": true, + "required": false, "type": "integer", "format": "uint8", "default": "255" @@ -520,7 +422,7 @@ "consumes": [ "multipart/form-data" ], - "description": "Get account api key" + "description": "Get account api key. Set `api_key_index` to 255 to retrieve all api keys associated with the account." } }, "/api/v1/block": { @@ -714,14 +616,18 @@ "in": "query", "required": true, "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 }, { "name": "end_timestamp", "in": "query", "required": true, "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 }, { "name": "count_back", @@ -791,6 +697,19 @@ } }, "parameters": [ + { + "name": "account_index", + "in": "query", + "required": true, + "type": "integer", + "format": "int64" + }, + { + "name": "auth", + "in": "query", + "required": true, + "type": "string" + }, { "name": "l1_address", "in": "query", @@ -924,14 +843,18 @@ "in": "query", "required": true, "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 }, { "name": "end_timestamp", "in": "query", "required": true, "type": "integer", - "format": "int64" + "format": "int64", + "minimum": 0, + "maximum": 5000000000000 }, { "name": "count_back", @@ -950,65 +873,6 @@ "description": "Get fundings" } }, - "/api/v1/isWhitelisted": { - "get": { - "summary": "isWhitelisted", - "operationId": "isWhitelisted", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/IsWhitelisted" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/ResultCode" - } - } - }, - "parameters": [ - { - "name": "l1_address", - "in": "query", - "required": true, - "type": "string" - } - ], - "tags": [ - "account" - ], - "consumes": [ - "multipart/form-data" - ], - "description": "Get is account whitelisted" - } - }, - "/api/v1/layer2BasicInfo": { - "get": { - "summary": "layer2BasicInfo", - "operationId": "layer2BasicInfo", - "responses": { - "200": { - "description": "A successful response.", - "schema": { - "$ref": "#/definitions/Layer2BasicInfo" - } - }, - "400": { - "description": "Bad request", - "schema": { - "$ref": "#/definitions/ResultCode" - } - } - }, - "tags": [ - "info" - ], - "description": "Get zklighter general info, including contract address, and count of transactions and active users" - } - }, "/api/v1/nextNonce": { "get": { "summary": "nextNonce", @@ -1049,7 +913,7 @@ "consumes": [ "multipart/form-data" ], - "description": "Get next nonce for a specific account" + "description": "Get next nonce for a specific account and api key" } }, "/api/v1/orderBookDetails": { @@ -1171,51 +1035,6 @@ "description": "Get order books metadata.