-
Notifications
You must be signed in to change notification settings - Fork 3
add max loss prompt, CS calculation, fallback logic; compute token re… #116
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
…quirements across non-collapsed bands
@@ -167,9 +167,396 @@ def async_act(self) -> Generator: | |||
|
|||
self.set_done() | |||
|
|||
def execute_hyper_strategy(self) -> None: | |||
def calculate_velodrome_cl_token_requirements( |
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.
This method is doing too many things (fetching prices, calculating amounts, etc). Please break it down into smaller methods
return None | ||
|
||
# Configure retry parameters | ||
sleep_time = 10 # Configurable sleep time |
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.
define these numbers as constants in base.py (sleep_time, retries, etc)
|
||
# Update max_amounts_in based on the requirements and actual balances | ||
# Using the weighted ratios from all the bands | ||
if requirements["overall_token0_ratio"] > 0.99: |
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.
define these numbers as constants
# Calculate max_amounts_in with special handling for ETH | ||
if assets[0] == ZERO_ADDRESS: | ||
# For ETH (token0), get the remaining ETH amount from kv_store | ||
eth_remaining = yield from self.get_eth_remaining_amount() |
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.
This ETH handling logic is duplicated a lot of times. Extract into a helper method.
|
||
# Fetch token0 price with retry handling | ||
token0_price = None | ||
for attempt in range(1, retries + 1): |
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.
Extract this retry pattern into a reusable method with exponential backoff
self.context.logger.info(f"max_amounts_in for velodrome : {max_amounts_in}") | ||
else: | ||
if not max_investment_amounts: | ||
token0_balance = self._get_balance(chain, assets[0], positions) |
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.
This pattern appears multiple times. Extract into a helper function.
self.context.logger.info( | ||
f"Using only token0: {token0_balance} {token0_symbol}" | ||
) | ||
elif requirements["overall_token1_ratio"] > 0.99: |
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.
Extract token allocation strategies into separate methods.
…quirements across non-collapsed bands