-
Notifications
You must be signed in to change notification settings - Fork 0
feat: ✨ Added config file support #29
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
Conversation
* feat: add validation for asset prices in total_assets calculation (#35) * feat: add validation for asset prices in total_assets calculation - Implemented checks for invalid prices (<= 0) in the calculate_total_assets function. - Added error handling to raise ValueError with details of invalid prices. - Introduced a new test to ensure that invalid prices trigger the appropriate exception. * refactor: turn invalid prices computation into list comprehension * feat: add price validation for price adapter (#36) * fix: update WstETHAdapter and tests to set ETH base asset price to 1 - Changed the base asset price for ETH in WstETHAdapter from 0 to 1 to ensure accurate pricing. - Updated related tests to verify that the ETH price is now correctly set to 1 instead of 0. - Adjusted documentation to clarify the base asset pricing behavior. * feat: add price validation to BasePriceAdapter * refactor: change validate_prices method to synchronous in price adapters - Updated the validate_prices method in BasePriceAdapter to be synchronous instead of asynchronous. - Adjusted calls to validate_prices in ChainlinkAdapter, CowSwapAdapter, and WstETHAdapter accordingly. * feat: add TypedDict for network addresses in constants.py * feat: add NetworkAddresses instances * refactor: rename NetworkAddresses to NetworkTokens and update address constants * feat: add network configuration and asset retrieval to OracleCLIConfig * refactor: update WstETHAdapter to use dynamic asset addresses from config * refactor: enhance WstETHAdapter to enforce required ETH address and simplify checks * refactor: update CowSwapAdapter to use dynamic asset addresses and improve network configuration * refactor: update ChainlinkAdapter to use dynamic asset addresses from config and enforce required ETH address * refactor: update IdleBalancesAdapter to use dynamic asset addresses from config and enforce required ETH and USDC addresses * refactor: remove optional asset address attributes from Chainlink, CowSwap, and WstETH adapters * refactor: enforce required USDC address in HyperliquidAdapter and update asset address retrieval from config * refactor: update Chainlink test suite to use dynamic asset addresses from config * refactor: update WstETHAdapter tests to utilize dynamic asset addresses from config * refactor: enhance HyperliquidAdapter tests to utilize dynamic USDC addresses from config * refactor: update tests to utilize dynamic asset addresses from config for improved consistency * refactor: update Chainlink and CowSwap tests to utilize dynamic asset addresses from config for improved consistency * refactor: update Chainlink tests to include dynamic ETH address in price fetching for USDT and USDS on testnet * refactor: update import paths from config to settings in CowSwap and Hyperliquid test files
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.
Pull Request Overview
Copilot reviewed 48 out of 50 changed files in this pull request and generated 6 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
* docs * docs
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
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.
Pull Request Overview
Copilot reviewed 49 out of 51 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/tq_oracle/processors/oracle_helper.py:1
- Inconsistent comment style: Line 89 is part of the docstring but uses # instead of proper docstring continuation. Move the Solidity sorting explanation into the main docstring or keep it as a standalone comment after the docstring closes.
from __future__ import annotations
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| TOKEN_DECIMALS: dict[str, int] = { | ||
| addr: decimals | ||
| for addr, decimals in [ | ||
| (ETH_MAINNET_ASSETS.get("USDC"), 6), | ||
| (SEPOLIA_ASSETS.get("USDC"), 6), | ||
| (ETH_MAINNET_ASSETS.get("USDT"), 6), | ||
| (ETH_MAINNET_ASSETS.get("USDS"), 18), | ||
| ] | ||
| if addr is not None | ||
| } | ||
|
|
Copilot
AI
Oct 24, 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.
The TOKEN_DECIMALS dictionary is constructed from hardcoded tuples that could become inconsistent with NetworkAssets definitions. Consider deriving decimals from a centralized constant or adding type hints to NetworkAssets to include decimals information.
| TOKEN_DECIMALS: dict[str, int] = { | |
| addr: decimals | |
| for addr, decimals in [ | |
| (ETH_MAINNET_ASSETS.get("USDC"), 6), | |
| (SEPOLIA_ASSETS.get("USDC"), 6), | |
| (ETH_MAINNET_ASSETS.get("USDT"), 6), | |
| (ETH_MAINNET_ASSETS.get("USDS"), 18), | |
| ] | |
| if addr is not None | |
| } | |
| # Centralized decimals per asset symbol | |
| ASSET_DECIMALS: dict[str, int] = { | |
| "USDC": 6, | |
| "USDT": 6, | |
| "USDS": 18, | |
| "ETH": 18, | |
| "WETH": 18, | |
| "WSTETH": 18, | |
| } | |
| # Collect all asset addresses from all NetworkAssets dicts | |
| TOKEN_DECIMALS: dict[str, int] = {} | |
| for assets in [ETH_MAINNET_ASSETS, SEPOLIA_ASSETS, BASE_ASSETS]: | |
| for symbol, addr in assets.items(): | |
| if addr is not None and symbol in ASSET_DECIMALS: | |
| TOKEN_DECIMALS[addr] = ASSET_DECIMALS[symbol] |
Co-authored-by: Copilot <[email protected]>
Configuration System Overhaul
This PR introduces comprehensive TOML-based configuration support alongside CLI arguments and environment variables, with clear precedence: CLI → ENV → TOML. The configuration loader (
config_loader.py) handles auto-detection from standard paths (./tq-oracle.toml,~/.config/tq-oracle/config.toml) and validates all settings with helpful error messages.Key configuration enhancements:
Asset Adapter Refactoring
Asset adapters now support multi-chain operations through a unified registry system (
ADAPTER_REGISTRY). TheAdapterChainenum distinguishes between L1 and Hyperliquid operations, allowing adapters to operate on different RPC endpoints.IdleBalancesAdapter gains chain awareness with separate
fetch_assets()(single subvault) andfetch_all_assets()(all subvaults) methods, supporting both L1 and Hyperliquid chains through constructor parameterization.HyperliquidAdapter switches from TWAP to latest portfolio value with staleness validation (rejects values older than
HL_MAX_PORTFOLIO_STALENESS_SECONDS). Improved error handling for empty/invalid history and better logging of portfolio age.Orchestrator & Main
Orchestrator refactored for cleaner adapter composition with chain-aware asset collection. Configuration validation moved earlier in the pipeline with clearer error messages. Main entry point simplified with TOML config integration and improved help text.