From 65874788b7b6cad9e3b45e3896dbe3092faa997a Mon Sep 17 00:00:00 2001 From: alb2001 Date: Fri, 22 Nov 2024 11:11:34 +0100 Subject: [PATCH] Added new endpoints: get pool locks and get token audit --- .github/workflows/python-app.yml | 2 +- CHANGELOG.md | 6 ++++++ README.md | 22 ++++++++++++++++++---- dextools_python/async_dextools_v2.py | 14 ++++++++++++++ dextools_python/dextools_v2.py | 12 ++++++++++++ examples/async_demov2.py | 20 ++++++++++++++++++++ examples/demov2.py | 10 ++++++++++ pyproject.toml | 2 +- tests/test_async_dextools_api_v2.py | 20 ++++++++++++++++++++ tests/test_dextools_api_v2.py | 18 ++++++++++++++++++ 10 files changed, 120 insertions(+), 6 deletions(-) diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 02aab0d..b14096e 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] steps: - uses: actions/checkout@v3 diff --git a/CHANGELOG.md b/CHANGELOG.md index da18a41..d7d72f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# Version 0.3.2 ++ Added Get pool locks ++ Added Get token audit ++ Updated doc with new methods ++ Updated demo examples + # Version 0.3.1 + Separated modules + Added logger diff --git a/README.md b/README.md index 33d6203..acad8b6 100644 --- a/README.md +++ b/README.md @@ -34,16 +34,18 @@ Supports [Dextools API v1](https://api.dextools.io/docs) and [Dextools API v2](h 2. [Get pool liquidity](#get-pool-liquidity) 3. [Get pool score](#get-pool-score) 4. [Get pool price](#get-pool-price) - 5. [Get pools](#get-pools) - 6. [Get pools sorted by `creationBlock` and descending order and providing block numbers instead](#get-pools-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead) + 5. [Get pool locks](#get-pool-locks) + 6. [Get pools](#get-pools) + 7. [Get pools sorted by `creationBlock` and descending order and providing block numbers instead](#get-pools-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead) 4. [Token](#token) 1. [Get token](#get-token) 2. [Get token locks](#get-token-locks) 3. [Get token score](#get-token-score) 4. [Get token info](#get-token-info) 5. [Get token price](#get-token-price) - 6. [Get tokens](#get-tokens) - 7. [Get tokens sorted by `creationBlock` and descending order and providing block numbers instead in descending order](#get-tokens-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead-in-descending-order) + 6. [Get token price](#get-token-audit) + 7. [Get tokens](#get-tokens) + 8. [Get tokens sorted by `creationBlock` and descending order and providing block numbers instead in descending order](#get-tokens-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead-in-descending-order) 8. [Get tokens sorted by `socialsInfoUpdated` and descending order and datetimes in descending order](#get-tokens-sorted-by-socialsinfoupdated-and-descending-order-and-datetimes-in-descending-order) 9. [Get token pools](#get-token-pools) 10. [Get token pools sorted by `creationBlock` and descending order and providing block numbers instead in descending order](#get-token-pools-sorted-by-creationblock-and-descending-order-and-providing-block-numbers-instead-in-descending-order) @@ -225,6 +227,12 @@ pool_price = dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1 print(pool_price) ``` +#### Get pool locks +``` +pool_locks = dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") +print(pool_locks) +``` + #### Get pools ``` pools = dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") @@ -268,6 +276,12 @@ token_price = dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae67 print(token_price) ``` +#### Get token audit +``` +token_audit = dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") +print(token_audit) +``` + #### Get tokens ``` tokens = dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") diff --git a/dextools_python/async_dextools_v2.py b/dextools_python/async_dextools_v2.py index 18ab87d..116c820 100644 --- a/dextools_python/async_dextools_v2.py +++ b/dextools_python/async_dextools_v2.py @@ -93,6 +93,13 @@ async def get_pool_price(self, chain, address): async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/price", headers=self._headers) as response: logger.debug(response.url) return await response.json() + + async def get_pool_locks(self, chain, address): + endpoint = "/pool/" + + async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/locks", headers=self._headers) as response: + logger.debug(response.url) + return await response.json() async def get_pools(self, chain, from_, to, order="asc", sort="creationTime", page=None, pageSize=None): endpoint = "/pool/" @@ -135,6 +142,13 @@ async def get_token_price(self, chain, address): async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/price", headers=self._headers) as response: logger.debug(response.url) return await response.json() + + async def get_token_audit(self, chain, address): + endpoint = "/token/" + + async with self._session.get(f"{self.url}{endpoint}{chain}/{address}/audit", headers=self._headers) as response: + logger.debug(response.url) + return await response.json() async def get_tokens(self, chain, from_, to, order="asc", sort="socialsInfoUpdated", page=None, pageSize=None): endpoint = "/token/" diff --git a/dextools_python/dextools_v2.py b/dextools_python/dextools_v2.py index b39233d..5523c86 100644 --- a/dextools_python/dextools_v2.py +++ b/dextools_python/dextools_v2.py @@ -75,6 +75,12 @@ def get_pool_price(self, chain, address): response = requests.get(f"{self.url}{endpoint}{chain}/{address}/price", headers=self._headers) logger.debug(response.url) return response.json() + + def get_pool_locks(self, chain, address): + endpoint = "/pool/" + response = requests.get(f"{self.url}{endpoint}{chain}/{address}/locks", headers=self._headers) + logger.debug(response.url) + return response.json() def get_pools(self, chain, from_, to, order="asc", sort="creationTime", page=None, pageSize=None): endpoint = "/pool/" @@ -112,6 +118,12 @@ def get_token_price(self, chain, address): logger.debug(response.url) return response.json() + def get_token_audit(self, chain, address): + endpoint = "/token/" + response = requests.get(f"{self.url}{endpoint}{chain}/{address}/audit", headers=self._headers) + logger.debug(response.url) + return response.json() + def get_tokens(self, chain, from_, to, order="asc", sort="socialsInfoUpdated", page=None, pageSize=None): endpoint = "/token/" response = requests.get(self.url + endpoint + chain, params={"order": order, "sort": sort, "from": from_, "to": to, "page": page, "pageSize": pageSize}, headers=self._headers) diff --git a/examples/async_demov2.py b/examples/async_demov2.py index b42b527..4450ad6 100644 --- a/examples/async_demov2.py +++ b/examples/async_demov2.py @@ -68,6 +68,11 @@ async def instance(): pool_price = await dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") pp.pprint(pool_price) + # Get pool locks + print("Get pool locks") + pool_locks = await dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") + pp.pprint(pool_locks) + # Get pools print("Get pools") pools = await dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") @@ -104,6 +109,11 @@ async def instance(): token_price = await dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") pp.pprint(token_price) + # Get token audit + print("Get token audit") + token_audit = await dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") + pp.pprint(token_audit) + # Get tokens print("Get tokens") tokens = await dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") @@ -213,6 +223,11 @@ async def context_manager(): pool_price = await dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") pp.pprint(pool_price) + # Get pool locks + print("Get pool locks") + pool_locks = await dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") + pp.pprint(pool_locks) + # Get pools print("Get pools") pools = await dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") @@ -249,6 +264,11 @@ async def context_manager(): token_price = await dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") pp.pprint(token_price) + # Get token audit + print("Get token audit") + token_audit = await dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") + pp.pprint(token_audit) + # Get tokens print("Get tokens") tokens = await dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") diff --git a/examples/demov2.py b/examples/demov2.py index 0cd7835..4038b74 100644 --- a/examples/demov2.py +++ b/examples/demov2.py @@ -66,6 +66,11 @@ pool_price = dextools.get_pool_price("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") pp.pprint(pool_price) +# Get pool locks +print("Get pool locks") +pool_locks = dextools.get_pool_locks("ether", "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d") +pp.pprint(pool_locks) + # Get pools print("Get pools") pools = dextools.get_pools("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") @@ -102,6 +107,11 @@ token_price = dextools.get_token_price("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") pp.pprint(token_price) +# Get token audit +print("Get token audit") +token_audit = dextools.get_token_audit("ether", "0xfb7b4564402e5500db5bb6d63ae671302777c75a") +pp.pprint(token_audit) + # Get tokens print("Get tokens") tokens = dextools.get_tokens("ether", from_="2023-11-14T19:00:00", to="2023-11-14T23:00:00") diff --git a/pyproject.toml b/pyproject.toml index 4296639..6300a3c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dextools-python" -version = "0.3.1" +version = "0.3.2" description = "A simple Python API wrapper for DEXTools" repository = "https://github.com/alb2001/dextools-python" authors = ["alb2001 "] diff --git a/tests/test_async_dextools_api_v2.py b/tests/test_async_dextools_api_v2.py index 3e99bc0..1c5f0d8 100644 --- a/tests/test_async_dextools_api_v2.py +++ b/tests/test_async_dextools_api_v2.py @@ -89,6 +89,16 @@ async def test_get_pool_score(dextools_instance): assert isinstance(response["data"]["votes"], dict) assert isinstance(response["data"]["dextScore"], dict) +@pytest.mark.asyncio +async def test_get_pool_locks(dextools_instance): + chain = "ether" + pool = "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d" + response = await dextools_instance.get_pool_locks(chain, pool) + + assert response["statusCode"] == 200 + assert isinstance(response, dict) + assert isinstance(response["data"], dict) + @pytest.mark.asyncio async def test_get_pool_price(dextools_instance): chain = "ether" @@ -187,6 +197,16 @@ async def test_get_token_price(dextools_instance): assert isinstance(response, dict) assert isinstance(response["data"], dict) +@pytest.mark.asyncio +async def test_get_token_audit(dextools_instance): + chain = "ether" + token = "0xfb7b4564402e5500db5bb6d63ae671302777c75a" + response = await dextools_instance.get_token_audit(chain, token) + + assert response["statusCode"] == 200 + assert isinstance(response, dict) + assert isinstance(response["data"], dict) + @pytest.mark.asyncio async def test_get_tokens(dextools_instance): chain = "ether" diff --git a/tests/test_dextools_api_v2.py b/tests/test_dextools_api_v2.py index b6d40a9..1eaccb0 100644 --- a/tests/test_dextools_api_v2.py +++ b/tests/test_dextools_api_v2.py @@ -80,6 +80,15 @@ def test_get_pool_score(dextools_instance): assert isinstance(response["data"]["votes"], dict) assert isinstance(response["data"]["dextScore"], dict) +def test_get_pool_locks(dextools_instance): + chain = "ether" + pool = "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d" + response = dextools_instance.get_pool_locks(chain, pool) + + assert response["statusCode"] == 200 + assert isinstance(response, dict) + assert isinstance(response["data"], dict) + def test_get_pool_price(dextools_instance): chain = "ether" pool = "0xa29fe6ef9592b5d408cca961d0fb9b1faf497d6d" @@ -170,6 +179,15 @@ def test_get_token_price(dextools_instance): assert isinstance(response, dict) assert isinstance(response["data"], dict) +def test_get_token_audit(dextools_instance): + chain = "ether" + token = "0xfb7b4564402e5500db5bb6d63ae671302777c75a" + response = dextools_instance.get_token_audit(chain, token) + + assert response["statusCode"] == 200 + assert isinstance(response, dict) + assert isinstance(response["data"], dict) + def test_get_tokens(dextools_instance): chain = "ether" from_ = "2023-11-14T19:00:00"