-
Notifications
You must be signed in to change notification settings - Fork 95
Kodiak integration #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Kodiak integration #119
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| from enum import Enum | ||
|
|
||
| KODIAK_API_URL = "https://backend.kodiak.finance" | ||
|
|
||
| class KodiakIslandAddress(Enum): | ||
| USDE = "0xE5A2ab5D2fb268E5fF43A5564e44c3309609aFF9" | ||
| SUSDE = "0xD5B6EA3544a51BfdDa7E6926BdF778339801dFe8" | ||
|
|
||
| class Tokens(Enum): | ||
| USDE = "0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34" | ||
| SUSDE = "0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from constants.chains import Chain | ||
| from integrations.integration_ids import IntegrationID | ||
| from utils.kodiak import KodiakIntegration | ||
|
|
||
| if __name__ == "__main__": | ||
| integration = KodiakIntegration( | ||
| IntegrationID.KODIAK_SUSDE, | ||
| 1, | ||
| Chain.BERACHAIN | ||
| ) | ||
|
|
||
| print(integration.get_block_balances({ | ||
| 1: { | ||
| "0x0000000000000000000000000000000000000000": 100.0 | ||
| } | ||
| }, [12886286, 1])) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from constants.chains import Chain | ||
| from integrations.integration_ids import IntegrationID | ||
| from utils.kodiak import KodiakIntegration | ||
|
|
||
| if __name__ == "__main__": | ||
| integration = KodiakIntegration( | ||
| IntegrationID.KODIAK_USDE, | ||
| 1, | ||
| Chain.BERACHAIN | ||
| ) | ||
|
|
||
| print(integration.get_block_balances({ | ||
| 1: { | ||
| "0x0000000000000000000000000000000000000000": 100.0 | ||
| } | ||
| }, [12886286, 1])) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,73 @@ | ||||||||||||||||||||||
| from copy import deepcopy | ||||||||||||||||||||||
| import json | ||||||||||||||||||||||
| from typing import Dict, List | ||||||||||||||||||||||
| from eth_typing import ChecksumAddress | ||||||||||||||||||||||
| import requests | ||||||||||||||||||||||
| from constants.chains import Chain | ||||||||||||||||||||||
| from integrations.integration import Integration | ||||||||||||||||||||||
| from integrations.integration_ids import IntegrationID | ||||||||||||||||||||||
| from constants.kodiak import KODIAK_API_URL, KodiakIslandAddress, Tokens | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| BASE_URL = f"{KODIAK_API_URL}/balances" | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| class KodiakIntegration(Integration): | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def __init__( | ||||||||||||||||||||||
| self, | ||||||||||||||||||||||
| integration_id: IntegrationID, | ||||||||||||||||||||||
| start_block: int, | ||||||||||||||||||||||
| chain: Chain, | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
| if chain not in [Chain.BERACHAIN]: | ||||||||||||||||||||||
| raise ValueError(f"KodiakIntegration not supported on chain {chain}") | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| 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 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
Copilot
AI
Nov 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
jsonimport is unused. It should be removed asresponse.json()is a method call on the response object and doesn't require importing the json module.