diff --git a/.apigen-state b/.apigen-state index 27246c3..b838f91 100644 --- a/.apigen-state +++ b/.apigen-state @@ -1,16 +1,16 @@ { "version": "1", "algorithm": "sha256", - "generated_at": "2026-02-23T19:51:11.960440Z", + "generated_at": "2026-02-23T21:15:02.935039Z", "spec_files": { - "resources/account-data-api.yaml": "006077b90f4300d364279d96d307f1274d44425c26d04f841e0fbcb21ca1b385", + "resources/account-data-api.yaml": "880923d021343a11da512c32154d8f220c308e97a6c0bf6ce1857774acc62fe4", "resources/auth-api.yaml": "d323937afd8fd9431a1075bb7ae06a28181848afd6e5278675b9a2945b9257c1", - "resources/bluefin-api.yaml": "78944468df304dc33cffbc2b63635ee8227a414bb6ec1c04cbd56d0f55524352", - "resources/common.yaml": "987eff2a0278455a20d99428d4fd79f242c80b6a2fc77ee6201fd46c993bd61e", + "resources/bluefin-api.yaml": "aa5ac52d740db0bfedb48ff771e06503a81fe80fb99b78229ca8b8b1d6b38b3f", + "resources/common.yaml": "f0140950057e524457e5197c5b20bf8d74342e596378043ff8b4c75b5a3fc036", "resources/exchange-api.yaml": "01fdc7056531ec2e71a16c3c982a0776cbe3f5af1444bd264a536457a2b023b0", "resources/rewards-data-api.yaml": "2c715683d080ad11aa7667d81e36b1f36839da5d2af1bd3ce0d164db6f19cb0c", "resources/trade-api.yaml": "229ac3d9a7a30b640db928cc5d99cddc4e185e70b76e7c0d7273f94225cd1d37", "resources/websocket-api.yaml": "eefb5b151d020ca372577927bb740b3bf1206cc2d31f8c0d8763bf6e56590330" }, - "combined_hash": "d3f4fe2bda4a48646eb70f674a5df17e0cb8df0e7917a89f832f437e61044895" + "combined_hash": "11b92543a2761210a11c1a3d643f86a9c5882c5c3fd8ad4a779e95179f3626ee" } \ No newline at end of file diff --git a/python/example/main.py b/python/example/main.py index b370730..f2ef808 100755 --- a/python/example/main.py +++ b/python/example/main.py @@ -132,6 +132,9 @@ async def main(): country = await exchange_data_api.get_country() log.info(f"{country=}") + leaderboard = await exchange_data_api.get_leaderboard() + log.info(f"{leaderboard=}") + # ========= Account Data API ========= account_data_api = client.account_data_api when = ((t := now()) - 60 * 60 * 1000, t) # The past hour. diff --git a/python/sdk/config.yaml b/python/sdk/config.yaml index e31729e..fa86789 100644 --- a/python/sdk/config.yaml +++ b/python/sdk/config.yaml @@ -2,4 +2,4 @@ additionalProperties: library: asyncio generateSourceCodeOnly: true useOneOfDiscriminatorLookup: true - packageVersion: 1.9.0 + packageVersion: 1.10.0 diff --git a/python/sdk/pyproject.toml b/python/sdk/pyproject.toml index 47f2bff..0bb742e 100644 --- a/python/sdk/pyproject.toml +++ b/python/sdk/pyproject.toml @@ -21,7 +21,7 @@ description = "Python Boilerplate contains all the boilerplate you need to creat name = "bluefin_pro_sdk" readme = "README.rst" requires-python = ">=3.9.2,<3.13.0" -version = "1.9.0" +version = "1.10.0" [[project.authors]] email = "audreyr@example.com" diff --git a/python/sdk/src/.openapi-generator/FILES b/python/sdk/src/.openapi-generator/FILES index 81209b6..15e9747 100644 --- a/python/sdk/src/.openapi-generator/FILES +++ b/python/sdk/src/.openapi-generator/FILES @@ -79,6 +79,9 @@ openapi_client/docs/IntervalMetadata.md openapi_client/docs/IntervalRewards.md openapi_client/docs/IssBase64Details.md openapi_client/docs/KlineInterval.md +openapi_client/docs/LeaderboardEntry.md +openapi_client/docs/LeaderboardInterval.md +openapi_client/docs/LeaderboardResponse.md openapi_client/docs/LoginRequest.md openapi_client/docs/LoginResponse.md openapi_client/docs/MarginType.md @@ -123,6 +126,7 @@ openapi_client/docs/RewardsPoolEntry.md openapi_client/docs/RewardsSummary.md openapi_client/docs/SelfTradePreventionType.md openapi_client/docs/SigPayload.md +openapi_client/docs/SortOrder.md openapi_client/docs/SponsorTxRequest.md openapi_client/docs/SponsorTxResponse.md openapi_client/docs/StatsAllTimeResponse.md @@ -220,6 +224,9 @@ openapi_client/models/interval_metadata.py openapi_client/models/interval_rewards.py openapi_client/models/iss_base64_details.py openapi_client/models/kline_interval.py +openapi_client/models/leaderboard_entry.py +openapi_client/models/leaderboard_interval.py +openapi_client/models/leaderboard_response.py openapi_client/models/login_request.py openapi_client/models/login_response.py openapi_client/models/margin_type.py @@ -263,6 +270,7 @@ openapi_client/models/rewards_pool_entry.py openapi_client/models/rewards_summary.py openapi_client/models/self_trade_prevention_type.py openapi_client/models/sig_payload.py +openapi_client/models/sort_order.py openapi_client/models/sponsor_tx_request.py openapi_client/models/sponsor_tx_response.py openapi_client/models/stats_all_time_response.py @@ -291,4 +299,8 @@ openapi_client/models/zk_login_zkp_request.py openapi_client/models/zk_login_zkp_response.py openapi_client/rest.py openapi_client/test/__init__.py +openapi_client/test/test_leaderboard_entry.py +openapi_client/test/test_leaderboard_interval.py +openapi_client/test/test_leaderboard_response.py +openapi_client/test/test_sort_order.py openapi_client_README.md diff --git a/python/sdk/src/openapi_client/__init__.py b/python/sdk/src/openapi_client/__init__.py index f3a3ad6..6fade1b 100644 --- a/python/sdk/src/openapi_client/__init__.py +++ b/python/sdk/src/openapi_client/__init__.py @@ -14,7 +14,7 @@ """ # noqa: E501 -__version__ = "1.9.0" +__version__ = "1.10.0" # import apis into sdk package from openapi_client.api.account_data_api import AccountDataApi @@ -103,6 +103,9 @@ from openapi_client.models.interval_rewards import IntervalRewards from openapi_client.models.iss_base64_details import IssBase64Details from openapi_client.models.kline_interval import KlineInterval +from openapi_client.models.leaderboard_entry import LeaderboardEntry +from openapi_client.models.leaderboard_interval import LeaderboardInterval +from openapi_client.models.leaderboard_response import LeaderboardResponse from openapi_client.models.login_request import LoginRequest from openapi_client.models.login_response import LoginResponse from openapi_client.models.margin_type import MarginType @@ -146,6 +149,7 @@ from openapi_client.models.rewards_summary import RewardsSummary from openapi_client.models.self_trade_prevention_type import SelfTradePreventionType from openapi_client.models.sig_payload import SigPayload +from openapi_client.models.sort_order import SortOrder from openapi_client.models.sponsor_tx_request import SponsorTxRequest from openapi_client.models.sponsor_tx_response import SponsorTxResponse from openapi_client.models.stats_all_time_response import StatsAllTimeResponse diff --git a/python/sdk/src/openapi_client/api/exchange_api.py b/python/sdk/src/openapi_client/api/exchange_api.py index 7b17dc5..1f66082 100644 --- a/python/sdk/src/openapi_client/api/exchange_api.py +++ b/python/sdk/src/openapi_client/api/exchange_api.py @@ -16,7 +16,7 @@ from typing import Any, Dict, List, Optional, Tuple, Union from typing_extensions import Annotated -from pydantic import Field, StrictInt, StrictStr +from pydantic import Field, StrictInt, StrictStr, field_validator from typing import List, Optional from typing_extensions import Annotated from openapi_client.models.candle_price_type import CandlePriceType @@ -24,7 +24,10 @@ from openapi_client.models.exchange_info_response import ExchangeInfoResponse from openapi_client.models.funding_rate_entry import FundingRateEntry from openapi_client.models.kline_interval import KlineInterval +from openapi_client.models.leaderboard_interval import LeaderboardInterval +from openapi_client.models.leaderboard_response import LeaderboardResponse from openapi_client.models.orderbook_depth_response import OrderbookDepthResponse +from openapi_client.models.sort_order import SortOrder from openapi_client.models.stats_all_time_response import StatsAllTimeResponse from openapi_client.models.stats_interval import StatsInterval from openapi_client.models.stats_response import StatsResponse @@ -2069,6 +2072,345 @@ def _get_funding_rate_history_serialize( + @validate_call + async def get_leaderboard( + self, + interval: Annotated[Optional[LeaderboardInterval], Field(description="The interval to get the leaderboard for. Default or Unspecified is 7d.")] = None, + sort_by: Annotated[Optional[StrictStr], Field(description="The field to sort by. Default or Unspecified is accountValue.")] = None, + sort_order: Annotated[Optional[SortOrder], Field(description="The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC.")] = None, + limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Default 50; max 100.")] = None, + page: Annotated[Optional[Annotated[int, Field(strict=True, ge=1)]], Field(description="The page number to retrieve in a paginated response.")] = 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, + ) -> LeaderboardResponse: + """/accounts/leaderboard + + Retrieves the leaderboard of traders based on their performance. + + :param interval: The interval to get the leaderboard for. Default or Unspecified is 7d. + :type interval: LeaderboardInterval + :param sort_by: The field to sort by. Default or Unspecified is accountValue. + :type sort_by: str + :param sort_order: The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + :type sort_order: SortOrder + :param limit: Default 50; max 100. + :type limit: int + :param page: The page number to retrieve in a paginated response. + :type page: 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._get_leaderboard_serialize( + interval=interval, + sort_by=sort_by, + sort_order=sort_order, + limit=limit, + page=page, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "LeaderboardResponse", + '400': "Error", + '404': "Error", + '500': "Error", + } + 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 get_leaderboard_with_http_info( + self, + interval: Annotated[Optional[LeaderboardInterval], Field(description="The interval to get the leaderboard for. Default or Unspecified is 7d.")] = None, + sort_by: Annotated[Optional[StrictStr], Field(description="The field to sort by. Default or Unspecified is accountValue.")] = None, + sort_order: Annotated[Optional[SortOrder], Field(description="The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC.")] = None, + limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Default 50; max 100.")] = None, + page: Annotated[Optional[Annotated[int, Field(strict=True, ge=1)]], Field(description="The page number to retrieve in a paginated response.")] = 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[LeaderboardResponse]: + """/accounts/leaderboard + + Retrieves the leaderboard of traders based on their performance. + + :param interval: The interval to get the leaderboard for. Default or Unspecified is 7d. + :type interval: LeaderboardInterval + :param sort_by: The field to sort by. Default or Unspecified is accountValue. + :type sort_by: str + :param sort_order: The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + :type sort_order: SortOrder + :param limit: Default 50; max 100. + :type limit: int + :param page: The page number to retrieve in a paginated response. + :type page: 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._get_leaderboard_serialize( + interval=interval, + sort_by=sort_by, + sort_order=sort_order, + limit=limit, + page=page, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "LeaderboardResponse", + '400': "Error", + '404': "Error", + '500': "Error", + } + 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 get_leaderboard_without_preload_content( + self, + interval: Annotated[Optional[LeaderboardInterval], Field(description="The interval to get the leaderboard for. Default or Unspecified is 7d.")] = None, + sort_by: Annotated[Optional[StrictStr], Field(description="The field to sort by. Default or Unspecified is accountValue.")] = None, + sort_order: Annotated[Optional[SortOrder], Field(description="The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC.")] = None, + limit: Annotated[Optional[Annotated[int, Field(le=100, strict=True, ge=1)]], Field(description="Default 50; max 100.")] = None, + page: Annotated[Optional[Annotated[int, Field(strict=True, ge=1)]], Field(description="The page number to retrieve in a paginated response.")] = None, + _request_timeout: Union[ + None, + Annotated[StrictFloat, Field(gt=0)], + Tuple[ + Annotated[StrictFloat, Field(gt=0)], + Annotated[StrictFloat, Field(gt=0)] + ] + ] = None, + _request_auth: Optional[Dict[StrictStr, Any]] = None, + _content_type: Optional[StrictStr] = None, + _headers: Optional[Dict[StrictStr, Any]] = None, + _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0, + ) -> RESTResponseType: + """/accounts/leaderboard + + Retrieves the leaderboard of traders based on their performance. + + :param interval: The interval to get the leaderboard for. Default or Unspecified is 7d. + :type interval: LeaderboardInterval + :param sort_by: The field to sort by. Default or Unspecified is accountValue. + :type sort_by: str + :param sort_order: The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + :type sort_order: SortOrder + :param limit: Default 50; max 100. + :type limit: int + :param page: The page number to retrieve in a paginated response. + :type page: 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._get_leaderboard_serialize( + interval=interval, + sort_by=sort_by, + sort_order=sort_order, + limit=limit, + page=page, + _request_auth=_request_auth, + _content_type=_content_type, + _headers=_headers, + _host_index=_host_index + ) + + _response_types_map: Dict[str, Optional[str]] = { + '200': "LeaderboardResponse", + '400': "Error", + '404': "Error", + '500': "Error", + } + response_data = await self.api_client.call_api( + *_param, + _request_timeout=_request_timeout + ) + return response_data.response + + + def _get_leaderboard_serialize( + self, + interval, + sort_by, + sort_order, + limit, + page, + _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, List[str], List[bytes], List[Tuple[str, bytes]]] + ] = {} + _body_params: Optional[bytes] = None + + # process the path parameters + # process the query parameters + if interval is not None: + + _query_params.append(('interval', interval.value)) + + if sort_by is not None: + + _query_params.append(('sortBy', sort_by)) + + if sort_order is not None: + + _query_params.append(('sortOrder', sort_order.value)) + + if limit is not None: + + _query_params.append(('limit', limit)) + + if page is not None: + + _query_params.append(('page', page)) + + # process the header parameters + # process the form parameters + # process the body parameter + + + # set the HTTP header `Accept` + if 'Accept' not in _header_params: + _header_params['Accept'] = self.api_client.select_header_accept( + [ + 'application/json' + ] + ) + + + # authentication setting + _auth_settings: List[str] = [ + ] + + return self.api_client.param_serialize( + method='GET', + resource_path='/api/v1/accounts/leaderboard', + 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 get_market_ticker( self, diff --git a/python/sdk/src/openapi_client/api_client.py b/python/sdk/src/openapi_client/api_client.py index c217c7c..d715ba7 100644 --- a/python/sdk/src/openapi_client/api_client.py +++ b/python/sdk/src/openapi_client/api_client.py @@ -90,7 +90,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.9.0/python' + self.user_agent = 'OpenAPI-Generator/1.10.0/python' self.client_side_validation = configuration.client_side_validation async def __aenter__(self): diff --git a/python/sdk/src/openapi_client/configuration.py b/python/sdk/src/openapi_client/configuration.py index e7ceaca..1f3d953 100644 --- a/python/sdk/src/openapi_client/configuration.py +++ b/python/sdk/src/openapi_client/configuration.py @@ -507,7 +507,7 @@ def to_debug_report(self) -> str: "OS: {env}\n"\ "Python Version: {pyversion}\n"\ "Version of the API: 1.0.0\n"\ - "SDK Package Version: 1.9.0".\ + "SDK Package Version: 1.10.0".\ format(env=sys.platform, pyversion=sys.version) def get_host_settings(self) -> List[HostSetting]: diff --git a/python/sdk/src/openapi_client/docs/ExchangeApi.md b/python/sdk/src/openapi_client/docs/ExchangeApi.md index 4fec260..e3fc992 100644 --- a/python/sdk/src/openapi_client/docs/ExchangeApi.md +++ b/python/sdk/src/openapi_client/docs/ExchangeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**get_exchange_stats**](ExchangeApi.md#get_exchange_stats) | **GET** /v1/exchange/stats | /exchange/stats [**get_exchange_stats_all_time**](ExchangeApi.md#get_exchange_stats_all_time) | **GET** /v1/exchange/stats/allTime | /v1/exchange/stats/allTime [**get_funding_rate_history**](ExchangeApi.md#get_funding_rate_history) | **GET** /v1/exchange/fundingRateHistory | /exchange/fundingRateHistory +[**get_leaderboard**](ExchangeApi.md#get_leaderboard) | **GET** /api/v1/accounts/leaderboard | /accounts/leaderboard [**get_market_ticker**](ExchangeApi.md#get_market_ticker) | **GET** /v1/exchange/ticker | /exchange/ticker [**get_orderbook_depth**](ExchangeApi.md#get_orderbook_depth) | **GET** /v1/exchange/depth | /exchange/depth [**get_recent_trades**](ExchangeApi.md#get_recent_trades) | **GET** /v1/exchange/trades | /exchange/trades @@ -511,6 +512,87 @@ 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) +# **get_leaderboard** +> LeaderboardResponse get_leaderboard(interval=interval, sort_by=sort_by, sort_order=sort_order, limit=limit, page=page) + +/accounts/leaderboard + +Retrieves the leaderboard of traders based on their performance. + +### Example + + +```python +import openapi_client +from openapi_client.models.leaderboard_interval import LeaderboardInterval +from openapi_client.models.leaderboard_response import LeaderboardResponse +from openapi_client.models.sort_order import SortOrder +from openapi_client.rest import ApiException +from pprint import pprint + +# Defining the host is optional and defaults to https://api.sui-staging.bluefin.io +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host = "https://api.sui-staging.bluefin.io" +) + + +# Enter a context with an instance of the API client +async with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = openapi_client.ExchangeApi(api_client) + interval = openapi_client.LeaderboardInterval() # LeaderboardInterval | The interval to get the leaderboard for. Default or Unspecified is 7d. (optional) + sort_by = accountValue # str | The field to sort by. Default or Unspecified is accountValue. (optional) (default to accountValue) + sort_order = openapi_client.SortOrder() # SortOrder | The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. (optional) + limit = 50 # int | Default 50; max 100. (optional) (default to 50) + page = 1 # int | The page number to retrieve in a paginated response. (optional) (default to 1) + + try: + # /accounts/leaderboard + api_response = await api_instance.get_leaderboard(interval=interval, sort_by=sort_by, sort_order=sort_order, limit=limit, page=page) + print("The response of ExchangeApi->get_leaderboard:\n") + pprint(api_response) + except Exception as e: + print("Exception when calling ExchangeApi->get_leaderboard: %s\n" % e) +``` + + + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **interval** | [**LeaderboardInterval**](.md)| The interval to get the leaderboard for. Default or Unspecified is 7d. | [optional] + **sort_by** | **str**| The field to sort by. Default or Unspecified is accountValue. | [optional] [default to accountValue] + **sort_order** | [**SortOrder**](.md)| The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. | [optional] + **limit** | **int**| Default 50; max 100. | [optional] [default to 50] + **page** | **int**| The page number to retrieve in a paginated response. | [optional] [default to 1] + +### Return type + +[**LeaderboardResponse**](LeaderboardResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +|-------------|-------------|------------------| +**200** | Leaderboard data | - | +**400** | Invalid parameters provided. | - | +**404** | No data found for the specified parameters. | - | +**500** | Internal server error. | - | + +[[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) + # **get_market_ticker** > TickerResponse get_market_ticker(symbol) diff --git a/python/sdk/src/openapi_client/docs/LeaderboardEntry.md b/python/sdk/src/openapi_client/docs/LeaderboardEntry.md new file mode 100644 index 0000000..bd138e8 --- /dev/null +++ b/python/sdk/src/openapi_client/docs/LeaderboardEntry.md @@ -0,0 +1,33 @@ +# LeaderboardEntry + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**rank** | **int** | Rank of the trader in the leaderboard. | +**account_address** | **str** | The address of the account. | +**account_value_e9** | **str** | Total account value of the trader in e9 format. | +**pnl_e9** | **str** | Total profit and loss of the trader in e9 format. | +**volume_e9** | **str** | Total trading volume of the trader in e9 format. | + +## Example + +```python +from openapi_client.models.leaderboard_entry import LeaderboardEntry + +# TODO update the JSON string below +json = "{}" +# create an instance of LeaderboardEntry from a JSON string +leaderboard_entry_instance = LeaderboardEntry.from_json(json) +# print the JSON string representation of the object +print(LeaderboardEntry.to_json()) + +# convert the object into a dict +leaderboard_entry_dict = leaderboard_entry_instance.to_dict() +# create an instance of LeaderboardEntry from a dict +leaderboard_entry_from_dict = LeaderboardEntry.from_dict(leaderboard_entry_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/python/sdk/src/openapi_client/docs/LeaderboardInterval.md b/python/sdk/src/openapi_client/docs/LeaderboardInterval.md new file mode 100644 index 0000000..1c62ad6 --- /dev/null +++ b/python/sdk/src/openapi_client/docs/LeaderboardInterval.md @@ -0,0 +1,18 @@ +# LeaderboardInterval + + +## Enum + +* `LeaderboardIntervalN1d` (value: `'1d'`) + +* `LeaderboardIntervalN7d` (value: `'7d'`) + +* `LeaderboardIntervalN30d` (value: `'30d'`) + +* `LeaderboardIntervalALLTIME` (value: `'ALL_TIME'`) + +* `LeaderboardIntervalUNSPECIFIED` (value: `'UNSPECIFIED'`) + +[[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/python/sdk/src/openapi_client/docs/LeaderboardResponse.md b/python/sdk/src/openapi_client/docs/LeaderboardResponse.md new file mode 100644 index 0000000..092b14a --- /dev/null +++ b/python/sdk/src/openapi_client/docs/LeaderboardResponse.md @@ -0,0 +1,29 @@ +# LeaderboardResponse + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**List[LeaderboardEntry]**](LeaderboardEntry.md) | | + +## Example + +```python +from openapi_client.models.leaderboard_response import LeaderboardResponse + +# TODO update the JSON string below +json = "{}" +# create an instance of LeaderboardResponse from a JSON string +leaderboard_response_instance = LeaderboardResponse.from_json(json) +# print the JSON string representation of the object +print(LeaderboardResponse.to_json()) + +# convert the object into a dict +leaderboard_response_dict = leaderboard_response_instance.to_dict() +# create an instance of LeaderboardResponse from a dict +leaderboard_response_from_dict = LeaderboardResponse.from_dict(leaderboard_response_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/python/sdk/src/openapi_client/docs/SortOrder.md b/python/sdk/src/openapi_client/docs/SortOrder.md new file mode 100644 index 0000000..9bcece1 --- /dev/null +++ b/python/sdk/src/openapi_client/docs/SortOrder.md @@ -0,0 +1,15 @@ +# SortOrder + +The order in which results should be sorted. + +## Enum + +* `ASC` (value: `'ASC'`) + +* `DESC` (value: `'DESC'`) + +* `UNSPECIFIED` (value: `'UNSPECIFIED'`) + +[[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/python/sdk/src/openapi_client/models/__init__.py b/python/sdk/src/openapi_client/models/__init__.py index 97eb416..2264399 100644 --- a/python/sdk/src/openapi_client/models/__init__.py +++ b/python/sdk/src/openapi_client/models/__init__.py @@ -81,6 +81,9 @@ from openapi_client.models.interval_rewards import IntervalRewards from openapi_client.models.iss_base64_details import IssBase64Details from openapi_client.models.kline_interval import KlineInterval +from openapi_client.models.leaderboard_entry import LeaderboardEntry +from openapi_client.models.leaderboard_interval import LeaderboardInterval +from openapi_client.models.leaderboard_response import LeaderboardResponse from openapi_client.models.login_request import LoginRequest from openapi_client.models.login_response import LoginResponse from openapi_client.models.margin_type import MarginType @@ -124,6 +127,7 @@ from openapi_client.models.rewards_summary import RewardsSummary from openapi_client.models.self_trade_prevention_type import SelfTradePreventionType from openapi_client.models.sig_payload import SigPayload +from openapi_client.models.sort_order import SortOrder from openapi_client.models.sponsor_tx_request import SponsorTxRequest from openapi_client.models.sponsor_tx_response import SponsorTxResponse from openapi_client.models.stats_all_time_response import StatsAllTimeResponse diff --git a/python/sdk/src/openapi_client/models/leaderboard_entry.py b/python/sdk/src/openapi_client/models/leaderboard_entry.py new file mode 100644 index 0000000..631a372 --- /dev/null +++ b/python/sdk/src/openapi_client/models/leaderboard_entry.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import pprint +import re # noqa: F401 +import json + +from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr +from typing import Any, ClassVar, Dict, List +from typing import Optional, Set +from typing_extensions import Self + +class LeaderboardEntry(BaseModel): + """ + LeaderboardEntry + """ # noqa: E501 + rank: StrictInt = Field(description="Rank of the trader in the leaderboard.") + account_address: StrictStr = Field(description="The address of the account.", alias="accountAddress") + account_value_e9: StrictStr = Field(description="Total account value of the trader in e9 format.", alias="accountValueE9") + pnl_e9: StrictStr = Field(description="Total profit and loss of the trader in e9 format.", alias="pnlE9") + volume_e9: StrictStr = Field(description="Total trading volume of the trader in e9 format.", alias="volumeE9") + __properties: ClassVar[List[str]] = ["rank", "accountAddress", "accountValueE9", "pnlE9", "volumeE9"] + + 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 LeaderboardEntry 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. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LeaderboardEntry from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "rank": obj.get("rank"), + "accountAddress": obj.get("accountAddress"), + "accountValueE9": obj.get("accountValueE9"), + "pnlE9": obj.get("pnlE9"), + "volumeE9": obj.get("volumeE9") + }) + return _obj + + diff --git a/python/sdk/src/openapi_client/models/leaderboard_interval.py b/python/sdk/src/openapi_client/models/leaderboard_interval.py new file mode 100644 index 0000000..b65a438 --- /dev/null +++ b/python/sdk/src/openapi_client/models/leaderboard_interval.py @@ -0,0 +1,40 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import json +from enum import Enum +from typing_extensions import Self + + +class LeaderboardInterval(str, Enum): + """ + LeaderboardInterval + """ + + """ + allowed enum values + """ + LeaderboardIntervalN1d = '1d' + LeaderboardIntervalN7d = '7d' + LeaderboardIntervalN30d = '30d' + LeaderboardIntervalALLTIME = 'ALL_TIME' + LeaderboardIntervalUNSPECIFIED = 'UNSPECIFIED' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of LeaderboardInterval from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/python/sdk/src/openapi_client/models/leaderboard_response.py b/python/sdk/src/openapi_client/models/leaderboard_response.py new file mode 100644 index 0000000..3180c68 --- /dev/null +++ b/python/sdk/src/openapi_client/models/leaderboard_response.py @@ -0,0 +1,95 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + 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 +from typing import Any, ClassVar, Dict, List +from openapi_client.models.leaderboard_entry import LeaderboardEntry +from typing import Optional, Set +from typing_extensions import Self + +class LeaderboardResponse(BaseModel): + """ + LeaderboardResponse + """ # noqa: E501 + data: List[LeaderboardEntry] + __properties: ClassVar[List[str]] = ["data"] + + 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 LeaderboardResponse 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. + """ + excluded_fields: Set[str] = set([ + ]) + + _dict = self.model_dump( + by_alias=True, + exclude=excluded_fields, + exclude_none=True, + ) + # override the default output from pydantic by calling `to_dict()` of each item in data (list) + _items = [] + if self.data: + for _item_data in self.data: + if _item_data: + _items.append(_item_data.to_dict()) + _dict['data'] = _items + return _dict + + @classmethod + def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: + """Create an instance of LeaderboardResponse from a dict""" + if obj is None: + return None + + if not isinstance(obj, dict): + return cls.model_validate(obj) + + _obj = cls.model_validate({ + "data": [LeaderboardEntry.from_dict(_item) for _item in obj["data"]] if obj.get("data") is not None else None + }) + return _obj + + diff --git a/python/sdk/src/openapi_client/models/sort_order.py b/python/sdk/src/openapi_client/models/sort_order.py new file mode 100644 index 0000000..95fc411 --- /dev/null +++ b/python/sdk/src/openapi_client/models/sort_order.py @@ -0,0 +1,38 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +from __future__ import annotations +import json +from enum import Enum +from typing_extensions import Self + + +class SortOrder(str, Enum): + """ + The order in which results should be sorted. + """ + + """ + allowed enum values + """ + ASC = 'ASC' + DESC = 'DESC' + UNSPECIFIED = 'UNSPECIFIED' + + @classmethod + def from_json(cls, json_str: str) -> Self: + """Create an instance of SortOrder from a JSON string""" + return cls(json.loads(json_str)) + + diff --git a/python/sdk/src/openapi_client/test/test_leaderboard_entry.py b/python/sdk/src/openapi_client/test/test_leaderboard_entry.py new file mode 100644 index 0000000..cd0906e --- /dev/null +++ b/python/sdk/src/openapi_client/test/test_leaderboard_entry.py @@ -0,0 +1,60 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.models.leaderboard_entry import LeaderboardEntry + +class TestLeaderboardEntry(unittest.TestCase): + """LeaderboardEntry unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> LeaderboardEntry: + """Test LeaderboardEntry + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `LeaderboardEntry` + """ + model = LeaderboardEntry() + if include_optional: + return LeaderboardEntry( + rank = 56, + account_address = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', + account_value_e9 = '', + pnl_e9 = '', + volume_e9 = '' + ) + else: + return LeaderboardEntry( + rank = 56, + account_address = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', + account_value_e9 = '', + pnl_e9 = '', + volume_e9 = '', + ) + """ + + def testLeaderboardEntry(self): + """Test LeaderboardEntry""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/sdk/src/openapi_client/test/test_leaderboard_interval.py b/python/sdk/src/openapi_client/test/test_leaderboard_interval.py new file mode 100644 index 0000000..1051c44 --- /dev/null +++ b/python/sdk/src/openapi_client/test/test_leaderboard_interval.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.models.leaderboard_interval import LeaderboardInterval + +class TestLeaderboardInterval(unittest.TestCase): + """LeaderboardInterval unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testLeaderboardInterval(self): + """Test LeaderboardInterval""" + # inst = LeaderboardInterval() + +if __name__ == '__main__': + unittest.main() diff --git a/python/sdk/src/openapi_client/test/test_leaderboard_response.py b/python/sdk/src/openapi_client/test/test_leaderboard_response.py new file mode 100644 index 0000000..b26e0c4 --- /dev/null +++ b/python/sdk/src/openapi_client/test/test_leaderboard_response.py @@ -0,0 +1,66 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.models.leaderboard_response import LeaderboardResponse + +class TestLeaderboardResponse(unittest.TestCase): + """LeaderboardResponse unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def make_instance(self, include_optional) -> LeaderboardResponse: + """Test LeaderboardResponse + include_optional is a boolean, when False only required + params are included, when True both required and + optional params are included """ + # uncomment below to create an instance of `LeaderboardResponse` + """ + model = LeaderboardResponse() + if include_optional: + return LeaderboardResponse( + data = [ + openapi_client.models.leaderboard_entry.LeaderboardEntry( + rank = 56, + account_address = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', + account_value_e9 = '', + pnl_e9 = '', + volume_e9 = '', ) + ] + ) + else: + return LeaderboardResponse( + data = [ + openapi_client.models.leaderboard_entry.LeaderboardEntry( + rank = 56, + account_address = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', + account_value_e9 = '', + pnl_e9 = '', + volume_e9 = '', ) + ], + ) + """ + + def testLeaderboardResponse(self): + """Test LeaderboardResponse""" + # inst_req_only = self.make_instance(include_optional=False) + # inst_req_and_optional = self.make_instance(include_optional=True) + +if __name__ == '__main__': + unittest.main() diff --git a/python/sdk/src/openapi_client/test/test_sort_order.py b/python/sdk/src/openapi_client/test/test_sort_order.py new file mode 100644 index 0000000..935bc5e --- /dev/null +++ b/python/sdk/src/openapi_client/test/test_sort_order.py @@ -0,0 +1,33 @@ +# coding: utf-8 + +""" + Bluefin API + + Bluefin API + + The version of the OpenAPI document: 1.0.0 + Generated by OpenAPI Generator (https://openapi-generator.tech) + + Do not edit the class manually. +""" # noqa: E501 + + +import unittest + +from openapi_client.models.sort_order import SortOrder + +class TestSortOrder(unittest.TestCase): + """SortOrder unit test stubs""" + + def setUp(self): + pass + + def tearDown(self): + pass + + def testSortOrder(self): + """Test SortOrder""" + # inst = SortOrder() + +if __name__ == '__main__': + unittest.main() diff --git a/python/sdk/src/openapi_client_README.md b/python/sdk/src/openapi_client_README.md index 397d60d..b1710b9 100644 --- a/python/sdk/src/openapi_client_README.md +++ b/python/sdk/src/openapi_client_README.md @@ -4,7 +4,7 @@ Bluefin API The `openapi_client` package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: - API version: 1.0.0 -- Package version: 1.9.0 +- Package version: 1.10.0 - Generator version: 7.13.0 - Build package: org.openapitools.codegen.languages.PythonClientCodegen @@ -88,6 +88,7 @@ Class | Method | HTTP request | Description *ExchangeApi* | [**get_exchange_stats**](openapi_client/docs/ExchangeApi.md#get_exchange_stats) | **GET** /v1/exchange/stats | /exchange/stats *ExchangeApi* | [**get_exchange_stats_all_time**](openapi_client/docs/ExchangeApi.md#get_exchange_stats_all_time) | **GET** /v1/exchange/stats/allTime | /v1/exchange/stats/allTime *ExchangeApi* | [**get_funding_rate_history**](openapi_client/docs/ExchangeApi.md#get_funding_rate_history) | **GET** /v1/exchange/fundingRateHistory | /exchange/fundingRateHistory +*ExchangeApi* | [**get_leaderboard**](openapi_client/docs/ExchangeApi.md#get_leaderboard) | **GET** /api/v1/accounts/leaderboard | /accounts/leaderboard *ExchangeApi* | [**get_market_ticker**](openapi_client/docs/ExchangeApi.md#get_market_ticker) | **GET** /v1/exchange/ticker | /exchange/ticker *ExchangeApi* | [**get_orderbook_depth**](openapi_client/docs/ExchangeApi.md#get_orderbook_depth) | **GET** /v1/exchange/depth | /exchange/depth *ExchangeApi* | [**get_recent_trades**](openapi_client/docs/ExchangeApi.md#get_recent_trades) | **GET** /v1/exchange/trades | /exchange/trades @@ -192,6 +193,9 @@ Class | Method | HTTP request | Description - [IntervalRewards](openapi_client/docs/IntervalRewards.md) - [IssBase64Details](openapi_client/docs/IssBase64Details.md) - [KlineInterval](openapi_client/docs/KlineInterval.md) + - [LeaderboardEntry](openapi_client/docs/LeaderboardEntry.md) + - [LeaderboardInterval](openapi_client/docs/LeaderboardInterval.md) + - [LeaderboardResponse](openapi_client/docs/LeaderboardResponse.md) - [LoginRequest](openapi_client/docs/LoginRequest.md) - [LoginResponse](openapi_client/docs/LoginResponse.md) - [MarginType](openapi_client/docs/MarginType.md) @@ -235,6 +239,7 @@ Class | Method | HTTP request | Description - [RewardsSummary](openapi_client/docs/RewardsSummary.md) - [SelfTradePreventionType](openapi_client/docs/SelfTradePreventionType.md) - [SigPayload](openapi_client/docs/SigPayload.md) + - [SortOrder](openapi_client/docs/SortOrder.md) - [SponsorTxRequest](openapi_client/docs/SponsorTxRequest.md) - [SponsorTxResponse](openapi_client/docs/SponsorTxResponse.md) - [StatsAllTimeResponse](openapi_client/docs/StatsAllTimeResponse.md) diff --git a/resources/account-data-api.yaml b/resources/account-data-api.yaml index 4e0a984..85f2788 100644 --- a/resources/account-data-api.yaml +++ b/resources/account-data-api.yaml @@ -470,6 +470,56 @@ components: description: Account value at this timestamp (e9 format). example: "0" + LeaderboardInterval: + type: string + enum: + - "1d" + - "7d" + - "30d" + - "ALL_TIME" + - "UNSPECIFIED" + x-enum-varnames: + - "LeaderboardIntervalN1d" + - "LeaderboardIntervalN7d" + - "LeaderboardIntervalN30d" + - "LeaderboardIntervalALLTIME" + - "LeaderboardIntervalUNSPECIFIED" + LeaderboardResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/LeaderboardEntry" + required: + - data + LeaderboardEntry: + type: object + properties: + rank: + type: integer + format: int64 + description: Rank of the trader in the leaderboard. + accountAddress: + type: string + description: The address of the account. + example: "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde" + accountValueE9: + type: string + description: Total account value of the trader in e9 format. + pnlE9: + type: string + description: Total profit and loss of the trader in e9 format. + volumeE9: + type: string + description: Total trading volume of the trader in e9 format. + required: + - rank + - accountAddress + - accountValueE9 + - pnlE9 + - volumeE9 + SponsorTxRequest: type: object required: @@ -1003,6 +1053,88 @@ paths: application/json: schema: $ref: "./common.yaml#/components/schemas/Error" + + /api/v1/accounts/leaderboard: + get: + tags: + - Exchange + operationId: getLeaderboard + summary: /accounts/leaderboard + description: Retrieves the leaderboard of traders based on their performance. + parameters: + - name: interval + in: query + required: false + description: "The interval to get the leaderboard for. Default or Unspecified is 7d." + schema: + $ref: "#/components/schemas/LeaderboardInterval" + - name: sortBy + in: query + required: false + description: "The field to sort by. Default or Unspecified is accountValue." + schema: + type: string + enum: + - accountValue + - pnl + - volume + - UNSPECIFIED + example: "accountValue" + default: "accountValue" + x-enum-varnames: + - "GetLeaderboardSortByAccountValue" + - "GetLeaderboardSortByPnL" + - "GetLeaderboardSortByVolume" + - "GetLeaderboardSortByUNSPECIFIED" + - name: sortOrder + in: query + required: false + description: "The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC." + schema: + $ref: "./common.yaml#/components/schemas/SortOrder" + - name: limit + in: query + required: false + schema: + type: integer + default: 50 + minimum: 1 + maximum: 100 + description: Default 50; max 100. + - name: page + in: query + required: false + description: The page number to retrieve in a paginated response. + schema: + type: integer + default: 1 + minimum: 1 + responses: + "200": + description: Leaderboard data + content: + application/json: + schema: + $ref: "#/components/schemas/LeaderboardResponse" + "400": + description: Invalid parameters provided. + content: + application/json: + schema: + $ref: "./common.yaml#/components/schemas/Error" + "404": + description: No data found for the specified parameters. + content: + application/json: + schema: + $ref: "./common.yaml#/components/schemas/Error" + "500": + description: Internal server error. + content: + application/json: + schema: + $ref: "./common.yaml#/components/schemas/Error" + /api/v1/account/sponsorTx: post: tags: diff --git a/resources/bluefin-api.yaml b/resources/bluefin-api.yaml index 95acf2d..bbf212c 100644 --- a/resources/bluefin-api.yaml +++ b/resources/bluefin-api.yaml @@ -107,6 +107,8 @@ paths: $ref: "./account-data-api.yaml#/paths/~1api~1v1~1account~1sponsorTx" /api/v1/account/valueHistory: $ref: "./account-data-api.yaml#/paths/~1api~1v1~1account~1valueHistory" + /api/v1/accounts/leaderboard: + $ref: "./account-data-api.yaml#/paths/~1api~1v1~1accounts~1leaderboard" /v1/exchange/depth: $ref: "./exchange-api.yaml#/paths/~1v1~1exchange~1depth" diff --git a/resources/common.yaml b/resources/common.yaml index 5f6c5cb..5d25327 100644 --- a/resources/common.yaml +++ b/resources/common.yaml @@ -80,6 +80,13 @@ components: BOTH: On a self trade, both the taker and the maker order will be cancelled UNSPECIFIED: set to default value + SortOrder: + type: string + description: "The order in which results should be sorted." + enum: + - ASC + - DESC + - UNSPECIFIED TradeSide: type: string description: Trade side based on the user order in this trade. diff --git a/rust/Cargo.lock b/rust/Cargo.lock index d4a0746..56677cf 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -99,7 +99,7 @@ dependencies = [ [[package]] name = "bluefin-pro" -version = "1.9.0" +version = "1.10.0" dependencies = [ "base64", "bcs", @@ -123,7 +123,7 @@ dependencies = [ [[package]] name = "bluefin_api" -version = "1.9.0" +version = "1.10.0" dependencies = [ "reqwest", "serde", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 3894d24..153ef24 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -9,7 +9,7 @@ sha2 = "0.10.8" [dependencies.bluefin_api] path = "gen/bluefin_api" -version = "1.9.0" +version = "1.10.0" [dependencies.ed25519-dalek] features = ["rand_core"] @@ -75,7 +75,7 @@ keywords = [ license = "Unlicense" name = "bluefin-pro" repository = "https://github.com/fireflyprotocol/pro-sdk" -version = "1.9.0" +version = "1.10.0" [workspace] members = [ diff --git a/rust/examples/exchange-leaderboard.rs b/rust/examples/exchange-leaderboard.rs new file mode 100644 index 0000000..0eeaa9d --- /dev/null +++ b/rust/examples/exchange-leaderboard.rs @@ -0,0 +1,27 @@ +use bluefin_api::apis::configuration::Configuration; +use bluefin_api::apis::exchange_api::get_leaderboard; +use bluefin_pro::prelude::*; + +type Error = Box; +type Result = std::result::Result; + +#[tokio::main] +async fn main() -> Result<()> { + let environment = Environment::Staging; + let response = get_leaderboard( + &Configuration { + base_path: exchange::url(environment).into(), + ..Configuration::default() + }, + None, // interval + None, // sort by + None, // sort order + None, // limit + None, // page + ) + .await?; + + println!("{response:#?}"); + + Ok(()) +} diff --git a/rust/gen/bluefin_api/.openapi-generator/FILES b/rust/gen/bluefin_api/.openapi-generator/FILES index f5c4d13..8bcdde3 100644 --- a/rust/gen/bluefin_api/.openapi-generator/FILES +++ b/rust/gen/bluefin_api/.openapi-generator/FILES @@ -72,6 +72,9 @@ docs/IntervalMetadata.md docs/IntervalRewards.md docs/IssBase64Details.md docs/KlineInterval.md +docs/LeaderboardEntry.md +docs/LeaderboardInterval.md +docs/LeaderboardResponse.md docs/LoginRequest.md docs/LoginResponse.md docs/MarginType.md @@ -116,6 +119,7 @@ docs/RewardsPoolEntry.md docs/RewardsSummary.md docs/SelfTradePreventionType.md docs/SigPayload.md +docs/SortOrder.md docs/SponsorTxRequest.md docs/SponsorTxResponse.md docs/StatsAllTimeResponse.md @@ -221,6 +225,9 @@ src/models/interval_metadata.rs src/models/interval_rewards.rs src/models/iss_base64_details.rs src/models/kline_interval.rs +src/models/leaderboard_entry.rs +src/models/leaderboard_interval.rs +src/models/leaderboard_response.rs src/models/login_request.rs src/models/login_response.rs src/models/margin_type.rs @@ -265,6 +272,7 @@ src/models/rewards_pool_entry.rs src/models/rewards_summary.rs src/models/self_trade_prevention_type.rs src/models/sig_payload.rs +src/models/sort_order.rs src/models/sponsor_tx_request.rs src/models/sponsor_tx_response.rs src/models/stats_all_time_response.rs diff --git a/rust/gen/bluefin_api/Cargo.toml b/rust/gen/bluefin_api/Cargo.toml index d18053e..ceb8608 100644 --- a/rust/gen/bluefin_api/Cargo.toml +++ b/rust/gen/bluefin_api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bluefin_api" -version = "1.9.0" +version = "1.10.0" authors = ["OpenAPI Generator team and contributors"] description = "Bluefin API" license = "MIT OR Apache-2.0" diff --git a/rust/gen/bluefin_api/README.md b/rust/gen/bluefin_api/README.md index 760bdc2..6bad89e 100644 --- a/rust/gen/bluefin_api/README.md +++ b/rust/gen/bluefin_api/README.md @@ -8,7 +8,7 @@ Bluefin API This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client. - API version: 1.0.0 -- Package version: 1.9.0 +- Package version: 1.10.0 - Generator version: 7.13.0 - Build package: `org.openapitools.codegen.languages.RustClientCodegen` @@ -48,6 +48,7 @@ Class | Method | HTTP request | Description *ExchangeApi* | [**get_exchange_stats**](docs/ExchangeApi.md#get_exchange_stats) | **GET** /v1/exchange/stats | /exchange/stats *ExchangeApi* | [**get_exchange_stats_all_time**](docs/ExchangeApi.md#get_exchange_stats_all_time) | **GET** /v1/exchange/stats/allTime | /v1/exchange/stats/allTime *ExchangeApi* | [**get_funding_rate_history**](docs/ExchangeApi.md#get_funding_rate_history) | **GET** /v1/exchange/fundingRateHistory | /exchange/fundingRateHistory +*ExchangeApi* | [**get_leaderboard**](docs/ExchangeApi.md#get_leaderboard) | **GET** /api/v1/accounts/leaderboard | /accounts/leaderboard *ExchangeApi* | [**get_market_ticker**](docs/ExchangeApi.md#get_market_ticker) | **GET** /v1/exchange/ticker | /exchange/ticker *ExchangeApi* | [**get_orderbook_depth**](docs/ExchangeApi.md#get_orderbook_depth) | **GET** /v1/exchange/depth | /exchange/depth *ExchangeApi* | [**get_recent_trades**](docs/ExchangeApi.md#get_recent_trades) | **GET** /v1/exchange/trades | /exchange/trades @@ -152,6 +153,9 @@ Class | Method | HTTP request | Description - [IntervalRewards](docs/IntervalRewards.md) - [IssBase64Details](docs/IssBase64Details.md) - [KlineInterval](docs/KlineInterval.md) + - [LeaderboardEntry](docs/LeaderboardEntry.md) + - [LeaderboardInterval](docs/LeaderboardInterval.md) + - [LeaderboardResponse](docs/LeaderboardResponse.md) - [LoginRequest](docs/LoginRequest.md) - [LoginResponse](docs/LoginResponse.md) - [MarginType](docs/MarginType.md) @@ -195,6 +199,7 @@ Class | Method | HTTP request | Description - [RewardsSummary](docs/RewardsSummary.md) - [SelfTradePreventionType](docs/SelfTradePreventionType.md) - [SigPayload](docs/SigPayload.md) + - [SortOrder](docs/SortOrder.md) - [SponsorTxRequest](docs/SponsorTxRequest.md) - [SponsorTxResponse](docs/SponsorTxResponse.md) - [StatsAllTimeResponse](docs/StatsAllTimeResponse.md) diff --git a/rust/gen/bluefin_api/docs/ExchangeApi.md b/rust/gen/bluefin_api/docs/ExchangeApi.md index 3b11b91..a9c3892 100644 --- a/rust/gen/bluefin_api/docs/ExchangeApi.md +++ b/rust/gen/bluefin_api/docs/ExchangeApi.md @@ -11,6 +11,7 @@ Method | HTTP request | Description [**get_exchange_stats**](ExchangeApi.md#get_exchange_stats) | **GET** /v1/exchange/stats | /exchange/stats [**get_exchange_stats_all_time**](ExchangeApi.md#get_exchange_stats_all_time) | **GET** /v1/exchange/stats/allTime | /v1/exchange/stats/allTime [**get_funding_rate_history**](ExchangeApi.md#get_funding_rate_history) | **GET** /v1/exchange/fundingRateHistory | /exchange/fundingRateHistory +[**get_leaderboard**](ExchangeApi.md#get_leaderboard) | **GET** /api/v1/accounts/leaderboard | /accounts/leaderboard [**get_market_ticker**](ExchangeApi.md#get_market_ticker) | **GET** /v1/exchange/ticker | /exchange/ticker [**get_orderbook_depth**](ExchangeApi.md#get_orderbook_depth) | **GET** /v1/exchange/depth | /exchange/depth [**get_recent_trades**](ExchangeApi.md#get_recent_trades) | **GET** /v1/exchange/trades | /exchange/trades @@ -229,6 +230,40 @@ 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) +## get_leaderboard + +> models::LeaderboardResponse get_leaderboard(interval, sort_by, sort_order, limit, page) +/accounts/leaderboard + +Retrieves the leaderboard of traders based on their performance. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**interval** | Option<[**LeaderboardInterval**](.md)> | The interval to get the leaderboard for. Default or Unspecified is 7d. | | +**sort_by** | Option<**String**> | The field to sort by. Default or Unspecified is accountValue. | |[default to accountValue] +**sort_order** | Option<[**SortOrder**](.md)> | The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. | | +**limit** | Option<**u32**> | Default 50; max 100. | |[default to 50] +**page** | Option<**u32**> | The page number to retrieve in a paginated response. | |[default to 1] + +### Return type + +[**models::LeaderboardResponse**](LeaderboardResponse.md) + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[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) + + ## get_market_ticker > models::TickerResponse get_market_ticker(symbol) diff --git a/rust/gen/bluefin_api/docs/LeaderboardEntry.md b/rust/gen/bluefin_api/docs/LeaderboardEntry.md new file mode 100644 index 0000000..43a772a --- /dev/null +++ b/rust/gen/bluefin_api/docs/LeaderboardEntry.md @@ -0,0 +1,15 @@ +# LeaderboardEntry + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**rank** | **i64** | Rank of the trader in the leaderboard. | +**account_address** | **String** | The address of the account. | +**account_value_e9** | **String** | Total account value of the trader in e9 format. | +**pnl_e9** | **String** | Total profit and loss of the trader in e9 format. | +**volume_e9** | **String** | Total trading volume of the trader in e9 format. | + +[[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/rust/gen/bluefin_api/docs/LeaderboardInterval.md b/rust/gen/bluefin_api/docs/LeaderboardInterval.md new file mode 100644 index 0000000..3d5c67d --- /dev/null +++ b/rust/gen/bluefin_api/docs/LeaderboardInterval.md @@ -0,0 +1,16 @@ +# LeaderboardInterval + +## Enum Variants + +| Name | Value | +|---- | -----| +| LeaderboardIntervalN1d | 1d | +| LeaderboardIntervalN7d | 7d | +| LeaderboardIntervalN30d | 30d | +| LeaderboardIntervalALLTIME | ALL_TIME | +| LeaderboardIntervalUNSPECIFIED | UNSPECIFIED | + + +[[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/rust/gen/bluefin_api/docs/LeaderboardResponse.md b/rust/gen/bluefin_api/docs/LeaderboardResponse.md new file mode 100644 index 0000000..8a583da --- /dev/null +++ b/rust/gen/bluefin_api/docs/LeaderboardResponse.md @@ -0,0 +1,11 @@ +# LeaderboardResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**Vec**](LeaderboardEntry.md) | | + +[[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/rust/gen/bluefin_api/docs/SortOrder.md b/rust/gen/bluefin_api/docs/SortOrder.md new file mode 100644 index 0000000..3e3753d --- /dev/null +++ b/rust/gen/bluefin_api/docs/SortOrder.md @@ -0,0 +1,14 @@ +# SortOrder + +## Enum Variants + +| Name | Value | +|---- | -----| +| Asc | ASC | +| Desc | DESC | +| Unspecified | UNSPECIFIED | + + +[[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/rust/gen/bluefin_api/src/apis/exchange_api.rs b/rust/gen/bluefin_api/src/apis/exchange_api.rs index cc03c6c..7a1ea25 100644 --- a/rust/gen/bluefin_api/src/apis/exchange_api.rs +++ b/rust/gen/bluefin_api/src/apis/exchange_api.rs @@ -69,6 +69,16 @@ pub enum GetFundingRateHistoryError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`get_leaderboard`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetLeaderboardError { + Status400(models::Error), + Status404(models::Error), + Status500(models::Error), + UnknownValue(serde_json::Value), +} + /// struct for typed errors of method [`get_market_ticker`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -400,6 +410,62 @@ pub async fn get_funding_rate_history(configuration: &configuration::Configurati } } +/// Retrieves the leaderboard of traders based on their performance. +pub async fn get_leaderboard(configuration: &configuration::Configuration, interval: Option, sort_by: Option<&str>, sort_order: Option, limit: Option, page: Option) -> Result> { + // add a prefix to parameters to efficiently prevent name collisions + let p_interval = interval; + let p_sort_by = sort_by; + let p_sort_order = sort_order; + let p_limit = limit; + let p_page = page; + + let uri_str = format!("{}/api/v1/accounts/leaderboard", configuration.base_path); + let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str); + + if let Some(ref param_value) = p_interval { + req_builder = req_builder.query(&[("interval", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_sort_by { + req_builder = req_builder.query(&[("sortBy", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_sort_order { + req_builder = req_builder.query(&[("sortOrder", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_limit { + req_builder = req_builder.query(&[("limit", ¶m_value.to_string())]); + } + if let Some(ref param_value) = p_page { + req_builder = req_builder.query(&[("page", ¶m_value.to_string())]); + } + if let Some(ref user_agent) = configuration.user_agent { + req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone()); + } + + let req = req_builder.build()?; + let resp = configuration.client.execute(req).await?; + + let status = resp.status(); + let content_type = resp + .headers() + .get("content-type") + .and_then(|v| v.to_str().ok()) + .unwrap_or("application/octet-stream"); + let content_type = super::ContentType::from(content_type); + + if !status.is_client_error() && !status.is_server_error() { + let content = resp.text().await?; + match content_type { + ContentType::Json => serde_json::from_str(&content).map_err(Error::from), + ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LeaderboardResponse`"))), + ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LeaderboardResponse`")))), + } + } else { + let content = resp.text().await?; + let entity: Option = serde_json::from_str(&content).ok(); + Err(Error::ResponseError(ResponseContent { status, content, entity })) + } +} + /// Retrieves aggregated ticker data for a market. pub async fn get_market_ticker(configuration: &configuration::Configuration, symbol: &str) -> Result> { // add a prefix to parameters to efficiently prevent name collisions diff --git a/rust/gen/bluefin_api/src/models/leaderboard_entry.rs b/rust/gen/bluefin_api/src/models/leaderboard_entry.rs new file mode 100644 index 0000000..6bc5a60 --- /dev/null +++ b/rust/gen/bluefin_api/src/models/leaderboard_entry.rs @@ -0,0 +1,44 @@ +/* + * Bluefin API + * + * Bluefin API + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LeaderboardEntry { + /// Rank of the trader in the leaderboard. + #[serde(rename = "rank")] + pub rank: i64, + /// The address of the account. + #[serde(rename = "accountAddress")] + pub account_address: String, + /// Total account value of the trader in e9 format. + #[serde(rename = "accountValueE9")] + pub account_value_e9: String, + /// Total profit and loss of the trader in e9 format. + #[serde(rename = "pnlE9")] + pub pnl_e9: String, + /// Total trading volume of the trader in e9 format. + #[serde(rename = "volumeE9")] + pub volume_e9: String, +} + +impl LeaderboardEntry { + pub fn new(rank: i64, account_address: String, account_value_e9: String, pnl_e9: String, volume_e9: String) -> LeaderboardEntry { + LeaderboardEntry { + rank, + account_address, + account_value_e9, + pnl_e9, + volume_e9, + } + } +} + diff --git a/rust/gen/bluefin_api/src/models/leaderboard_interval.rs b/rust/gen/bluefin_api/src/models/leaderboard_interval.rs new file mode 100644 index 0000000..6748e80 --- /dev/null +++ b/rust/gen/bluefin_api/src/models/leaderboard_interval.rs @@ -0,0 +1,47 @@ +/* + * Bluefin API + * + * Bluefin API + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum LeaderboardInterval { + #[serde(rename = "1d")] + LeaderboardIntervalN1d, + #[serde(rename = "7d")] + LeaderboardIntervalN7d, + #[serde(rename = "30d")] + LeaderboardIntervalN30d, + #[serde(rename = "ALL_TIME")] + LeaderboardIntervalALLTIME, + #[serde(rename = "UNSPECIFIED")] + LeaderboardIntervalUNSPECIFIED, + +} + +impl std::fmt::Display for LeaderboardInterval { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::LeaderboardIntervalN1d => write!(f, "1d"), + Self::LeaderboardIntervalN7d => write!(f, "7d"), + Self::LeaderboardIntervalN30d => write!(f, "30d"), + Self::LeaderboardIntervalALLTIME => write!(f, "ALL_TIME"), + Self::LeaderboardIntervalUNSPECIFIED => write!(f, "UNSPECIFIED"), + } + } +} + +impl Default for LeaderboardInterval { + fn default() -> LeaderboardInterval { + Self::LeaderboardIntervalN1d + } +} + diff --git a/rust/gen/bluefin_api/src/models/leaderboard_response.rs b/rust/gen/bluefin_api/src/models/leaderboard_response.rs new file mode 100644 index 0000000..9dd3ab1 --- /dev/null +++ b/rust/gen/bluefin_api/src/models/leaderboard_response.rs @@ -0,0 +1,27 @@ +/* + * Bluefin API + * + * Bluefin API + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)] +pub struct LeaderboardResponse { + #[serde(rename = "data")] + pub data: Vec, +} + +impl LeaderboardResponse { + pub fn new(data: Vec) -> LeaderboardResponse { + LeaderboardResponse { + data, + } + } +} + diff --git a/rust/gen/bluefin_api/src/models/mod.rs b/rust/gen/bluefin_api/src/models/mod.rs index f514121..bf58f9c 100644 --- a/rust/gen/bluefin_api/src/models/mod.rs +++ b/rust/gen/bluefin_api/src/models/mod.rs @@ -132,6 +132,12 @@ pub mod iss_base64_details; pub use self::iss_base64_details::IssBase64Details; pub mod kline_interval; pub use self::kline_interval::KlineInterval; +pub mod leaderboard_entry; +pub use self::leaderboard_entry::LeaderboardEntry; +pub mod leaderboard_interval; +pub use self::leaderboard_interval::LeaderboardInterval; +pub mod leaderboard_response; +pub use self::leaderboard_response::LeaderboardResponse; pub mod login_request; pub use self::login_request::LoginRequest; pub mod login_response; @@ -218,6 +224,8 @@ pub mod self_trade_prevention_type; pub use self::self_trade_prevention_type::SelfTradePreventionType; pub mod sig_payload; pub use self::sig_payload::SigPayload; +pub mod sort_order; +pub use self::sort_order::SortOrder; pub mod sponsor_tx_request; pub use self::sponsor_tx_request::SponsorTxRequest; pub mod sponsor_tx_response; diff --git a/rust/gen/bluefin_api/src/models/sort_order.rs b/rust/gen/bluefin_api/src/models/sort_order.rs new file mode 100644 index 0000000..e60c525 --- /dev/null +++ b/rust/gen/bluefin_api/src/models/sort_order.rs @@ -0,0 +1,42 @@ +/* + * Bluefin API + * + * Bluefin API + * + * The version of the OpenAPI document: 1.0.0 + * + * Generated by: https://openapi-generator.tech + */ + +use crate::models; +use serde::{Deserialize, Serialize}; + +/// SortOrder : The order in which results should be sorted. +/// The order in which results should be sorted. +#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +pub enum SortOrder { + #[serde(rename = "ASC")] + Asc, + #[serde(rename = "DESC")] + Desc, + #[serde(rename = "UNSPECIFIED")] + Unspecified, + +} + +impl std::fmt::Display for SortOrder { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + match self { + Self::Asc => write!(f, "ASC"), + Self::Desc => write!(f, "DESC"), + Self::Unspecified => write!(f, "UNSPECIFIED"), + } + } +} + +impl Default for SortOrder { + fn default() -> SortOrder { + Self::Asc + } +} + diff --git a/rust/gen/config.yaml b/rust/gen/config.yaml index 74e05c8..48b6340 100644 --- a/rust/gen/config.yaml +++ b/rust/gen/config.yaml @@ -2,5 +2,5 @@ additionalProperties: hideGenerationTimestamp: 'true' avoidBoxedModels: 'true' packageName: bluefin_api - packageVersion: 1.9.0 + packageVersion: 1.10.0 preferUnsignedInt: 'true' diff --git a/ts/sdk/example.ts b/ts/sdk/example.ts index 93dfc61..db99f61 100644 --- a/ts/sdk/example.ts +++ b/ts/sdk/example.ts @@ -207,16 +207,21 @@ async function main() { ).data; logger.info(`Stats: ${JSON.stringify(stats)}`); - const statsAllTime = ( - await client.exchangeDataApi.getExchangeStatsAllTime() - ).data; - logger.info(`Stats All Time: ${JSON.stringify(statsAllTime)}`); + const statsAllTime = ( + await client.exchangeDataApi.getExchangeStatsAllTime() + ).data; + logger.info(`Stats All Time: ${JSON.stringify(statsAllTime)}`); - const country = ( + const country = ( await client.exchangeDataApi.getCountry() ).data; logger.info(`Country: ${JSON.stringify(country)}`); + const leaderboard = ( + await client.exchangeDataApi.getLeaderboard() + ).data; + logger.info(`Leaderboard: ${JSON.stringify(leaderboard)}`); + // Account Data API calls const accountTrades = ( await client.accountDataApi.getAccountTrades( diff --git a/ts/sdk/package.json b/ts/sdk/package.json index 0d5070d..a167a44 100644 --- a/ts/sdk/package.json +++ b/ts/sdk/package.json @@ -51,5 +51,5 @@ "prepare": "npm run build" }, "types": "./dist/types/index.d.ts", - "version": "1.9.0" -} + "version": "1.10.0" +} \ No newline at end of file diff --git a/ts/sdk/src/.openapi-generator/FILES b/ts/sdk/src/.openapi-generator/FILES index d94586f..51d10d9 100644 --- a/ts/sdk/src/.openapi-generator/FILES +++ b/ts/sdk/src/.openapi-generator/FILES @@ -74,6 +74,9 @@ docs/IntervalMetadata.md docs/IntervalRewards.md docs/IssBase64Details.md docs/KlineInterval.md +docs/LeaderboardEntry.md +docs/LeaderboardInterval.md +docs/LeaderboardResponse.md docs/LoginRequest.md docs/LoginResponse.md docs/MarginType.md @@ -118,6 +121,7 @@ docs/RewardsPoolEntry.md docs/RewardsSummary.md docs/SelfTradePreventionType.md docs/SigPayload.md +docs/SortOrder.md docs/SponsorTxRequest.md docs/SponsorTxResponse.md docs/StatsAllTimeResponse.md diff --git a/ts/sdk/src/api.ts b/ts/sdk/src/api.ts index b137734..300fa00 100644 --- a/ts/sdk/src/api.ts +++ b/ts/sdk/src/api.ts @@ -2813,6 +2813,73 @@ export const KlineInterval = { export type KlineInterval = typeof KlineInterval[keyof typeof KlineInterval]; +/** + * + * @export + * @interface LeaderboardEntry + */ +export interface LeaderboardEntry { + /** + * Rank of the trader in the leaderboard. + * @type {number} + * @memberof LeaderboardEntry + */ + 'rank': number; + /** + * The address of the account. + * @type {string} + * @memberof LeaderboardEntry + */ + 'accountAddress': string; + /** + * Total account value of the trader in e9 format. + * @type {string} + * @memberof LeaderboardEntry + */ + 'accountValueE9': string; + /** + * Total profit and loss of the trader in e9 format. + * @type {string} + * @memberof LeaderboardEntry + */ + 'pnlE9': string; + /** + * Total trading volume of the trader in e9 format. + * @type {string} + * @memberof LeaderboardEntry + */ + 'volumeE9': string; +} +/** + * + * @export + * @enum {string} + */ + +export const LeaderboardInterval = { + LeaderboardIntervalN1d: '1d', + LeaderboardIntervalN7d: '7d', + LeaderboardIntervalN30d: '30d', + LeaderboardIntervalALLTIME: 'ALL_TIME', + LeaderboardIntervalUNSPECIFIED: 'UNSPECIFIED' +} as const; + +export type LeaderboardInterval = typeof LeaderboardInterval[keyof typeof LeaderboardInterval]; + + +/** + * + * @export + * @interface LeaderboardResponse + */ +export interface LeaderboardResponse { + /** + * + * @type {Array} + * @memberof LeaderboardResponse + */ + 'data': Array; +} /** * User is expected to sign this payload and sends is signature in login api as header and payload itself in request body * @export @@ -4449,6 +4516,21 @@ export interface SigPayload { */ 'type': number; } +/** + * The order in which results should be sorted. + * @export + * @enum {string} + */ + +export const SortOrder = { + Asc: 'ASC', + Desc: 'DESC', + Unspecified: 'UNSPECIFIED' +} as const; + +export type SortOrder = typeof SortOrder[keyof typeof SortOrder]; + + /** * * @export @@ -7260,6 +7342,61 @@ export const ExchangeApiAxiosParamCreator = function (configuration?: Configurat + setSearchParams(localVarUrlObj, localVarQueryParameter); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, + /** + * Retrieves the leaderboard of traders based on their performance. + * @summary /accounts/leaderboard + * @param {LeaderboardInterval} [interval] The interval to get the leaderboard for. Default or Unspecified is 7d. + * @param {GetLeaderboardSortByEnum} [sortBy] The field to sort by. Default or Unspecified is accountValue. + * @param {SortOrder} [sortOrder] The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + * @param {number} [limit] Default 50; max 100. + * @param {number} [page] The page number to retrieve in a paginated response. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getLeaderboard: async (interval?: LeaderboardInterval, sortBy?: GetLeaderboardSortByEnum, sortOrder?: SortOrder, limit?: number, page?: number, options: RawAxiosRequestConfig = {}): Promise => { + const localVarPath = `/api/v1/accounts/leaderboard`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + if (interval !== undefined) { + localVarQueryParameter['interval'] = interval; + } + + if (sortBy !== undefined) { + localVarQueryParameter['sortBy'] = sortBy; + } + + if (sortOrder !== undefined) { + localVarQueryParameter['sortOrder'] = sortOrder; + } + + if (limit !== undefined) { + localVarQueryParameter['limit'] = limit; + } + + if (page !== undefined) { + localVarQueryParameter['page'] = page; + } + + + setSearchParams(localVarUrlObj, localVarQueryParameter); let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; @@ -7521,6 +7658,23 @@ export const ExchangeApiFp = function(configuration?: Configuration) { const localVarOperationServerBasePath = operationServerMap['ExchangeApi.getFundingRateHistory']?.[localVarOperationServerIndex]?.url; return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); }, + /** + * Retrieves the leaderboard of traders based on their performance. + * @summary /accounts/leaderboard + * @param {LeaderboardInterval} [interval] The interval to get the leaderboard for. Default or Unspecified is 7d. + * @param {GetLeaderboardSortByEnum} [sortBy] The field to sort by. Default or Unspecified is accountValue. + * @param {SortOrder} [sortOrder] The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + * @param {number} [limit] Default 50; max 100. + * @param {number} [page] The page number to retrieve in a paginated response. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getLeaderboard(interval?: LeaderboardInterval, sortBy?: GetLeaderboardSortByEnum, sortOrder?: SortOrder, limit?: number, page?: number, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await localVarAxiosParamCreator.getLeaderboard(interval, sortBy, sortOrder, limit, page, options); + const localVarOperationServerIndex = configuration?.serverIndex ?? 0; + const localVarOperationServerBasePath = operationServerMap['ExchangeApi.getLeaderboard']?.[localVarOperationServerIndex]?.url; + return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); + }, /** * Retrieves aggregated ticker data for a market. * @summary /exchange/ticker @@ -7656,6 +7810,20 @@ export const ExchangeApiFactory = function (configuration?: Configuration, baseP getFundingRateHistory(symbol: string, limit?: number, startTimeAtMillis?: number, endTimeAtMillis?: number, page?: number, options?: RawAxiosRequestConfig): AxiosPromise> { return localVarFp.getFundingRateHistory(symbol, limit, startTimeAtMillis, endTimeAtMillis, page, options).then((request) => request(axios, basePath)); }, + /** + * Retrieves the leaderboard of traders based on their performance. + * @summary /accounts/leaderboard + * @param {LeaderboardInterval} [interval] The interval to get the leaderboard for. Default or Unspecified is 7d. + * @param {GetLeaderboardSortByEnum} [sortBy] The field to sort by. Default or Unspecified is accountValue. + * @param {SortOrder} [sortOrder] The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + * @param {number} [limit] Default 50; max 100. + * @param {number} [page] The page number to retrieve in a paginated response. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getLeaderboard(interval?: LeaderboardInterval, sortBy?: GetLeaderboardSortByEnum, sortOrder?: SortOrder, limit?: number, page?: number, options?: RawAxiosRequestConfig): AxiosPromise { + return localVarFp.getLeaderboard(interval, sortBy, sortOrder, limit, page, options).then((request) => request(axios, basePath)); + }, /** * Retrieves aggregated ticker data for a market. * @summary /exchange/ticker @@ -7796,6 +7964,22 @@ export class ExchangeApi extends BaseAPI { return ExchangeApiFp(this.configuration).getFundingRateHistory(symbol, limit, startTimeAtMillis, endTimeAtMillis, page, options).then((request) => request(this.axios, this.basePath)); } + /** + * Retrieves the leaderboard of traders based on their performance. + * @summary /accounts/leaderboard + * @param {LeaderboardInterval} [interval] The interval to get the leaderboard for. Default or Unspecified is 7d. + * @param {GetLeaderboardSortByEnum} [sortBy] The field to sort by. Default or Unspecified is accountValue. + * @param {SortOrder} [sortOrder] The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. + * @param {number} [limit] Default 50; max 100. + * @param {number} [page] The page number to retrieve in a paginated response. + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof ExchangeApi + */ + public getLeaderboard(interval?: LeaderboardInterval, sortBy?: GetLeaderboardSortByEnum, sortOrder?: SortOrder, limit?: number, page?: number, options?: RawAxiosRequestConfig) { + return ExchangeApiFp(this.configuration).getLeaderboard(interval, sortBy, sortOrder, limit, page, options).then((request) => request(this.axios, this.basePath)); + } + /** * Retrieves aggregated ticker data for a market. * @summary /exchange/ticker @@ -7839,6 +8023,16 @@ export class ExchangeApi extends BaseAPI { } } +/** + * @export + */ +export const GetLeaderboardSortByEnum = { + GetLeaderboardSortByAccountValue: 'accountValue', + GetLeaderboardSortByPnL: 'pnl', + GetLeaderboardSortByVolume: 'volume', + GetLeaderboardSortByUNSPECIFIED: 'UNSPECIFIED' +} as const; +export type GetLeaderboardSortByEnum = typeof GetLeaderboardSortByEnum[keyof typeof GetLeaderboardSortByEnum]; /** diff --git a/ts/sdk/src/docs/ExchangeApi.md b/ts/sdk/src/docs/ExchangeApi.md index 8a92bab..a34b66a 100644 --- a/ts/sdk/src/docs/ExchangeApi.md +++ b/ts/sdk/src/docs/ExchangeApi.md @@ -11,6 +11,7 @@ All URIs are relative to *https://api.sui-staging.bluefin.io* |[**getExchangeStats**](#getexchangestats) | **GET** /v1/exchange/stats | /exchange/stats| |[**getExchangeStatsAllTime**](#getexchangestatsalltime) | **GET** /v1/exchange/stats/allTime | /v1/exchange/stats/allTime| |[**getFundingRateHistory**](#getfundingratehistory) | **GET** /v1/exchange/fundingRateHistory | /exchange/fundingRateHistory| +|[**getLeaderboard**](#getleaderboard) | **GET** /api/v1/accounts/leaderboard | /accounts/leaderboard| |[**getMarketTicker**](#getmarketticker) | **GET** /v1/exchange/ticker | /exchange/ticker| |[**getOrderbookDepth**](#getorderbookdepth) | **GET** /v1/exchange/depth | /exchange/depth| |[**getRecentTrades**](#getrecenttrades) | **GET** /v1/exchange/trades | /exchange/trades| @@ -391,6 +392,72 @@ 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) +# **getLeaderboard** +> LeaderboardResponse getLeaderboard() + +Retrieves the leaderboard of traders based on their performance. + +### Example + +```typescript +import { + ExchangeApi, + Configuration +} from '@bluefin/api-client'; + +const configuration = new Configuration(); +const apiInstance = new ExchangeApi(configuration); + +let interval: LeaderboardInterval; //The interval to get the leaderboard for. Default or Unspecified is 7d. (optional) (default to undefined) +let sortBy: 'accountValue' | 'pnl' | 'volume' | 'UNSPECIFIED'; //The field to sort by. Default or Unspecified is accountValue. (optional) (default to 'accountValue') +let sortOrder: SortOrder; //The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. (optional) (default to undefined) +let limit: number; //Default 50; max 100. (optional) (default to 50) +let page: number; //The page number to retrieve in a paginated response. (optional) (default to 1) + +const { status, data } = await apiInstance.getLeaderboard( + interval, + sortBy, + sortOrder, + limit, + page +); +``` + +### Parameters + +|Name | Type | Description | Notes| +|------------- | ------------- | ------------- | -------------| +| **interval** | **LeaderboardInterval** | The interval to get the leaderboard for. Default or Unspecified is 7d. | (optional) defaults to undefined| +| **sortBy** | [**'accountValue' | 'pnl' | 'volume' | 'UNSPECIFIED'**]**Array<'accountValue' | 'pnl' | 'volume' | 'UNSPECIFIED'>** | The field to sort by. Default or Unspecified is accountValue. | (optional) defaults to 'accountValue'| +| **sortOrder** | **SortOrder** | The sort order, either ascending (ASC) or descending (DESC). Default or UNSPECIFIED is DESC. | (optional) defaults to undefined| +| **limit** | [**number**] | Default 50; max 100. | (optional) defaults to 50| +| **page** | [**number**] | The page number to retrieve in a paginated response. | (optional) defaults to 1| + + +### Return type + +**LeaderboardResponse** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +|**200** | Leaderboard data | - | +|**400** | Invalid parameters provided. | - | +|**404** | No data found for the specified parameters. | - | +|**500** | Internal server error. | - | + +[[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) + # **getMarketTicker** > TickerResponse getMarketTicker() diff --git a/ts/sdk/src/docs/LeaderboardEntry.md b/ts/sdk/src/docs/LeaderboardEntry.md new file mode 100644 index 0000000..b2c0a2f --- /dev/null +++ b/ts/sdk/src/docs/LeaderboardEntry.md @@ -0,0 +1,28 @@ +# LeaderboardEntry + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**rank** | **number** | Rank of the trader in the leaderboard. | [default to undefined] +**accountAddress** | **string** | The address of the account. | [default to undefined] +**accountValueE9** | **string** | Total account value of the trader in e9 format. | [default to undefined] +**pnlE9** | **string** | Total profit and loss of the trader in e9 format. | [default to undefined] +**volumeE9** | **string** | Total trading volume of the trader in e9 format. | [default to undefined] + +## Example + +```typescript +import { LeaderboardEntry } from '@bluefin/api-client'; + +const instance: LeaderboardEntry = { + rank, + accountAddress, + accountValueE9, + pnlE9, + volumeE9, +}; +``` + +[[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/ts/sdk/src/docs/LeaderboardInterval.md b/ts/sdk/src/docs/LeaderboardInterval.md new file mode 100644 index 0000000..505d31c --- /dev/null +++ b/ts/sdk/src/docs/LeaderboardInterval.md @@ -0,0 +1,16 @@ +# LeaderboardInterval + + +## Enum + +* `LeaderboardIntervalN1d` (value: `'1d'`) + +* `LeaderboardIntervalN7d` (value: `'7d'`) + +* `LeaderboardIntervalN30d` (value: `'30d'`) + +* `LeaderboardIntervalALLTIME` (value: `'ALL_TIME'`) + +* `LeaderboardIntervalUNSPECIFIED` (value: `'UNSPECIFIED'`) + +[[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/ts/sdk/src/docs/LeaderboardResponse.md b/ts/sdk/src/docs/LeaderboardResponse.md new file mode 100644 index 0000000..f22265b --- /dev/null +++ b/ts/sdk/src/docs/LeaderboardResponse.md @@ -0,0 +1,20 @@ +# LeaderboardResponse + + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**data** | [**Array<LeaderboardEntry>**](LeaderboardEntry.md) | | [default to undefined] + +## Example + +```typescript +import { LeaderboardResponse } from '@bluefin/api-client'; + +const instance: LeaderboardResponse = { + data, +}; +``` + +[[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/ts/sdk/src/docs/SortOrder.md b/ts/sdk/src/docs/SortOrder.md new file mode 100644 index 0000000..018830b --- /dev/null +++ b/ts/sdk/src/docs/SortOrder.md @@ -0,0 +1,13 @@ +# SortOrder + +The order in which results should be sorted. + +## Enum + +* `Asc` (value: `'ASC'`) + +* `Desc` (value: `'DESC'`) + +* `Unspecified` (value: `'UNSPECIFIED'`) + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)