Kodiak integration - #119
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for Kodiak Finance integration on Berachain, enabling tracking of USDe and sUSDe token balances across Kodiak's liquidity pools. The integration fetches balance data from Kodiak's API and filters by specific island addresses and v3 positions.
Key changes:
- Implements
KodiakIntegrationclass that extends the baseIntegrationinterface - Adds support for two token types: USDe and sUSDe with their respective island addresses
- Fetches and aggregates user balances from Kodiak's API at specified block numbers
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| utils/kodiak.py | Core integration logic for fetching and processing Kodiak balance data from API |
| integrations/kodiak_usde_integration.py | Entry point script for testing/running USDe integration |
| integrations/kodiak_susde_integration.py | Entry point script for testing/running sUSDe integration |
| integrations/integration_ids.py | Adds KODIAK_USDE and KODIAK_SUSDE integration identifiers |
| constants/summary_columns.py | Adds summary column definitions for Kodiak points tracking |
| constants/kodiak.py | Defines Kodiak API URL and token/island address constants |
Comments suppressed due to low confidence (1)
utils/kodiak.py:2
- Import of 'json' is not used.
import json
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,73 @@ | |||
| from copy import deepcopy | |||
| import json | |||
There was a problem hiding this comment.
The json import is unused. It should be removed as response.json() is a method call on the response object and doesn't require importing the json module.
| import json |
| if integration_id is IntegrationID.KODIAK_USDE: | ||
| self.island = KodiakIslandAddress.USDE | ||
| self.token = Tokens.USDE | ||
| elif integration_id is IntegrationID.KODIAK_SUSDE: |
There was a problem hiding this comment.
Use == instead of is for enum comparison. While is may work due to Python's identity caching for some enum values, == is the correct and reliable way to compare enum members.
| if integration_id is IntegrationID.KODIAK_USDE: | |
| self.island = KodiakIslandAddress.USDE | |
| self.token = Tokens.USDE | |
| elif integration_id is IntegrationID.KODIAK_SUSDE: | |
| if integration_id == IntegrationID.KODIAK_USDE: | |
| self.island = KodiakIslandAddress.USDE | |
| self.token = Tokens.USDE | |
| elif integration_id == IntegrationID.KODIAK_SUSDE: |
| if integration_id is IntegrationID.KODIAK_USDE: | ||
| self.island = KodiakIslandAddress.USDE | ||
| self.token = Tokens.USDE | ||
| elif integration_id is IntegrationID.KODIAK_SUSDE: |
There was a problem hiding this comment.
Use == instead of is for enum comparison. While is may work due to Python's identity caching for some enum values, == is the correct and reliable way to compare enum members.
| elif integration_id is IntegrationID.KODIAK_SUSDE: | |
| elif integration_id == IntegrationID.KODIAK_SUSDE: |
| response = requests.get(base_url, params=params) | ||
| data = response.json() |
There was a problem hiding this comment.
Missing error handling for API request failures. If the API returns an error status code or the request fails, response.json() could raise an exception, causing the entire batch processing to fail. Consider adding try-except blocks with appropriate error handling (similar to other integrations in the codebase), checking response status with response.raise_for_status(), and setting an empty dict for failed blocks to allow processing of other blocks to continue.
| response = requests.get(base_url, params=params) | |
| data = response.json() | |
| try: | |
| response = requests.get(base_url, params=params) | |
| response.raise_for_status() | |
| data = response.json() | |
| except Exception as e: | |
| # Optionally, log the error here | |
| result[block] = {} | |
| continue |
| continue | ||
|
|
||
| params = {"excludeSources": "balance", "blockNumber": block} | ||
| response = requests.get(base_url, params=params) |
There was a problem hiding this comment.
Missing timeout parameter for HTTP request. Following the pattern in other integrations (e.g., zerolend_integration.py, echelon_integration.py), add a timeout parameter (e.g., timeout=10) to prevent the request from hanging indefinitely.
| response = requests.get(base_url, params=params) | |
| response = requests.get(base_url, params=params, timeout=10) |
No description provided.