Skip to content

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

Closed
wants to merge 8 commits into from

Conversation

princevijay27
Copy link
Contributor

…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(
Copy link
Collaborator

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
Copy link
Collaborator

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:
Copy link
Collaborator

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()
Copy link
Collaborator

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):
Copy link
Collaborator

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)
Copy link
Collaborator

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:
Copy link
Collaborator

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.

@DIvyaNautiyal07 DIvyaNautiyal07 deleted the chore/velodrome-chatui branch June 4, 2025 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants