diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 2f225cd..071d41f 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -1,6 +1,7 @@ docs/Account.md docs/AccountApi.md docs/AccountApiKeys.md +docs/AccountAsset.md docs/AccountLimits.md docs/AccountMarginStats.md docs/AccountMarketStats.md @@ -14,9 +15,12 @@ docs/Announcement.md docs/AnnouncementApi.md docs/Announcements.md docs/ApiKey.md +docs/Asset.md +docs/AssetDetails.md docs/Block.md docs/BlockApi.md docs/Blocks.md +docs/Bridge.md docs/BridgeApi.md docs/BridgeSupportedNetwork.md docs/Candlestick.md @@ -46,28 +50,27 @@ docs/LiqTrade.md docs/Liquidation.md docs/LiquidationInfo.md docs/LiquidationInfos.md -docs/MarketInfo.md +docs/MarketConfig.md docs/NextNonce.md docs/NotificationApi.md docs/Order.md docs/OrderApi.md docs/OrderBook.md docs/OrderBookDepth.md -docs/OrderBookDetail.md docs/OrderBookDetails.md docs/OrderBookOrders.md docs/OrderBookStats.md docs/OrderBooks.md docs/Orders.md +docs/PerpsMarketStats.md +docs/PerpsOrderBookDetail.md docs/PnLEntry.md docs/PositionFunding.md docs/PositionFundings.md docs/PriceLevel.md -docs/PublicPool.md docs/PublicPoolInfo.md docs/PublicPoolMetadata.md docs/PublicPoolShare.md -docs/PublicPools.md docs/ReferralApi.md docs/ReferralPointEntry.md docs/ReferralPoints.md @@ -81,8 +84,10 @@ docs/ReqGetAccountLimits.md docs/ReqGetAccountMetadata.md docs/ReqGetAccountPnL.md docs/ReqGetAccountTxs.md +docs/ReqGetAssetDetails.md docs/ReqGetBlock.md docs/ReqGetBlockTxs.md +docs/ReqGetBridgesByL1Addr.md docs/ReqGetByAccount.md docs/ReqGetCandlesticks.md docs/ReqGetDepositHistory.md @@ -97,7 +102,6 @@ docs/ReqGetOrderBookDetails.md docs/ReqGetOrderBookOrders.md docs/ReqGetOrderBooks.md docs/ReqGetPositionFunding.md -docs/ReqGetPublicPools.md docs/ReqGetPublicPoolsMetadata.md docs/ReqGetRangeWithCursor.md docs/ReqGetRangeWithIndex.md @@ -110,10 +114,14 @@ docs/ReqGetTransferHistory.md docs/ReqGetTx.md docs/ReqGetWithdrawHistory.md docs/RespChangeAccountTier.md +docs/RespGetBridgesByL1Addr.md docs/RespGetFastBridgeInfo.md +docs/RespGetIsNextBridgeFast.md docs/RespPublicPoolsMetadata.md docs/RespSendTx.md docs/RespSendTxBatch.md +docs/RespUpdateKickback.md +docs/RespUpdateReferralCode.md docs/RespWithdrawalDelay.md docs/ResultCode.md docs/RiskInfo.md @@ -121,6 +129,8 @@ docs/RiskParameters.md docs/RootApi.md docs/SharePrice.md docs/SimpleOrder.md +docs/SpotMarketStats.md +docs/SpotOrderBookDetail.md docs/Status.md docs/SubAccounts.md docs/Ticker.md @@ -160,6 +170,7 @@ lighter/exceptions.py lighter/models/__init__.py lighter/models/account.py lighter/models/account_api_keys.py +lighter/models/account_asset.py lighter/models/account_limits.py lighter/models/account_margin_stats.py lighter/models/account_market_stats.py @@ -172,8 +183,11 @@ lighter/models/account_trade_stats.py lighter/models/announcement.py lighter/models/announcements.py lighter/models/api_key.py +lighter/models/asset.py +lighter/models/asset_details.py lighter/models/block.py lighter/models/blocks.py +lighter/models/bridge.py lighter/models/bridge_supported_network.py lighter/models/candlestick.py lighter/models/candlesticks.py @@ -199,26 +213,25 @@ lighter/models/liq_trade.py lighter/models/liquidation.py lighter/models/liquidation_info.py lighter/models/liquidation_infos.py -lighter/models/market_info.py +lighter/models/market_config.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 lighter/models/order_book_stats.py lighter/models/order_books.py lighter/models/orders.py +lighter/models/perps_market_stats.py +lighter/models/perps_order_book_detail.py lighter/models/pn_l_entry.py lighter/models/position_funding.py lighter/models/position_fundings.py lighter/models/price_level.py -lighter/models/public_pool.py lighter/models/public_pool_info.py lighter/models/public_pool_metadata.py lighter/models/public_pool_share.py -lighter/models/public_pools.py lighter/models/referral_point_entry.py lighter/models/referral_points.py lighter/models/req_export_data.py @@ -231,8 +244,10 @@ lighter/models/req_get_account_limits.py lighter/models/req_get_account_metadata.py lighter/models/req_get_account_pn_l.py lighter/models/req_get_account_txs.py +lighter/models/req_get_asset_details.py lighter/models/req_get_block.py lighter/models/req_get_block_txs.py +lighter/models/req_get_bridges_by_l1_addr.py lighter/models/req_get_by_account.py lighter/models/req_get_candlesticks.py lighter/models/req_get_deposit_history.py @@ -247,7 +262,6 @@ 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_position_funding.py -lighter/models/req_get_public_pools.py lighter/models/req_get_public_pools_metadata.py lighter/models/req_get_range_with_cursor.py lighter/models/req_get_range_with_index.py @@ -260,16 +274,22 @@ lighter/models/req_get_transfer_history.py lighter/models/req_get_tx.py lighter/models/req_get_withdraw_history.py lighter/models/resp_change_account_tier.py +lighter/models/resp_get_bridges_by_l1_addr.py lighter/models/resp_get_fast_bridge_info.py +lighter/models/resp_get_is_next_bridge_fast.py lighter/models/resp_public_pools_metadata.py lighter/models/resp_send_tx.py lighter/models/resp_send_tx_batch.py +lighter/models/resp_update_kickback.py +lighter/models/resp_update_referral_code.py lighter/models/resp_withdrawal_delay.py lighter/models/result_code.py lighter/models/risk_info.py lighter/models/risk_parameters.py lighter/models/share_price.py lighter/models/simple_order.py +lighter/models/spot_market_stats.py +lighter/models/spot_order_book_detail.py lighter/models/status.py lighter/models/sub_accounts.py lighter/models/ticker.py @@ -291,4 +311,19 @@ lighter/rest.py setup.cfg test-requirements.txt test/__init__.py +test/test_account_asset.py +test/test_asset.py +test/test_asset_details.py +test/test_bridge.py +test/test_market_config.py +test/test_perps_market_stats.py +test/test_perps_order_book_detail.py +test/test_req_get_asset_details.py +test/test_req_get_bridges_by_l1_addr.py +test/test_resp_get_bridges_by_l1_addr.py +test/test_resp_get_is_next_bridge_fast.py +test/test_resp_update_kickback.py +test/test_resp_update_referral_code.py +test/test_spot_market_stats.py +test/test_spot_order_book_detail.py tox.ini diff --git a/docs/Account.md b/docs/Account.md index 173acf4..68a4b51 100644 --- a/docs/Account.md +++ b/docs/Account.md @@ -12,7 +12,6 @@ Name | Type | Description | Notes **l1_address** | **str** | | **cancel_all_time** | **int** | | **total_order_count** | **int** | | -**total_isolated_order_count** | **int** | | **pending_order_count** | **int** | | **available_balance** | **str** | | **status** | **int** | | diff --git a/docs/AccountApi.md b/docs/AccountApi.md index 9e90478..77df45d 100644 --- a/docs/AccountApi.md +++ b/docs/AccountApi.md @@ -14,7 +14,6 @@ Method | HTTP request | Description [**liquidations**](AccountApi.md#liquidations) | **GET** /api/v1/liquidations | liquidations [**pnl**](AccountApi.md#pnl) | **GET** /api/v1/pnl | pnl [**position_funding**](AccountApi.md#position_funding) | **GET** /api/v1/positionFunding | positionFunding -[**public_pools**](AccountApi.md#public_pools) | **GET** /api/v1/publicPools | publicPools [**public_pools_metadata**](AccountApi.md#public_pools_metadata) | **GET** /api/v1/publicPoolsMetadata | publicPoolsMetadata @@ -770,85 +769,6 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) -# **public_pools** -> PublicPools public_pools(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) - -publicPools - -Get public pools - -### Example - - -```python -import lighter -from lighter.models.public_pools import PublicPools -from lighter.rest import ApiException -from pprint import pprint - -# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai -# See configuration.py for a list of all supported configuration parameters. -configuration = lighter.Configuration( - host = "https://mainnet.zklighter.elliot.ai" -) - - -# Enter a context with an instance of the API client -async with lighter.ApiClient(configuration) as api_client: - # Create an instance of the API class - api_instance = lighter.AccountApi(api_client) - index = 56 # int | - limit = 56 # int | - authorization = 'authorization_example' # str | (optional) - auth = 'auth_example' # str | (optional) - filter = 'filter_example' # str | (optional) - account_index = 56 # int | (optional) - - try: - # publicPools - api_response = await api_instance.public_pools(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) - print("The response of AccountApi->public_pools:\n") - pprint(api_response) - except Exception as e: - print("Exception when calling AccountApi->public_pools: %s\n" % e) -``` - - - -### Parameters - - -Name | Type | Description | Notes -------------- | ------------- | ------------- | ------------- - **index** | **int**| | - **limit** | **int**| | - **authorization** | **str**| | [optional] - **auth** | **str**| | [optional] - **filter** | **str**| | [optional] - **account_index** | **int**| | [optional] - -### Return type - -[**PublicPools**](PublicPools.md) - -### Authorization - -No authorization required - -### HTTP request headers - - - **Content-Type**: Not defined - - **Accept**: application/json - -### HTTP response details - -| Status code | Description | Response headers | -|-------------|-------------|------------------| -**200** | A successful response. | - | -**400** | Bad request | - | - -[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) - # **public_pools_metadata** > RespPublicPoolsMetadata public_pools_metadata(index, limit, authorization=authorization, auth=auth, filter=filter, account_index=account_index) diff --git a/docs/AccountAsset.md b/docs/AccountAsset.md new file mode 100644 index 0000000..45956b9 --- /dev/null +++ b/docs/AccountAsset.md @@ -0,0 +1,32 @@ +# AccountAsset + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | +**asset_id** | **int** | | +**balance** | **str** | | +**locked_balance** | **str** | | + +## Example + +```python +from lighter.models.account_asset import AccountAsset + +# TODO update the JSON string below +json = "{}" +# create an instance of AccountAsset from a JSON string +account_asset_instance = AccountAsset.from_json(json) +# print the JSON string representation of the object +print(AccountAsset.to_json()) + +# convert the object into a dict +account_asset_dict = account_asset_instance.to_dict() +# create an instance of AccountAsset from a dict +account_asset_from_dict = AccountAsset.from_dict(account_asset_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/AccountLimits.md b/docs/AccountLimits.md index 0ca7ba2..f19b1a0 100644 --- a/docs/AccountLimits.md +++ b/docs/AccountLimits.md @@ -8,7 +8,9 @@ Name | Type | Description | Notes **code** | **int** | | **message** | **str** | | [optional] **max_llp_percentage** | **int** | | +**max_llp_amount** | **str** | | **user_tier** | **str** | | +**can_create_public_pool** | **bool** | | ## Example diff --git a/docs/Announcement.md b/docs/Announcement.md index 271e6d9..3cb4b46 100644 --- a/docs/Announcement.md +++ b/docs/Announcement.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **title** | **str** | | **content** | **str** | | **created_at** | **int** | | +**expired_at** | **int** | | ## Example diff --git a/docs/Asset.md b/docs/Asset.md new file mode 100644 index 0000000..1987347 --- /dev/null +++ b/docs/Asset.md @@ -0,0 +1,37 @@ +# Asset + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**asset_id** | **int** | | +**symbol** | **str** | | +**l1_decimals** | **int** | | +**decimals** | **int** | | +**min_transfer_amount** | **str** | | +**min_withdrawal_amount** | **str** | | +**margin_mode** | **str** | | +**index_price** | **str** | | +**l1_address** | **str** | | + +## Example + +```python +from lighter.models.asset import Asset + +# TODO update the JSON string below +json = "{}" +# create an instance of Asset from a JSON string +asset_instance = Asset.from_json(json) +# print the JSON string representation of the object +print(Asset.to_json()) + +# convert the object into a dict +asset_dict = asset_instance.to_dict() +# create an instance of Asset from a dict +asset_from_dict = Asset.from_dict(asset_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/PublicPools.md b/docs/AssetDetails.md similarity index 52% rename from docs/PublicPools.md rename to docs/AssetDetails.md index 5ebeb86..df406f7 100644 --- a/docs/PublicPools.md +++ b/docs/AssetDetails.md @@ -1,4 +1,4 @@ -# PublicPools +# AssetDetails ## Properties @@ -7,25 +7,24 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **code** | **int** | | **message** | **str** | | [optional] -**total** | **int** | | -**public_pools** | [**List[PublicPool]**](PublicPool.md) | | +**asset_details** | [**List[Asset]**](Asset.md) | | ## Example ```python -from lighter.models.public_pools import PublicPools +from lighter.models.asset_details import AssetDetails # TODO update the JSON string below json = "{}" -# create an instance of PublicPools from a JSON string -public_pools_instance = PublicPools.from_json(json) +# create an instance of AssetDetails from a JSON string +asset_details_instance = AssetDetails.from_json(json) # print the JSON string representation of the object -print(PublicPools.to_json()) +print(AssetDetails.to_json()) # convert the object into a dict -public_pools_dict = public_pools_instance.to_dict() -# create an instance of PublicPools from a dict -public_pools_from_dict = PublicPools.from_dict(public_pools_dict) +asset_details_dict = asset_details_instance.to_dict() +# create an instance of AssetDetails from a dict +asset_details_from_dict = AssetDetails.from_dict(asset_details_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Bridge.md b/docs/Bridge.md new file mode 100644 index 0000000..9147bde --- /dev/null +++ b/docs/Bridge.md @@ -0,0 +1,43 @@ +# Bridge + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | +**version** | **int** | | +**source** | **str** | | +**source_chain_id** | **str** | | +**fast_bridge_tx_hash** | **str** | | +**batch_claim_tx_hash** | **str** | | +**cctp_burn_tx_hash** | **str** | | +**amount** | **str** | | +**intent_address** | **str** | | +**status** | **str** | | +**step** | **str** | | +**description** | **str** | | +**created_at** | **int** | | +**updated_at** | **int** | | +**is_external_deposit** | **bool** | | + +## Example + +```python +from lighter.models.bridge import Bridge + +# TODO update the JSON string below +json = "{}" +# create an instance of Bridge from a JSON string +bridge_instance = Bridge.from_json(json) +# print the JSON string representation of the object +print(Bridge.to_json()) + +# convert the object into a dict +bridge_dict = bridge_instance.to_dict() +# create an instance of Bridge from a dict +bridge_from_dict = Bridge.from_dict(bridge_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/BridgeApi.md b/docs/BridgeApi.md index 4180a8f..29092ef 100644 --- a/docs/BridgeApi.md +++ b/docs/BridgeApi.md @@ -4,9 +4,149 @@ All URIs are relative to *https://mainnet.zklighter.elliot.ai* Method | HTTP request | Description ------------- | ------------- | ------------- +[**bridges**](BridgeApi.md#bridges) | **GET** /api/v1/bridges | bridges +[**bridges_is_next_bridge_fast**](BridgeApi.md#bridges_is_next_bridge_fast) | **GET** /api/v1/bridges/isNextBridgeFast | bridges_isNextBridgeFast [**fastbridge_info**](BridgeApi.md#fastbridge_info) | **GET** /api/v1/fastbridge/info | fastbridge_info +# **bridges** +> RespGetBridgesByL1Addr bridges(l1_address) + +bridges + +Get bridges for given l1 address + +### Example + + +```python +import lighter +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.BridgeApi(api_client) + l1_address = 'l1_address_example' # str | + + try: + # bridges + api_response = await api_instance.bridges(l1_address) + print("The response of BridgeApi->bridges:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BridgeApi->bridges: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **l1_address** | **str**| | + +### Return type + +[**RespGetBridgesByL1Addr**](RespGetBridgesByL1Addr.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **bridges_is_next_bridge_fast** +> RespGetIsNextBridgeFast bridges_is_next_bridge_fast(l1_address) + +bridges_isNextBridgeFast + +Get if next bridge is fast + +### Example + + +```python +import lighter +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.BridgeApi(api_client) + l1_address = 'l1_address_example' # str | + + try: + # bridges_isNextBridgeFast + api_response = await api_instance.bridges_is_next_bridge_fast(l1_address) + print("The response of BridgeApi->bridges_is_next_bridge_fast:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling BridgeApi->bridges_is_next_bridge_fast: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **l1_address** | **str**| | + +### Return type + +[**RespGetIsNextBridgeFast**](RespGetIsNextBridgeFast.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **fastbridge_info** > RespGetFastBridgeInfo fastbridge_info() diff --git a/docs/Candlestick.md b/docs/Candlestick.md index 6071dfc..c7f48e8 100644 --- a/docs/Candlestick.md +++ b/docs/Candlestick.md @@ -10,6 +10,10 @@ Name | Type | Description | Notes **high** | **float** | | **low** | **float** | | **close** | **float** | | +**open_raw** | **float** | | +**high_raw** | **float** | | +**low_raw** | **float** | | +**close_raw** | **float** | | **volume0** | **float** | | **volume1** | **float** | | **last_trade_id** | **int** | | diff --git a/docs/DepositHistoryItem.md b/docs/DepositHistoryItem.md index 3e850fe..c046dfc 100644 --- a/docs/DepositHistoryItem.md +++ b/docs/DepositHistoryItem.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **str** | | +**asset_id** | **int** | | **amount** | **str** | | **timestamp** | **int** | | **status** | **str** | | diff --git a/docs/DetailedAccount.md b/docs/DetailedAccount.md index 768c3e2..d96f4b6 100644 --- a/docs/DetailedAccount.md +++ b/docs/DetailedAccount.md @@ -12,7 +12,6 @@ Name | Type | Description | Notes **l1_address** | **str** | | **cancel_all_time** | **int** | | **total_order_count** | **int** | | -**total_isolated_order_count** | **int** | | **pending_order_count** | **int** | | **available_balance** | **str** | | **status** | **int** | | @@ -23,6 +22,7 @@ Name | Type | Description | Notes **can_invite** | **bool** | Remove After FE uses L1 meta endpoint | **referral_points_percentage** | **str** | Remove After FE uses L1 meta endpoint | **positions** | [**List[AccountPosition]**](AccountPosition.md) | | +**assets** | [**List[AccountAsset]**](AccountAsset.md) | | **total_asset_value** | **str** | | **cross_asset_value** | **str** | | **pool_info** | [**PublicPoolInfo**](PublicPoolInfo.md) | | diff --git a/docs/DetailedCandlestick.md b/docs/DetailedCandlestick.md index 4bba057..f00f2e1 100644 --- a/docs/DetailedCandlestick.md +++ b/docs/DetailedCandlestick.md @@ -10,6 +10,10 @@ Name | Type | Description | Notes **high** | **float** | | **low** | **float** | | **close** | **float** | | +**open_raw** | **float** | | +**high_raw** | **float** | | +**low_raw** | **float** | | +**close_raw** | **float** | | **volume0** | **float** | | **volume1** | **float** | | **last_trade_id** | **int** | | diff --git a/docs/EnrichedTx.md b/docs/EnrichedTx.md index 27d2156..e9b0a32 100644 --- a/docs/EnrichedTx.md +++ b/docs/EnrichedTx.md @@ -22,6 +22,7 @@ Name | Type | Description | Notes **executed_at** | **int** | | **sequence_index** | **int** | | **parent_hash** | **str** | | +**api_key_index** | **int** | | **committed_at** | **int** | | **verified_at** | **int** | | diff --git a/docs/MarketConfig.md b/docs/MarketConfig.md new file mode 100644 index 0000000..1a94e25 --- /dev/null +++ b/docs/MarketConfig.md @@ -0,0 +1,33 @@ +# MarketConfig + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**market_margin_mode** | **int** | | +**insurance_fund_account_index** | **int** | | +**liquidation_mode** | **int** | | +**force_reduce_only** | **bool** | | +**trading_hours** | **str** | | + +## Example + +```python +from lighter.models.market_config import MarketConfig + +# TODO update the JSON string below +json = "{}" +# create an instance of MarketConfig from a JSON string +market_config_instance = MarketConfig.from_json(json) +# print the JSON string representation of the object +print(MarketConfig.to_json()) + +# convert the object into a dict +market_config_dict = market_config_instance.to_dict() +# create an instance of MarketConfig from a dict +market_config_from_dict = MarketConfig.from_dict(market_config_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Order.md b/docs/Order.md index a3415f4..c1eac6d 100644 --- a/docs/Order.md +++ b/docs/Order.md @@ -36,6 +36,8 @@ Name | Type | Description | Notes **to_cancel_order_id_0** | **str** | | **block_height** | **int** | | **timestamp** | **int** | | +**created_at** | **int** | | +**updated_at** | **int** | | ## Example diff --git a/docs/OrderApi.md b/docs/OrderApi.md index 2b59510..46d6379 100644 --- a/docs/OrderApi.md +++ b/docs/OrderApi.md @@ -6,6 +6,7 @@ Method | HTTP request | Description ------------- | ------------- | ------------- [**account_active_orders**](OrderApi.md#account_active_orders) | **GET** /api/v1/accountActiveOrders | accountActiveOrders [**account_inactive_orders**](OrderApi.md#account_inactive_orders) | **GET** /api/v1/accountInactiveOrders | accountInactiveOrders +[**asset_details**](OrderApi.md#asset_details) | **GET** /api/v1/assetDetails | assetDetails [**exchange_stats**](OrderApi.md#exchange_stats) | **GET** /api/v1/exchangeStats | exchangeStats [**export**](OrderApi.md#export) | **GET** /api/v1/export | export [**order_book_details**](OrderApi.md#order_book_details) | **GET** /api/v1/orderBookDetails | orderBookDetails @@ -173,6 +174,75 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **asset_details** +> AssetDetails asset_details(asset_id=asset_id) + +assetDetails + +Get asset details + +### Example + + +```python +import lighter +from lighter.models.asset_details import AssetDetails +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.OrderApi(api_client) + asset_id = 0 # int | (optional) (default to 0) + + try: + # assetDetails + api_response = await api_instance.asset_details(asset_id=asset_id) + print("The response of OrderApi->asset_details:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling OrderApi->asset_details: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **asset_id** | **int**| | [optional] [default to 0] + +### Return type + +[**AssetDetails**](AssetDetails.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **exchange_stats** > ExchangeStats exchange_stats() @@ -316,7 +386,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **order_book_details** -> OrderBookDetails order_book_details(market_id=market_id) +> OrderBookDetails order_book_details(market_id=market_id, filter=filter) orderBookDetails @@ -343,10 +413,11 @@ async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.OrderApi(api_client) market_id = 255 # int | (optional) (default to 255) + filter = all # str | (optional) (default to all) try: # orderBookDetails - api_response = await api_instance.order_book_details(market_id=market_id) + api_response = await api_instance.order_book_details(market_id=market_id, filter=filter) print("The response of OrderApi->order_book_details:\n") pprint(api_response) except Exception as e: @@ -361,6 +432,7 @@ async with lighter.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **market_id** | **int**| | [optional] [default to 255] + **filter** | **str**| | [optional] [default to all] ### Return type @@ -456,7 +528,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **order_books** -> OrderBooks order_books(market_id=market_id) +> OrderBooks order_books(market_id=market_id, filter=filter) orderBooks @@ -483,10 +555,11 @@ async with lighter.ApiClient(configuration) as api_client: # Create an instance of the API class api_instance = lighter.OrderApi(api_client) market_id = 255 # int | (optional) (default to 255) + filter = all # str | (optional) (default to all) try: # orderBooks - api_response = await api_instance.order_books(market_id=market_id) + api_response = await api_instance.order_books(market_id=market_id, filter=filter) print("The response of OrderApi->order_books:\n") pprint(api_response) except Exception as e: @@ -501,6 +574,7 @@ async with lighter.ApiClient(configuration) as api_client: Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **market_id** | **int**| | [optional] [default to 255] + **filter** | **str**| | [optional] [default to all] ### Return type @@ -596,7 +670,7 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) # **trades** -> Trades trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter) +> Trades trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter, role=role, type=type, aggregate=aggregate) trades @@ -633,10 +707,13 @@ async with lighter.ApiClient(configuration) as api_client: cursor = 'cursor_example' # str | (optional) var_from = -1 # int | (optional) (default to -1) ask_filter = -1 # int | (optional) (default to -1) + role = all # str | (optional) (default to all) + type = all # str | (optional) (default to all) + aggregate = False # bool | (optional) (default to False) try: # trades - api_response = await api_instance.trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter) + api_response = await api_instance.trades(sort_by, limit, authorization=authorization, auth=auth, market_id=market_id, account_index=account_index, order_index=order_index, sort_dir=sort_dir, cursor=cursor, var_from=var_from, ask_filter=ask_filter, role=role, type=type, aggregate=aggregate) print("The response of OrderApi->trades:\n") pprint(api_response) except Exception as e: @@ -661,6 +738,9 @@ Name | Type | Description | Notes **cursor** | **str**| | [optional] **var_from** | **int**| | [optional] [default to -1] **ask_filter** | **int**| | [optional] [default to -1] + **role** | **str**| | [optional] [default to all] + **type** | **str**| | [optional] [default to all] + **aggregate** | **bool**| | [optional] [default to False] ### Return type diff --git a/docs/OrderBook.md b/docs/OrderBook.md index 054b931..18d7edb 100644 --- a/docs/OrderBook.md +++ b/docs/OrderBook.md @@ -7,12 +7,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **symbol** | **str** | | **market_id** | **int** | | +**market_type** | **str** | | +**base_asset_id** | **int** | | +**quote_asset_id** | **int** | | **status** | **str** | | **taker_fee** | **str** | | **maker_fee** | **str** | | **liquidation_fee** | **str** | | **min_base_amount** | **str** | | **min_quote_amount** | **str** | | +**order_quote_limit** | **str** | | **supported_size_decimals** | **int** | | **supported_price_decimals** | **int** | | **supported_quote_decimals** | **int** | | diff --git a/docs/OrderBookDepth.md b/docs/OrderBookDepth.md index d2cafe9..6659c51 100644 --- a/docs/OrderBookDepth.md +++ b/docs/OrderBookDepth.md @@ -10,6 +10,7 @@ Name | Type | Description | Notes **asks** | [**List[PriceLevel]**](PriceLevel.md) | | **bids** | [**List[PriceLevel]**](PriceLevel.md) | | **offset** | **int** | | +**nonce** | **int** | | ## Example diff --git a/docs/OrderBookDetails.md b/docs/OrderBookDetails.md index 8480c35..0256daa 100644 --- a/docs/OrderBookDetails.md +++ b/docs/OrderBookDetails.md @@ -7,7 +7,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **code** | **int** | | **message** | **str** | | [optional] -**order_book_details** | [**List[OrderBookDetail]**](OrderBookDetail.md) | | +**order_book_details** | [**List[PerpsOrderBookDetail]**](PerpsOrderBookDetail.md) | | +**spot_order_book_details** | [**List[SpotOrderBookDetail]**](SpotOrderBookDetail.md) | | ## Example diff --git a/docs/MarketInfo.md b/docs/PerpsMarketStats.md similarity index 61% rename from docs/MarketInfo.md rename to docs/PerpsMarketStats.md index 7b495c7..bd2ed7b 100644 --- a/docs/MarketInfo.md +++ b/docs/PerpsMarketStats.md @@ -1,14 +1,18 @@ -# MarketInfo +# PerpsMarketStats ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | **market_id** | **int** | | **index_price** | **str** | | **mark_price** | **str** | | **open_interest** | **str** | | +**open_interest_limit** | **str** | | +**funding_clamp_small** | **str** | | +**funding_clamp_big** | **str** | | **last_trade_price** | **str** | | **current_funding_rate** | **str** | | **funding_rate** | **str** | | @@ -22,19 +26,19 @@ Name | Type | Description | Notes ## Example ```python -from lighter.models.market_info import MarketInfo +from lighter.models.perps_market_stats import PerpsMarketStats # TODO update the JSON string below json = "{}" -# create an instance of MarketInfo from a JSON string -market_info_instance = MarketInfo.from_json(json) +# create an instance of PerpsMarketStats from a JSON string +perps_market_stats_instance = PerpsMarketStats.from_json(json) # print the JSON string representation of the object -print(MarketInfo.to_json()) +print(PerpsMarketStats.to_json()) # convert the object into a dict -market_info_dict = market_info_instance.to_dict() -# create an instance of MarketInfo from a dict -market_info_from_dict = MarketInfo.from_dict(market_info_dict) +perps_market_stats_dict = perps_market_stats_instance.to_dict() +# create an instance of PerpsMarketStats from a dict +perps_market_stats_from_dict = PerpsMarketStats.from_dict(perps_market_stats_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/OrderBookDetail.md b/docs/PerpsOrderBookDetail.md similarity index 68% rename from docs/OrderBookDetail.md rename to docs/PerpsOrderBookDetail.md index 69de4ba..ad69ae3 100644 --- a/docs/OrderBookDetail.md +++ b/docs/PerpsOrderBookDetail.md @@ -1,4 +1,4 @@ -# OrderBookDetail +# PerpsOrderBookDetail ## Properties @@ -7,12 +7,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **symbol** | **str** | | **market_id** | **int** | | +**market_type** | **str** | | +**base_asset_id** | **int** | | +**quote_asset_id** | **int** | | **status** | **str** | | **taker_fee** | **str** | | **maker_fee** | **str** | | **liquidation_fee** | **str** | | **min_base_amount** | **str** | | **min_quote_amount** | **str** | | +**order_quote_limit** | **str** | | **supported_size_decimals** | **int** | | **supported_price_decimals** | **int** | | **supported_quote_decimals** | **int** | | @@ -32,23 +36,24 @@ Name | Type | Description | Notes **daily_price_change** | **float** | | **open_interest** | **float** | | **daily_chart** | **Dict[str, float]** | | +**market_config** | [**MarketConfig**](MarketConfig.md) | | ## Example ```python -from lighter.models.order_book_detail import OrderBookDetail +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail # TODO update the JSON string below json = "{}" -# create an instance of OrderBookDetail from a JSON string -order_book_detail_instance = OrderBookDetail.from_json(json) +# create an instance of PerpsOrderBookDetail from a JSON string +perps_order_book_detail_instance = PerpsOrderBookDetail.from_json(json) # print the JSON string representation of the object -print(OrderBookDetail.to_json()) +print(PerpsOrderBookDetail.to_json()) # convert the object into a dict -order_book_detail_dict = order_book_detail_instance.to_dict() -# create an instance of OrderBookDetail from a dict -order_book_detail_from_dict = OrderBookDetail.from_dict(order_book_detail_dict) +perps_order_book_detail_dict = perps_order_book_detail_instance.to_dict() +# create an instance of PerpsOrderBookDetail from a dict +perps_order_book_detail_from_dict = PerpsOrderBookDetail.from_dict(perps_order_book_detail_dict) ``` [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/PnLEntry.md b/docs/PnLEntry.md index 6f80183..6032475 100644 --- a/docs/PnLEntry.md +++ b/docs/PnLEntry.md @@ -7,8 +7,11 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **timestamp** | **int** | | **trade_pnl** | **float** | | +**trade_spot_pnl** | **float** | | **inflow** | **float** | | **outflow** | **float** | | +**spot_outflow** | **float** | | +**spot_inflow** | **float** | | **pool_pnl** | **float** | | **pool_inflow** | **float** | | **pool_outflow** | **float** | | diff --git a/docs/PublicPool.md b/docs/PublicPool.md deleted file mode 100644 index 527e94e..0000000 --- a/docs/PublicPool.md +++ /dev/null @@ -1,49 +0,0 @@ -# PublicPool - - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**code** | **int** | | -**message** | **str** | | [optional] -**account_type** | **int** | | -**index** | **int** | | -**l1_address** | **str** | | -**cancel_all_time** | **int** | | -**total_order_count** | **int** | | -**total_isolated_order_count** | **int** | | -**pending_order_count** | **int** | | -**available_balance** | **str** | | -**status** | **int** | | -**collateral** | **str** | | -**account_index** | **int** | | -**name** | **str** | | -**description** | **str** | | -**can_invite** | **bool** | Remove After FE uses L1 meta endpoint | -**referral_points_percentage** | **str** | Remove After FE uses L1 meta endpoint | -**total_asset_value** | **str** | | -**cross_asset_value** | **str** | | -**pool_info** | [**PublicPoolInfo**](PublicPoolInfo.md) | | -**account_share** | [**PublicPoolShare**](PublicPoolShare.md) | | [optional] - -## Example - -```python -from lighter.models.public_pool import PublicPool - -# TODO update the JSON string below -json = "{}" -# create an instance of PublicPool from a JSON string -public_pool_instance = PublicPool.from_json(json) -# print the JSON string representation of the object -print(PublicPool.to_json()) - -# convert the object into a dict -public_pool_dict = public_pool_instance.to_dict() -# create an instance of PublicPool from a dict -public_pool_from_dict = PublicPool.from_dict(public_pool_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/docs/PublicPoolInfo.md b/docs/PublicPoolInfo.md index d3aac46..da382c3 100644 --- a/docs/PublicPoolInfo.md +++ b/docs/PublicPoolInfo.md @@ -11,6 +11,7 @@ Name | Type | Description | Notes **total_shares** | **int** | | **operator_shares** | **int** | | **annual_percentage_yield** | **float** | | +**sharpe_ratio** | **float** | | **daily_returns** | [**List[DailyReturn]**](DailyReturn.md) | | **share_prices** | [**List[SharePrice]**](SharePrice.md) | | diff --git a/docs/PublicPoolMetadata.md b/docs/PublicPoolMetadata.md index f3769c2..453108f 100644 --- a/docs/PublicPoolMetadata.md +++ b/docs/PublicPoolMetadata.md @@ -8,10 +8,13 @@ Name | Type | Description | Notes **code** | **int** | | **message** | **str** | | [optional] **account_index** | **int** | | +**created_at** | **int** | | +**master_account_index** | **int** | | **account_type** | **int** | | **name** | **str** | | **l1_address** | **str** | | **annual_percentage_yield** | **float** | | +**sharpe_ratio** | **float** | | **status** | **int** | | **operator_fee** | **str** | | **total_asset_value** | **str** | | diff --git a/docs/ReferralApi.md b/docs/ReferralApi.md index 0ee3c8b..77c7db1 100644 --- a/docs/ReferralApi.md +++ b/docs/ReferralApi.md @@ -4,9 +4,86 @@ All URIs are relative to *https://mainnet.zklighter.elliot.ai* Method | HTTP request | Description ------------- | ------------- | ------------- +[**referral_kickback_update**](ReferralApi.md#referral_kickback_update) | **POST** /api/v1/referral/kickback/update | referral_kickback_update [**referral_points**](ReferralApi.md#referral_points) | **GET** /api/v1/referral/points | referral_points +[**referral_update**](ReferralApi.md#referral_update) | **POST** /api/v1/referral/update | referral_update +# **referral_kickback_update** +> RespUpdateKickback referral_kickback_update(account_index, kickback_percentage, authorization=authorization, auth=auth) + +referral_kickback_update + +Update kickback percentage for referral rewards + +### Example + + +```python +import lighter +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.ReferralApi(api_client) + account_index = 56 # int | + kickback_percentage = 3.4 # float | + authorization = 'authorization_example' # str | make required after integ is done (optional) + auth = 'auth_example' # str | made optional to support header auth clients (optional) + + try: + # referral_kickback_update + api_response = await api_instance.referral_kickback_update(account_index, kickback_percentage, authorization=authorization, auth=auth) + print("The response of ReferralApi->referral_kickback_update:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ReferralApi->referral_kickback_update: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_index** | **int**| | + **kickback_percentage** | **float**| | + **authorization** | **str**| make required after integ is done | [optional] + **auth** | **str**| made optional to support header auth clients | [optional] + +### Return type + +[**RespUpdateKickback**](RespUpdateKickback.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + # **referral_points** > ReferralPoints referral_points(account_index, authorization=authorization, auth=auth) @@ -80,3 +157,78 @@ No authorization required [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) +# **referral_update** +> RespUpdateReferralCode referral_update(account_index, new_referral_code, authorization=authorization, auth=auth) + +referral_update + +Update referral code (allowed once per account) + +### Example + + +```python +import lighter +from lighter.models.resp_update_referral_code import RespUpdateReferralCode +from lighter.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://mainnet.zklighter.elliot.ai +# See configuration.py for a list of all supported configuration parameters. +configuration = lighter.Configuration( + host = "https://mainnet.zklighter.elliot.ai" +) + + +# Enter a context with an instance of the API client +async with lighter.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = lighter.ReferralApi(api_client) + account_index = 56 # int | + new_referral_code = 'new_referral_code_example' # str | + authorization = 'authorization_example' # str | make required after integ is done (optional) + auth = 'auth_example' # str | made optional to support header auth clients (optional) + + try: + # referral_update + api_response = await api_instance.referral_update(account_index, new_referral_code, authorization=authorization, auth=auth) + print("The response of ReferralApi->referral_update:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ReferralApi->referral_update: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_index** | **int**| | + **new_referral_code** | **str**| | + **authorization** | **str**| make required after integ is done | [optional] + **auth** | **str**| made optional to support header auth clients | [optional] + +### Return type + +[**RespUpdateReferralCode**](RespUpdateReferralCode.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | A successful response. | - | +**400** | Bad request | - | + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/docs/ReferralPointEntry.md b/docs/ReferralPointEntry.md index 2bb70bb..359a2eb 100644 --- a/docs/ReferralPointEntry.md +++ b/docs/ReferralPointEntry.md @@ -6,10 +6,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **l1_address** | **str** | | -**total_points** | **int** | | -**week_points** | **int** | | -**total_reward_points** | **int** | | -**week_reward_points** | **int** | | +**total_points** | **float** | | +**week_points** | **float** | | +**total_reward_points** | **float** | | +**week_reward_points** | **float** | | **reward_point_multiplier** | **str** | | ## Example diff --git a/docs/ReferralPoints.md b/docs/ReferralPoints.md index 3ed5f35..4235fa6 100644 --- a/docs/ReferralPoints.md +++ b/docs/ReferralPoints.md @@ -6,10 +6,10 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **referrals** | [**List[ReferralPointEntry]**](ReferralPointEntry.md) | | -**user_total_points** | **int** | | -**user_last_week_points** | **int** | | -**user_total_referral_reward_points** | **int** | | -**user_last_week_referral_reward_points** | **int** | | +**user_total_points** | **float** | | +**user_last_week_points** | **float** | | +**user_total_referral_reward_points** | **float** | | +**user_last_week_referral_reward_points** | **float** | | **reward_point_multiplier** | **str** | | ## Example diff --git a/docs/ReqGetAssetDetails.md b/docs/ReqGetAssetDetails.md new file mode 100644 index 0000000..ee1e39d --- /dev/null +++ b/docs/ReqGetAssetDetails.md @@ -0,0 +1,29 @@ +# ReqGetAssetDetails + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**asset_id** | **int** | | [optional] + +## Example + +```python +from lighter.models.req_get_asset_details import ReqGetAssetDetails + +# TODO update the JSON string below +json = "{}" +# create an instance of ReqGetAssetDetails from a JSON string +req_get_asset_details_instance = ReqGetAssetDetails.from_json(json) +# print the JSON string representation of the object +print(ReqGetAssetDetails.to_json()) + +# convert the object into a dict +req_get_asset_details_dict = req_get_asset_details_instance.to_dict() +# create an instance of ReqGetAssetDetails from a dict +req_get_asset_details_from_dict = ReqGetAssetDetails.from_dict(req_get_asset_details_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ReqGetBridgesByL1Addr.md b/docs/ReqGetBridgesByL1Addr.md new file mode 100644 index 0000000..a06ef98 --- /dev/null +++ b/docs/ReqGetBridgesByL1Addr.md @@ -0,0 +1,29 @@ +# ReqGetBridgesByL1Addr + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**l1_address** | **str** | | + +## Example + +```python +from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr + +# TODO update the JSON string below +json = "{}" +# create an instance of ReqGetBridgesByL1Addr from a JSON string +req_get_bridges_by_l1_addr_instance = ReqGetBridgesByL1Addr.from_json(json) +# print the JSON string representation of the object +print(ReqGetBridgesByL1Addr.to_json()) + +# convert the object into a dict +req_get_bridges_by_l1_addr_dict = req_get_bridges_by_l1_addr_instance.to_dict() +# create an instance of ReqGetBridgesByL1Addr from a dict +req_get_bridges_by_l1_addr_from_dict = ReqGetBridgesByL1Addr.from_dict(req_get_bridges_by_l1_addr_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ReqGetOrderBookDetails.md b/docs/ReqGetOrderBookDetails.md index 333f27a..81d1cf8 100644 --- a/docs/ReqGetOrderBookDetails.md +++ b/docs/ReqGetOrderBookDetails.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **market_id** | **int** | | [optional] +**filter** | **str** | | [optional] [default to 'all'] ## Example diff --git a/docs/ReqGetOrderBooks.md b/docs/ReqGetOrderBooks.md index 4cb4b5d..0b89605 100644 --- a/docs/ReqGetOrderBooks.md +++ b/docs/ReqGetOrderBooks.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **market_id** | **int** | | [optional] +**filter** | **str** | | [optional] [default to 'all'] ## Example diff --git a/docs/ReqGetPublicPools.md b/docs/ReqGetPublicPools.md deleted file mode 100644 index 367eef0..0000000 --- a/docs/ReqGetPublicPools.md +++ /dev/null @@ -1,33 +0,0 @@ -# ReqGetPublicPools - - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**auth** | **str** | | [optional] -**filter** | **str** | | [optional] -**index** | **int** | | -**limit** | **int** | | -**account_index** | **int** | | [optional] - -## Example - -```python -from lighter.models.req_get_public_pools import ReqGetPublicPools - -# TODO update the JSON string below -json = "{}" -# create an instance of ReqGetPublicPools from a JSON string -req_get_public_pools_instance = ReqGetPublicPools.from_json(json) -# print the JSON string representation of the object -print(ReqGetPublicPools.to_json()) - -# convert the object into a dict -req_get_public_pools_dict = req_get_public_pools_instance.to_dict() -# create an instance of ReqGetPublicPools from a dict -req_get_public_pools_from_dict = ReqGetPublicPools.from_dict(req_get_public_pools_dict) -``` -[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) - - diff --git a/docs/ReqGetTrades.md b/docs/ReqGetTrades.md index 947005c..2d11282 100644 --- a/docs/ReqGetTrades.md +++ b/docs/ReqGetTrades.md @@ -14,7 +14,10 @@ Name | Type | Description | Notes **cursor** | **str** | | [optional] **var_from** | **int** | | [optional] [default to -1] **ask_filter** | **int** | | [optional] +**role** | **str** | | [optional] [default to 'all'] +**type** | **str** | | [optional] [default to 'all'] **limit** | **int** | | +**aggregate** | **bool** | | [optional] [default to False] ## Example diff --git a/docs/RespGetBridgesByL1Addr.md b/docs/RespGetBridgesByL1Addr.md new file mode 100644 index 0000000..3d797bd --- /dev/null +++ b/docs/RespGetBridgesByL1Addr.md @@ -0,0 +1,31 @@ +# RespGetBridgesByL1Addr + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**bridges** | [**List[Bridge]**](Bridge.md) | | + +## Example + +```python +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr + +# TODO update the JSON string below +json = "{}" +# create an instance of RespGetBridgesByL1Addr from a JSON string +resp_get_bridges_by_l1_addr_instance = RespGetBridgesByL1Addr.from_json(json) +# print the JSON string representation of the object +print(RespGetBridgesByL1Addr.to_json()) + +# convert the object into a dict +resp_get_bridges_by_l1_addr_dict = resp_get_bridges_by_l1_addr_instance.to_dict() +# create an instance of RespGetBridgesByL1Addr from a dict +resp_get_bridges_by_l1_addr_from_dict = RespGetBridgesByL1Addr.from_dict(resp_get_bridges_by_l1_addr_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/RespGetIsNextBridgeFast.md b/docs/RespGetIsNextBridgeFast.md new file mode 100644 index 0000000..09ccf87 --- /dev/null +++ b/docs/RespGetIsNextBridgeFast.md @@ -0,0 +1,31 @@ +# RespGetIsNextBridgeFast + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**is_next_bridge_fast** | **bool** | | + +## Example + +```python +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast + +# TODO update the JSON string below +json = "{}" +# create an instance of RespGetIsNextBridgeFast from a JSON string +resp_get_is_next_bridge_fast_instance = RespGetIsNextBridgeFast.from_json(json) +# print the JSON string representation of the object +print(RespGetIsNextBridgeFast.to_json()) + +# convert the object into a dict +resp_get_is_next_bridge_fast_dict = resp_get_is_next_bridge_fast_instance.to_dict() +# create an instance of RespGetIsNextBridgeFast from a dict +resp_get_is_next_bridge_fast_from_dict = RespGetIsNextBridgeFast.from_dict(resp_get_is_next_bridge_fast_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/RespSendTx.md b/docs/RespSendTx.md index 5d58479..1fa1758 100644 --- a/docs/RespSendTx.md +++ b/docs/RespSendTx.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **message** | **str** | | [optional] **tx_hash** | **str** | | **predicted_execution_time_ms** | **int** | | +**volume_quota_remaining** | **int** | | ## Example diff --git a/docs/RespSendTxBatch.md b/docs/RespSendTxBatch.md index 1b02a5b..cf70435 100644 --- a/docs/RespSendTxBatch.md +++ b/docs/RespSendTxBatch.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **message** | **str** | | [optional] **tx_hash** | **List[str]** | | **predicted_execution_time_ms** | **int** | | +**volume_quota_remaining** | **int** | | ## Example diff --git a/docs/RespUpdateKickback.md b/docs/RespUpdateKickback.md new file mode 100644 index 0000000..db81414 --- /dev/null +++ b/docs/RespUpdateKickback.md @@ -0,0 +1,31 @@ +# RespUpdateKickback + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**success** | **bool** | | + +## Example + +```python +from lighter.models.resp_update_kickback import RespUpdateKickback + +# TODO update the JSON string below +json = "{}" +# create an instance of RespUpdateKickback from a JSON string +resp_update_kickback_instance = RespUpdateKickback.from_json(json) +# print the JSON string representation of the object +print(RespUpdateKickback.to_json()) + +# convert the object into a dict +resp_update_kickback_dict = resp_update_kickback_instance.to_dict() +# create an instance of RespUpdateKickback from a dict +resp_update_kickback_from_dict = RespUpdateKickback.from_dict(resp_update_kickback_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/RespUpdateReferralCode.md b/docs/RespUpdateReferralCode.md new file mode 100644 index 0000000..0579638 --- /dev/null +++ b/docs/RespUpdateReferralCode.md @@ -0,0 +1,31 @@ +# RespUpdateReferralCode + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | +**message** | **str** | | [optional] +**success** | **bool** | | + +## Example + +```python +from lighter.models.resp_update_referral_code import RespUpdateReferralCode + +# TODO update the JSON string below +json = "{}" +# create an instance of RespUpdateReferralCode from a JSON string +resp_update_referral_code_instance = RespUpdateReferralCode.from_json(json) +# print the JSON string representation of the object +print(RespUpdateReferralCode.to_json()) + +# convert the object into a dict +resp_update_referral_code_dict = resp_update_referral_code_instance.to_dict() +# create an instance of RespUpdateReferralCode from a dict +resp_update_referral_code_from_dict = RespUpdateReferralCode.from_dict(resp_update_referral_code_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SpotMarketStats.md b/docs/SpotMarketStats.md new file mode 100644 index 0000000..d471d39 --- /dev/null +++ b/docs/SpotMarketStats.md @@ -0,0 +1,38 @@ +# SpotMarketStats + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | +**market_id** | **int** | | +**index_price** | **str** | | +**mid_price** | **str** | | +**last_trade_price** | **str** | | +**daily_base_token_volume** | **float** | | +**daily_quote_token_volume** | **float** | | +**daily_price_low** | **float** | | +**daily_price_high** | **float** | | +**daily_price_change** | **float** | | + +## Example + +```python +from lighter.models.spot_market_stats import SpotMarketStats + +# TODO update the JSON string below +json = "{}" +# create an instance of SpotMarketStats from a JSON string +spot_market_stats_instance = SpotMarketStats.from_json(json) +# print the JSON string representation of the object +print(SpotMarketStats.to_json()) + +# convert the object into a dict +spot_market_stats_dict = spot_market_stats_instance.to_dict() +# create an instance of SpotMarketStats from a dict +spot_market_stats_from_dict = SpotMarketStats.from_dict(spot_market_stats_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/SpotOrderBookDetail.md b/docs/SpotOrderBookDetail.md new file mode 100644 index 0000000..a41e15e --- /dev/null +++ b/docs/SpotOrderBookDetail.md @@ -0,0 +1,53 @@ +# SpotOrderBookDetail + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**symbol** | **str** | | +**market_id** | **int** | | +**market_type** | **str** | | +**base_asset_id** | **int** | | +**quote_asset_id** | **int** | | +**status** | **str** | | +**taker_fee** | **str** | | +**maker_fee** | **str** | | +**liquidation_fee** | **str** | | +**min_base_amount** | **str** | | +**min_quote_amount** | **str** | | +**order_quote_limit** | **str** | | +**supported_size_decimals** | **int** | | +**supported_price_decimals** | **int** | | +**supported_quote_decimals** | **int** | | +**size_decimals** | **int** | | +**price_decimals** | **int** | | +**last_trade_price** | **float** | | +**daily_trades_count** | **int** | | +**daily_base_token_volume** | **float** | | +**daily_quote_token_volume** | **float** | | +**daily_price_low** | **float** | | +**daily_price_high** | **float** | | +**daily_price_change** | **float** | | +**daily_chart** | **Dict[str, float]** | | + +## Example + +```python +from lighter.models.spot_order_book_detail import SpotOrderBookDetail + +# TODO update the JSON string below +json = "{}" +# create an instance of SpotOrderBookDetail from a JSON string +spot_order_book_detail_instance = SpotOrderBookDetail.from_json(json) +# print the JSON string representation of the object +print(SpotOrderBookDetail.to_json()) + +# convert the object into a dict +spot_order_book_detail_dict = spot_order_book_detail_instance.to_dict() +# create an instance of SpotOrderBookDetail from a dict +spot_order_book_detail_from_dict = SpotOrderBookDetail.from_dict(spot_order_book_detail_dict) +``` +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Trade.md b/docs/Trade.md index ac611a0..2e00927 100644 --- a/docs/Trade.md +++ b/docs/Trade.md @@ -14,6 +14,8 @@ Name | Type | Description | Notes **usd_amount** | **str** | | **ask_id** | **int** | | **bid_id** | **int** | | +**ask_client_id** | **int** | | +**bid_client_id** | **int** | | **ask_account_id** | **int** | | **bid_account_id** | **int** | | **is_maker_ask** | **bool** | | diff --git a/docs/TransferHistoryItem.md b/docs/TransferHistoryItem.md index 4d7f5df..b3984ce 100644 --- a/docs/TransferHistoryItem.md +++ b/docs/TransferHistoryItem.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **str** | | +**asset_id** | **int** | | **amount** | **str** | | **timestamp** | **int** | | **type** | **str** | | @@ -13,6 +14,8 @@ Name | Type | Description | Notes **to_l1_address** | **str** | | **from_account_index** | **int** | | **to_account_index** | **int** | | +**from_route** | **str** | | +**to_route** | **str** | | **tx_hash** | **str** | | ## Example diff --git a/docs/Tx.md b/docs/Tx.md index 76f8f11..193c21e 100644 --- a/docs/Tx.md +++ b/docs/Tx.md @@ -20,6 +20,7 @@ Name | Type | Description | Notes **executed_at** | **int** | | **sequence_index** | **int** | | **parent_hash** | **str** | | +**api_key_index** | **int** | | ## Example diff --git a/docs/WithdrawHistoryItem.md b/docs/WithdrawHistoryItem.md index 1ae6002..8ce329d 100644 --- a/docs/WithdrawHistoryItem.md +++ b/docs/WithdrawHistoryItem.md @@ -6,6 +6,7 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **id** | **str** | | +**asset_id** | **int** | | **amount** | **str** | | **timestamp** | **int** | | **status** | **str** | | diff --git a/examples/README.md b/examples/README.md index 43780cf..f565290 100644 --- a/examples/README.md +++ b/examples/README.md @@ -19,6 +19,11 @@ - same flow as `create_modify_cancel_order_http.py` - sends TXs over WS instead of HTTP +- `create_market_order_eth_buy.py` + - creates a market buy order for 0.1 ETH @ market price +- `create_market_order_eth_sell.py` + - creates a market sell order for 0.1 ETH @ market price + - `create_grouped_ioc_with_attached_sl_tp.py` - creates an ask (sell) IoC order for 0.1 ETH - along w/ the order, it sets up a Stop Loss (SL) and a Take Profit (TP) order for the whole size of the order @@ -31,7 +36,7 @@ - the orders will grow / shrink as you accumulate more position - the SL/TP orders are canceled when the sign of your position changes -### On SL/TP orders +## On SL/TP orders SL/TP orders need to be configured beyond just setting the trigger price. When the trigger price is set, the order will just be executed, like a normal order. This means that a market order, for example, might not have enough slippage! \ Let's say that you have a 1 BTC long position, and the current price is $110'000. \ @@ -43,7 +48,7 @@ What about the order types? Just as normal orders, SL/TP orders trigger an order - market order - limit IOC / GTC -### Modify leverage / Margin Mode (Cross, Isolated) / Add Collateral to isolated-only positions +## Modify leverage / Margin Mode (Cross, Isolated) / Add Collateral to isolated-only positions - `margin_eth_20x_cross_http` - sets ETH market to 20x leverage and cross-margin mode, using HTTP - `margin_eth_50x_isolate_ws` @@ -53,7 +58,7 @@ What about the order types? Just as normal orders, SL/TP orders trigger an order - `margin_eth_remove_collateral_ws.py` - removes $5 USDC from the ETH position (must be opened and in isolated mode) -### Batch orders +## Batch orders - `send_batch_tx_http.py` - sends multiple orders in a single HTTP request - `send_batch_tx_ws.py` @@ -61,6 +66,92 @@ What about the order types? Just as normal orders, SL/TP orders trigger an order Batch TXs will be executed back to back, without the possibility of other TXs interfering. +## Spot Trading +To trade spot markets, you need to have spot USDC. USDC used in your perpetual account will be used as collateral for your cross-positions. +USDC deposited in the spot account can only be used to buy spot assets. +To transfer USDC between spot <> perp balance, or vice verse, check out +- `spot_self_transfer_perp_spot.py` +- `spot_self_transfer_spot_perp.py` + +Order placement / trades work in the same way as for perpetual markets. +The fee will be paid in the received asset for premium spot trades. +This means that if you sell ETH, you'll receive less USDC, and if you BUY 1 ETH, you'll receive slightly less than 1 ETH. +You can check out the following examples, which should work on spot ETH by changing the market index to 2048 instead of 0. +- `create_modify_cancel_order_http.py` +- `create_modify_cancel_order_ws.py` +- `create_market_order_eth_buy.py` +- `create_market_order_eth_sell.py` +- `send_batch_tx_http.py` +- `send_batch_tx_ws.py` + +Trading setup is very similar to perpetual markets. +The only difference is that you'll need to hold USDC / ETH before placing an order. +For example, on perp markets you can place an order to short (sell) ETH without having to worry that much. +The limitation there would be to have enough available collateral to cover the order. +On spot orders, you need to have enough assets in your spot account to cover all open orders. +If you want to place two orders, to buy 1000 USDC worth of ETH and 1000 USDC worth of ZK, you'll need to have at least 2000 available USDC. + +You can get the order book details (including symbol and market index) as well as quote asset id (ETH) and base asset id (USDC) +by following the example below: +- `spot_get_order_books.py` + +Note: you'll need the quote asset id and base asset id to check available balance. +Available balance is not locked in open orders. + +To keep track of your spot balance, you can use HTTP calls or a websocket subscription. +Examples on how to do this can be found here: +- `spot_get_account_assets_http.py` +- `spot_get_account_assets_ws.py` + +Moving money to / from subaccounts is possible for spot assets. +For USDC, you can move directly from main perp balance to subaccount spot balance, for example. +More details can be found in the following example: +- `sub_account_create.py` +- `sub_account_transfer_eth.py` +- `sub_account_transfer_usdc.py` + +## Public Pools +Public pools behave just like subaccounts, except that anyone can join them. +You can create / modify a public pool using the SDK. Check out the following example: +- `public_pool_create_modify.py` + +To create API keys for a public pool, you need to run the setup script but specify the `ACCOUNT_INDEX` to be the one of the public pool. +After that, you can trade from the public as from any other account. + +If you want to deposit / withdraw from a public pool, check the following example: +- `public_pool_deposit.py` +- `public_pool_withdraw.py` + +To get information about pools, check: +- `public_pool_info.py` + +## Moving funds around +- `withdraw_fast.py` + - send USDC directly from Lighter to Arbitrum +- `withdraw_normal.py` + - send USDC/ETH from Lighter to Ethereum +- `transfer.py` + - generic example of how to transfer funds between accounts. + - same functionality as `sub_account_transfer_eth` and `sub_account_transfer_usdc` + +## Transfer Notes +The `memo` field is a user message, and it has to be exactly 32 bytes long. In case of fast withdrawals, you need to specify the recipient in the memo. +This is the case since the memo is part of the signature. This way, the recipient is verified. + +When calling `client.transfer`, you pass the amount without needing to worry about the decimals. +When calling `client.sign_transfer` on the other hand, you need to specify the decimals and pass an integer. + +The `fee` field can be obtained by calling `info_api.transfer_fee_info(...)`. The field can be passed as it is. +Transfers between subaccounts are free for all assets. + +When sending assets, you can specify the source and destination routes. +A route is either `perp` or `spot`. You can send USDC directly from your perp balance to another person's spot balance. +If you receive USDC in your perp account, it will be instantly used as collateral for open positions. +This also allows you to move USDC from your spot balance to your perp balance. +Spot assets (like ETH) need to have both the from and to route set to `spot`. +You can get all `asset_id`s by following the example below: +- `spot_get_order_books.py` + ## Setup steps for mainnet - deposit money on Lighter to create an account first - change the URL to `mainnet.zklighter.elliot.ai` diff --git a/examples/create_market_order_eth_buy.py b/examples/create_market_order_eth_buy.py new file mode 100644 index 0000000..32a6128 --- /dev/null +++ b/examples/create_market_order_eth_buy.py @@ -0,0 +1,28 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + client.check_client() + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + + tx, tx_hash, err = await client.create_market_order( + market_index=market_index, + client_order_index=0, + base_amount=1000, # 0.1 ETH + avg_execution_price=4000_00, # $4000 -- worst acceptable price for the order + is_ask=False, + ) + print(f"Create Order {tx=} {tx_hash=} {err=}") + if err is not None: + raise Exception(err) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/create_market_order.py b/examples/create_market_order_eth_sell.py similarity index 64% rename from examples/create_market_order.py rename to examples/create_market_order_eth_sell.py index 367f89a..1eac770 100644 --- a/examples/create_market_order.py +++ b/examples/create_market_order_eth_sell.py @@ -4,12 +4,16 @@ async def main(): client, api_client, _ = default_example_setup() + client.check_client() + + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 tx, tx_hash, err = await client.create_market_order( - market_index=0, + market_index=market_index, client_order_index=0, base_amount=1000, # 0.1 ETH - avg_execution_price=170000, # $1700 -- worst acceptable price for the order + avg_execution_price=1700_00, # $1700 -- worst acceptable price for the order is_ask=True, ) print(f"Create Order {tx=} {tx_hash=} {err=}") diff --git a/examples/create_modify_cancel_order_http.py b/examples/create_modify_cancel_order_http.py index 05637f2..4cab96d 100644 --- a/examples/create_modify_cancel_order_http.py +++ b/examples/create_modify_cancel_order_http.py @@ -6,10 +6,13 @@ async def main(): client, api_client, _ = default_example_setup() client.check_client() + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + # create order api_key_index, nonce = client.nonce_manager.next_nonce() tx, tx_hash, err = await client.create_order( - market_index=0, + market_index=market_index, client_order_index=123, base_amount=1000, # 0.1 ETH price=4050_00, # $4050 @@ -29,7 +32,7 @@ async def main(): # use the same API key so the TX goes after the create order TX api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) tx, tx_hash, err = await client.modify_order( - market_index=0, + market_index=market_index, order_index=123, base_amount=1100, # 0.11 ETH price=4100_00, # $4100 @@ -45,7 +48,7 @@ async def main(): # use the same API key so the TX goes after the modify order TX api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) tx, tx_hash, err = await client.cancel_order( - market_index=0, + market_index=market_index, order_index=123, nonce=nonce, api_key_index=api_key_index, diff --git a/examples/create_modify_cancel_order_ws.py b/examples/create_modify_cancel_order_ws.py index 63e1e73..1c8f2d6 100644 --- a/examples/create_modify_cancel_order_ws.py +++ b/examples/create_modify_cancel_order_ws.py @@ -6,15 +6,19 @@ # this example does the same thing as the create_modify_cancel_order.py example, but sends the TX over WS instead of HTTP async def main(): client, api_client, ws_client_promise = default_example_setup() + client.check_client() # set up WS client and print a connected message ws_client: websockets.ClientConnection = await ws_client_promise print("Received:", await ws_client.recv()) + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + # create order api_key_index, nonce = client.nonce_manager.next_nonce() tx_type, tx_info, tx_hash, err = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=123, base_amount=1000, # 0.1 ETH price=4050_00, # $4050 @@ -34,7 +38,7 @@ async def main(): # use the same API key so the TX goes after the create order TX api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) tx_type, tx_info, tx_hash, err = client.sign_modify_order( - market_index=0, + market_index=market_index, order_index=123, base_amount=1100, # 0.11 ETH price=4100_00, # $4100 @@ -50,7 +54,7 @@ async def main(): # use the same API key so the TX goes after the modify order TX api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) tx_type, tx_info, tx_hash, err = client.sign_cancel_order( - market_index=0, + market_index=market_index, order_index=123, nonce=nonce, api_key_index=api_key_index, diff --git a/examples/public_pool_create_modify.py b/examples/public_pool_create_modify.py new file mode 100644 index 0000000..dbffee7 --- /dev/null +++ b/examples/public_pool_create_modify.py @@ -0,0 +1,59 @@ +import time +import json +import asyncio +import lighter +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + tx_api = lighter.TransactionApi(api_client) + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + auth, _ = client.create_auth_token_with_expiry() + + # create a public pool + tx_info, response, err = await client.create_public_pool( + operator_fee=100000, # 10% + initial_total_shares=1_000_000, # 1000 USDC + min_operator_share_rate=100, # 1% + ) + if err is not None: + raise Exception(f'failed to create public pool {err}') + tx_hash = response.tx_hash + print(f"✅ send create public pool tx. hash: {tx_hash}") + + # fetch pool account index from tx hash + pool_account_index = -1 + for i in range(10): + time.sleep(1) + try: + response = await tx_api.tx(by="hash", value=tx_hash) + event_info_j = json.loads(response.event_info) + pool_account_index = event_info_j['a'] + except Exception as e: + pass + if pool_account_index != -1: + break + if pool_account_index == -1: + raise Exception(f"failed to find pool account index for tx {tx_hash}") + print(f"✅ pool account index: {pool_account_index}") + + # Note: ❗️operator_fee can only decrease + # modify pool metadata + tx_info, response, err = await client.update_public_pool( + public_pool_index=pool_account_index, + status=0, # 0 is active | 1 is frozen + operator_fee=50000, # 5% + min_operator_share_rate=1000, # 10% + ) + if err is not None: + raise Exception(f'failed to create update pool {err}') + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/public_pool_deposit.py b/examples/public_pool_deposit.py new file mode 100644 index 0000000..dae44fe --- /dev/null +++ b/examples/public_pool_deposit.py @@ -0,0 +1,25 @@ +import asyncio + +from utils import default_example_setup + +POOL_ACCOUNT_INDEX = 281474976710651 + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + tx_info, response, err = await client.mint_shares(public_pool_index=POOL_ACCOUNT_INDEX, share_amount=10_000) + if err is not None: + raise Exception(f'failed to mint shares {err}') + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/public_pool_info.py b/examples/public_pool_info.py new file mode 100644 index 0000000..e519407 --- /dev/null +++ b/examples/public_pool_info.py @@ -0,0 +1,33 @@ +import asyncio +import lighter +from utils import default_example_setup + +POOL_ACCOUNT_INDEX = 281474976710651 + + +async def main(): + client, api_client, _ = default_example_setup() + account_api = lighter.AccountApi(api_client) + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + account = await account_api.account(by="index", value=str(client.account_index)) + + # Note: ❗️shares field does not return the shared you have in pools that you're the operator + for pool in account.accounts[0].shares: + pool_resp = await account_api.account(by="index", value=str(pool.public_pool_index)) + pool_account = pool_resp.accounts[0] + + share_price = float(pool_account.total_asset_value) / float(pool_account.pool_info.total_shares) + print( + f"poolAccountId: {pool.public_pool_index} numShared: {pool.shares_amount} sharePrice: {share_price:.6f} value: {share_price * pool.shares_amount:.2f} pnl: {share_price * pool.shares_amount - float(pool.entry_usdc):.2f}") + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/public_pool_withdraw.py b/examples/public_pool_withdraw.py new file mode 100644 index 0000000..f3ce3f3 --- /dev/null +++ b/examples/public_pool_withdraw.py @@ -0,0 +1,26 @@ +import asyncio +from utils import default_example_setup + +POOL_ACCOUNT_INDEX = 281474976710651 + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + auth, _ = client.create_auth_token_with_expiry() + + tx_info, response, err = await client.burn_shares(public_pool_index=POOL_ACCOUNT_INDEX, share_amount=10_000) + if err is not None: + raise Exception(f'failed to mint shares {err}') + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/send_batch_tx_http.py b/examples/send_batch_tx_http.py index 3264099..d9ac8c1 100644 --- a/examples/send_batch_tx_http.py +++ b/examples/send_batch_tx_http.py @@ -7,9 +7,12 @@ async def main(): client, api_client, _ = default_example_setup() + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 0 + api_key_index, nonce = client.nonce_manager.next_nonce() ask_tx_type, ask_tx_info, ask_tx_hash, error = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=1001, # Unique identifier for this order base_amount=1000, # 0.1 ETH price=5000_00, # $5000 @@ -30,7 +33,7 @@ async def main(): # in batch TXs, all TXs must come from the same API key. api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) bid_tx_type, bid_tx_info, bid_tx_hash, error = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=1002, # Different unique identifier base_amount=1000, # 0.1 ETH price=1500_00, # $1500 @@ -63,7 +66,7 @@ async def main(): # since this is a new batch, we can request a fresh API key api_key_index, nonce = client.nonce_manager.next_nonce() cancel_tx_type, cancel_tx_info, cancel_tx_hash, error = client.sign_cancel_order( - market_index=0, + market_index=market_index, order_index=1001, # the index of the order we want cancelled nonce=nonce, api_key_index=api_key_index, @@ -77,7 +80,7 @@ async def main(): # in batch TXs, all TXs must come from the same API key. api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) new_ask_tx_type, new_ask_tx_info, new_ask_tx_hash, error = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=1003, # Different unique identifier base_amount=2000, # 0.2 ETH price=5500_00, # $5500 @@ -96,7 +99,45 @@ async def main(): tx_types = [cancel_tx_type, new_ask_tx_type] tx_infos = [cancel_tx_info, new_ask_tx_info] - tx_hashes = [ask_tx_hash, bid_tx_hash] + tx_hashes = [cancel_tx_hash, new_ask_tx_hash] + + try: + response = await client.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) + print(f"Batch transaction successful: {response} expected: {tx_hashes}") + except Exception as e: + print(f"Error sending batch transaction: {trim_exception(e)}") + + # In case we want to see the changes in the UI, sleep a bit + time.sleep(5) + + # since this is a new batch, we can request a fresh API key + api_key_index, nonce = client.nonce_manager.next_nonce() + cancel_1_tx_type, cancel_1_tx_info, cancel_1_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1002, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing first order (third batch): {trim_exception(error)}") + return + + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + cancel_2_tx_type, cancel_2_tx_info, cancel_2_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1003, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (third batch): {trim_exception(error)}") + return + + tx_types = [cancel_1_tx_type, cancel_2_tx_type] + tx_infos = [cancel_1_tx_info, cancel_2_tx_info] + tx_hashes = [cancel_1_tx_hash, cancel_2_tx_hash] try: response = await client.send_tx_batch(tx_types=tx_types, tx_infos=tx_infos) @@ -104,6 +145,7 @@ async def main(): except Exception as e: print(f"Error sending batch transaction: {trim_exception(e)}") + # Clean up await client.close() await api_client.close() diff --git a/examples/send_batch_tx_ws.py b/examples/send_batch_tx_ws.py index 9fca11d..8266b53 100644 --- a/examples/send_batch_tx_ws.py +++ b/examples/send_batch_tx_ws.py @@ -13,9 +13,12 @@ async def main(): ws_client: websockets.ClientConnection = await ws_client_promise print("Received:", await ws_client.recv()) + # Note: change this to 2048 to trade spot ETH. Make sure you have at least 0.1 ETH to trade spot. + market_index = 2048 + api_key_index, nonce = client.nonce_manager.next_nonce() ask_tx_type, ask_tx_info, ask_tx_hash, error = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=1001, # Unique identifier for this order base_amount=1000, # 0.1 ETH price=5000_00, # $5000 @@ -36,7 +39,7 @@ async def main(): # in batch TXs, all TXs must come from the same API key. api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) bid_tx_type, bid_tx_info, bid_tx_hash, error = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=1002, # Different unique identifier base_amount=1000, # 0.1 ETH price=1500_00, # $1500 @@ -65,7 +68,7 @@ async def main(): # since this is a new batch, we can request a fresh API key api_key_index, nonce = client.nonce_manager.next_nonce() cancel_tx_type, cancel_tx_info, cancel_tx_hash, error = client.sign_cancel_order( - market_index=0, + market_index=market_index, order_index=1001, # the index of the order we want cancelled nonce=nonce, api_key_index=api_key_index, @@ -79,7 +82,7 @@ async def main(): # in batch TXs, all TXs must come from the same API key. api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) new_ask_tx_type, new_ask_tx_info, new_ask_tx_hash, error = client.sign_create_order( - market_index=0, + market_index=market_index, client_order_index=1003, # Different unique identifier base_amount=2000, # 0.2 ETH price=5500_00, # $5500 @@ -102,6 +105,41 @@ async def main(): await ws_send_batch_tx(ws_client, tx_types, tx_infos, tx_hashes) + # In case we want to see the changes in the UI, sleep a bit + time.sleep(5) + + # since this is a new batch, we can request a fresh API key + api_key_index, nonce = client.nonce_manager.next_nonce() + cancel_1_tx_type, cancel_1_tx_info, cancel_1_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1002, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing first order (third batch): {trim_exception(error)}") + return + + api_key_index, nonce = client.nonce_manager.next_nonce(api_key_index) + cancel_2_tx_type, cancel_2_tx_info, cancel_2_tx_hash, error = client.sign_cancel_order( + market_index=market_index, + order_index=1003, # the index of the order we want cancelled + nonce=nonce, + api_key_index=api_key_index, + ) + + if error is not None: + print(f"Error signing second order (third batch): {trim_exception(error)}") + return + + tx_types = [cancel_1_tx_type, cancel_2_tx_type] + tx_infos = [cancel_1_tx_info, cancel_2_tx_info] + tx_hashes = [cancel_1_tx_hash, cancel_2_tx_hash] + + await ws_send_batch_tx(ws_client, tx_types, tx_infos, tx_hashes) + + # Clean up await client.close() await api_client.close() diff --git a/examples/spot_get_account_assets_http.py b/examples/spot_get_account_assets_http.py new file mode 100644 index 0000000..dd5d1d6 --- /dev/null +++ b/examples/spot_get_account_assets_http.py @@ -0,0 +1,31 @@ +import logging +import asyncio +import lighter +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + logging.basicConfig(level=logging.INFO) + + account_api = lighter.AccountApi(api_client) + response = await account_api.account(by="index", value=str(client.account_index)) + if len(response.accounts) == 0: + raise "No account found" + + account = response.accounts[0] + # Note: cross-account value does not take into account isolated positions, but total does + print("=== perp assets ===") + print(f"total: {account.total_asset_value} available: {account.available_balance}") + print(f"cross: {account.cross_asset_value} isolated: {float(account.total_asset_value) - float(account.cross_asset_value)}") + + # Spot Assets + print("=== spot assets ===") + for asset in account.assets: + print(f"{asset.symbol} total: {asset.balance} available: {float(asset.balance) - float(asset.locked_balance)}") + + await client.close() + await api_client.close() + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/spot_get_account_assets_ws.py b/examples/spot_get_account_assets_ws.py new file mode 100644 index 0000000..de5522e --- /dev/null +++ b/examples/spot_get_account_assets_ws.py @@ -0,0 +1,53 @@ +import json +import logging +import asyncio +import websockets + +from lighter.models import WSAccountAssets +from utils import default_example_setup, ws_subscribe, ws_ping + + +async def consume_messages(ws): + while True: + msg_str = await ws.recv() + if isinstance(msg_str, str): + msg = json.loads(msg_str) + else: + raise msg_str + + # handle ping here; if we receive, send pong + if msg["type"] == "ping": + await ws_ping(ws) + continue + + # handle account_all_assets updates -- just print stuff + if msg["type"] == "subscribed/account_all_assets" or msg["type"] == "update/account_all_assets" : + o = WSAccountAssets.from_dict(msg) + for asset in o.assets.values(): + print(f"{asset.symbol} total: {asset.balance} available: {float(asset.balance) - float(asset.locked_balance)} accountId: {o.account_id}") + + +async def main(): + client, api_client, ws_client_promise = default_example_setup() + logging.basicConfig(level=logging.INFO) + + # set up WS client and print a connected message + ws_client: websockets.ClientConnection = await ws_client_promise + await ws_client.recv() + + consume_task = asyncio.create_task(consume_messages(ws_client)) + + auth, _ = client.create_auth_token_with_expiry() + await ws_subscribe(ws_client, f"account_all_assets/{client.account_index}", auth) + + # wait a bit to print messages + await asyncio.sleep(1000) + + consume_task.cancel() + await client.close() + await api_client.close() + await ws_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/spot_get_order_books.py b/examples/spot_get_order_books.py new file mode 100644 index 0000000..d5b84e6 --- /dev/null +++ b/examples/spot_get_order_books.py @@ -0,0 +1,42 @@ +import logging +import asyncio +import lighter +from lighter import Asset +from utils import default_example_setup + +# This example shows how to fetch order books and assets details +# This information should be enough to be able to trade on Lighter +# Select the market ID accordingly to the symbol. +# For spot markets, the order book contains base asset (ETH) and quote asset (USDC) +# You can use these to keep track of your inventory +async def main(): + client, api_client, _ = default_example_setup() + logging.basicConfig(level=logging.INFO) + + orders_api = lighter.OrderApi(api_client) + response = await orders_api.order_books() + response.order_books.sort(key=lambda x: x.market_id) + + # fetch all assets + assets_response = await orders_api.asset_details() + + assets_dict: dict[int, Asset] = {} + for asset in assets_response.asset_details: + assets_dict[asset.asset_id] = asset + + for order_book in response.order_books: + if order_book.market_type == 'perp': + print(f'symbol={order_book.symbol} id={order_book.market_id} type={order_book.market_type} sizeDecimals={order_book.supported_size_decimals} priceDecimals={order_book.supported_price_decimals}') + else: + print(f'symbol={order_book.symbol} id={order_book.market_id} type={order_book.market_type} sizeDecimals={order_book.supported_size_decimals} priceDecimals={order_book.supported_price_decimals} baseAssetId={order_book.base_asset_id} quoteAssetId={order_book.quote_asset_id}') + b = assets_dict[order_book.base_asset_id] + q = assets_dict[order_book.quote_asset_id] + print(f' baseAsset: symbol={b.symbol} assetId={b.asset_id} decimals={b.decimals} price={b.index_price} min_withdraw={b.min_withdrawal_amount}') + print(f' quoteAsset: symbol={q.symbol} assetId={q.asset_id} decimals={q.decimals} price={q.index_price} min_withdraw={q.min_withdrawal_amount}') + + + await client.close() + await api_client.close() + +if __name__ == "__main__": + asyncio.run(main()) diff --git a/examples/spot_self_transfer_perp_spot.py b/examples/spot_self_transfer_perp_spot.py new file mode 100644 index 0000000..b0962fe --- /dev/null +++ b/examples/spot_self_transfer_perp_spot.py @@ -0,0 +1,34 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=client.account_index, + asset_id=client.ASSET_ID_USDC, + amount=1.234567, # decimals are added by sdk + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_SPOT, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + lev_tx, response, err = await client.update_leverage(4, client.CROSS_MARGIN_MODE, 3) + print(lev_tx, response, err) + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/examples/spot_self_transfer_spot_perp.py b/examples/spot_self_transfer_spot_perp.py new file mode 100644 index 0000000..52c9afe --- /dev/null +++ b/examples/spot_self_transfer_spot_perp.py @@ -0,0 +1,34 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=client.account_index, + asset_id=client.ASSET_ID_USDC, + amount=1.234567, # decimals are added by sdk + route_from=client.ROUTE_SPOT, + route_to=client.ROUTE_PERP, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + lev_tx, response, err = await client.update_leverage(4, client.CROSS_MARGIN_MODE, 3) + print(lev_tx, response, err) + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/examples/sub_account_create.py b/examples/sub_account_create.py new file mode 100644 index 0000000..e634b25 --- /dev/null +++ b/examples/sub_account_create.py @@ -0,0 +1,17 @@ +import asyncio +from utils import default_example_setup + + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + tx_info, response, err = await client.create_sub_account() + print(tx_info, response, err) + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/examples/sub_account_transfer_eth.py b/examples/sub_account_transfer_eth.py new file mode 100644 index 0000000..5fb8cb0 --- /dev/null +++ b/examples/sub_account_transfer_eth.py @@ -0,0 +1,32 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +TO_ACCOUNT_INDEX = 281474976710649 + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=TO_ACCOUNT_INDEX, + asset_id=client.ASSET_ID_ETH, + amount=0.4, # decimals are added by sdk + route_from=client.ROUTE_SPOT, + route_to=client.ROUTE_SPOT, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/examples/sub_account_transfer_usdc.py b/examples/sub_account_transfer_usdc.py new file mode 100644 index 0000000..d253be5 --- /dev/null +++ b/examples/sub_account_transfer_usdc.py @@ -0,0 +1,32 @@ +import asyncio +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +TO_ACCOUNT_INDEX = 281474976710649 + +async def main(): + client, api_client, _ = default_example_setup() + + err = client.check_client() + if err is not None: + print(f"CheckClient error: {err}") + return + + # You can find more notes on transfers in the README.md file, under `Transfer Notes` + transfer_tx, response, err = await client.transfer( + ETH_PRIVATE_KEY, + to_account_index=TO_ACCOUNT_INDEX, + asset_id=client.ASSET_ID_USDC, + amount=100, # decimals are added by sdk + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_SPOT, + fee=0, + memo="0x" + "00" * 32, + ) + if err is not None: + raise Exception(f"error transferring {err}") + print(transfer_tx, response) + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/examples/system_setup.py b/examples/system_setup.py index e288bd0..859274b 100644 --- a/examples/system_setup.py +++ b/examples/system_setup.py @@ -14,6 +14,10 @@ API_KEY_INDEX = 3 NUM_API_KEYS = 5 +# If you set this to something other than None, the script will use that account index instead of using the master account index. +# This is useful if you have multiple accounts on the same L1 address or are the owner of a public pool. +# You need to use the private key associated to the master account or the owner of the public pool to change the API keys. +ACCOUNT_INDEX = None async def main(): # verify that the account exists & fetch account index @@ -21,25 +25,28 @@ async def main(): 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 + if ACCOUNT_INDEX is not None: + account_index = ACCOUNT_INDEX + else: + 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}") + + account = min(response.sub_accounts, key=lambda x: int(x.index)) + account_index = account.index + print(f"multiple accounts found, using the master account {account_index}") else: - raise e + account_index = response.sub_accounts[0].index - if len(response.sub_accounts) > 1: - for sub_account in response.sub_accounts: - print(f"found accountIndex: {sub_account.index}") - - print("multiple accounts found, using the first one") - account_index = response.sub_accounts[0].index - 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 diff --git a/examples/transfer.py b/examples/transfer.py index 07f4a34..0b14d2e 100644 --- a/examples/transfer.py +++ b/examples/transfer.py @@ -2,37 +2,36 @@ import lighter from utils import default_example_setup +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" TO_ACCOUNT_INDEX = 9 -ETH_PRIVATE_KEY = "0x..." async def main(): client, api_client, _ = default_example_setup() info_api = lighter.InfoApi(api_client) - auth_token, _ = client.create_auth_token_with_expiry() - fee_info = await info_api.transfer_fee_info(client.account_index, authorization=auth_token, auth=auth_token, to_account_index=TO_ACCOUNT_INDEX) - print(fee_info) + auth_token, err = client.create_auth_token_with_expiry() + if err: + raise Exception(f"Auth token failed: {err}") - err = client.check_client() - if err is not None: - print(f"CheckClient error: {err}") - return + fee_info = await info_api.transfer_fee_info(client.account_index, authorization=auth_token, auth=auth_token, to_account_index=TO_ACCOUNT_INDEX) - memo = "a"*32 # memo is a user message, and it has to be exactly 32 bytes long + # You can find more notes on transfers in the README.md file, under `Transfer Notes` transfer_tx, response, err = await client.transfer( - ETH_PRIVATE_KEY, - usdc_amount=100, # decimals are added by sdk + eth_private_key=ETH_PRIVATE_KEY, to_account_index=TO_ACCOUNT_INDEX, + asset_id=client.ASSET_ID_USDC, + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_PERP, + amount=5, # decimals are added by sdk fee=fee_info.transfer_fee_usdc, - memo=memo, + memo="0x" + "00" * 32, ) if err is not None: - raise Exception(f"error transferring {err}") + raise Exception(f"error transferring {err}") + print(transfer_tx, response) - lev_tx, response, err = await client.update_leverage(4, client.CROSS_MARGIN_MODE, 3) - print(lev_tx, response, err) if __name__ == "__main__": - asyncio.run(main()) \ No newline at end of file + asyncio.run(main()) diff --git a/examples/utils.py b/examples/utils.py index 7210716..8ae2f29 100644 --- a/examples/utils.py +++ b/examples/utils.py @@ -49,6 +49,15 @@ def default_example_setup(config_file="./api_key_config.json") -> Optional[Tuple return client, api_client, websockets.connect(f"{base_url.replace('https', 'wss')}/stream") +async def ws_ping(ws_client: websockets.ClientConnection): + await ws_client.send(json.dumps({"type": "pong"})) + +async def ws_subscribe(ws_client: websockets.ClientConnection, channel: str, auth: Optional[str] = None): + if auth is None: + await ws_client.send(json.dumps({"type": "subscribe", "channel": channel})) + else: + await ws_client.send(json.dumps({"type": "subscribe", "channel": channel, "auth": auth})) + async def ws_send_tx(ws_client: websockets.ClientConnection, tx_type, tx_info, tx_hash): # Note: you have the TX Hash from signing the TX # You can use this TX Hash to check the status of the TX later on diff --git a/examples/withdraw_fast.py b/examples/withdraw_fast.py new file mode 100644 index 0000000..7532e4e --- /dev/null +++ b/examples/withdraw_fast.py @@ -0,0 +1,104 @@ +import asyncio +import json +import lighter +from utils import default_example_setup + +ETH_PRIVATE_KEY = "1234567812345678123456781234567812345678123456781234567812345678" +WITHDRAW_ADDRESS = "0x0000..." +AMOUNT_USDC = 5.0 + +async def main(): + client, api_client, _ = default_example_setup() + + auth_token, err = client.create_auth_token_with_expiry() + if err: + raise Exception(f"Auth token failed: {err}") + + info_api = lighter.InfoApi(api_client) + + try: + # Get fast withdraw pool + params = api_client.param_serialize( + method='GET', + resource_path='/api/v1/fastwithdraw/info', + query_params=[('account_index', client.account_index)], + header_params={'Authorization': auth_token} + ) + response = await api_client.call_api(*params) + await response.read() + data = response.data + assert data is not None + + # get account to which to send money + pool_info = json.loads(data.decode('utf-8')) + if pool_info.get('code') != 200: + raise Exception(f"Pool info failed: {pool_info.get('message')}") + to_account = pool_info['to_account_index'] + print(f"Pool: {to_account}, Limit: {pool_info.get('withdraw_limit')}") + + # get transfer fee + fee_info = await info_api.transfer_fee_info( + account_index=client.account_index, + to_account_index=to_account, + auth=auth_token + ) + fee = fee_info.transfer_fee_usdc # this is already int + + # Get Nonce & API key -- you can get this using HTTP call as well + api_key_index, nonce = client.nonce_manager.next_nonce() + + # Build memo (20-byte address + 12 zeros) + addr_hex = WITHDRAW_ADDRESS.lower().removeprefix("0x") + addr_bytes = bytes.fromhex(addr_hex) + if len(addr_bytes) != 20: + raise ValueError(f"Invalid address length: {len(addr_bytes)}") + memo_list = list(addr_bytes + b"\x00" * 12) + memo_hex = ''.join(format(b, '02x') for b in memo_list) + + # create TX + tx_type, tx_info_str, tx_hash, err = client.sign_transfer( + eth_private_key=ETH_PRIVATE_KEY, + to_account_index=to_account, + asset_id=client.ASSET_ID_USDC, + route_from=client.ROUTE_PERP, + route_to=client.ROUTE_PERP, + usdc_amount=int(AMOUNT_USDC) * 10 ** 6, + fee=fee, + memo=memo_hex, + api_key_index=api_key_index, + nonce=nonce + ) + if err: + raise Exception(f"L2 signing failed: {err}") + + # Submit + params = api_client.param_serialize( + method='POST', + resource_path='/api/v1/fastwithdraw', + post_params=[ + ('tx_info', tx_info_str), + ('to_address', WITHDRAW_ADDRESS) + ], + header_params={ + 'Authorization': auth_token, + 'Content-Type': 'application/x-www-form-urlencoded' + } + ) + response = await api_client.call_api(*params) + await response.read() + data = response.data + assert data is not None + result = json.loads(data.decode('utf-8')) + + if result.get('code') == 200: + print(f"✓ Success! TX: {result.get('tx_hash')}") + else: + raise Exception(f"Failed: {result.get('message')}") + + finally: + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/examples/withdraw_normal.py b/examples/withdraw_normal.py new file mode 100644 index 0000000..acd3611 --- /dev/null +++ b/examples/withdraw_normal.py @@ -0,0 +1,25 @@ +import asyncio +from utils import default_example_setup + +AMOUNT = 5.0 + +async def main(): + client, api_client, _ = default_example_setup() + + # Note: There is no limit or fee for normal withdrawal + withdraw_tx, response, err = await client.withdraw( + asset_id=client.ASSET_ID_USDC, # change this to `client.ASSET_ID_ETH` to withdraw ETH. Also, change route_type to spot + route_type=client.ROUTE_PERP, # change this to `client.ROUTE_SPOT` to withdraw from spot balance + amount=AMOUNT, + ) + if err is not None: + raise Exception(f"error withdrawing {err}") + + print(withdraw_tx, response) + + await client.close() + await api_client.close() + + +if __name__ == "__main__": + asyncio.run(main()) \ No newline at end of file diff --git a/lighter/__init__.py b/lighter/__init__.py index a0af3c2..afcc0a9 100644 --- a/lighter/__init__.py +++ b/lighter/__init__.py @@ -44,6 +44,7 @@ # import models into sdk package from lighter.models.account import Account from lighter.models.account_api_keys import AccountApiKeys +from lighter.models.account_asset import AccountAsset from lighter.models.account_limits import AccountLimits from lighter.models.account_margin_stats import AccountMarginStats from lighter.models.account_market_stats import AccountMarketStats @@ -56,8 +57,11 @@ from lighter.models.announcement import Announcement from lighter.models.announcements import Announcements from lighter.models.api_key import ApiKey +from lighter.models.asset import Asset +from lighter.models.asset_details import AssetDetails from lighter.models.block import Block from lighter.models.blocks import Blocks +from lighter.models.bridge import Bridge from lighter.models.bridge_supported_network import BridgeSupportedNetwork from lighter.models.candlestick import Candlestick from lighter.models.candlesticks import Candlesticks @@ -83,26 +87,25 @@ from lighter.models.liquidation import Liquidation from lighter.models.liquidation_info import LiquidationInfo from lighter.models.liquidation_infos import LiquidationInfos -from lighter.models.market_info import MarketInfo +from lighter.models.market_config import MarketConfig 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 from lighter.models.order_book_stats import OrderBookStats from lighter.models.order_books import OrderBooks from lighter.models.orders import Orders +from lighter.models.perps_market_stats import PerpsMarketStats +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail from lighter.models.pn_l_entry import PnLEntry from lighter.models.position_funding import PositionFunding from lighter.models.position_fundings import PositionFundings 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_metadata import PublicPoolMetadata from lighter.models.public_pool_share import PublicPoolShare -from lighter.models.public_pools import PublicPools from lighter.models.referral_point_entry import ReferralPointEntry from lighter.models.referral_points import ReferralPoints from lighter.models.req_export_data import ReqExportData @@ -115,8 +118,10 @@ from lighter.models.req_get_account_metadata import ReqGetAccountMetadata from lighter.models.req_get_account_pn_l import ReqGetAccountPnL from lighter.models.req_get_account_txs import ReqGetAccountTxs +from lighter.models.req_get_asset_details import ReqGetAssetDetails from lighter.models.req_get_block import ReqGetBlock from lighter.models.req_get_block_txs import ReqGetBlockTxs +from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr 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 @@ -131,7 +136,6 @@ from lighter.models.req_get_order_book_orders import ReqGetOrderBookOrders from lighter.models.req_get_order_books import ReqGetOrderBooks from lighter.models.req_get_position_funding import ReqGetPositionFunding -from lighter.models.req_get_public_pools import ReqGetPublicPools from lighter.models.req_get_public_pools_metadata import ReqGetPublicPoolsMetadata from lighter.models.req_get_range_with_cursor import ReqGetRangeWithCursor from lighter.models.req_get_range_with_index import ReqGetRangeWithIndex @@ -144,16 +148,22 @@ from lighter.models.req_get_tx import ReqGetTx from lighter.models.req_get_withdraw_history import ReqGetWithdrawHistory from lighter.models.resp_change_account_tier import RespChangeAccountTier +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr from lighter.models.resp_get_fast_bridge_info import RespGetFastBridgeInfo +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata from lighter.models.resp_send_tx import RespSendTx from lighter.models.resp_send_tx_batch import RespSendTxBatch +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.models.resp_update_referral_code import RespUpdateReferralCode from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay from lighter.models.result_code import ResultCode from lighter.models.risk_info import RiskInfo from lighter.models.risk_parameters import RiskParameters from lighter.models.share_price import SharePrice from lighter.models.simple_order import SimpleOrder +from lighter.models.spot_market_stats import SpotMarketStats +from lighter.models.spot_order_book_detail import SpotOrderBookDetail from lighter.models.status import Status from lighter.models.sub_accounts import SubAccounts from lighter.models.ticker import Ticker diff --git a/lighter/api/account_api.py b/lighter/api/account_api.py index c92f6dc..688ac0f 100644 --- a/lighter/api/account_api.py +++ b/lighter/api/account_api.py @@ -27,7 +27,6 @@ from lighter.models.l1_metadata import L1Metadata from lighter.models.liquidation_infos import LiquidationInfos from lighter.models.position_fundings import PositionFundings -from lighter.models.public_pools import PublicPools from lighter.models.resp_change_account_tier import RespChangeAccountTier from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata from lighter.models.sub_accounts import SubAccounts @@ -3199,353 +3198,6 @@ def _position_funding_serialize( - - @validate_call - async def public_pools( - self, - index: StrictInt, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], - authorization: Optional[StrictStr] = None, - auth: Optional[StrictStr] = None, - filter: Optional[StrictStr] = None, - account_index: Optional[StrictInt] = 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, - ) -> PublicPools: - """publicPools - - Get public pools - - :param index: (required) - :type index: int - :param limit: (required) - :type limit: int - :param authorization: - :type authorization: str - :param auth: - :type auth: str - :param filter: - :type filter: str - :param account_index: - :type account_index: int - :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._public_pools_serialize( - index=index, - limit=limit, - authorization=authorization, - auth=auth, - filter=filter, - account_index=account_index, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index - ) - - _response_types_map: Dict[str, Optional[str]] = { - '200': "PublicPools", - '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 public_pools_with_http_info( - self, - index: StrictInt, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], - authorization: Optional[StrictStr] = None, - auth: Optional[StrictStr] = None, - filter: Optional[StrictStr] = None, - account_index: Optional[StrictInt] = 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[PublicPools]: - """publicPools - - Get public pools - - :param index: (required) - :type index: int - :param limit: (required) - :type limit: int - :param authorization: - :type authorization: str - :param auth: - :type auth: str - :param filter: - :type filter: str - :param account_index: - :type account_index: int - :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._public_pools_serialize( - index=index, - limit=limit, - authorization=authorization, - auth=auth, - filter=filter, - account_index=account_index, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index - ) - - _response_types_map: Dict[str, Optional[str]] = { - '200': "PublicPools", - '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 public_pools_without_preload_content( - self, - index: StrictInt, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], - authorization: Optional[StrictStr] = None, - auth: Optional[StrictStr] = None, - filter: Optional[StrictStr] = None, - account_index: Optional[StrictInt] = 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: - """publicPools - - Get public pools - - :param index: (required) - :type index: int - :param limit: (required) - :type limit: int - :param authorization: - :type authorization: str - :param auth: - :type auth: str - :param filter: - :type filter: str - :param account_index: - :type account_index: int - :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._public_pools_serialize( - index=index, - limit=limit, - authorization=authorization, - auth=auth, - filter=filter, - account_index=account_index, - _request_auth=_request_auth, - _content_type=_content_type, - _headers=_headers, - _host_index=_host_index - ) - - _response_types_map: Dict[str, Optional[str]] = { - '200': "PublicPools", - '400': "ResultCode", - } - response_data = await self.api_client.call_api( - *_param, - _request_timeout=_request_timeout - ) - return response_data.response - - - def _public_pools_serialize( - self, - index, - limit, - authorization, - auth, - filter, - account_index, - _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 auth is not None: - - _query_params.append(('auth', auth)) - - if filter is not None: - - _query_params.append(('filter', filter)) - - if index is not None: - - _query_params.append(('index', index)) - - if limit is not None: - - _query_params.append(('limit', limit)) - - if account_index is not None: - - _query_params.append(('account_index', account_index)) - - # process the header parameters - if authorization is not None: - _header_params['authorization'] = authorization - # 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/publicPools', - 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 public_pools_metadata( self, diff --git a/lighter/api/bridge_api.py b/lighter/api/bridge_api.py index f9d7851..73e739f 100644 --- a/lighter/api/bridge_api.py +++ b/lighter/api/bridge_api.py @@ -16,7 +16,10 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated +from pydantic import StrictStr +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr from lighter.models.resp_get_fast_bridge_info import RespGetFastBridgeInfo +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast from lighter.api_client import ApiClient, RequestSerialized from lighter.api_response import ApiResponse @@ -36,7 +39,526 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client - @validate_call + async def bridges( + self, + l1_address: StrictStr, + _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, + ) -> RespGetBridgesByL1Addr: + """bridges + + Get bridges for given l1 address + + :param l1_address: (required) + :type l1_address: 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._bridges_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetBridgesByL1Addr", + '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 + + + async def bridges_with_http_info( + self, + l1_address: StrictStr, + _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[RespGetBridgesByL1Addr]: + """bridges + + Get bridges for given l1 address + + :param l1_address: (required) + :type l1_address: 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._bridges_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetBridgesByL1Addr", + '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, + ) + + + async def bridges_without_preload_content( + self, + l1_address: StrictStr, + _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: + """bridges + + Get bridges for given l1 address + + :param l1_address: (required) + :type l1_address: 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._bridges_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetBridgesByL1Addr", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _bridges_serialize( + self, + l1_address, + _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 l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + # 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/bridges', + 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 + ) + + + + + async def bridges_is_next_bridge_fast( + self, + l1_address: StrictStr, + _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, + ) -> RespGetIsNextBridgeFast: + """bridges_isNextBridgeFast + + Get if next bridge is fast + + :param l1_address: (required) + :type l1_address: 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._bridges_is_next_bridge_fast_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetIsNextBridgeFast", + '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 + + + async def bridges_is_next_bridge_fast_with_http_info( + self, + l1_address: StrictStr, + _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[RespGetIsNextBridgeFast]: + """bridges_isNextBridgeFast + + Get if next bridge is fast + + :param l1_address: (required) + :type l1_address: 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._bridges_is_next_bridge_fast_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetIsNextBridgeFast", + '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, + ) + + + async def bridges_is_next_bridge_fast_without_preload_content( + self, + l1_address: StrictStr, + _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: + """bridges_isNextBridgeFast + + Get if next bridge is fast + + :param l1_address: (required) + :type l1_address: 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._bridges_is_next_bridge_fast_serialize( + l1_address=l1_address, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespGetIsNextBridgeFast", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _bridges_is_next_bridge_fast_serialize( + self, + l1_address, + _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 l1_address is not None: + + _query_params.append(('l1_address', l1_address)) + + # 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/bridges/isNextBridgeFast', + 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 + ) + + + + async def fastbridge_info( self, _request_timeout: Union[ diff --git a/lighter/api/order_api.py b/lighter/api/order_api.py index 6b89d83..76154ef 100644 --- a/lighter/api/order_api.py +++ b/lighter/api/order_api.py @@ -16,9 +16,10 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from pydantic import Field, 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.asset_details import AssetDetails from lighter.models.exchange_stats import ExchangeStats from lighter.models.export_data import ExportData from lighter.models.order_book_details import OrderBookDetails @@ -45,7 +46,6 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client - @validate_call async def account_active_orders( self, account_index: StrictInt, @@ -737,6 +737,267 @@ def _account_inactive_orders_serialize( + @validate_call + async def asset_details( + self, + asset_id: Optional[StrictInt] = 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, + ) -> AssetDetails: + """assetDetails + + Get asset details + + :param asset_id: + :type asset_id: int + :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._asset_details_serialize( + asset_id=asset_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AssetDetails", + '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 + + + async def asset_details_with_http_info( + self, + asset_id: Optional[StrictInt] = 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[AssetDetails]: + """assetDetails + + Get asset details + + :param asset_id: + :type asset_id: int + :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._asset_details_serialize( + asset_id=asset_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AssetDetails", + '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, + ) + + + async def asset_details_without_preload_content( + self, + asset_id: Optional[StrictInt] = 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: + """assetDetails + + Get asset details + + :param asset_id: + :type asset_id: int + :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._asset_details_serialize( + asset_id=asset_id, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "AssetDetails", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _asset_details_serialize( + self, + asset_id, + _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 asset_id is not None: + + _query_params.append(('asset_id', asset_id)) + + # 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/assetDetails', + 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 exchange_stats( self, @@ -1316,6 +1577,7 @@ def _export_serialize( async def order_book_details( self, market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1335,6 +1597,8 @@ async def order_book_details( :param market_id: :type market_id: int + :param filter: + :type filter: 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 @@ -1359,6 +1623,7 @@ async def order_book_details( _param = self._order_book_details_serialize( market_id=market_id, + filter=filter, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1384,6 +1649,7 @@ async def order_book_details( async def order_book_details_with_http_info( self, market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1403,6 +1669,8 @@ async def order_book_details_with_http_info( :param market_id: :type market_id: int + :param filter: + :type filter: 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 @@ -1427,6 +1695,7 @@ async def order_book_details_with_http_info( _param = self._order_book_details_serialize( market_id=market_id, + filter=filter, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1452,6 +1721,7 @@ async def order_book_details_with_http_info( async def order_book_details_without_preload_content( self, market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1471,6 +1741,8 @@ async def order_book_details_without_preload_content( :param market_id: :type market_id: int + :param filter: + :type filter: 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 @@ -1495,6 +1767,7 @@ async def order_book_details_without_preload_content( _param = self._order_book_details_serialize( market_id=market_id, + filter=filter, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1515,6 +1788,7 @@ async def order_book_details_without_preload_content( def _order_book_details_serialize( self, market_id, + filter, _request_auth, _content_type, _headers, @@ -1539,6 +1813,10 @@ def _order_book_details_serialize( _query_params.append(('market_id', market_id)) + if filter is not None: + + _query_params.append(('filter', filter)) + # process the header parameters # process the form parameters # process the body parameter @@ -1579,7 +1857,7 @@ def _order_book_details_serialize( async def order_book_orders( self, market_id: StrictInt, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], + limit: Annotated[int, Field(le=250, strict=True, ge=1)], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1651,7 +1929,7 @@ async def order_book_orders( async def order_book_orders_with_http_info( self, market_id: StrictInt, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], + limit: Annotated[int, Field(le=250, strict=True, ge=1)], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1723,7 +2001,7 @@ async def order_book_orders_with_http_info( async def order_book_orders_without_preload_content( self, market_id: StrictInt, - limit: Annotated[int, Field(le=100, strict=True, ge=1)], + limit: Annotated[int, Field(le=250, strict=True, ge=1)], _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1859,6 +2137,7 @@ def _order_book_orders_serialize( async def order_books( self, market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1878,6 +2157,8 @@ async def order_books( :param market_id: :type market_id: int + :param filter: + :type filter: 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 @@ -1902,6 +2183,7 @@ async def order_books( _param = self._order_books_serialize( market_id=market_id, + filter=filter, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1927,6 +2209,7 @@ async def order_books( async def order_books_with_http_info( self, market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -1946,6 +2229,8 @@ async def order_books_with_http_info( :param market_id: :type market_id: int + :param filter: + :type filter: 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 @@ -1970,6 +2255,7 @@ async def order_books_with_http_info( _param = self._order_books_serialize( market_id=market_id, + filter=filter, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -1995,6 +2281,7 @@ async def order_books_with_http_info( async def order_books_without_preload_content( self, market_id: Optional[StrictInt] = None, + filter: Optional[StrictStr] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2014,6 +2301,8 @@ async def order_books_without_preload_content( :param market_id: :type market_id: int + :param filter: + :type filter: 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 @@ -2038,6 +2327,7 @@ async def order_books_without_preload_content( _param = self._order_books_serialize( market_id=market_id, + filter=filter, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2058,6 +2348,7 @@ async def order_books_without_preload_content( def _order_books_serialize( self, market_id, + filter, _request_auth, _content_type, _headers, @@ -2082,6 +2373,10 @@ def _order_books_serialize( _query_params.append(('market_id', market_id)) + if filter is not None: + + _query_params.append(('filter', filter)) + # process the header parameters # process the form parameters # process the body parameter @@ -2412,6 +2707,9 @@ async def trades( cursor: Optional[StrictStr] = None, var_from: Optional[StrictInt] = None, ask_filter: Optional[StrictInt] = None, + role: Optional[StrictStr] = None, + type: Optional[StrictStr] = None, + aggregate: Optional[StrictBool] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2451,6 +2749,12 @@ async def trades( :type var_from: int :param ask_filter: :type ask_filter: int + :param role: + :type role: str + :param type: + :type type: str + :param aggregate: + :type aggregate: bool :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 @@ -2485,6 +2789,9 @@ async def trades( cursor=cursor, var_from=var_from, ask_filter=ask_filter, + role=role, + type=type, + aggregate=aggregate, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2520,6 +2827,9 @@ async def trades_with_http_info( cursor: Optional[StrictStr] = None, var_from: Optional[StrictInt] = None, ask_filter: Optional[StrictInt] = None, + role: Optional[StrictStr] = None, + type: Optional[StrictStr] = None, + aggregate: Optional[StrictBool] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2559,6 +2869,12 @@ async def trades_with_http_info( :type var_from: int :param ask_filter: :type ask_filter: int + :param role: + :type role: str + :param type: + :type type: str + :param aggregate: + :type aggregate: bool :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 @@ -2593,6 +2909,9 @@ async def trades_with_http_info( cursor=cursor, var_from=var_from, ask_filter=ask_filter, + role=role, + type=type, + aggregate=aggregate, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2628,6 +2947,9 @@ async def trades_without_preload_content( cursor: Optional[StrictStr] = None, var_from: Optional[StrictInt] = None, ask_filter: Optional[StrictInt] = None, + role: Optional[StrictStr] = None, + type: Optional[StrictStr] = None, + aggregate: Optional[StrictBool] = None, _request_timeout: Union[ None, Annotated[StrictFloat, Field(gt=0)], @@ -2667,6 +2989,12 @@ async def trades_without_preload_content( :type var_from: int :param ask_filter: :type ask_filter: int + :param role: + :type role: str + :param type: + :type type: str + :param aggregate: + :type aggregate: bool :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 @@ -2701,6 +3029,9 @@ async def trades_without_preload_content( cursor=cursor, var_from=var_from, ask_filter=ask_filter, + role=role, + type=type, + aggregate=aggregate, _request_auth=_request_auth, _content_type=_content_type, _headers=_headers, @@ -2731,6 +3062,9 @@ def _trades_serialize( cursor, var_from, ask_filter, + role, + type, + aggregate, _request_auth, _content_type, _headers, @@ -2787,10 +3121,22 @@ def _trades_serialize( _query_params.append(('ask_filter', ask_filter)) + if role is not None: + + _query_params.append(('role', role)) + + if type is not None: + + _query_params.append(('type', type)) + if limit is not None: _query_params.append(('limit', limit)) + if aggregate is not None: + + _query_params.append(('aggregate', aggregate)) + # process the header parameters if authorization is not None: _header_params['authorization'] = authorization diff --git a/lighter/api/referral_api.py b/lighter/api/referral_api.py index 733ac60..7425d71 100644 --- a/lighter/api/referral_api.py +++ b/lighter/api/referral_api.py @@ -17,9 +17,11 @@ from typing_extensions import Annotated from pydantic import Field, StrictInt, StrictStr -from typing import Optional +from typing import Optional, Union from typing_extensions import Annotated from lighter.models.referral_points import ReferralPoints +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.models.resp_update_referral_code import RespUpdateReferralCode from lighter.api_client import ApiClient, RequestSerialized from lighter.api_response import ApiResponse @@ -39,7 +41,322 @@ def __init__(self, api_client=None) -> None: self.api_client = api_client - @validate_call + async def referral_kickback_update( + self, + account_index: StrictInt, + kickback_percentage: Union[Annotated[float, Field(le=1E+2, strict=True)], Annotated[int, Field(le=100, strict=True)]], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = 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, + ) -> RespUpdateKickback: + """referral_kickback_update + + Update kickback percentage for referral rewards + + :param account_index: (required) + :type account_index: int + :param kickback_percentage: (required) + :type kickback_percentage: float + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: 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._referral_kickback_update_serialize( + account_index=account_index, + kickback_percentage=kickback_percentage, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateKickback", + '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 + + + async def referral_kickback_update_with_http_info( + self, + account_index: StrictInt, + kickback_percentage: Union[Annotated[float, Field(le=1E+2, strict=True)], Annotated[int, Field(le=100, strict=True)]], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = 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[RespUpdateKickback]: + """referral_kickback_update + + Update kickback percentage for referral rewards + + :param account_index: (required) + :type account_index: int + :param kickback_percentage: (required) + :type kickback_percentage: float + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: 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._referral_kickback_update_serialize( + account_index=account_index, + kickback_percentage=kickback_percentage, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateKickback", + '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, + ) + + + async def referral_kickback_update_without_preload_content( + self, + account_index: StrictInt, + kickback_percentage: Union[Annotated[float, Field(le=1E+2, strict=True)], Annotated[int, Field(le=100, strict=True)]], + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = 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: + """referral_kickback_update + + Update kickback percentage for referral rewards + + :param account_index: (required) + :type account_index: int + :param kickback_percentage: (required) + :type kickback_percentage: float + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: 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._referral_kickback_update_serialize( + account_index=account_index, + kickback_percentage=kickback_percentage, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateKickback", + '400': "ResultCode", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _referral_kickback_update_serialize( + self, + account_index, + kickback_percentage, + authorization, + auth, + _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 + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # process the form parameters + if auth is not None: + _form_params.append(('auth', auth)) + if account_index is not None: + _form_params.append(('account_index', account_index)) + if kickback_percentage is not None: + _form_params.append(('kickback_percentage', kickback_percentage)) + # 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' + ] + ) + + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='POST', + resource_path='/api/v1/referral/kickback/update', + 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 + ) + + + + async def referral_points( self, account_index: StrictInt, @@ -57,7 +374,82 @@ async def referral_points( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ReferralPoints: + ) -> ReferralPoints: + """referral_points + + Get referral points + + :param account_index: (required) + :type account_index: int + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: 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._referral_points_serialize( + account_index=account_index, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "ReferralPoints", + '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 + + + async def referral_points_with_http_info( + self, + account_index: StrictInt, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = 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[ReferralPoints]: """referral_points Get referral points @@ -112,11 +504,10 @@ async def referral_points( return self.api_client.response_deserialize( response_data=response_data, response_types_map=_response_types_map, - ).data + ) - @validate_call - async def referral_points_with_http_info( + async def referral_points_without_preload_content( self, account_index: StrictInt, authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, @@ -133,7 +524,7 @@ async def referral_points_with_http_info( _content_type: Optional[StrictStr] = None, _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, - ) -> ApiResponse[ReferralPoints]: + ) -> RESTResponseType: """referral_points Get referral points @@ -184,6 +575,231 @@ async def referral_points_with_http_info( *_param, _request_timeout=_request_timeout ) + return response_data.response + + + def _referral_points_serialize( + self, + account_index, + authorization, + auth, + _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 auth is not None: + + _query_params.append(('auth', auth)) + + if account_index is not None: + + _query_params.append(('account_index', account_index)) + + # process the header parameters + if authorization is not None: + _header_params['authorization'] = authorization + # 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/referral/points', + 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 + ) + + + + + async def referral_update( + self, + account_index: StrictInt, + new_referral_code: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = 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, + ) -> RespUpdateReferralCode: + """referral_update + + Update referral code (allowed once per account) + + :param account_index: (required) + :type account_index: int + :param new_referral_code: (required) + :type new_referral_code: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: 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._referral_update_serialize( + account_index=account_index, + new_referral_code=new_referral_code, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateReferralCode", + '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 + + + async def referral_update_with_http_info( + self, + account_index: StrictInt, + new_referral_code: StrictStr, + authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, + auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = 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[RespUpdateReferralCode]: + """referral_update + + Update referral code (allowed once per account) + + :param account_index: (required) + :type account_index: int + :param new_referral_code: (required) + :type new_referral_code: str + :param authorization: make required after integ is done + :type authorization: str + :param auth: made optional to support header auth clients + :type auth: 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._referral_update_serialize( + account_index=account_index, + new_referral_code=new_referral_code, + authorization=authorization, + auth=auth, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "RespUpdateReferralCode", + '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, @@ -191,10 +807,10 @@ async def referral_points_with_http_info( ) - @validate_call - async def referral_points_without_preload_content( + async def referral_update_without_preload_content( self, account_index: StrictInt, + new_referral_code: StrictStr, authorization: Annotated[Optional[StrictStr], Field(description=" make required after integ is done")] = None, auth: Annotated[Optional[StrictStr], Field(description=" made optional to support header auth clients")] = None, _request_timeout: Union[ @@ -210,12 +826,14 @@ async def referral_points_without_preload_content( _headers: Optional[Dict[StrictStr, Any]] = None, _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, ) -> RESTResponseType: - """referral_points + """referral_update - Get referral points + Update referral code (allowed once per account) :param account_index: (required) :type account_index: int + :param new_referral_code: (required) + :type new_referral_code: str :param authorization: make required after integ is done :type authorization: str :param auth: made optional to support header auth clients @@ -242,8 +860,9 @@ async def referral_points_without_preload_content( :return: Returns the result object. """ # noqa: E501 - _param = self._referral_points_serialize( + _param = self._referral_update_serialize( account_index=account_index, + new_referral_code=new_referral_code, authorization=authorization, auth=auth, _request_auth=_request_auth, @@ -253,7 +872,7 @@ async def referral_points_without_preload_content( ) _response_types_map: Dict[str, Optional[str]] = { - '200': "ReferralPoints", + '200': "RespUpdateReferralCode", '400': "ResultCode", } response_data = await self.api_client.call_api( @@ -263,9 +882,10 @@ async def referral_points_without_preload_content( return response_data.response - def _referral_points_serialize( + def _referral_update_serialize( self, account_index, + new_referral_code, authorization, auth, _request_auth, @@ -288,18 +908,16 @@ def _referral_points_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)) - # process the header parameters if authorization is not None: _header_params['authorization'] = authorization # process the form parameters + if auth is not None: + _form_params.append(('auth', auth)) + if account_index is not None: + _form_params.append(('account_index', account_index)) + if new_referral_code is not None: + _form_params.append(('new_referral_code', new_referral_code)) # process the body parameter @@ -311,14 +929,27 @@ def _referral_points_serialize( ] ) + # set the HTTP header `Content-Type` + if _content_type: + _header_params['Content-Type'] = _content_type + else: + _default_content_type = ( + self.api_client.select_header_content_type( + [ + 'multipart/form-data' + ] + ) + ) + if _default_content_type is not None: + _header_params['Content-Type'] = _default_content_type # authentication setting _auth_settings: List[str] = [ ] return self.api_client.param_serialize( - method='GET', - resource_path='/api/v1/referral/points', + method='POST', + resource_path='/api/v1/referral/update', path_params=_path_params, query_params=_query_params, header_params=_header_params, diff --git a/lighter/models/__init__.py b/lighter/models/__init__.py index f5abd92..3123460 100644 --- a/lighter/models/__init__.py +++ b/lighter/models/__init__.py @@ -16,6 +16,7 @@ # import models into model package from lighter.models.account import Account from lighter.models.account_api_keys import AccountApiKeys +from lighter.models.account_asset import AccountAsset from lighter.models.account_limits import AccountLimits from lighter.models.account_margin_stats import AccountMarginStats from lighter.models.account_market_stats import AccountMarketStats @@ -28,8 +29,11 @@ from lighter.models.announcement import Announcement from lighter.models.announcements import Announcements from lighter.models.api_key import ApiKey +from lighter.models.asset import Asset +from lighter.models.asset_details import AssetDetails from lighter.models.block import Block from lighter.models.blocks import Blocks +from lighter.models.bridge import Bridge from lighter.models.bridge_supported_network import BridgeSupportedNetwork from lighter.models.candlestick import Candlestick from lighter.models.candlesticks import Candlesticks @@ -55,26 +59,25 @@ from lighter.models.liquidation import Liquidation from lighter.models.liquidation_info import LiquidationInfo from lighter.models.liquidation_infos import LiquidationInfos -from lighter.models.market_info import MarketInfo +from lighter.models.market_config import MarketConfig 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 from lighter.models.order_book_stats import OrderBookStats from lighter.models.order_books import OrderBooks from lighter.models.orders import Orders +from lighter.models.perps_market_stats import PerpsMarketStats +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail from lighter.models.pn_l_entry import PnLEntry from lighter.models.position_funding import PositionFunding from lighter.models.position_fundings import PositionFundings 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_metadata import PublicPoolMetadata from lighter.models.public_pool_share import PublicPoolShare -from lighter.models.public_pools import PublicPools from lighter.models.referral_point_entry import ReferralPointEntry from lighter.models.referral_points import ReferralPoints from lighter.models.req_export_data import ReqExportData @@ -87,8 +90,10 @@ from lighter.models.req_get_account_metadata import ReqGetAccountMetadata from lighter.models.req_get_account_pn_l import ReqGetAccountPnL from lighter.models.req_get_account_txs import ReqGetAccountTxs +from lighter.models.req_get_asset_details import ReqGetAssetDetails from lighter.models.req_get_block import ReqGetBlock from lighter.models.req_get_block_txs import ReqGetBlockTxs +from lighter.models.req_get_bridges_by_l1_addr import ReqGetBridgesByL1Addr 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 @@ -103,7 +108,6 @@ from lighter.models.req_get_order_book_orders import ReqGetOrderBookOrders from lighter.models.req_get_order_books import ReqGetOrderBooks from lighter.models.req_get_position_funding import ReqGetPositionFunding -from lighter.models.req_get_public_pools import ReqGetPublicPools from lighter.models.req_get_public_pools_metadata import ReqGetPublicPoolsMetadata from lighter.models.req_get_range_with_cursor import ReqGetRangeWithCursor from lighter.models.req_get_range_with_index import ReqGetRangeWithIndex @@ -116,16 +120,22 @@ from lighter.models.req_get_tx import ReqGetTx from lighter.models.req_get_withdraw_history import ReqGetWithdrawHistory from lighter.models.resp_change_account_tier import RespChangeAccountTier +from lighter.models.resp_get_bridges_by_l1_addr import RespGetBridgesByL1Addr from lighter.models.resp_get_fast_bridge_info import RespGetFastBridgeInfo +from lighter.models.resp_get_is_next_bridge_fast import RespGetIsNextBridgeFast from lighter.models.resp_public_pools_metadata import RespPublicPoolsMetadata from lighter.models.resp_send_tx import RespSendTx from lighter.models.resp_send_tx_batch import RespSendTxBatch +from lighter.models.resp_update_kickback import RespUpdateKickback +from lighter.models.resp_update_referral_code import RespUpdateReferralCode from lighter.models.resp_withdrawal_delay import RespWithdrawalDelay from lighter.models.result_code import ResultCode from lighter.models.risk_info import RiskInfo from lighter.models.risk_parameters import RiskParameters from lighter.models.share_price import SharePrice from lighter.models.simple_order import SimpleOrder +from lighter.models.spot_market_stats import SpotMarketStats +from lighter.models.spot_order_book_detail import SpotOrderBookDetail from lighter.models.status import Status from lighter.models.sub_accounts import SubAccounts from lighter.models.ticker import Ticker @@ -142,3 +152,5 @@ 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.models.ws_account_assets import WSAccountAssets \ No newline at end of file diff --git a/lighter/models/account.py b/lighter/models/account.py index c14398c..82958bf 100644 --- a/lighter/models/account.py +++ b/lighter/models/account.py @@ -33,13 +33,12 @@ class Account(BaseModel): l1_address: StrictStr cancel_all_time: StrictInt total_order_count: StrictInt - total_isolated_order_count: StrictInt pending_order_count: StrictInt available_balance: Optional[StrictStr] status: StrictInt collateral: StrictStr additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "total_isolated_order_count", "pending_order_count", "available_balance", "status", "collateral"] + __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "available_balance", "status", "collateral"] model_config = ConfigDict( populate_by_name=True, @@ -106,7 +105,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "l1_address": obj.get("l1_address"), "cancel_all_time": obj.get("cancel_all_time"), "total_order_count": obj.get("total_order_count"), - "total_isolated_order_count": obj.get("total_isolated_order_count"), "pending_order_count": obj.get("pending_order_count"), "available_balance": obj.get("available_balance"), "status": obj.get("status"), diff --git a/lighter/models/account_asset.py b/lighter/models/account_asset.py new file mode 100644 index 0000000..a5a8c7b --- /dev/null +++ b/lighter/models/account_asset.py @@ -0,0 +1,106 @@ +# 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 AccountAsset(BaseModel): + """ + AccountAsset + """ # noqa: E501 + symbol: StrictStr + asset_id: StrictInt + balance: StrictStr + locked_balance: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "asset_id", "balance", "locked_balance"] + + 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 AccountAsset 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 AccountAsset from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "asset_id": obj.get("asset_id"), + "balance": obj.get("balance"), + "locked_balance": obj.get("locked_balance") + }) + # 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_limits.py b/lighter/models/account_limits.py index 81eff07..a6bdc2a 100644 --- a/lighter/models/account_limits.py +++ b/lighter/models/account_limits.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 typing import Optional, Set from typing_extensions import Self @@ -29,9 +29,11 @@ class AccountLimits(BaseModel): code: StrictInt message: Optional[StrictStr] = None max_llp_percentage: StrictInt + max_llp_amount: StrictStr user_tier: StrictStr + can_create_public_pool: StrictBool additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "max_llp_percentage", "user_tier"] + __properties: ClassVar[List[str]] = ["code", "message", "max_llp_percentage", "max_llp_amount", "user_tier", "can_create_public_pool"] model_config = ConfigDict( populate_by_name=True, @@ -94,7 +96,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "code": obj.get("code"), "message": obj.get("message"), "max_llp_percentage": obj.get("max_llp_percentage"), - "user_tier": obj.get("user_tier") + "max_llp_amount": obj.get("max_llp_amount"), + "user_tier": obj.get("user_tier"), + "can_create_public_pool": obj.get("can_create_public_pool") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/announcement.py b/lighter/models/announcement.py index cbccae5..27ab271 100644 --- a/lighter/models/announcement.py +++ b/lighter/models/announcement.py @@ -29,8 +29,9 @@ class Announcement(BaseModel): title: StrictStr content: StrictStr created_at: StrictInt + expired_at: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["title", "content", "created_at"] + __properties: ClassVar[List[str]] = ["title", "content", "created_at", "expired_at"] model_config = ConfigDict( populate_by_name=True, @@ -92,7 +93,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "title": obj.get("title"), "content": obj.get("content"), - "created_at": obj.get("created_at") + "created_at": obj.get("created_at"), + "expired_at": obj.get("expired_at") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/asset.py b/lighter/models/asset.py new file mode 100644 index 0000000..ec3b522 --- /dev/null +++ b/lighter/models/asset.py @@ -0,0 +1,123 @@ +# 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 Asset(BaseModel): + """ + Asset + """ # noqa: E501 + asset_id: StrictInt + symbol: StrictStr + l1_decimals: StrictInt + decimals: StrictInt + min_transfer_amount: StrictStr + min_withdrawal_amount: StrictStr + margin_mode: StrictStr + index_price: StrictStr + l1_address: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["asset_id", "symbol", "l1_decimals", "decimals", "min_transfer_amount", "min_withdrawal_amount", "margin_mode", "index_price", "l1_address"] + + @field_validator('margin_mode') + def margin_mode_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['enabled', 'disabled']): + raise ValueError("must be one of enum values ('enabled', 'disabled')") + 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 Asset 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 Asset from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "asset_id": obj.get("asset_id"), + "symbol": obj.get("symbol"), + "l1_decimals": obj.get("l1_decimals"), + "decimals": obj.get("decimals"), + "min_transfer_amount": obj.get("min_transfer_amount"), + "min_withdrawal_amount": obj.get("min_withdrawal_amount"), + "margin_mode": obj.get("margin_mode"), + "index_price": obj.get("index_price"), + "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/public_pools.py b/lighter/models/asset_details.py similarity index 81% rename from lighter/models/public_pools.py rename to lighter/models/asset_details.py index 1ad4092..6437910 100644 --- a/lighter/models/public_pools.py +++ b/lighter/models/asset_details.py @@ -19,20 +19,19 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from lighter.models.public_pool import PublicPool +from lighter.models.asset import Asset from typing import Optional, Set from typing_extensions import Self -class PublicPools(BaseModel): +class AssetDetails(BaseModel): """ - PublicPools + AssetDetails """ # noqa: E501 code: StrictInt message: Optional[StrictStr] = None - total: StrictInt - public_pools: List[PublicPool] + asset_details: List[Asset] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "total", "public_pools"] + __properties: ClassVar[List[str]] = ["code", "message", "asset_details"] model_config = ConfigDict( populate_by_name=True, @@ -52,7 +51,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of PublicPools from a JSON string""" + """Create an instance of AssetDetails from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -75,13 +74,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 public_pools (list) + # override the default output from pydantic by calling `to_dict()` of each item in asset_details (list) _items = [] - if self.public_pools: - for _item in self.public_pools: + if self.asset_details: + for _item in self.asset_details: if _item: _items.append(_item.to_dict()) - _dict['public_pools'] = _items + _dict['asset_details'] = _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(): @@ -91,7 +90,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of PublicPools from a dict""" + """Create an instance of AssetDetails from a dict""" if obj is None: return None @@ -101,8 +100,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "code": obj.get("code"), "message": obj.get("message"), - "total": obj.get("total"), - "public_pools": [PublicPool.from_dict(_item) for _item in obj["public_pools"]] if obj.get("public_pools") is not None else None + "asset_details": [Asset.from_dict(_item) for _item in obj["asset_details"]] if obj.get("asset_details") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/bridge.py b/lighter/models/bridge.py new file mode 100644 index 0000000..23bc14d --- /dev/null +++ b/lighter/models/bridge.py @@ -0,0 +1,142 @@ +# 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 +from typing import Optional, Set +from typing_extensions import Self + +class Bridge(BaseModel): + """ + Bridge + """ # noqa: E501 + id: StrictInt + version: StrictInt + source: StrictStr + source_chain_id: StrictStr + fast_bridge_tx_hash: StrictStr + batch_claim_tx_hash: StrictStr + cctp_burn_tx_hash: StrictStr + amount: StrictStr + intent_address: StrictStr + status: StrictStr + step: StrictStr + description: StrictStr + created_at: StrictInt + updated_at: StrictInt + is_external_deposit: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["id", "version", "source", "source_chain_id", "fast_bridge_tx_hash", "batch_claim_tx_hash", "cctp_burn_tx_hash", "amount", "intent_address", "status", "step", "description", "created_at", "updated_at", "is_external_deposit"] + + @field_validator('version') + def version_validate_enum(cls, value): + """Validates the enum""" + if value not in set([1, 2]): + raise ValueError("must be one of enum values (1, 2)") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['pending', 'bridging', 'completed']): + raise ValueError("must be one of enum values ('pending', 'bridging', 'completed')") + 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 Bridge 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 Bridge from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "id": obj.get("id"), + "version": obj.get("version"), + "source": obj.get("source"), + "source_chain_id": obj.get("source_chain_id"), + "fast_bridge_tx_hash": obj.get("fast_bridge_tx_hash"), + "batch_claim_tx_hash": obj.get("batch_claim_tx_hash"), + "cctp_burn_tx_hash": obj.get("cctp_burn_tx_hash"), + "amount": obj.get("amount"), + "intent_address": obj.get("intent_address"), + "status": obj.get("status"), + "step": obj.get("step"), + "description": obj.get("description"), + "created_at": obj.get("created_at"), + "updated_at": obj.get("updated_at"), + "is_external_deposit": obj.get("is_external_deposit") + }) + # 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/candlestick.py b/lighter/models/candlestick.py index ea9d42e..b1722af 100644 --- a/lighter/models/candlestick.py +++ b/lighter/models/candlestick.py @@ -31,11 +31,15 @@ class Candlestick(BaseModel): high: Union[StrictFloat, StrictInt] low: Union[StrictFloat, StrictInt] close: Union[StrictFloat, StrictInt] + open_raw: Union[StrictFloat, StrictInt] + high_raw: Union[StrictFloat, StrictInt] + low_raw: Union[StrictFloat, StrictInt] + close_raw: Union[StrictFloat, StrictInt] volume0: Union[StrictFloat, StrictInt] volume1: Union[StrictFloat, StrictInt] last_trade_id: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["timestamp", "open", "high", "low", "close", "volume0", "volume1", "last_trade_id"] + __properties: ClassVar[List[str]] = ["timestamp", "open", "high", "low", "close", "open_raw", "high_raw", "low_raw", "close_raw", "volume0", "volume1", "last_trade_id"] model_config = ConfigDict( populate_by_name=True, @@ -100,6 +104,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "high": obj.get("high"), "low": obj.get("low"), "close": obj.get("close"), + "open_raw": obj.get("open_raw"), + "high_raw": obj.get("high_raw"), + "low_raw": obj.get("low_raw"), + "close_raw": obj.get("close_raw"), "volume0": obj.get("volume0"), "volume1": obj.get("volume1"), "last_trade_id": obj.get("last_trade_id") diff --git a/lighter/models/deposit_history_item.py b/lighter/models/deposit_history_item.py index c7a1894..41fb0da 100644 --- a/lighter/models/deposit_history_item.py +++ b/lighter/models/deposit_history_item.py @@ -27,12 +27,13 @@ class DepositHistoryItem(BaseModel): DepositHistoryItem """ # noqa: E501 id: StrictStr + asset_id: StrictInt amount: StrictStr timestamp: StrictInt status: StrictStr l1_tx_hash: StrictStr additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "amount", "timestamp", "status", "l1_tx_hash"] + __properties: ClassVar[List[str]] = ["id", "asset_id", "amount", "timestamp", "status", "l1_tx_hash"] @field_validator('status') def status_validate_enum(cls, value): @@ -100,6 +101,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "id": obj.get("id"), + "asset_id": obj.get("asset_id"), "amount": obj.get("amount"), "timestamp": obj.get("timestamp"), "status": obj.get("status"), diff --git a/lighter/models/detailed_account.py b/lighter/models/detailed_account.py index eb8a0b0..e0c4b07 100644 --- a/lighter/models/detailed_account.py +++ b/lighter/models/detailed_account.py @@ -19,6 +19,7 @@ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional +from lighter.models.account_asset import AccountAsset from lighter.models.account_position import AccountPosition from lighter.models.public_pool_info import PublicPoolInfo from lighter.models.public_pool_share import PublicPoolShare @@ -36,7 +37,6 @@ class DetailedAccount(BaseModel): l1_address: StrictStr cancel_all_time: StrictInt total_order_count: StrictInt - total_isolated_order_count: StrictInt pending_order_count: StrictInt available_balance: Optional[StrictStr] status: StrictInt @@ -47,12 +47,13 @@ class DetailedAccount(BaseModel): can_invite: StrictBool = Field(description=" Remove After FE uses L1 meta endpoint") referral_points_percentage: StrictStr = Field(description=" Remove After FE uses L1 meta endpoint") positions: List[AccountPosition] + assets: List[AccountAsset] total_asset_value: StrictStr cross_asset_value: StrictStr pool_info: Optional[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", "total_isolated_order_count", "pending_order_count", "available_balance", "status", "collateral", "account_index", "name", "description", "can_invite", "referral_points_percentage", "positions", "total_asset_value", "cross_asset_value", "pool_info", "shares"] + __properties: ClassVar[List[str]] = ["code", "message", "account_type", "index", "l1_address", "cancel_all_time", "total_order_count", "pending_order_count", "available_balance", "status", "collateral", "account_index", "name", "description", "can_invite", "referral_points_percentage", "positions", "assets", "total_asset_value", "cross_asset_value", "pool_info", "shares"] model_config = ConfigDict( populate_by_name=True, @@ -102,6 +103,13 @@ 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 assets (list) + _items = [] + if self.assets: + for _item in self.assets: + if _item: + _items.append(_item.to_dict()) + _dict['assets'] = _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() @@ -136,7 +144,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "l1_address": obj.get("l1_address"), "cancel_all_time": obj.get("cancel_all_time"), "total_order_count": obj.get("total_order_count"), - "total_isolated_order_count": obj.get("total_isolated_order_count"), "pending_order_count": obj.get("pending_order_count"), "available_balance": obj.get("available_balance"), "status": obj.get("status"), @@ -147,6 +154,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "can_invite": obj.get("can_invite"), "referral_points_percentage": obj.get("referral_points_percentage"), "positions": [AccountPosition.from_dict(_item) for _item in obj["positions"]] if obj.get("positions") is not None else None, + "assets": [AccountAsset.from_dict(_item) for _item in obj["assets"]] if obj.get("assets") is not None else None, "total_asset_value": obj.get("total_asset_value"), "cross_asset_value": obj.get("cross_asset_value"), "pool_info": PublicPoolInfo.from_dict(obj["pool_info"]) if obj.get("pool_info") is not None else None, diff --git a/lighter/models/detailed_candlestick.py b/lighter/models/detailed_candlestick.py index 36a84ca..1a1460d 100644 --- a/lighter/models/detailed_candlestick.py +++ b/lighter/models/detailed_candlestick.py @@ -31,12 +31,16 @@ class DetailedCandlestick(BaseModel): high: Union[StrictFloat, StrictInt] low: Union[StrictFloat, StrictInt] close: Union[StrictFloat, StrictInt] + open_raw: Union[StrictFloat, StrictInt] + high_raw: Union[StrictFloat, StrictInt] + low_raw: Union[StrictFloat, StrictInt] + close_raw: 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"] + __properties: ClassVar[List[str]] = ["timestamp", "open", "high", "low", "close", "open_raw", "high_raw", "low_raw", "close_raw", "volume0", "volume1", "last_trade_id", "trade_count"] model_config = ConfigDict( populate_by_name=True, @@ -101,6 +105,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "high": obj.get("high"), "low": obj.get("low"), "close": obj.get("close"), + "open_raw": obj.get("open_raw"), + "high_raw": obj.get("high_raw"), + "low_raw": obj.get("low_raw"), + "close_raw": obj.get("close_raw"), "volume0": obj.get("volume0"), "volume1": obj.get("volume1"), "last_trade_id": obj.get("last_trade_id"), diff --git a/lighter/models/enriched_tx.py b/lighter/models/enriched_tx.py index 08567b2..caa40af 100644 --- a/lighter/models/enriched_tx.py +++ b/lighter/models/enriched_tx.py @@ -44,10 +44,11 @@ class EnrichedTx(BaseModel): executed_at: StrictInt sequence_index: StrictInt parent_hash: StrictStr + api_key_index: StrictInt committed_at: StrictInt verified_at: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "hash", "type", "info", "event_info", "status", "transaction_index", "l1_address", "account_index", "nonce", "expire_at", "block_height", "queued_at", "executed_at", "sequence_index", "parent_hash", "committed_at", "verified_at"] + __properties: ClassVar[List[str]] = ["code", "message", "hash", "type", "info", "event_info", "status", "transaction_index", "l1_address", "account_index", "nonce", "expire_at", "block_height", "queued_at", "executed_at", "sequence_index", "parent_hash", "api_key_index", "committed_at", "verified_at"] model_config = ConfigDict( populate_by_name=True, @@ -124,6 +125,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "executed_at": obj.get("executed_at"), "sequence_index": obj.get("sequence_index"), "parent_hash": obj.get("parent_hash"), + "api_key_index": obj.get("api_key_index"), "committed_at": obj.get("committed_at"), "verified_at": obj.get("verified_at") }) diff --git a/lighter/models/market_config.py b/lighter/models/market_config.py new file mode 100644 index 0000000..c5f9ddb --- /dev/null +++ b/lighter/models/market_config.py @@ -0,0 +1,108 @@ +# 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 +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class MarketConfig(BaseModel): + """ + MarketConfig + """ # noqa: E501 + market_margin_mode: StrictInt + insurance_fund_account_index: StrictInt + liquidation_mode: StrictInt + force_reduce_only: StrictBool + trading_hours: StrictStr + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["market_margin_mode", "insurance_fund_account_index", "liquidation_mode", "force_reduce_only", "trading_hours"] + + 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 MarketConfig 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 MarketConfig from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "market_margin_mode": obj.get("market_margin_mode"), + "insurance_fund_account_index": obj.get("insurance_fund_account_index"), + "liquidation_mode": obj.get("liquidation_mode"), + "force_reduce_only": obj.get("force_reduce_only"), + "trading_hours": obj.get("trading_hours") + }) + # 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 47d6543..a0db5d2 100644 --- a/lighter/models/order.py +++ b/lighter/models/order.py @@ -57,8 +57,10 @@ class Order(BaseModel): to_cancel_order_id_0: StrictStr block_height: StrictInt timestamp: StrictInt + created_at: StrictInt + updated_at: StrictInt additional_properties: Dict[str, Any] = {} - __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"] + __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", "created_at", "updated_at"] @field_validator('type') def type_validate_enum(cls, value): @@ -77,8 +79,8 @@ 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', 'canceled-oco', 'canceled-child', 'canceled-liquidation']): - 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', 'canceled-liquidation')") + 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', 'canceled-liquidation', 'canceled-invalid-balance']): + 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', 'canceled-liquidation', 'canceled-invalid-balance')") return value @field_validator('trigger_status') @@ -176,7 +178,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "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") + "timestamp": obj.get("timestamp"), + "created_at": obj.get("created_at"), + "updated_at": obj.get("updated_at") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/order_book.py b/lighter/models/order_book.py index 4cbdb56..0c39960 100644 --- a/lighter/models/order_book.py +++ b/lighter/models/order_book.py @@ -28,23 +28,34 @@ class OrderBook(BaseModel): """ # noqa: E501 symbol: StrictStr market_id: StrictInt + market_type: StrictStr + base_asset_id: StrictInt + quote_asset_id: StrictInt status: StrictStr taker_fee: StrictStr maker_fee: StrictStr liquidation_fee: StrictStr min_base_amount: StrictStr min_quote_amount: StrictStr + order_quote_limit: StrictStr supported_size_decimals: StrictInt supported_price_decimals: StrictInt supported_quote_decimals: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["symbol", "market_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals"] + __properties: ClassVar[List[str]] = ["symbol", "market_id", "market_type", "base_asset_id", "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals"] + + @field_validator('market_type') + def market_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['perp', 'spot']): + raise ValueError("must be one of enum values ('perp', 'spot')") + return value @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" - if value not in set(['inactive', 'frozen', 'active']): - raise ValueError("must be one of enum values ('inactive', 'frozen', 'active')") + if value not in set(['inactive', 'active']): + raise ValueError("must be one of enum values ('inactive', 'active')") return value model_config = ConfigDict( @@ -107,12 +118,16 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "symbol": obj.get("symbol"), "market_id": obj.get("market_id"), + "market_type": obj.get("market_type"), + "base_asset_id": obj.get("base_asset_id"), + "quote_asset_id": obj.get("quote_asset_id"), "status": obj.get("status"), "taker_fee": obj.get("taker_fee"), "maker_fee": obj.get("maker_fee"), "liquidation_fee": obj.get("liquidation_fee"), "min_base_amount": obj.get("min_base_amount"), "min_quote_amount": obj.get("min_quote_amount"), + "order_quote_limit": obj.get("order_quote_limit"), "supported_size_decimals": obj.get("supported_size_decimals"), "supported_price_decimals": obj.get("supported_price_decimals"), "supported_quote_decimals": obj.get("supported_quote_decimals") diff --git a/lighter/models/order_book_depth.py b/lighter/models/order_book_depth.py index 214d798..68d7534 100644 --- a/lighter/models/order_book_depth.py +++ b/lighter/models/order_book_depth.py @@ -32,8 +32,9 @@ class OrderBookDepth(BaseModel): asks: List[PriceLevel] bids: List[PriceLevel] offset: StrictInt + nonce: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "asks", "bids", "offset"] + __properties: ClassVar[List[str]] = ["code", "message", "asks", "bids", "offset", "nonce"] model_config = ConfigDict( populate_by_name=True, @@ -111,7 +112,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "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") + "offset": obj.get("offset"), + "nonce": obj.get("nonce") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/order_book_details.py b/lighter/models/order_book_details.py index a67276f..b2f5091 100644 --- a/lighter/models/order_book_details.py +++ b/lighter/models/order_book_details.py @@ -19,7 +19,8 @@ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from lighter.models.order_book_detail import OrderBookDetail +from lighter.models.perps_order_book_detail import PerpsOrderBookDetail +from lighter.models.spot_order_book_detail import SpotOrderBookDetail from typing import Optional, Set from typing_extensions import Self @@ -29,9 +30,10 @@ class OrderBookDetails(BaseModel): """ # noqa: E501 code: StrictInt message: Optional[StrictStr] = None - order_book_details: List[OrderBookDetail] + order_book_details: List[PerpsOrderBookDetail] + spot_order_book_details: List[SpotOrderBookDetail] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "order_book_details"] + __properties: ClassVar[List[str]] = ["code", "message", "order_book_details", "spot_order_book_details"] model_config = ConfigDict( populate_by_name=True, @@ -81,6 +83,13 @@ def to_dict(self) -> Dict[str, Any]: if _item: _items.append(_item.to_dict()) _dict['order_book_details'] = _items + # override the default output from pydantic by calling `to_dict()` of each item in spot_order_book_details (list) + _items = [] + if self.spot_order_book_details: + for _item in self.spot_order_book_details: + if _item: + _items.append(_item.to_dict()) + _dict['spot_order_book_details'] = _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(): @@ -100,7 +109,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "code": obj.get("code"), "message": obj.get("message"), - "order_book_details": [OrderBookDetail.from_dict(_item) for _item in obj["order_book_details"]] if obj.get("order_book_details") is not None else None + "order_book_details": [PerpsOrderBookDetail.from_dict(_item) for _item in obj["order_book_details"]] if obj.get("order_book_details") is not None else None, + "spot_order_book_details": [SpotOrderBookDetail.from_dict(_item) for _item in obj["spot_order_book_details"]] if obj.get("spot_order_book_details") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/market_info.py b/lighter/models/perps_market_stats.py similarity index 81% rename from lighter/models/market_info.py rename to lighter/models/perps_market_stats.py index c836971..e810dc5 100644 --- a/lighter/models/market_info.py +++ b/lighter/models/perps_market_stats.py @@ -22,14 +22,18 @@ from typing import Optional, Set from typing_extensions import Self -class MarketInfo(BaseModel): +class PerpsMarketStats(BaseModel): """ - MarketInfo + PerpsMarketStats """ # noqa: E501 + symbol: StrictStr market_id: StrictInt index_price: StrictStr mark_price: StrictStr open_interest: StrictStr + open_interest_limit: StrictStr + funding_clamp_small: StrictStr + funding_clamp_big: StrictStr last_trade_price: StrictStr current_funding_rate: StrictStr funding_rate: StrictStr @@ -40,7 +44,7 @@ class MarketInfo(BaseModel): 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"] + __properties: ClassVar[List[str]] = ["symbol", "market_id", "index_price", "mark_price", "open_interest", "open_interest_limit", "funding_clamp_small", "funding_clamp_big", "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, @@ -60,7 +64,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of MarketInfo from a JSON string""" + """Create an instance of PerpsMarketStats from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -92,7 +96,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of MarketInfo from a dict""" + """Create an instance of PerpsMarketStats from a dict""" if obj is None: return None @@ -100,10 +104,14 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ + "symbol": obj.get("symbol"), "market_id": obj.get("market_id"), "index_price": obj.get("index_price"), "mark_price": obj.get("mark_price"), "open_interest": obj.get("open_interest"), + "open_interest_limit": obj.get("open_interest_limit"), + "funding_clamp_small": obj.get("funding_clamp_small"), + "funding_clamp_big": obj.get("funding_clamp_big"), "last_trade_price": obj.get("last_trade_price"), "current_funding_rate": obj.get("current_funding_rate"), "funding_rate": obj.get("funding_rate"), diff --git a/lighter/models/perps_order_book_detail.py b/lighter/models/perps_order_book_detail.py new file mode 100644 index 0000000..2ec0269 --- /dev/null +++ b/lighter/models/perps_order_book_detail.py @@ -0,0 +1,180 @@ +# 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, field_validator +from typing import Any, ClassVar, Dict, List, Union +from lighter.models.market_config import MarketConfig +from typing import Optional, Set +from typing_extensions import Self + +class PerpsOrderBookDetail(BaseModel): + """ + PerpsOrderBookDetail + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + market_type: StrictStr + base_asset_id: StrictInt + quote_asset_id: StrictInt + status: StrictStr + taker_fee: StrictStr + maker_fee: StrictStr + liquidation_fee: StrictStr + min_base_amount: StrictStr + min_quote_amount: StrictStr + order_quote_limit: StrictStr + supported_size_decimals: StrictInt + supported_price_decimals: StrictInt + supported_quote_decimals: StrictInt + size_decimals: StrictInt + price_decimals: StrictInt + quote_multiplier: StrictInt + default_initial_margin_fraction: StrictInt + min_initial_margin_fraction: StrictInt + maintenance_margin_fraction: StrictInt + closeout_margin_fraction: StrictInt + last_trade_price: Union[StrictFloat, StrictInt] + daily_trades_count: 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] + open_interest: Union[StrictFloat, StrictInt] + daily_chart: Dict[str, Union[StrictFloat, StrictInt]] + market_config: MarketConfig + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["symbol", "market_id", "market_type", "base_asset_id", "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals", "size_decimals", "price_decimals", "quote_multiplier", "default_initial_margin_fraction", "min_initial_margin_fraction", "maintenance_margin_fraction", "closeout_margin_fraction", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change", "open_interest", "daily_chart", "market_config"] + + @field_validator('market_type') + def market_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['perp', 'spot']): + raise ValueError("must be one of enum values ('perp', 'spot')") + return value + + @field_validator('status') + def status_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['inactive', 'active']): + raise ValueError("must be one of enum values ('inactive', 'active')") + 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 PerpsOrderBookDetail 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 market_config + if self.market_config: + _dict['market_config'] = self.market_config.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 PerpsOrderBookDetail from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "market_type": obj.get("market_type"), + "base_asset_id": obj.get("base_asset_id"), + "quote_asset_id": obj.get("quote_asset_id"), + "status": obj.get("status"), + "taker_fee": obj.get("taker_fee"), + "maker_fee": obj.get("maker_fee"), + "liquidation_fee": obj.get("liquidation_fee"), + "min_base_amount": obj.get("min_base_amount"), + "min_quote_amount": obj.get("min_quote_amount"), + "order_quote_limit": obj.get("order_quote_limit"), + "supported_size_decimals": obj.get("supported_size_decimals"), + "supported_price_decimals": obj.get("supported_price_decimals"), + "supported_quote_decimals": obj.get("supported_quote_decimals"), + "size_decimals": obj.get("size_decimals"), + "price_decimals": obj.get("price_decimals"), + "quote_multiplier": obj.get("quote_multiplier"), + "default_initial_margin_fraction": obj.get("default_initial_margin_fraction"), + "min_initial_margin_fraction": obj.get("min_initial_margin_fraction"), + "maintenance_margin_fraction": obj.get("maintenance_margin_fraction"), + "closeout_margin_fraction": obj.get("closeout_margin_fraction"), + "last_trade_price": obj.get("last_trade_price"), + "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"), + "daily_price_low": obj.get("daily_price_low"), + "daily_price_high": obj.get("daily_price_high"), + "daily_price_change": obj.get("daily_price_change"), + "open_interest": obj.get("open_interest"), + "daily_chart": obj.get("daily_chart"), + "market_config": MarketConfig.from_dict(obj["market_config"]) if obj.get("market_config") 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/pn_l_entry.py b/lighter/models/pn_l_entry.py index 5bedea7..bff1f17 100644 --- a/lighter/models/pn_l_entry.py +++ b/lighter/models/pn_l_entry.py @@ -28,14 +28,17 @@ class PnLEntry(BaseModel): """ # noqa: E501 timestamp: StrictInt trade_pnl: Union[StrictFloat, StrictInt] + trade_spot_pnl: Union[StrictFloat, StrictInt] inflow: Union[StrictFloat, StrictInt] outflow: Union[StrictFloat, StrictInt] + spot_outflow: Union[StrictFloat, StrictInt] + spot_inflow: Union[StrictFloat, StrictInt] pool_pnl: Union[StrictFloat, StrictInt] pool_inflow: Union[StrictFloat, StrictInt] pool_outflow: Union[StrictFloat, StrictInt] pool_total_shares: Union[StrictFloat, StrictInt] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["timestamp", "trade_pnl", "inflow", "outflow", "pool_pnl", "pool_inflow", "pool_outflow", "pool_total_shares"] + __properties: ClassVar[List[str]] = ["timestamp", "trade_pnl", "trade_spot_pnl", "inflow", "outflow", "spot_outflow", "spot_inflow", "pool_pnl", "pool_inflow", "pool_outflow", "pool_total_shares"] model_config = ConfigDict( populate_by_name=True, @@ -97,8 +100,11 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "timestamp": obj.get("timestamp"), "trade_pnl": obj.get("trade_pnl"), + "trade_spot_pnl": obj.get("trade_spot_pnl"), "inflow": obj.get("inflow"), "outflow": obj.get("outflow"), + "spot_outflow": obj.get("spot_outflow"), + "spot_inflow": obj.get("spot_inflow"), "pool_pnl": obj.get("pool_pnl"), "pool_inflow": obj.get("pool_inflow"), "pool_outflow": obj.get("pool_outflow"), diff --git a/lighter/models/public_pool.py b/lighter/models/public_pool.py deleted file mode 100644 index 5d9b61a..0000000 --- a/lighter/models/public_pool.py +++ /dev/null @@ -1,148 +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, 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 -from typing import Optional, Set -from typing_extensions import Self - -class PublicPool(BaseModel): - """ - PublicPool - """ # noqa: E501 - code: StrictInt - message: Optional[StrictStr] = None - account_type: StrictInt - index: StrictInt - l1_address: StrictStr - cancel_all_time: StrictInt - total_order_count: StrictInt - total_isolated_order_count: StrictInt - pending_order_count: StrictInt - available_balance: StrictStr - status: StrictInt - collateral: StrictStr - account_index: StrictInt - name: StrictStr - description: StrictStr - can_invite: StrictBool = Field(description=" Remove After FE uses L1 meta endpoint") - referral_points_percentage: StrictStr = Field(description=" Remove After FE uses L1 meta endpoint") - total_asset_value: StrictStr - cross_asset_value: StrictStr - pool_info: PublicPoolInfo - 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", "total_isolated_order_count", "pending_order_count", "available_balance", "status", "collateral", "account_index", "name", "description", "can_invite", "referral_points_percentage", "total_asset_value", "cross_asset_value", "pool_info", "account_share"] - - 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 PublicPool 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 pool_info - if self.pool_info: - _dict['pool_info'] = self.pool_info.to_dict() - # override the default output from pydantic by calling `to_dict()` of account_share - if self.account_share: - _dict['account_share'] = self.account_share.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 PublicPool 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"), - "account_type": obj.get("account_type"), - "index": obj.get("index"), - "l1_address": obj.get("l1_address"), - "cancel_all_time": obj.get("cancel_all_time"), - "total_order_count": obj.get("total_order_count"), - "total_isolated_order_count": obj.get("total_isolated_order_count"), - "pending_order_count": obj.get("pending_order_count"), - "available_balance": obj.get("available_balance"), - "status": obj.get("status"), - "collateral": obj.get("collateral"), - "account_index": obj.get("account_index"), - "name": obj.get("name"), - "description": obj.get("description"), - "can_invite": obj.get("can_invite"), - "referral_points_percentage": obj.get("referral_points_percentage"), - "total_asset_value": obj.get("total_asset_value"), - "cross_asset_value": obj.get("cross_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 - }) - # 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_info.py b/lighter/models/public_pool_info.py index 7ee99d5..ea35eba 100644 --- a/lighter/models/public_pool_info.py +++ b/lighter/models/public_pool_info.py @@ -34,10 +34,11 @@ class PublicPoolInfo(BaseModel): total_shares: StrictInt operator_shares: StrictInt annual_percentage_yield: Union[StrictFloat, StrictInt] + sharpe_ratio: Union[StrictFloat, StrictInt] daily_returns: List[DailyReturn] share_prices: List[SharePrice] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["status", "operator_fee", "min_operator_share_rate", "total_shares", "operator_shares", "annual_percentage_yield", "daily_returns", "share_prices"] + __properties: ClassVar[List[str]] = ["status", "operator_fee", "min_operator_share_rate", "total_shares", "operator_shares", "annual_percentage_yield", "sharpe_ratio", "daily_returns", "share_prices"] model_config = ConfigDict( populate_by_name=True, @@ -117,6 +118,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "total_shares": obj.get("total_shares"), "operator_shares": obj.get("operator_shares"), "annual_percentage_yield": obj.get("annual_percentage_yield"), + "sharpe_ratio": obj.get("sharpe_ratio"), "daily_returns": [DailyReturn.from_dict(_item) for _item in obj["daily_returns"]] if obj.get("daily_returns") is not None else None, "share_prices": [SharePrice.from_dict(_item) for _item in obj["share_prices"]] if obj.get("share_prices") is not None else None }) diff --git a/lighter/models/public_pool_metadata.py b/lighter/models/public_pool_metadata.py index a0c5359..f4ec073 100644 --- a/lighter/models/public_pool_metadata.py +++ b/lighter/models/public_pool_metadata.py @@ -30,17 +30,20 @@ class PublicPoolMetadata(BaseModel): code: StrictInt message: Optional[StrictStr] = None account_index: StrictInt + created_at: StrictInt + master_account_index: StrictInt account_type: StrictInt name: StrictStr l1_address: StrictStr annual_percentage_yield: Union[StrictFloat, StrictInt] + sharpe_ratio: Union[StrictFloat, StrictInt] status: StrictInt operator_fee: StrictStr total_asset_value: StrictStr total_shares: StrictInt account_share: Optional[PublicPoolShare] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "account_index", "account_type", "name", "l1_address", "annual_percentage_yield", "status", "operator_fee", "total_asset_value", "total_shares", "account_share"] + __properties: ClassVar[List[str]] = ["code", "message", "account_index", "created_at", "master_account_index", "account_type", "name", "l1_address", "annual_percentage_yield", "sharpe_ratio", "status", "operator_fee", "total_asset_value", "total_shares", "account_share"] model_config = ConfigDict( populate_by_name=True, @@ -106,10 +109,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "code": obj.get("code"), "message": obj.get("message"), "account_index": obj.get("account_index"), + "created_at": obj.get("created_at"), + "master_account_index": obj.get("master_account_index"), "account_type": obj.get("account_type"), "name": obj.get("name"), "l1_address": obj.get("l1_address"), "annual_percentage_yield": obj.get("annual_percentage_yield"), + "sharpe_ratio": obj.get("sharpe_ratio"), "status": obj.get("status"), "operator_fee": obj.get("operator_fee"), "total_asset_value": obj.get("total_asset_value"), diff --git a/lighter/models/referral_point_entry.py b/lighter/models/referral_point_entry.py index fdce287..5524e71 100644 --- a/lighter/models/referral_point_entry.py +++ b/lighter/models/referral_point_entry.py @@ -17,8 +17,8 @@ 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 typing import Optional, Set from typing_extensions import Self @@ -27,10 +27,10 @@ class ReferralPointEntry(BaseModel): ReferralPointEntry """ # noqa: E501 l1_address: StrictStr - total_points: StrictInt - week_points: StrictInt - total_reward_points: StrictInt - week_reward_points: StrictInt + total_points: Union[StrictFloat, StrictInt] + week_points: Union[StrictFloat, StrictInt] + total_reward_points: Union[StrictFloat, StrictInt] + week_reward_points: Union[StrictFloat, StrictInt] reward_point_multiplier: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["l1_address", "total_points", "week_points", "total_reward_points", "week_reward_points", "reward_point_multiplier"] diff --git a/lighter/models/referral_points.py b/lighter/models/referral_points.py index ffabae7..e6f4900 100644 --- a/lighter/models/referral_points.py +++ b/lighter/models/referral_points.py @@ -17,8 +17,8 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictFloat, 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.referral_point_entry import ReferralPointEntry from typing import Optional, Set from typing_extensions import Self @@ -28,10 +28,10 @@ class ReferralPoints(BaseModel): ReferralPoints """ # noqa: E501 referrals: List[ReferralPointEntry] - user_total_points: StrictFloat - user_last_week_points: StrictFloat - user_total_referral_reward_points: StrictFloat - user_last_week_referral_reward_points: StrictFloat + user_total_points: Union[StrictFloat, StrictInt] + user_last_week_points: Union[StrictFloat, StrictInt] + user_total_referral_reward_points: Union[StrictFloat, StrictInt] + user_last_week_referral_reward_points: Union[StrictFloat, StrictInt] reward_point_multiplier: StrictStr additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["referrals", "user_total_points", "user_last_week_points", "user_total_referral_reward_points", "user_last_week_referral_reward_points", "reward_point_multiplier"] diff --git a/lighter/models/req_get_asset_details.py b/lighter/models/req_get_asset_details.py new file mode 100644 index 0000000..9f4b7ef --- /dev/null +++ b/lighter/models/req_get_asset_details.py @@ -0,0 +1,100 @@ +# 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 ReqGetAssetDetails(BaseModel): + """ + ReqGetAssetDetails + """ # noqa: E501 + asset_id: Optional[StrictInt] = None + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["asset_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 ReqGetAssetDetails 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 ReqGetAssetDetails from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "asset_id": obj.get("asset_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_bridges_by_l1_addr.py b/lighter/models/req_get_bridges_by_l1_addr.py new file mode 100644 index 0000000..6b3d0dc --- /dev/null +++ b/lighter/models/req_get_bridges_by_l1_addr.py @@ -0,0 +1,100 @@ +# 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 ReqGetBridgesByL1Addr(BaseModel): + """ + ReqGetBridgesByL1Addr + """ # 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 ReqGetBridgesByL1Addr 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 ReqGetBridgesByL1Addr 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_candlesticks.py b/lighter/models/req_get_candlesticks.py index 0fc9642..33aecbe 100644 --- a/lighter/models/req_get_candlesticks.py +++ b/lighter/models/req_get_candlesticks.py @@ -39,8 +39,8 @@ class ReqGetCandlesticks(BaseModel): @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')") + if value not in set(['1m', '5m', '15m', '30m', '1h', '4h', '12h', '1d', '1w']): + raise ValueError("must be one of enum values ('1m', '5m', '15m', '30m', '1h', '4h', '12h', '1d', '1w')") return value model_config = ConfigDict( diff --git a/lighter/models/req_get_order_book_details.py b/lighter/models/req_get_order_book_details.py index e38a012..a172c1f 100644 --- a/lighter/models/req_get_order_book_details.py +++ b/lighter/models/req_get_order_book_details.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt +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 @@ -27,8 +27,19 @@ class ReqGetOrderBookDetails(BaseModel): ReqGetOrderBookDetails """ # noqa: E501 market_id: Optional[StrictInt] = None + filter: Optional[StrictStr] = 'all' additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id"] + __properties: ClassVar[List[str]] = ["market_id", "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', 'spot', 'perp']): + raise ValueError("must be one of enum values ('all', 'spot', 'perp')") + return value model_config = ConfigDict( populate_by_name=True, @@ -88,7 +99,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "market_id": obj.get("market_id") + "market_id": obj.get("market_id"), + "filter": obj.get("filter") if obj.get("filter") is not None else 'all' }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/req_get_order_book_orders.py b/lighter/models/req_get_order_book_orders.py index 52c008f..19c6a71 100644 --- a/lighter/models/req_get_order_book_orders.py +++ b/lighter/models/req_get_order_book_orders.py @@ -28,7 +28,7 @@ class ReqGetOrderBookOrders(BaseModel): ReqGetOrderBookOrders """ # noqa: E501 market_id: StrictInt - limit: Annotated[int, Field(le=100, strict=True, ge=1)] + limit: Annotated[int, Field(le=250, strict=True, ge=1)] additional_properties: Dict[str, Any] = {} __properties: ClassVar[List[str]] = ["market_id", "limit"] diff --git a/lighter/models/req_get_order_books.py b/lighter/models/req_get_order_books.py index 9608c4b..d7cd179 100644 --- a/lighter/models/req_get_order_books.py +++ b/lighter/models/req_get_order_books.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, StrictInt +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 @@ -27,8 +27,19 @@ class ReqGetOrderBooks(BaseModel): ReqGetOrderBooks """ # noqa: E501 market_id: Optional[StrictInt] = None + filter: Optional[StrictStr] = 'all' additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["market_id"] + __properties: ClassVar[List[str]] = ["market_id", "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', 'spot', 'perp']): + raise ValueError("must be one of enum values ('all', 'spot', 'perp')") + return value model_config = ConfigDict( populate_by_name=True, @@ -88,7 +99,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "market_id": obj.get("market_id") + "market_id": obj.get("market_id"), + "filter": obj.get("filter") if obj.get("filter") is not None else 'all' }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/req_get_trades.py b/lighter/models/req_get_trades.py index c760bce..60a8b90 100644 --- a/lighter/models/req_get_trades.py +++ b/lighter/models/req_get_trades.py @@ -17,7 +17,7 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator from typing import Any, ClassVar, Dict, List, Optional from typing_extensions import Annotated from typing import Optional, Set @@ -36,9 +36,12 @@ class ReqGetTrades(BaseModel): cursor: Optional[StrictStr] = None var_from: Optional[StrictInt] = Field(default=-1, alias="from") ask_filter: Optional[StrictInt] = None + role: Optional[StrictStr] = 'all' + type: Optional[StrictStr] = 'all' limit: Annotated[int, Field(le=100, strict=True, ge=1)] + aggregate: Optional[StrictBool] = False additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["auth", "market_id", "account_index", "order_index", "sort_by", "sort_dir", "cursor", "from", "ask_filter", "limit"] + __properties: ClassVar[List[str]] = ["auth", "market_id", "account_index", "order_index", "sort_by", "sort_dir", "cursor", "from", "ask_filter", "role", "type", "limit", "aggregate"] @field_validator('sort_by') def sort_by_validate_enum(cls, value): @@ -57,6 +60,26 @@ def sort_dir_validate_enum(cls, value): raise ValueError("must be one of enum values ('desc')") return value + @field_validator('role') + def role_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'maker', 'taker']): + raise ValueError("must be one of enum values ('all', 'maker', 'taker')") + return value + + @field_validator('type') + def type_validate_enum(cls, value): + """Validates the enum""" + if value is None: + return value + + if value not in set(['all', 'trade', 'liquidation', 'deleverage', 'market-settlement']): + raise ValueError("must be one of enum values ('all', 'trade', 'liquidation', 'deleverage', 'market-settlement')") + return value + model_config = ConfigDict( populate_by_name=True, validate_assignment=True, @@ -124,7 +147,10 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "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") + "role": obj.get("role") if obj.get("role") is not None else 'all', + "type": obj.get("type") if obj.get("type") is not None else 'all', + "limit": obj.get("limit"), + "aggregate": obj.get("aggregate") if obj.get("aggregate") is not None else False }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/req_get_public_pools.py b/lighter/models/resp_get_bridges_by_l1_addr.py similarity index 69% rename from lighter/models/req_get_public_pools.py rename to lighter/models/resp_get_bridges_by_l1_addr.py index 94786e4..8d8961f 100644 --- a/lighter/models/req_get_public_pools.py +++ b/lighter/models/resp_get_bridges_by_l1_addr.py @@ -17,33 +17,21 @@ import re # noqa: F401 import json -from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr from typing import Any, ClassVar, Dict, List, Optional -from typing_extensions import Annotated +from lighter.models.bridge import Bridge from typing import Optional, Set from typing_extensions import Self -class ReqGetPublicPools(BaseModel): +class RespGetBridgesByL1Addr(BaseModel): """ - ReqGetPublicPools + RespGetBridgesByL1Addr """ # noqa: E501 - auth: Optional[StrictStr] = None - filter: Optional[StrictStr] = None - index: StrictInt - limit: Annotated[int, Field(le=100, strict=True, ge=1)] - account_index: Optional[StrictInt] = None + code: StrictInt + message: Optional[StrictStr] = None + bridges: List[Bridge] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["auth", "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 + __properties: ClassVar[List[str]] = ["code", "message", "bridges"] model_config = ConfigDict( populate_by_name=True, @@ -63,7 +51,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of ReqGetPublicPools from a JSON string""" + """Create an instance of RespGetBridgesByL1Addr from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -86,6 +74,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 bridges (list) + _items = [] + if self.bridges: + for _item in self.bridges: + if _item: + _items.append(_item.to_dict()) + _dict['bridges'] = _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(): @@ -95,7 +90,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of ReqGetPublicPools from a dict""" + """Create an instance of RespGetBridgesByL1Addr from a dict""" if obj is None: return None @@ -103,11 +98,9 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: return cls.model_validate(obj) _obj = cls.model_validate({ - "auth": obj.get("auth"), - "filter": obj.get("filter"), - "index": obj.get("index"), - "limit": obj.get("limit"), - "account_index": obj.get("account_index") + "code": obj.get("code"), + "message": obj.get("message"), + "bridges": [Bridge.from_dict(_item) for _item in obj["bridges"]] if obj.get("bridges") is not None else None }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/resp_get_is_next_bridge_fast.py b/lighter/models/resp_get_is_next_bridge_fast.py new file mode 100644 index 0000000..31496a5 --- /dev/null +++ b/lighter/models/resp_get_is_next_bridge_fast.py @@ -0,0 +1,104 @@ +# 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 +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespGetIsNextBridgeFast(BaseModel): + """ + RespGetIsNextBridgeFast + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + is_next_bridge_fast: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "is_next_bridge_fast"] + + 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 RespGetIsNextBridgeFast 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 RespGetIsNextBridgeFast 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"), + "is_next_bridge_fast": obj.get("is_next_bridge_fast") + }) + # 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/resp_send_tx.py b/lighter/models/resp_send_tx.py index cc6adcc..7a52c88 100644 --- a/lighter/models/resp_send_tx.py +++ b/lighter/models/resp_send_tx.py @@ -30,8 +30,9 @@ class RespSendTx(BaseModel): message: Optional[StrictStr] = None tx_hash: StrictStr predicted_execution_time_ms: StrictInt + volume_quota_remaining: Optional[StrictInt] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "tx_hash", "predicted_execution_time_ms"] + __properties: ClassVar[List[str]] = ["code", "message", "tx_hash", "predicted_execution_time_ms", "volume_quota_remaining"] model_config = ConfigDict( populate_by_name=True, @@ -94,7 +95,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "code": obj.get("code"), "message": obj.get("message"), "tx_hash": obj.get("tx_hash"), - "predicted_execution_time_ms": obj.get("predicted_execution_time_ms") + "predicted_execution_time_ms": obj.get("predicted_execution_time_ms"), + "volume_quota_remaining": obj.get("volume_quota_remaining") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/resp_send_tx_batch.py b/lighter/models/resp_send_tx_batch.py index 2b16358..33b3d3d 100644 --- a/lighter/models/resp_send_tx_batch.py +++ b/lighter/models/resp_send_tx_batch.py @@ -30,8 +30,9 @@ class RespSendTxBatch(BaseModel): message: Optional[StrictStr] = None tx_hash: List[StrictStr] predicted_execution_time_ms: StrictInt + volume_quota_remaining: Optional[StrictInt] = None additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["code", "message", "tx_hash", "predicted_execution_time_ms"] + __properties: ClassVar[List[str]] = ["code", "message", "tx_hash", "predicted_execution_time_ms", "volume_quota_remaining"] model_config = ConfigDict( populate_by_name=True, @@ -94,7 +95,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "code": obj.get("code"), "message": obj.get("message"), "tx_hash": obj.get("tx_hash"), - "predicted_execution_time_ms": obj.get("predicted_execution_time_ms") + "predicted_execution_time_ms": obj.get("predicted_execution_time_ms"), + "volume_quota_remaining": obj.get("volume_quota_remaining") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/resp_update_kickback.py b/lighter/models/resp_update_kickback.py new file mode 100644 index 0000000..308cb5c --- /dev/null +++ b/lighter/models/resp_update_kickback.py @@ -0,0 +1,104 @@ +# 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 +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespUpdateKickback(BaseModel): + """ + RespUpdateKickback + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + success: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "success"] + + 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 RespUpdateKickback 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 RespUpdateKickback 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"), + "success": obj.get("success") + }) + # 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/resp_update_referral_code.py b/lighter/models/resp_update_referral_code.py new file mode 100644 index 0000000..c1f215f --- /dev/null +++ b/lighter/models/resp_update_referral_code.py @@ -0,0 +1,104 @@ +# 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 +from typing import Any, ClassVar, Dict, List, Optional +from typing import Optional, Set +from typing_extensions import Self + +class RespUpdateReferralCode(BaseModel): + """ + RespUpdateReferralCode + """ # noqa: E501 + code: StrictInt + message: Optional[StrictStr] = None + success: StrictBool + additional_properties: Dict[str, Any] = {} + __properties: ClassVar[List[str]] = ["code", "message", "success"] + + 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 RespUpdateReferralCode 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 RespUpdateReferralCode 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"), + "success": obj.get("success") + }) + # 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/spot_market_stats.py b/lighter/models/spot_market_stats.py new file mode 100644 index 0000000..c060462 --- /dev/null +++ b/lighter/models/spot_market_stats.py @@ -0,0 +1,118 @@ +# 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 SpotMarketStats(BaseModel): + """ + SpotMarketStats + """ # noqa: E501 + symbol: StrictStr + market_id: StrictInt + index_price: StrictStr + mid_price: StrictStr + last_trade_price: StrictStr + 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]] = ["symbol", "market_id", "index_price", "mid_price", "last_trade_price", "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 SpotMarketStats 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 SpotMarketStats from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "symbol": obj.get("symbol"), + "market_id": obj.get("market_id"), + "index_price": obj.get("index_price"), + "mid_price": obj.get("mid_price"), + "last_trade_price": obj.get("last_trade_price"), + "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_book_detail.py b/lighter/models/spot_order_book_detail.py similarity index 77% rename from lighter/models/order_book_detail.py rename to lighter/models/spot_order_book_detail.py index 012a8a5..70cd0d8 100644 --- a/lighter/models/order_book_detail.py +++ b/lighter/models/spot_order_book_detail.py @@ -22,28 +22,27 @@ from typing import Optional, Set from typing_extensions import Self -class OrderBookDetail(BaseModel): +class SpotOrderBookDetail(BaseModel): """ - OrderBookDetail + SpotOrderBookDetail """ # noqa: E501 symbol: StrictStr market_id: StrictInt + market_type: StrictStr + base_asset_id: StrictInt + quote_asset_id: StrictInt status: StrictStr taker_fee: StrictStr maker_fee: StrictStr liquidation_fee: StrictStr min_base_amount: StrictStr min_quote_amount: StrictStr + order_quote_limit: StrictStr supported_size_decimals: StrictInt supported_price_decimals: StrictInt supported_quote_decimals: StrictInt size_decimals: StrictInt price_decimals: StrictInt - quote_multiplier: StrictInt - default_initial_margin_fraction: StrictInt - min_initial_margin_fraction: StrictInt - maintenance_margin_fraction: StrictInt - closeout_margin_fraction: StrictInt last_trade_price: Union[StrictFloat, StrictInt] daily_trades_count: StrictInt daily_base_token_volume: Union[StrictFloat, StrictInt] @@ -51,16 +50,22 @@ class OrderBookDetail(BaseModel): daily_price_low: Union[StrictFloat, StrictInt] daily_price_high: Union[StrictFloat, StrictInt] daily_price_change: Union[StrictFloat, StrictInt] - open_interest: Union[StrictFloat, StrictInt] daily_chart: Dict[str, Union[StrictFloat, StrictInt]] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["symbol", "market_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals", "size_decimals", "price_decimals", "quote_multiplier", "default_initial_margin_fraction", "min_initial_margin_fraction", "maintenance_margin_fraction", "closeout_margin_fraction", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change", "open_interest", "daily_chart"] + __properties: ClassVar[List[str]] = ["symbol", "market_id", "market_type", "base_asset_id", "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals", "size_decimals", "price_decimals", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", "daily_price_low", "daily_price_high", "daily_price_change", "daily_chart"] + + @field_validator('market_type') + def market_type_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['perp', 'spot']): + raise ValueError("must be one of enum values ('perp', 'spot')") + return value @field_validator('status') def status_validate_enum(cls, value): """Validates the enum""" - if value not in set(['inactive', 'frozen', 'active']): - raise ValueError("must be one of enum values ('inactive', 'frozen', 'active')") + if value not in set(['inactive', 'active']): + raise ValueError("must be one of enum values ('inactive', 'active')") return value model_config = ConfigDict( @@ -81,7 +86,7 @@ def to_json(self) -> str: @classmethod def from_json(cls, json_str: str) -> Optional[Self]: - """Create an instance of OrderBookDetail from a JSON string""" + """Create an instance of SpotOrderBookDetail from a JSON string""" return cls.from_dict(json.loads(json_str)) def to_dict(self) -> Dict[str, Any]: @@ -113,7 +118,7 @@ def to_dict(self) -> Dict[str, Any]: @classmethod def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: - """Create an instance of OrderBookDetail from a dict""" + """Create an instance of SpotOrderBookDetail from a dict""" if obj is None: return None @@ -123,22 +128,21 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "symbol": obj.get("symbol"), "market_id": obj.get("market_id"), + "market_type": obj.get("market_type"), + "base_asset_id": obj.get("base_asset_id"), + "quote_asset_id": obj.get("quote_asset_id"), "status": obj.get("status"), "taker_fee": obj.get("taker_fee"), "maker_fee": obj.get("maker_fee"), "liquidation_fee": obj.get("liquidation_fee"), "min_base_amount": obj.get("min_base_amount"), "min_quote_amount": obj.get("min_quote_amount"), + "order_quote_limit": obj.get("order_quote_limit"), "supported_size_decimals": obj.get("supported_size_decimals"), "supported_price_decimals": obj.get("supported_price_decimals"), "supported_quote_decimals": obj.get("supported_quote_decimals"), "size_decimals": obj.get("size_decimals"), "price_decimals": obj.get("price_decimals"), - "quote_multiplier": obj.get("quote_multiplier"), - "default_initial_margin_fraction": obj.get("default_initial_margin_fraction"), - "min_initial_margin_fraction": obj.get("min_initial_margin_fraction"), - "maintenance_margin_fraction": obj.get("maintenance_margin_fraction"), - "closeout_margin_fraction": obj.get("closeout_margin_fraction"), "last_trade_price": obj.get("last_trade_price"), "daily_trades_count": obj.get("daily_trades_count"), "daily_base_token_volume": obj.get("daily_base_token_volume"), @@ -146,7 +150,6 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "daily_price_low": obj.get("daily_price_low"), "daily_price_high": obj.get("daily_price_high"), "daily_price_change": obj.get("daily_price_change"), - "open_interest": obj.get("open_interest"), "daily_chart": obj.get("daily_chart") }) # store additional fields in additional_properties diff --git a/lighter/models/trade.py b/lighter/models/trade.py index 9156a47..a8c1de4 100644 --- a/lighter/models/trade.py +++ b/lighter/models/trade.py @@ -35,6 +35,8 @@ class Trade(BaseModel): usd_amount: StrictStr ask_id: StrictInt bid_id: StrictInt + ask_client_id: StrictInt + bid_client_id: StrictInt ask_account_id: StrictInt bid_account_id: StrictInt is_maker_ask: StrictBool @@ -51,13 +53,13 @@ class Trade(BaseModel): maker_initial_margin_fraction_before: Optional[StrictInt] maker_position_sign_changed: Optional[StrictBool] additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["trade_id", "tx_hash", "type", "market_id", "size", "price", "usd_amount", "ask_id", "bid_id", "ask_account_id", "bid_account_id", "is_maker_ask", "block_height", "timestamp", "taker_fee", "taker_position_size_before", "taker_entry_quote_before", "taker_initial_margin_fraction_before", "taker_position_sign_changed", "maker_fee", "maker_position_size_before", "maker_entry_quote_before", "maker_initial_margin_fraction_before", "maker_position_sign_changed"] + __properties: ClassVar[List[str]] = ["trade_id", "tx_hash", "type", "market_id", "size", "price", "usd_amount", "ask_id", "bid_id", "ask_client_id", "bid_client_id", "ask_account_id", "bid_account_id", "is_maker_ask", "block_height", "timestamp", "taker_fee", "taker_position_size_before", "taker_entry_quote_before", "taker_initial_margin_fraction_before", "taker_position_sign_changed", "maker_fee", "maker_position_size_before", "maker_entry_quote_before", "maker_initial_margin_fraction_before", "maker_position_sign_changed"] @field_validator('type') def type_validate_enum(cls, value): """Validates the enum""" - if value not in set(['trade', 'liquidation', 'deleverage']): - raise ValueError("must be one of enum values ('trade', 'liquidation', 'deleverage')") + if value not in set(['trade', 'liquidation', 'deleverage', 'market-settlement']): + raise ValueError("must be one of enum values ('trade', 'liquidation', 'deleverage', 'market-settlement')") return value model_config = ConfigDict( @@ -127,6 +129,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "usd_amount": obj.get("usd_amount"), "ask_id": obj.get("ask_id"), "bid_id": obj.get("bid_id"), + "ask_client_id": obj.get("ask_client_id"), + "bid_client_id": obj.get("bid_client_id"), "ask_account_id": obj.get("ask_account_id"), "bid_account_id": obj.get("bid_account_id"), "is_maker_ask": obj.get("is_maker_ask"), diff --git a/lighter/models/transfer_history_item.py b/lighter/models/transfer_history_item.py index dcebc4a..5edf41c 100644 --- a/lighter/models/transfer_history_item.py +++ b/lighter/models/transfer_history_item.py @@ -27,6 +27,7 @@ class TransferHistoryItem(BaseModel): TransferHistoryItem """ # noqa: E501 id: StrictStr + asset_id: StrictInt amount: StrictStr timestamp: StrictInt type: StrictStr @@ -34,15 +35,31 @@ class TransferHistoryItem(BaseModel): to_l1_address: StrictStr from_account_index: StrictInt to_account_index: StrictInt + from_route: StrictStr + to_route: StrictStr tx_hash: StrictStr additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "amount", "timestamp", "type", "from_l1_address", "to_l1_address", "from_account_index", "to_account_index", "tx_hash"] + __properties: ClassVar[List[str]] = ["id", "asset_id", "amount", "timestamp", "type", "from_l1_address", "to_l1_address", "from_account_index", "to_account_index", "from_route", "to_route", "tx_hash"] @field_validator('type') def type_validate_enum(cls, value): """Validates the enum""" - if value not in set(['L2TransferInflow', 'L2TransferOutflow']): - raise ValueError("must be one of enum values ('L2TransferInflow', 'L2TransferOutflow')") + if value not in set(['L2TransferInflow', 'L2TransferOutflow', 'L2BurnSharesInflow', 'L2BurnSharesOutflow', 'L2MintSharesInflow', 'L2MintSharesOutflow', 'L2SelfTransfer']): + raise ValueError("must be one of enum values ('L2TransferInflow', 'L2TransferOutflow', 'L2BurnSharesInflow', 'L2BurnSharesOutflow', 'L2MintSharesInflow', 'L2MintSharesOutflow', 'L2SelfTransfer')") + return value + + @field_validator('from_route') + def from_route_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['spot', 'perps']): + raise ValueError("must be one of enum values ('spot', 'perps')") + return value + + @field_validator('to_route') + def to_route_validate_enum(cls, value): + """Validates the enum""" + if value not in set(['spot', 'perps']): + raise ValueError("must be one of enum values ('spot', 'perps')") return value model_config = ConfigDict( @@ -104,6 +121,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "id": obj.get("id"), + "asset_id": obj.get("asset_id"), "amount": obj.get("amount"), "timestamp": obj.get("timestamp"), "type": obj.get("type"), @@ -111,6 +129,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "to_l1_address": obj.get("to_l1_address"), "from_account_index": obj.get("from_account_index"), "to_account_index": obj.get("to_account_index"), + "from_route": obj.get("from_route"), + "to_route": obj.get("to_route"), "tx_hash": obj.get("tx_hash") }) # store additional fields in additional_properties diff --git a/lighter/models/tx.py b/lighter/models/tx.py index 1b78ad1..be33ff6 100644 --- a/lighter/models/tx.py +++ b/lighter/models/tx.py @@ -42,8 +42,9 @@ class Tx(BaseModel): executed_at: StrictInt sequence_index: StrictInt parent_hash: StrictStr + api_key_index: StrictInt additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["hash", "type", "info", "event_info", "status", "transaction_index", "l1_address", "account_index", "nonce", "expire_at", "block_height", "queued_at", "executed_at", "sequence_index", "parent_hash"] + __properties: ClassVar[List[str]] = ["hash", "type", "info", "event_info", "status", "transaction_index", "l1_address", "account_index", "nonce", "expire_at", "block_height", "queued_at", "executed_at", "sequence_index", "parent_hash", "api_key_index"] model_config = ConfigDict( populate_by_name=True, @@ -117,7 +118,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: "queued_at": obj.get("queued_at"), "executed_at": obj.get("executed_at"), "sequence_index": obj.get("sequence_index"), - "parent_hash": obj.get("parent_hash") + "parent_hash": obj.get("parent_hash"), + "api_key_index": obj.get("api_key_index") }) # store additional fields in additional_properties for _key in obj.keys(): diff --git a/lighter/models/withdraw_history_item.py b/lighter/models/withdraw_history_item.py index fdc9a82..abb5596 100644 --- a/lighter/models/withdraw_history_item.py +++ b/lighter/models/withdraw_history_item.py @@ -27,13 +27,14 @@ class WithdrawHistoryItem(BaseModel): WithdrawHistoryItem """ # noqa: E501 id: StrictStr + asset_id: StrictInt amount: StrictStr timestamp: StrictInt status: StrictStr type: StrictStr l1_tx_hash: StrictStr additional_properties: Dict[str, Any] = {} - __properties: ClassVar[List[str]] = ["id", "amount", "timestamp", "status", "type", "l1_tx_hash"] + __properties: ClassVar[List[str]] = ["id", "asset_id", "amount", "timestamp", "status", "type", "l1_tx_hash"] @field_validator('status') def status_validate_enum(cls, value): @@ -108,6 +109,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: _obj = cls.model_validate({ "id": obj.get("id"), + "asset_id": obj.get("asset_id"), "amount": obj.get("amount"), "timestamp": obj.get("timestamp"), "status": obj.get("status"), diff --git a/lighter/models/ws_account_assets.py b/lighter/models/ws_account_assets.py new file mode 100644 index 0000000..03520dd --- /dev/null +++ b/lighter/models/ws_account_assets.py @@ -0,0 +1,86 @@ +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from lighter.models.account_asset import AccountAsset +from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, Field +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set + +class WSAccountAssets(BaseModel): + type: StrictStr + channel: StrictStr + assets: Dict[StrictStr, AccountAsset] + account_id: StrictInt + + additional_properties: Dict[str, Any] = Field(default_factory=dict) + __properties: ClassVar[List[str]] = ["type", "channel", "assets"] + + model_config = ConfigDict( + populate_by_name=True, + validate_assignment=True, + protected_namespaces=(), + ) + + def to_str(self) -> str: + return pprint.pformat(self.model_dump(by_alias=True)) + + def to_json(self) -> str: + return json.dumps(self.to_dict()) + + @classmethod + def from_json(cls, json_str: str) -> Optional["WSAccountAssets"]: + return cls.from_dict(json.loads(json_str)) + + def to_dict(self) -> Dict[str, Any]: + excluded_fields: Set[str] = {"additional_properties"} + + # dump base fields + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + + # add extra fields + 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["WSAccountAssets"]: + if obj["type"] != "subscribed/account_all_assets" and obj["type"] != "update/account_all_assets": + raise ValueError(f"invalid type {obj['type']} for WSAccountAssets") + + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + # parse inner assets dict into AccountAsset objects + raw_assets = obj.get("assets") or {} + parsed_assets: Dict[str, AccountAsset] = { + k: AccountAsset.from_dict(v) for k, v in raw_assets.items() + } + + account_id = int(obj.get("channel").split(":")[1]) + + _obj = cls.model_validate( + { + "type": obj.get("type"), + "channel": obj.get("channel"), + "assets": parsed_assets, + "account_id": account_id + } + ) + + # store additional fields + for _key in obj.keys(): + if _key not in cls.__properties: + _obj.additional_properties[_key] = obj.get(_key) + + return _obj \ No newline at end of file diff --git a/lighter/signer_client.py b/lighter/signer_client.py index 7f4c209..a473042 100644 --- a/lighter/signer_client.py +++ b/lighter/signer_client.py @@ -107,7 +107,7 @@ def __populate_shared_library_functions(signer): signer.SignCancelOrder.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] signer.SignCancelOrder.restype = SignedTxResponse - signer.SignWithdraw.argtypes = [ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignWithdraw.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] signer.SignWithdraw.restype = SignedTxResponse signer.SignCreateSubAccount.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] @@ -119,13 +119,13 @@ def __populate_shared_library_functions(signer): signer.SignModifyOrder.argtypes = [ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] signer.SignModifyOrder.restype = SignedTxResponse - signer.SignTransfer.argtypes = [ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_char_p, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignTransfer.argtypes = [ctypes.c_longlong, ctypes.c_int16, ctypes.c_int8, ctypes.c_int8, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_char_p, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] signer.SignTransfer.restype = SignedTxResponse - signer.SignCreatePublicPool.argtypes = [ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignCreatePublicPool.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] signer.SignCreatePublicPool.restype = SignedTxResponse - signer.SignUpdatePublicPool.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] + signer.SignUpdatePublicPool.argtypes = [ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] signer.SignUpdatePublicPool.restype = SignedTxResponse signer.SignMintShares.argtypes = [ctypes.c_longlong, ctypes.c_longlong, ctypes.c_longlong, ctypes.c_int, ctypes.c_longlong] @@ -213,6 +213,7 @@ class SignerClient: DEFAULT_API_KEY_INDEX = 255 USDC_TICKER_SCALE = 1e6 + ETH_TICKER_SCALE = 1e8 ORDER_TYPE_LIMIT = 0 ORDER_TYPE_MARKET = 1 @@ -246,6 +247,12 @@ class SignerClient: GROUPING_TYPE_ONE_CANCELS_THE_OTHER = 2 GROUPING_TYPE_ONE_TRIGGERS_A_ONE_CANCELS_THE_OTHER = 3 + ROUTE_PERP = 0 + ROUTE_SPOT = 1 + + ASSET_ID_USDC = 3 + ASSET_ID_ETH = 1 + def __init__( self, url, @@ -444,8 +451,8 @@ def sign_create_grouped_orders( def sign_cancel_order(self, market_index: int, order_index: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: return self.__decode_tx_info(self.signer.SignCancelOrder(market_index, order_index, nonce, api_key_index, self.account_index)) - def sign_withdraw(self, usdc_amount: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: - return self.__decode_tx_info(self.signer.SignWithdraw(usdc_amount, nonce, api_key_index, self.account_index)) + def sign_withdraw(self, asset_index: int, route_type: int, amount: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_tx_info(self.signer.SignWithdraw(asset_index, route_type, amount, nonce, api_key_index, self.account_index)) def sign_create_sub_account(self, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: return self.__decode_tx_info(self.signer.SignCreateSubAccount(nonce, api_key_index, self.account_index)) @@ -456,8 +463,8 @@ def sign_cancel_all_orders(self, time_in_force: int, timestamp_ms: int, nonce: i def sign_modify_order(self, market_index: int, order_index: int, base_amount: int, price: int, trigger_price: int = NIL_TRIGGER_PRICE, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: return self.__decode_tx_info(self.signer.SignModifyOrder(market_index, order_index, base_amount, price, trigger_price, nonce, api_key_index, self.account_index)) - def sign_transfer(self, eth_private_key: str, to_account_index: int, usdc_amount: int, fee: int, memo: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: - return self.__decode_and_sign_tx_info(eth_private_key, self.signer.SignTransfer(to_account_index,usdc_amount,fee,ctypes.c_char_p(memo.encode("utf-8")),nonce,api_key_index,self.account_index)) + def sign_transfer(self, eth_private_key: str, to_account_index: int, asset_id: int, route_from: int, route_to: int, usdc_amount: int, fee: int, memo: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: + return self.__decode_and_sign_tx_info(eth_private_key, self.signer.SignTransfer(to_account_index, asset_id, route_from, route_to, usdc_amount, fee, ctypes.c_char_p(memo.encode("utf-8")), nonce, api_key_index, self.account_index)) def sign_create_public_pool(self, operator_fee: int, initial_total_shares: int, min_operator_share_rate: int, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[str, str, str, None], Tuple[None, None, None, str]]: return self.__decode_tx_info(self.signer.SignCreatePublicPool(operator_fee, initial_total_shares, min_operator_share_rate, nonce, api_key_index, self.account_index)) @@ -735,10 +742,15 @@ async def create_sl_limit_order(self, market_index, client_order_index, base_amo ) @process_api_key_and_nonce - async def withdraw(self, usdc_amount, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[Withdraw, RespSendTx, None], Tuple[None, None, str]]: - usdc_amount = int(usdc_amount * self.USDC_TICKER_SCALE) - - tx_type, tx_info, tx_hash, error = self.sign_withdraw(usdc_amount, nonce, api_key_index) + async def withdraw(self, asset_id: int, route_type: int, amount: float, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX) -> Union[Tuple[Withdraw, RespSendTx, None], Tuple[None, None, str]]: + if asset_id == self.ASSET_ID_USDC: + amount = int(amount * self.USDC_TICKER_SCALE) + elif asset_id == self.ASSET_ID_ETH: + amount = int(amount * self.ETH_TICKER_SCALE) + else: + raise ValueError(f"Unsupported asset id: {asset_id}") + + tx_type, tx_info, tx_hash, error = self.sign_withdraw(asset_id, route_type, amount, nonce, api_key_index) if error is not None: return None, None, error @@ -747,6 +759,7 @@ async def withdraw(self, usdc_amount, nonce: int = DEFAULT_NONCE, api_key_index: logging.debug(f"Withdraw Send. TxResponse: {api_response}") return Withdraw.from_json(tx_info), api_response, None + @process_api_key_and_nonce async def create_sub_account(self, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): tx_type, tx_info, tx_hash, error = self.sign_create_sub_account(nonce, api_key_index) if error is not None: @@ -782,10 +795,15 @@ async def modify_order( return tx_info, api_response, None @process_api_key_and_nonce - async def transfer(self, eth_private_key: str, to_account_index, usdc_amount, fee, memo, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): - usdc_amount = int(usdc_amount * self.USDC_TICKER_SCALE) - - tx_type, tx_info, tx_hash, error = self.sign_transfer(eth_private_key, to_account_index, usdc_amount, fee, memo, nonce, api_key_index) + async def transfer(self, eth_private_key: str, to_account_index: int, asset_id: int, route_from: int, route_to: int, amount: float, fee: int, memo: str, nonce: int = DEFAULT_NONCE, api_key_index: int = DEFAULT_API_KEY_INDEX): + if asset_id == self.ASSET_ID_USDC: + amount = int(amount * self.USDC_TICKER_SCALE) + elif asset_id == self.ASSET_ID_ETH: + amount = int(amount * self.ETH_TICKER_SCALE) + else: + raise ValueError(f"Unsupported asset id: {asset_id}") + + tx_type, tx_info, tx_hash, error = self.sign_transfer(eth_private_key, to_account_index, asset_id, route_from, route_to, amount, fee, memo, nonce, api_key_index) if error is not None: return None, None, error diff --git a/lighter/signers/lighter-signer-darwin-arm64.dylib b/lighter/signers/lighter-signer-darwin-arm64.dylib index 6d164ae..0dd7cec 100644 Binary files a/lighter/signers/lighter-signer-darwin-arm64.dylib and b/lighter/signers/lighter-signer-darwin-arm64.dylib differ diff --git a/lighter/signers/lighter-signer-darwin-arm64.h b/lighter/signers/lighter-signer-darwin-arm64.h index 6361a6f..15a6068 100644 --- a/lighter/signers/lighter-signer-darwin-arm64.h +++ b/lighter/signers/lighter-signer-darwin-arm64.h @@ -19,7 +19,7 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_; /* Start of preamble from import "C" comments. */ -#line 15 "main.go" +#line 16 "main.go" #include #include @@ -118,13 +118,13 @@ extern SignedTxResponse SignChangePubKey(char* cPubKey, long long cNonce, int cA extern SignedTxResponse SignCreateOrder(int cMarketIndex, long long cClientOrderIndex, long long cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long cOrderExpiry, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignCancelOrder(int cMarketIndex, long long cOrderIndex, long long cNonce, int cApiKeyIndex, long long cAccountIndex); -extern SignedTxResponse SignWithdraw(long long cUSDCAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, unsigned long long cAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignCreateSubAccount(long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long cTime, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignModifyOrder(int cMarketIndex, long long cIndex, long long cBaseAmount, long long cPrice, long long cTriggerPrice, long long cNonce, int cApiKeyIndex, long long cAccountIndex); -extern SignedTxResponse SignTransfer(long long cToAccountIndex, long long cUSDCAmount, long long cFee, char* cMemo, long long cNonce, int cApiKeyIndex, long long cAccountIndex); -extern SignedTxResponse SignCreatePublicPool(long long cOperatorFee, long long cInitialTotalShares, long long cMinOperatorShareRate, long long cNonce, int cApiKeyIndex, long long cAccountIndex); -extern SignedTxResponse SignUpdatePublicPool(long long cPublicPoolIndex, int cStatus, long long cOperatorFee, long long cMinOperatorShareRate, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignTransfer(long long cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long cAmount, long long cUsdcFee, char* cMemo, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignCreatePublicPool(long long cOperatorFee, int cInitialTotalShares, long long cMinOperatorShareRate, long long cNonce, int cApiKeyIndex, long long cAccountIndex); +extern SignedTxResponse SignUpdatePublicPool(long long cPublicPoolIndex, int cStatus, long long cOperatorFee, int cMinOperatorShareRate, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignMintShares(long long cPublicPoolIndex, long long cShareAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignBurnShares(long long cPublicPoolIndex, long long cShareAmount, long long cNonce, int cApiKeyIndex, long long cAccountIndex); extern SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long cNonce, int cApiKeyIndex, long long cAccountIndex); diff --git a/lighter/signers/lighter-signer-linux-amd64.h b/lighter/signers/lighter-signer-linux-amd64.h index e68289d..887f09e 100644 --- a/lighter/signers/lighter-signer-linux-amd64.h +++ b/lighter/signers/lighter-signer-linux-amd64.h @@ -19,7 +19,7 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_; /* Start of preamble from import "C" comments. */ -#line 15 "main.go" +#line 16 "main.go" #include #include @@ -118,13 +118,13 @@ extern SignedTxResponse SignChangePubKey(char* cPubKey, long long int cNonce, in extern SignedTxResponse SignCreateOrder(int cMarketIndex, long long int cClientOrderIndex, long long int cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long int cOrderExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCancelOrder(int cMarketIndex, long long int cOrderIndex, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignWithdraw(long long int cUSDCAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, long long unsigned int cAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCreateSubAccount(long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long int cTime, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignModifyOrder(int cMarketIndex, long long int cIndex, long long int cBaseAmount, long long int cPrice, long long int cTriggerPrice, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignTransfer(long long int cToAccountIndex, long long int cUSDCAmount, long long int cFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, long long int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignTransfer(long long int cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long int cAmount, long long int cUsdcFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignMintShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignBurnShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); diff --git a/lighter/signers/lighter-signer-linux-amd64.so b/lighter/signers/lighter-signer-linux-amd64.so index 66944dc..424cac5 100644 Binary files a/lighter/signers/lighter-signer-linux-amd64.so and b/lighter/signers/lighter-signer-linux-amd64.so differ diff --git a/lighter/signers/lighter-signer-linux-arm64.h b/lighter/signers/lighter-signer-linux-arm64.h index e68289d..887f09e 100644 --- a/lighter/signers/lighter-signer-linux-arm64.h +++ b/lighter/signers/lighter-signer-linux-arm64.h @@ -19,7 +19,7 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_; /* Start of preamble from import "C" comments. */ -#line 15 "main.go" +#line 16 "main.go" #include #include @@ -118,13 +118,13 @@ extern SignedTxResponse SignChangePubKey(char* cPubKey, long long int cNonce, in extern SignedTxResponse SignCreateOrder(int cMarketIndex, long long int cClientOrderIndex, long long int cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long int cOrderExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCancelOrder(int cMarketIndex, long long int cOrderIndex, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignWithdraw(long long int cUSDCAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, long long unsigned int cAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCreateSubAccount(long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long int cTime, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignModifyOrder(int cMarketIndex, long long int cIndex, long long int cBaseAmount, long long int cPrice, long long int cTriggerPrice, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignTransfer(long long int cToAccountIndex, long long int cUSDCAmount, long long int cFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, long long int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignTransfer(long long int cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long int cAmount, long long int cUsdcFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignMintShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignBurnShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); diff --git a/lighter/signers/lighter-signer-linux-arm64.so b/lighter/signers/lighter-signer-linux-arm64.so index d4d5c60..30645c3 100644 Binary files a/lighter/signers/lighter-signer-linux-arm64.so and b/lighter/signers/lighter-signer-linux-arm64.so differ diff --git a/lighter/signers/lighter-signer-windows-amd64.dll b/lighter/signers/lighter-signer-windows-amd64.dll index 1601cc6..7b3fb5d 100644 Binary files a/lighter/signers/lighter-signer-windows-amd64.dll and b/lighter/signers/lighter-signer-windows-amd64.dll differ diff --git a/lighter/signers/lighter-signer-windows-amd64.h b/lighter/signers/lighter-signer-windows-amd64.h index f923486..6ad24a1 100644 --- a/lighter/signers/lighter-signer-windows-amd64.h +++ b/lighter/signers/lighter-signer-windows-amd64.h @@ -19,7 +19,7 @@ typedef struct { const char *p; ptrdiff_t n; } _GoString_; /* Start of preamble from import "C" comments. */ -#line 15 "main.go" +#line 16 "main.go" #include #include @@ -118,13 +118,13 @@ extern __declspec(dllexport) SignedTxResponse SignChangePubKey(char* cPubKey, lo extern __declspec(dllexport) SignedTxResponse SignCreateOrder(int cMarketIndex, long long int cClientOrderIndex, long long int cBaseAmount, int cPrice, int cIsAsk, int cOrderType, int cTimeInForce, int cReduceOnly, int cTriggerPrice, long long int cOrderExpiry, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignCreateGroupedOrders(uint8_t cGroupingType, CreateOrderTxReq* cOrders, int cLen, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignCancelOrder(int cMarketIndex, long long int cOrderIndex, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern __declspec(dllexport) SignedTxResponse SignWithdraw(long long int cUSDCAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignWithdraw(int cAssetIndex, int cRouteType, long long unsigned int cAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignCreateSubAccount(long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignCancelAllOrders(int cTimeInForce, long long int cTime, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignModifyOrder(int cMarketIndex, long long int cIndex, long long int cBaseAmount, long long int cPrice, long long int cTriggerPrice, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern __declspec(dllexport) SignedTxResponse SignTransfer(long long int cToAccountIndex, long long int cUSDCAmount, long long int cFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern __declspec(dllexport) SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, long long int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); -extern __declspec(dllexport) SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignTransfer(long long int cToAccountIndex, int16_t cAssetIndex, uint8_t cFromRouteType, uint8_t cToRouteType, long long int cAmount, long long int cUsdcFee, char* cMemo, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignCreatePublicPool(long long int cOperatorFee, int cInitialTotalShares, long long int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); +extern __declspec(dllexport) SignedTxResponse SignUpdatePublicPool(long long int cPublicPoolIndex, int cStatus, long long int cOperatorFee, int cMinOperatorShareRate, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignMintShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignBurnShares(long long int cPublicPoolIndex, long long int cShareAmount, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); extern __declspec(dllexport) SignedTxResponse SignUpdateLeverage(int cMarketIndex, int cInitialMarginFraction, int cMarginMode, long long int cNonce, int cApiKeyIndex, long long int cAccountIndex); diff --git a/openapi.json b/openapi.json index 37729d5..a30275b 100644 --- a/openapi.json +++ b/openapi.json @@ -122,7 +122,7 @@ "in": "query", "required": true, "type": "integer", - "format": "uint8" + "format": "int16" }, { "name": "auth", @@ -186,7 +186,7 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, { @@ -520,6 +520,43 @@ "description": "Get account api key. Set `api_key_index` to 255 to retrieve all api keys associated with the account." } }, + "/api/v1/assetDetails": { + "get": { + "summary": "assetDetails", + "operationId": "assetDetails", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/AssetDetails" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "asset_id", + "in": "query", + "required": false, + "type": "integer", + "format": "int16", + "default": "0" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get asset details" + } + }, "/api/v1/block": { "get": { "summary": "block", @@ -666,6 +703,76 @@ "description": "Get blocks" } }, + "/api/v1/bridges": { + "get": { + "summary": "bridges", + "operationId": "bridges", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespGetBridgesByL1Addr" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "bridge" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get bridges for given l1 address" + } + }, + "/api/v1/bridges/isNextBridgeFast": { + "get": { + "summary": "bridges_isNextBridgeFast", + "operationId": "bridges_isNextBridgeFast", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespGetIsNextBridgeFast" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "l1_address", + "in": "query", + "required": true, + "type": "string" + } + ], + "tags": [ + "bridge" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get if next bridge is fast" + } + }, "/api/v1/candlesticks": { "get": { "summary": "candlesticks", @@ -690,7 +797,7 @@ "in": "query", "required": true, "type": "integer", - "format": "uint8" + "format": "int16" }, { "name": "resolution", @@ -701,9 +808,12 @@ "1m", "5m", "15m", + "30m", "1h", "4h", - "1d" + "12h", + "1d", + "1w" ] }, { @@ -958,7 +1068,7 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, { @@ -1053,7 +1163,7 @@ "in": "query", "required": true, "type": "integer", - "format": "uint8" + "format": "int16" }, { "name": "resolution", @@ -1194,7 +1304,7 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, { @@ -1333,8 +1443,20 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" } ], "tags": [ @@ -1370,7 +1492,7 @@ "in": "query", "required": true, "type": "integer", - "format": "uint8" + "format": "int16" }, { "name": "limit", @@ -1379,7 +1501,7 @@ "type": "integer", "format": "int64", "minimum": 1, - "maximum": 100 + "maximum": 250 } ], "tags": [ @@ -1415,8 +1537,20 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" + }, + { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" } ], "tags": [ @@ -1574,7 +1708,7 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, { @@ -1614,15 +1748,15 @@ "description": "Get accounts position fundings" } }, - "/api/v1/publicPools": { + "/api/v1/publicPoolsMetadata": { "get": { - "summary": "publicPools", - "operationId": "publicPools", + "summary": "publicPoolsMetadata", + "operationId": "publicPoolsMetadata", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/PublicPools" + "$ref": "#/definitions/RespPublicPoolsMetadata" } }, "400": { @@ -1687,18 +1821,18 @@ "consumes": [ "multipart/form-data" ], - "description": "Get public pools" + "description": "Get public pools metadata" } }, - "/api/v1/publicPoolsMetadata": { + "/api/v1/recentTrades": { "get": { - "summary": "publicPoolsMetadata", - "operationId": "publicPoolsMetadata", + "summary": "recentTrades", + "operationId": "recentTrades", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/RespPublicPoolsMetadata" + "$ref": "#/definitions/Trades" } }, "400": { @@ -1710,35 +1844,11 @@ }, "parameters": [ { - "name": "authorization", - "in": "header", - "required": false, - "type": "string" - }, - { - "name": "auth", - "in": "query", - "required": false, - "type": "string" - }, - { - "name": "filter", - "in": "query", - "required": false, - "type": "string", - "enum": [ - "all", - "user", - "protocol", - "account_index" - ] - }, - { - "name": "index", + "name": "market_id", "in": "query", "required": true, "type": "integer", - "format": "int64" + "format": "int16" }, { "name": "limit", @@ -1748,33 +1858,26 @@ "format": "int64", "minimum": 1, "maximum": 100 - }, - { - "name": "account_index", - "in": "query", - "required": false, - "type": "integer", - "format": "int64" } ], "tags": [ - "account" + "order" ], "consumes": [ "multipart/form-data" ], - "description": "Get public pools metadata" + "description": "Get recent trades" } }, - "/api/v1/recentTrades": { - "get": { - "summary": "recentTrades", - "operationId": "recentTrades", + "/api/v1/referral/kickback/update": { + "post": { + "summary": "referral_kickback_update", + "operationId": "referral_kickback_update", "responses": { "200": { "description": "A successful response.", "schema": { - "$ref": "#/definitions/Trades" + "$ref": "#/definitions/RespUpdateKickback" } }, "400": { @@ -1786,29 +1889,28 @@ }, "parameters": [ { - "name": "market_id", - "in": "query", - "required": true, - "type": "integer", - "format": "uint8" + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" }, { - "name": "limit", - "in": "query", + "name": "body", + "in": "body", "required": true, - "type": "integer", - "format": "int64", - "minimum": 1, - "maximum": 100 + "schema": { + "$ref": "#/definitions/ReqUpdateKickback" + } } ], "tags": [ - "order" + "referral" ], "consumes": [ "multipart/form-data" ], - "description": "Get recent trades" + "description": "Update kickback percentage for referral rewards" } }, "/api/v1/referral/points": { @@ -1861,6 +1963,50 @@ "description": "Get referral points" } }, + "/api/v1/referral/update": { + "post": { + "summary": "referral_update", + "operationId": "referral_update", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/RespUpdateReferralCode" + } + }, + "400": { + "description": "Bad request", + "schema": { + "$ref": "#/definitions/ResultCode" + } + } + }, + "parameters": [ + { + "name": "authorization", + "description": " make required after integ is done", + "in": "header", + "required": false, + "type": "string" + }, + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ReqUpdateReferralCode" + } + } + ], + "tags": [ + "referral" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Update referral code (allowed once per account)" + } + }, "/api/v1/sendTx": { "post": { "summary": "sendTx", @@ -1971,7 +2117,7 @@ "in": "query", "required": false, "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, { @@ -2033,23 +2179,57 @@ "default": "-1" }, { - "name": "limit", + "name": "role", "in": "query", - "required": true, - "type": "integer", - "format": "int64", - "minimum": 1, - "maximum": 100 - } - ], - "tags": [ - "order" - ], - "consumes": [ - "multipart/form-data" - ], - "description": "Get trades" - } + "required": false, + "type": "string", + "enum": [ + "all", + "maker", + "taker" + ], + "default": "all" + }, + { + "name": "type", + "in": "query", + "required": false, + "type": "string", + "enum": [ + "all", + "trade", + "liquidation", + "deleverage", + "market-settlement" + ], + "default": "all" + }, + { + "name": "limit", + "in": "query", + "required": true, + "type": "integer", + "format": "int64", + "minimum": 1, + "maximum": 100 + }, + { + "name": "aggregate", + "in": "query", + "required": false, + "type": "boolean", + "format": "boolean", + "default": "false" + } + ], + "tags": [ + "order" + ], + "consumes": [ + "multipart/form-data" + ], + "description": "Get trades" + } }, "/api/v1/transfer/history": { "get": { @@ -2440,11 +2620,6 @@ "format": "int64", "example": "100" }, - "total_isolated_order_count": { - "type": "integer", - "format": "int64", - "example": "100" - }, "pending_order_count": { "type": "integer", "format": "int64", @@ -2472,7 +2647,6 @@ "l1_address", "cancel_all_time", "total_order_count", - "total_isolated_order_count", "pending_order_count", "available_balance", "status", @@ -2503,6 +2677,35 @@ "api_keys" ] }, + "AccountAsset": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "USDC" + }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "balance": { + "type": "string", + "example": "1000" + }, + "locked_balance": { + "type": "string", + "example": "1000" + } + }, + "title": "AccountAsset", + "required": [ + "symbol", + "asset_id", + "balance", + "locked_balance" + ] + }, "AccountLimits": { "type": "object", "properties": { @@ -2519,16 +2722,27 @@ "format": "int32", "example": "25" }, + "max_llp_amount": { + "type": "string", + "example": "1000000" + }, "user_tier": { "type": "string", "example": "std" + }, + "can_create_public_pool": { + "type": "boolean", + "format": "boolean", + "example": "true" } }, "title": "AccountLimits", "required": [ "code", "max_llp_percentage", - "user_tier" + "max_llp_amount", + "user_tier", + "can_create_public_pool" ] }, "AccountMarginStats": { @@ -2574,7 +2788,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "example": "1" }, "daily_trades_count": { @@ -2745,7 +2959,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "example": "1" }, "symbol": { @@ -2947,13 +3161,18 @@ "created_at": { "type": "integer", "format": "int64" + }, + "expired_at": { + "type": "integer", + "format": "int64" } }, "title": "Announcement", "required": [ "title", "content", - "created_at" + "created_at", + "expired_at" ] }, "Announcements": { @@ -3010,6 +3229,90 @@ "public_key" ] }, + "Asset": { + "type": "object", + "properties": { + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "symbol": { + "type": "string", + "example": "ETH" + }, + "l1_decimals": { + "type": "integer", + "format": "uint8", + "example": "18" + }, + "decimals": { + "type": "integer", + "format": "uint8", + "example": "2" + }, + "min_transfer_amount": { + "type": "string", + "example": "0.01" + }, + "min_withdrawal_amount": { + "type": "string", + "example": "0.01" + }, + "margin_mode": { + "type": "string", + "example": "enabled", + "enum": [ + "enabled", + "disabled" + ] + }, + "index_price": { + "type": "string", + "example": "3024.66" + }, + "l1_address": { + "type": "string", + "example": "0x0000000000000000000000000000000000000000" + } + }, + "title": "Asset", + "required": [ + "asset_id", + "symbol", + "l1_decimals", + "decimals", + "min_transfer_amount", + "min_withdrawal_amount", + "margin_mode", + "index_price", + "l1_address" + ] + }, + "AssetDetails": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "asset_details": { + "type": "array", + "items": { + "$ref": "#/definitions/Asset" + } + } + }, + "title": "AssetDetails", + "required": [ + "code", + "asset_details" + ] + }, "Block": { "type": "object", "properties": { @@ -3109,6 +3412,93 @@ "blocks" ] }, + "Bridge": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "version": { + "type": "integer", + "format": "int32", + "enum": [ + "1", + "2" + ] + }, + "source": { + "type": "string", + "example": "Arbitrum" + }, + "source_chain_id": { + "type": "string", + "example": "42161" + }, + "fast_bridge_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "batch_claim_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "cctp_burn_tx_hash": { + "type": "string", + "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "amount": { + "type": "string" + }, + "intent_address": { + "type": "string" + }, + "status": { + "type": "string", + "enum": [ + "pending", + "bridging", + "completed" + ] + }, + "step": { + "type": "string" + }, + "description": { + "type": "string" + }, + "created_at": { + "type": "integer", + "format": "int64" + }, + "updated_at": { + "type": "integer", + "format": "int64" + }, + "is_external_deposit": { + "type": "boolean", + "format": "boolean" + } + }, + "title": "Bridge", + "required": [ + "id", + "version", + "source", + "source_chain_id", + "fast_bridge_tx_hash", + "batch_claim_tx_hash", + "cctp_burn_tx_hash", + "amount", + "intent_address", + "status", + "step", + "description", + "created_at", + "updated_at", + "is_external_deposit" + ] + }, "BridgeSupportedNetwork": { "type": "object", "properties": { @@ -3160,6 +3550,26 @@ "format": "double", "example": "3024.66" }, + "open_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "high_raw": { + "type": "number", + "format": "double", + "example": "3034.66" + }, + "low_raw": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "close_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, "volume0": { "type": "number", "format": "double", @@ -3183,6 +3593,10 @@ "high", "low", "close", + "open_raw", + "high_raw", + "low_raw", + "close_raw", "volume0", "volume1", "last_trade_id" @@ -3320,6 +3734,11 @@ "id": { "type": "string" }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, "amount": { "type": "string", "example": "0.1" @@ -3346,6 +3765,7 @@ "title": "DepositHistoryItem", "required": [ "id", + "asset_id", "amount", "timestamp", "status", @@ -3387,11 +3807,6 @@ "format": "int64", "example": "100" }, - "total_isolated_order_count": { - "type": "integer", - "format": "int64", - "example": "100" - }, "pending_order_count": { "type": "integer", "format": "int64", @@ -3435,6 +3850,12 @@ "$ref": "#/definitions/AccountPosition" } }, + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/AccountAsset" + } + }, "total_asset_value": { "type": "string", "example": "19995" @@ -3461,7 +3882,6 @@ "l1_address", "cancel_all_time", "total_order_count", - "total_isolated_order_count", "pending_order_count", "available_balance", "status", @@ -3472,6 +3892,7 @@ "can_invite", "referral_points_percentage", "positions", + "assets", "total_asset_value", "cross_asset_value", "pool_info", @@ -3536,6 +3957,26 @@ "format": "double", "example": "3024.66" }, + "open_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "high_raw": { + "type": "number", + "format": "double", + "example": "3034.66" + }, + "low_raw": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "close_raw": { + "type": "number", + "format": "double", + "example": "3024.66" + }, "volume0": { "type": "number", "format": "double", @@ -3564,6 +4005,10 @@ "high", "low", "close", + "open_raw", + "high_raw", + "low_raw", + "close_raw", "volume0", "volume1", "last_trade_id", @@ -3653,6 +4098,11 @@ "type": "string", "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" }, + "api_key_index": { + "type": "integer", + "format": "uint8", + "example": "0" + }, "committed_at": { "type": "integer", "format": "int64", @@ -3682,6 +4132,7 @@ "executed_at", "sequence_index", "parent_hash", + "api_key_index", "committed_at", "verified_at" ] @@ -3784,7 +4235,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "exchange": { "type": "string", @@ -3944,7 +4395,7 @@ }, "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "type": { "type": "string", @@ -4032,84 +4483,36 @@ "liquidations" ] }, - "MarketInfo": { + "MarketConfig": { "type": "object", "properties": { - "market_id": { + "market_margin_mode": { "type": "integer", - "format": "uint8", - "example": "1" + "format": "int32" }, - "index_price": { - "type": "string", - "example": "3024.66" + "insurance_fund_account_index": { + "type": "integer", + "format": "int64" }, - "mark_price": { - "type": "string", - "example": "3024.66" - }, - "open_interest": { - "type": "string", - "example": "235.25" - }, - "last_trade_price": { - "type": "string", - "example": "3024.66" - }, - "current_funding_rate": { - "type": "string", - "example": "0.0001" - }, - "funding_rate": { - "type": "string", - "example": "0.0001" - }, - "funding_timestamp": { + "liquidation_mode": { "type": "integer", - "format": "int64", - "example": "1640995200" - }, - "daily_base_token_volume": { - "type": "number", - "format": "double", - "example": "235.25" - }, - "daily_quote_token_volume": { - "type": "number", - "format": "double", - "example": "93566.25" - }, - "daily_price_low": { - "type": "number", - "format": "double", - "example": "3014.66" + "format": "int32" }, - "daily_price_high": { - "type": "number", - "format": "double", - "example": "3024.66" + "force_reduce_only": { + "type": "boolean", + "format": "boolean" }, - "daily_price_change": { - "type": "number", - "format": "double", - "example": "3.66" + "trading_hours": { + "type": "string" } }, - "title": "MarketInfo", + "title": "MarketConfig", "required": [ - "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" + "market_margin_mode", + "insurance_fund_account_index", + "liquidation_mode", + "force_reduce_only", + "trading_hours" ] }, "NextNonce": { @@ -4158,7 +4561,7 @@ }, "market_index": { "type": "integer", - "format": "uint8", + "format": "int16", "example": "1" }, "owner_account_index": { @@ -4270,7 +4673,8 @@ "canceled-expired", "canceled-oco", "canceled-child", - "canceled-liquidation" + "canceled-liquidation", + "canceled-invalid-balance" ] }, "trigger_status": { @@ -4319,6 +4723,16 @@ "type": "integer", "format": "int64", "example": "1640995200" + }, + "created_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" + }, + "updated_at": { + "type": "integer", + "format": "int64", + "example": "1640995200" } }, "title": "Order", @@ -4353,7 +4767,9 @@ "to_trigger_order_id_1", "to_cancel_order_id_0", "block_height", - "timestamp" + "timestamp", + "created_at", + "updated_at" ] }, "OrderBook": { @@ -4365,15 +4781,32 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", + "example": "1" + }, + "market_type": { + "type": "string", + "example": "perp", + "enum": [ + "perp", + "spot" + ] + }, + "base_asset_id": { + "type": "integer", + "format": "int16", "example": "1" }, + "quote_asset_id": { + "type": "integer", + "format": "int16", + "example": "2" + }, "status": { "type": "string", "example": "active", "enum": [ "inactive", - "frozen", "active" ] }, @@ -4397,6 +4830,10 @@ "type": "string", "example": "0.1" }, + "order_quote_limit": { + "type": "string", + "example": "235.25" + }, "supported_size_decimals": { "type": "integer", "format": "uint8", @@ -4417,12 +4854,16 @@ "required": [ "symbol", "market_id", + "market_type", + "base_asset_id", + "quote_asset_id", "status", "taker_fee", "maker_fee", "liquidation_fee", "min_base_amount", "min_quote_amount", + "order_quote_limit", "supported_size_decimals", "supported_price_decimals", "supported_quote_decimals" @@ -4455,6 +4896,11 @@ "type": "integer", "format": "int64", "example": "0" + }, + "nonce": { + "type": "integer", + "format": "int64", + "example": "0" } }, "title": "OrderBookDepth", @@ -4462,99 +4908,90 @@ "code", "asks", "bids", - "offset" + "offset", + "nonce" ] }, - "OrderBookDetail": { + "OrderBookDetails": { "type": "object", "properties": { - "symbol": { - "type": "string", - "example": "ETH" - }, - "market_id": { - "type": "integer", - "format": "uint8", - "example": "1" - }, - "status": { - "type": "string", - "example": "active", - "enum": [ - "inactive", - "frozen", - "active" - ] - }, - "taker_fee": { - "type": "string", - "example": "0.0001" - }, - "maker_fee": { - "type": "string", - "example": "0.0000" - }, - "liquidation_fee": { - "type": "string", - "example": "0.01" - }, - "min_base_amount": { - "type": "string", - "example": "0.01" - }, - "min_quote_amount": { - "type": "string", - "example": "0.1" - }, - "supported_size_decimals": { + "code": { "type": "integer", - "format": "uint8", - "example": "4" + "format": "int32", + "example": "200" }, - "supported_price_decimals": { - "type": "integer", - "format": "uint8", - "example": "4" + "message": { + "type": "string" }, - "supported_quote_decimals": { - "type": "integer", - "format": "uint8", - "example": "4" + "order_book_details": { + "type": "array", + "items": { + "$ref": "#/definitions/PerpsOrderBookDetail" + } }, - "size_decimals": { + "spot_order_book_details": { + "type": "array", + "items": { + "$ref": "#/definitions/SpotOrderBookDetail" + } + } + }, + "title": "OrderBookDetails", + "required": [ + "code", + "order_book_details", + "spot_order_book_details" + ] + }, + "OrderBookOrders": { + "type": "object", + "properties": { + "code": { "type": "integer", - "format": "uint8", - "example": "4" + "format": "int32", + "example": "200" }, - "price_decimals": { - "type": "integer", - "format": "uint8", - "example": "4" + "message": { + "type": "string" }, - "quote_multiplier": { + "total_asks": { "type": "integer", "format": "int64", - "example": "10000" - }, - "default_initial_margin_fraction": { - "type": "integer", - "format": "uin16", - "example": "100" + "example": "1" }, - "min_initial_margin_fraction": { - "type": "integer", - "format": "uin16", - "example": "100" + "asks": { + "type": "array", + "items": { + "$ref": "#/definitions/SimpleOrder" + } }, - "maintenance_margin_fraction": { + "total_bids": { "type": "integer", - "format": "uin16", - "example": "50" + "format": "int64", + "example": "1" }, - "closeout_margin_fraction": { - "type": "integer", - "format": "uin16", - "example": "100" + "bids": { + "type": "array", + "items": { + "$ref": "#/definitions/SimpleOrder" + } + } + }, + "title": "OrderBookOrders", + "required": [ + "code", + "total_asks", + "asks", + "total_bids", + "bids" + ] + }, + "OrderBookStats": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" }, "last_trade_price": { "type": "number", @@ -4576,67 +5013,23 @@ "format": "double", "example": "93566.25" }, - "daily_price_low": { - "type": "number", - "format": "double", - "example": "3014.66" - }, - "daily_price_high": { - "type": "number", - "format": "double", - "example": "3024.66" - }, "daily_price_change": { "type": "number", "format": "double", "example": "3.66" - }, - "open_interest": { - "type": "number", - "format": "double", - "example": "93.0" - }, - "daily_chart": { - "type": "object", - "example": "{1640995200:3024.66}", - "additionalProperties": { - "type": "number", - "format": "double" - } } }, - "title": "OrderBookDetail", + "title": "OrderBookStats", "required": [ "symbol", - "market_id", - "status", - "taker_fee", - "maker_fee", - "liquidation_fee", - "min_base_amount", - "min_quote_amount", - "supported_size_decimals", - "supported_price_decimals", - "supported_quote_decimals", - "size_decimals", - "price_decimals", - "quote_multiplier", - "default_initial_margin_fraction", - "min_initial_margin_fraction", - "maintenance_margin_fraction", - "closeout_margin_fraction", "last_trade_price", "daily_trades_count", "daily_base_token_volume", "daily_quote_token_volume", - "daily_price_low", - "daily_price_high", - "daily_price_change", - "open_interest", - "daily_chart" + "daily_price_change" ] }, - "OrderBookDetails": { + "OrderBooks": { "type": "object", "properties": { "code": { @@ -4647,20 +5040,20 @@ "message": { "type": "string" }, - "order_book_details": { + "order_books": { "type": "array", "items": { - "$ref": "#/definitions/OrderBookDetail" + "$ref": "#/definitions/OrderBook" } } }, - "title": "OrderBookDetails", + "title": "OrderBooks", "required": [ "code", - "order_book_details" + "order_books" ] }, - "OrderBookOrders": { + "Orders": { "type": "object", "properties": { "code": { @@ -4671,54 +5064,74 @@ "message": { "type": "string" }, - "total_asks": { - "type": "integer", - "format": "int64", - "example": "1" - }, - "asks": { - "type": "array", - "items": { - "$ref": "#/definitions/SimpleOrder" - } - }, - "total_bids": { - "type": "integer", - "format": "int64", - "example": "1" + "next_cursor": { + "type": "string" }, - "bids": { + "orders": { "type": "array", "items": { - "$ref": "#/definitions/SimpleOrder" + "$ref": "#/definitions/Order" } } }, - "title": "OrderBookOrders", + "title": "Orders", "required": [ "code", - "total_asks", - "asks", - "total_bids", - "bids" + "orders" ] }, - "OrderBookStats": { + "PerpsMarketStats": { "type": "object", "properties": { "symbol": { "type": "string", "example": "ETH" }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "index_price": { + "type": "string", + "example": "3024.66" + }, + "mark_price": { + "type": "string", + "example": "3024.66" + }, + "open_interest": { + "type": "string", + "example": "235.25" + }, + "open_interest_limit": { + "type": "string", + "example": "235.25" + }, + "funding_clamp_small": { + "type": "string", + "example": "0.005" + }, + "funding_clamp_big": { + "type": "string", + "example": "0.4" + }, "last_trade_price": { - "type": "number", - "format": "double", + "type": "string", "example": "3024.66" }, - "daily_trades_count": { + "current_funding_rate": { + "type": "string", + "example": "0.0001" + }, + "funding_rate": { + "type": "string", + "example": "0.0001" + }, + "funding_timestamp": { "type": "integer", "format": "int64", - "example": "68" + "example": "1640995200" }, "daily_base_token_volume": { "type": "number", @@ -4730,71 +5143,241 @@ "format": "double", "example": "93566.25" }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, "daily_price_change": { "type": "number", "format": "double", "example": "3.66" } }, - "title": "OrderBookStats", + "title": "PerpsMarketStats", "required": [ "symbol", + "market_id", + "index_price", + "mark_price", + "open_interest", + "open_interest_limit", + "funding_clamp_small", + "funding_clamp_big", "last_trade_price", - "daily_trades_count", + "current_funding_rate", + "funding_rate", + "funding_timestamp", "daily_base_token_volume", "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", "daily_price_change" ] }, - "OrderBooks": { + "PerpsOrderBookDetail": { "type": "object", "properties": { - "code": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "market_id": { "type": "integer", - "format": "int32", - "example": "200" + "format": "int16", + "example": "1" }, - "message": { - "type": "string" + "market_type": { + "type": "string", + "example": "perp", + "enum": [ + "perp", + "spot" + ] }, - "order_books": { - "type": "array", - "items": { - "$ref": "#/definitions/OrderBook" - } - } - }, - "title": "OrderBooks", - "required": [ - "code", - "order_books" - ] - }, - "Orders": { - "type": "object", - "properties": { - "code": { + "base_asset_id": { "type": "integer", - "format": "int32", - "example": "200" + "format": "int16", + "example": "1" }, - "message": { - "type": "string" + "quote_asset_id": { + "type": "integer", + "format": "int16", + "example": "2" }, - "next_cursor": { - "type": "string" + "status": { + "type": "string", + "example": "active", + "enum": [ + "inactive", + "active" + ] }, - "orders": { - "type": "array", - "items": { - "$ref": "#/definitions/Order" + "taker_fee": { + "type": "string", + "example": "0.0001" + }, + "maker_fee": { + "type": "string", + "example": "0.0000" + }, + "liquidation_fee": { + "type": "string", + "example": "0.01" + }, + "min_base_amount": { + "type": "string", + "example": "0.01" + }, + "min_quote_amount": { + "type": "string", + "example": "0.1" + }, + "order_quote_limit": { + "type": "string", + "example": "235.25" + }, + "supported_size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_quote_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "quote_multiplier": { + "type": "integer", + "format": "int64", + "example": "10000" + }, + "default_initial_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "100" + }, + "min_initial_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "100" + }, + "maintenance_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "50" + }, + "closeout_margin_fraction": { + "type": "integer", + "format": "uin16", + "example": "100" + }, + "last_trade_price": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + }, + "open_interest": { + "type": "number", + "format": "double", + "example": "93.0" + }, + "daily_chart": { + "type": "object", + "example": "{1640995200:3024.66}", + "additionalProperties": { + "type": "number", + "format": "double" } + }, + "market_config": { + "$ref": "#/definitions/MarketConfig" } }, - "title": "Orders", + "title": "PerpsOrderBookDetail", "required": [ - "code", - "orders" + "symbol", + "market_id", + "market_type", + "base_asset_id", + "quote_asset_id", + "status", + "taker_fee", + "maker_fee", + "liquidation_fee", + "min_base_amount", + "min_quote_amount", + "order_quote_limit", + "supported_size_decimals", + "supported_price_decimals", + "supported_quote_decimals", + "size_decimals", + "price_decimals", + "quote_multiplier", + "default_initial_margin_fraction", + "min_initial_margin_fraction", + "maintenance_margin_fraction", + "closeout_margin_fraction", + "last_trade_price", + "daily_trades_count", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change", + "open_interest", + "daily_chart", + "market_config" ] }, "PnLEntry": { @@ -4810,6 +5393,11 @@ "format": "double", "example": "12.0" }, + "trade_spot_pnl": { + "type": "number", + "format": "double", + "example": "12.0" + }, "inflow": { "type": "number", "format": "double", @@ -4820,6 +5408,16 @@ "format": "double", "example": "12.0" }, + "spot_outflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, + "spot_inflow": { + "type": "number", + "format": "double", + "example": "12.0" + }, "pool_pnl": { "type": "number", "format": "double", @@ -4845,8 +5443,11 @@ "required": [ "timestamp", "trade_pnl", + "trade_spot_pnl", "inflow", "outflow", + "spot_outflow", + "spot_inflow", "pool_pnl", "pool_inflow", "pool_outflow", @@ -4863,7 +5464,7 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "example": "1" }, "funding_id": { @@ -4948,121 +5549,6 @@ "size" ] }, - "PublicPool": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32", - "example": "200" - }, - "message": { - "type": "string" - }, - "account_type": { - "type": "integer", - "format": "uint8", - "example": "1" - }, - "index": { - "type": "integer", - "format": "int64", - "example": "1" - }, - "l1_address": { - "type": "string", - "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" - }, - "cancel_all_time": { - "type": "integer", - "format": "int64", - "example": "1640995200" - }, - "total_order_count": { - "type": "integer", - "format": "int64", - "example": "100" - }, - "total_isolated_order_count": { - "type": "integer", - "format": "int64", - "example": "100" - }, - "pending_order_count": { - "type": "integer", - "format": "int64", - "example": "100" - }, - "available_balance": { - "type": "string", - "example": "19995" - }, - "status": { - "type": "integer", - "format": "uint8", - "example": "1" - }, - "collateral": { - "type": "string", - "example": "46342" - }, - "account_index": { - "type": "integer", - "format": "int64" - }, - "name": { - "type": "string" - }, - "description": { - "type": "string" - }, - "can_invite": { - "type": "boolean", - "format": "boolean", - "description": " Remove After FE uses L1 meta endpoint" - }, - "referral_points_percentage": { - "type": "string", - "description": " Remove After FE uses L1 meta endpoint" - }, - "total_asset_value": { - "type": "string", - "example": "19995" - }, - "cross_asset_value": { - "type": "string", - "example": "19995" - }, - "pool_info": { - "$ref": "#/definitions/PublicPoolInfo" - }, - "account_share": { - "$ref": "#/definitions/PublicPoolShare" - } - }, - "title": "PublicPool", - "required": [ - "code", - "account_type", - "index", - "l1_address", - "cancel_all_time", - "total_order_count", - "total_isolated_order_count", - "pending_order_count", - "available_balance", - "status", - "collateral", - "account_index", - "name", - "description", - "can_invite", - "referral_points_percentage", - "total_asset_value", - "cross_asset_value", - "pool_info" - ] - }, "PublicPoolInfo": { "type": "object", "properties": { @@ -5094,6 +5580,11 @@ "format": "double", "example": "20.5000" }, + "sharpe_ratio": { + "type": "number", + "format": "double", + "example": "1.5" + }, "daily_returns": { "type": "array", "items": { @@ -5115,6 +5606,7 @@ "total_shares", "operator_shares", "annual_percentage_yield", + "sharpe_ratio", "daily_returns", "share_prices" ] @@ -5135,6 +5627,15 @@ "format": "int64", "example": "3" }, + "created_at": { + "type": "integer", + "format": "int64" + }, + "master_account_index": { + "type": "integer", + "format": "int64", + "example": "61" + }, "account_type": { "type": "integer", "format": "uint8", @@ -5152,6 +5653,11 @@ "format": "double", "example": "20.5000" }, + "sharpe_ratio": { + "type": "number", + "format": "double", + "example": "1.5" + }, "status": { "type": "integer", "format": "uint8", @@ -5178,10 +5684,13 @@ "required": [ "code", "account_index", + "created_at", + "master_account_index", "account_type", "name", "l1_address", "annual_percentage_yield", + "sharpe_ratio", "status", "operator_fee", "total_asset_value", @@ -5201,45 +5710,16 @@ "format": "int64", "example": "3000" }, - "entry_usdc": { - "type": "string", - "example": "3000" - } - }, - "title": "PublicPoolShare", - "required": [ - "public_pool_index", - "shares_amount", - "entry_usdc" - ] - }, - "PublicPools": { - "type": "object", - "properties": { - "code": { - "type": "integer", - "format": "int32", - "example": "200" - }, - "message": { - "type": "string" - }, - "total": { - "type": "integer", - "format": "int64" - }, - "public_pools": { - "type": "array", - "items": { - "$ref": "#/definitions/PublicPool" - } + "entry_usdc": { + "type": "string", + "example": "3000" } }, - "title": "PublicPools", + "title": "PublicPoolShare", "required": [ - "code", - "total", - "public_pools" + "public_pool_index", + "shares_amount", + "entry_usdc" ] }, "ReferralPointEntry": { @@ -5249,23 +5729,23 @@ "type": "string" }, "total_points": { - "type": "integer", - "format": "int64", - "example": "1000" + "type": "number", + "format": "float", + "example": "1000.01" }, "week_points": { - "type": "integer", - "format": "int64", - "example": "1000" + "type": "number", + "format": "float", + "example": "1000.01" }, "total_reward_points": { - "type": "integer", - "format": "int64", + "type": "number", + "format": "float", "example": "200" }, "week_reward_points": { - "type": "integer", - "format": "int64", + "type": "number", + "format": "float", "example": "200" }, "reward_point_multiplier": { @@ -5293,23 +5773,23 @@ } }, "user_total_points": { - "type": "integer", - "format": "int64", + "type": "number", + "format": "float", "example": "1000" }, "user_last_week_points": { - "type": "integer", - "format": "int64", + "type": "number", + "format": "float", "example": "1000" }, "user_total_referral_reward_points": { - "type": "integer", - "format": "int64", + "type": "number", + "format": "float", "example": "1000" }, "user_last_week_referral_reward_points": { - "type": "integer", - "format": "int64", + "type": "number", + "format": "float", "example": "1000" }, "reward_point_multiplier": { @@ -5383,7 +5863,7 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, "type": { @@ -5428,7 +5908,7 @@ }, "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "auth": { "type": "string", @@ -5484,7 +5964,7 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, "ask_filter": { @@ -5642,6 +6122,17 @@ }, "title": "ReqGetAccountTxs" }, + "ReqGetAssetDetails": { + "type": "object", + "properties": { + "asset_id": { + "type": "integer", + "format": "int16", + "default": "0" + } + }, + "title": "ReqGetAssetDetails" + }, "ReqGetBlock": { "type": "object", "properties": { @@ -5682,6 +6173,18 @@ "value" ] }, + "ReqGetBridgesByL1Addr": { + "type": "object", + "properties": { + "l1_address": { + "type": "string" + } + }, + "title": "ReqGetBridgesByL1Addr", + "required": [ + "l1_address" + ] + }, "ReqGetByAccount": { "type": "object", "properties": { @@ -5706,7 +6209,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "resolution": { "type": "string", @@ -5714,9 +6217,12 @@ "1m", "5m", "15m", + "30m", "1h", "4h", - "1d" + "12h", + "1d", + "1w" ] }, "start_timestamp": { @@ -5806,7 +6312,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "resolution": { "type": "string", @@ -5892,7 +6398,7 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, "cursor": { @@ -5934,8 +6440,17 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" } }, "title": "ReqGetOrderBookDetails" @@ -5945,12 +6460,12 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "limit": { "type": "integer", "format": "int64", - "maximum": 100, + "maximum": 250, "minimum": 1 } }, @@ -5965,8 +6480,17 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" + }, + "filter": { + "type": "string", + "enum": [ + "all", + "spot", + "perp" + ], + "default": "all" } }, "title": "ReqGetOrderBooks" @@ -5983,7 +6507,7 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, "cursor": { @@ -6011,42 +6535,6 @@ "limit" ] }, - "ReqGetPublicPools": { - "type": "object", - "properties": { - "auth": { - "type": "string" - }, - "filter": { - "type": "string", - "enum": [ - "all", - "user", - "protocol", - "account_index" - ] - }, - "index": { - "type": "integer", - "format": "int64" - }, - "limit": { - "type": "integer", - "format": "int64", - "maximum": 100, - "minimum": 1 - }, - "account_index": { - "type": "integer", - "format": "int64" - } - }, - "title": "ReqGetPublicPools", - "required": [ - "index", - "limit" - ] - }, "ReqGetPublicPoolsMetadata": { "type": "object", "properties": { @@ -6149,7 +6637,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "limit": { "type": "integer", @@ -6189,7 +6677,7 @@ }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "default": "255" }, "account_index": { @@ -6229,11 +6717,36 @@ "format": "int8", "default": "-1" }, + "role": { + "type": "string", + "enum": [ + "all", + "maker", + "taker" + ], + "default": "all" + }, + "type": { + "type": "string", + "enum": [ + "all", + "trade", + "liquidation", + "deleverage", + "market-settlement" + ], + "default": "all" + }, "limit": { "type": "integer", "format": "int64", "maximum": 100, "minimum": 1 + }, + "aggregate": { + "type": "boolean", + "format": "boolean", + "default": "false" } }, "title": "ReqGetTrades", @@ -6369,6 +6882,50 @@ "tx_infos" ] }, + "ReqUpdateKickback": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "kickback_percentage": { + "type": "number", + "format": "double", + "maximum": 100 + } + }, + "title": "ReqUpdateKickback", + "required": [ + "account_index", + "kickback_percentage" + ] + }, + "ReqUpdateReferralCode": { + "type": "object", + "properties": { + "auth": { + "type": "string", + "description": " made optional to support header auth clients" + }, + "account_index": { + "type": "integer", + "format": "int64" + }, + "new_referral_code": { + "type": "string" + } + }, + "title": "ReqUpdateReferralCode", + "required": [ + "account_index", + "new_referral_code" + ] + }, "RespChangeAccountTier": { "type": "object", "properties": { @@ -6386,6 +6943,30 @@ "code" ] }, + "RespGetBridgesByL1Addr": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "bridges": { + "type": "array", + "items": { + "$ref": "#/definitions/Bridge" + } + } + }, + "title": "RespGetBridgesByL1Addr", + "required": [ + "code", + "bridges" + ] + }, "RespGetFastBridgeInfo": { "type": "object", "properties": { @@ -6407,6 +6988,28 @@ "fast_bridge_limit" ] }, + "RespGetIsNextBridgeFast": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "is_next_bridge_fast": { + "type": "boolean", + "format": "boolean" + } + }, + "title": "RespGetIsNextBridgeFast", + "required": [ + "code", + "is_next_bridge_fast" + ] + }, "RespPublicPoolsMetadata": { "type": "object", "properties": { @@ -6450,16 +7053,79 @@ "type": "integer", "format": "int64", "example": "1751465474" + }, + "volume_quota_remaining": { + "type": "integer", + "format": "int64" + } + }, + "title": "RespSendTx", + "required": [ + "code", + "tx_hash", + "predicted_execution_time_ms", + "volume_quota_remaining" + ] + }, + "RespSendTxBatch": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "tx_hash": { + "type": "array", + "items": { + "type": "string" + } + }, + "predicted_execution_time_ms": { + "type": "integer", + "format": "int64", + "example": "1751465474" + }, + "volume_quota_remaining": { + "type": "integer", + "format": "int64" + } + }, + "title": "RespSendTxBatch", + "required": [ + "code", + "tx_hash", + "predicted_execution_time_ms", + "volume_quota_remaining" + ] + }, + "RespUpdateKickback": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "example": "200" + }, + "message": { + "type": "string" + }, + "success": { + "type": "boolean", + "format": "boolean", + "example": "true" } }, - "title": "RespSendTx", + "title": "RespUpdateKickback", "required": [ "code", - "tx_hash", - "predicted_execution_time_ms" + "success" ] }, - "RespSendTxBatch": { + "RespUpdateReferralCode": { "type": "object", "properties": { "code": { @@ -6470,23 +7136,16 @@ "message": { "type": "string" }, - "tx_hash": { - "type": "array", - "items": { - "type": "string" - } - }, - "predicted_execution_time_ms": { - "type": "integer", - "format": "int64", - "example": "1751465474" + "success": { + "type": "boolean", + "format": "boolean", + "example": "true" } }, - "title": "RespSendTxBatch", + "title": "RespUpdateReferralCode", "required": [ "code", - "tx_hash", - "predicted_execution_time_ms" + "success" ] }, "RespWithdrawalDelay": { @@ -6544,7 +7203,7 @@ "properties": { "market_id": { "type": "integer", - "format": "uint8" + "format": "int16" }, "collateral": { "type": "string" @@ -6638,6 +7297,230 @@ "order_expiry" ] }, + "SpotMarketStats": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH/USDC" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "index_price": { + "type": "string", + "example": "3024.66" + }, + "mid_price": { + "type": "string", + "example": "3024.66" + }, + "last_trade_price": { + "type": "string", + "example": "3024.66" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + } + }, + "title": "SpotMarketStats", + "required": [ + "symbol", + "market_id", + "index_price", + "mid_price", + "last_trade_price", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change" + ] + }, + "SpotOrderBookDetail": { + "type": "object", + "properties": { + "symbol": { + "type": "string", + "example": "ETH" + }, + "market_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "market_type": { + "type": "string", + "example": "perp", + "enum": [ + "perp", + "spot" + ] + }, + "base_asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, + "quote_asset_id": { + "type": "integer", + "format": "int16", + "example": "2" + }, + "status": { + "type": "string", + "example": "active", + "enum": [ + "inactive", + "active" + ] + }, + "taker_fee": { + "type": "string", + "example": "0.0001" + }, + "maker_fee": { + "type": "string", + "example": "0.0000" + }, + "liquidation_fee": { + "type": "string", + "example": "0.01" + }, + "min_base_amount": { + "type": "string", + "example": "0.01" + }, + "min_quote_amount": { + "type": "string", + "example": "0.1" + }, + "order_quote_limit": { + "type": "string", + "example": "235.25" + }, + "supported_size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "supported_quote_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "size_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "price_decimals": { + "type": "integer", + "format": "uint8", + "example": "4" + }, + "last_trade_price": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_trades_count": { + "type": "integer", + "format": "int64", + "example": "68" + }, + "daily_base_token_volume": { + "type": "number", + "format": "double", + "example": "235.25" + }, + "daily_quote_token_volume": { + "type": "number", + "format": "double", + "example": "93566.25" + }, + "daily_price_low": { + "type": "number", + "format": "double", + "example": "3014.66" + }, + "daily_price_high": { + "type": "number", + "format": "double", + "example": "3024.66" + }, + "daily_price_change": { + "type": "number", + "format": "double", + "example": "3.66" + }, + "daily_chart": { + "type": "object", + "example": "{1640995200:3024.66}", + "additionalProperties": { + "type": "number", + "format": "double" + } + } + }, + "title": "SpotOrderBookDetail", + "required": [ + "symbol", + "market_id", + "market_type", + "base_asset_id", + "quote_asset_id", + "status", + "taker_fee", + "maker_fee", + "liquidation_fee", + "min_base_amount", + "min_quote_amount", + "order_quote_limit", + "supported_size_decimals", + "supported_price_decimals", + "supported_quote_decimals", + "size_decimals", + "price_decimals", + "last_trade_price", + "daily_trades_count", + "daily_base_token_volume", + "daily_quote_token_volume", + "daily_price_low", + "daily_price_high", + "daily_price_change", + "daily_chart" + ] + }, "Status": { "type": "object", "properties": { @@ -6733,12 +7616,13 @@ "enum": [ "trade", "liquidation", - "deleverage" + "deleverage", + "market-settlement" ] }, "market_id": { "type": "integer", - "format": "uint8", + "format": "int16", "example": "1" }, "size": { @@ -6763,6 +7647,16 @@ "format": "int64", "example": "245" }, + "ask_client_id": { + "type": "integer", + "format": "int64", + "example": "145" + }, + "bid_client_id": { + "type": "integer", + "format": "int64", + "example": "245" + }, "ask_account_id": { "type": "integer", "format": "int64", @@ -6846,6 +7740,8 @@ "usd_amount", "ask_id", "bid_id", + "ask_client_id", + "bid_client_id", "ask_account_id", "bid_account_id", "is_maker_ask", @@ -6946,6 +7842,11 @@ "id": { "type": "string" }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, "amount": { "type": "string", "example": "0.1" @@ -6959,7 +7860,12 @@ "type": "string", "enum": [ "L2TransferInflow", - "L2TransferOutflow" + "L2TransferOutflow", + "L2BurnSharesInflow", + "L2BurnSharesOutflow", + "L2MintSharesInflow", + "L2MintSharesOutflow", + "L2SelfTransfer" ] }, "from_l1_address": { @@ -6980,6 +7886,20 @@ "format": "int64", "example": "1" }, + "from_route": { + "type": "string", + "enum": [ + "spot", + "perps" + ] + }, + "to_route": { + "type": "string", + "enum": [ + "spot", + "perps" + ] + }, "tx_hash": { "type": "string", "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" @@ -6988,6 +7908,7 @@ "title": "TransferHistoryItem", "required": [ "id", + "asset_id", "amount", "timestamp", "type", @@ -6995,6 +7916,8 @@ "to_l1_address", "from_account_index", "to_account_index", + "from_route", + "to_route", "tx_hash" ] }, @@ -7072,6 +7995,11 @@ "parent_hash": { "type": "string", "example": "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" + }, + "api_key_index": { + "type": "integer", + "format": "uint8", + "example": "0" } }, "title": "Tx", @@ -7090,7 +8018,8 @@ "queued_at", "executed_at", "sequence_index", - "parent_hash" + "parent_hash", + "api_key_index" ] }, "TxHash": { @@ -7216,6 +8145,11 @@ "id": { "type": "string" }, + "asset_id": { + "type": "integer", + "format": "int16", + "example": "1" + }, "amount": { "type": "string", "example": "0.1" @@ -7250,6 +8184,7 @@ "title": "WithdrawHistoryItem", "required": [ "id", + "asset_id", "amount", "timestamp", "status",