From 89a840957a947b015610a899a8406d91b90e8d9f Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:44:34 +0000 Subject: [PATCH 1/2] client headers --- fee_allocator/helpers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fee_allocator/helpers.py b/fee_allocator/helpers.py index 42e676de..1ffb5d01 100644 --- a/fee_allocator/helpers.py +++ b/fee_allocator/helpers.py @@ -42,6 +42,10 @@ class PoolBalance: "zkevm": "1101", } BAL_GQL_URL = "https://api-v3.balancer.fi/" +BAL_DEFAULT_HEADERS = { + "x-graphql-client-name": "Maxxis", + "x-graphql-client-version": "protocol_fee_allocator", +} BLOCKS_QUERY = """ query {{ blocks(where:{{timestamp_gt: {ts_gt}, timestamp_lt: {ts_lt} }}) {{ @@ -162,6 +166,7 @@ def get_block_by_ts(timestamp: int, chain: str) -> int: transport = RequestsHTTPTransport( url=Subgraph(chain).get_subgraph_url("blocks"), retries=2, + headers=BAL_DEFAULT_HEADERS ) query = gql( BLOCKS_QUERY.format( @@ -284,7 +289,7 @@ def fetch_token_price_balgql_timerange( transport = RequestsHTTPTransport( url=BAL_GQL_URL, retries=2, - headers={"chainId": CHAIN_TO_CHAIN_ID_MAP[chain]}, + headers={**BAL_DEFAULT_HEADERS, "chainId": CHAIN_TO_CHAIN_ID_MAP[chain]}, ) client = Client(transport=transport, fetch_schema_from_transport=True) query = gql( @@ -313,7 +318,7 @@ def fetch_token_price_balgql_timerange( def get_balancer_pool_snapshots(block: int, graph_url: str) -> Optional[List[Dict]]: - transport = RequestsHTTPTransport(url=graph_url, retries=3) + transport = RequestsHTTPTransport(url=graph_url, retries=3, headers=BAL_DEFAULT_HEADERS) client = Client( transport=transport, fetch_schema_from_transport=True, execute_timeout=60 ) @@ -357,6 +362,7 @@ def fetch_all_pools_info() -> List[Dict]: transport = RequestsHTTPTransport( url=BAL_GQL_URL, retries=2, + headers=BAL_DEFAULT_HEADERS ) client = Client(transport=transport, fetch_schema_from_transport=True) query = gql(BAL_GET_VOTING_LIST_QUERY) From 0f2624cdb4d25944304189bdc80d5c9fe7b6ec79 Mon Sep 17 00:00:00 2001 From: gmbronco <83549293+gmbronco@users.noreply.github.com> Date: Wed, 15 Jan 2025 11:48:49 +0000 Subject: [PATCH 2/2] fix naming --- fee_allocator/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fee_allocator/helpers.py b/fee_allocator/helpers.py index 1ffb5d01..93cc2421 100644 --- a/fee_allocator/helpers.py +++ b/fee_allocator/helpers.py @@ -43,7 +43,7 @@ class PoolBalance: } BAL_GQL_URL = "https://api-v3.balancer.fi/" BAL_DEFAULT_HEADERS = { - "x-graphql-client-name": "Maxxis", + "x-graphql-client-name": "Maxis", "x-graphql-client-version": "protocol_fee_allocator", } BLOCKS_QUERY = """