-
Notifications
You must be signed in to change notification settings - Fork 48
feat: improve add liquidity logic #725
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
feat: improve add liquidity logic #725
Conversation
|
@basfroman |
thewhaleking
left a comment
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.
I've gotten only about 100 lines into this PR, and it's a mess. It doesn't work in many situations, it hand-holds in the wrong ways, it ignores the use of --no-prompt.
Please don't submit PRs like this in the future. I'm assuming this was entirely chatGPT generated without even a look-over at the output, but please don't do this.
|
@thewhaleking
|
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.
Still no respect for --no-prompt
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.
I think extrinsic function doesn't accept prompt, let me know if I am wrong
btcli/bittensor_cli/src/commands/liquidity/liquidity.py
Lines 31 to 32 in f48829d
| async def add_liquidity_extrinsic( | |
| subtensor: "SubtensorInterface", |
|
@thewhaleking |
| price_high: Optional[float], | ||
| tao_amount: Optional[float], | ||
| alpha_amount: Optional[float], | ||
| prompt: bool, |
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.
@thewhaleking
prompt is supported here
I've moved all extrinsic functions to extrinsic folder, and this is the command function which accepts prompt
| ) | ||
|
|
||
| # Step 6: Confirm and execute the extrinsic | ||
| if prompt: |
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 is where it checks if prompt is enabled or not and ask user confirmation if enabled
|
Sorry, I meant This command: works fine in the {
"success": false,
"message": "Subtensor returned `SubstrateRequestException(Invalid Transaction)` error. This means: `Inability to pay some fees (e.g. account balance too low)`.",
"extrinsic_identifier": null
}However, in your branch, it produces no output whatsoever (at least when unsuccessful). |
|
@thewhaleking |


Improve Add Liquidity Logic
Closes #532
Summary
This PR improves the
btcli liquidity addcommand by implementing a more dynamic and user-friendly interactive flow for liquidity provision. The new logic guides users through a series of prompts based on the current subnet price and their available balances.Changes
1. New Helper Functions (
bittensor_cli/src/commands/liquidity/utils.py)calculate_max_liquidity_from_balances()- Calculates the maximum liquidity that can be provided given TAO and Alpha balances, current price, and price rangecalculate_alpha_from_tao()- Calculates the Alpha amount needed for a given TAO amountcalculate_tao_from_alpha()- Calculates the TAO amount needed for a given Alpha amount2. Interactive Flow (
bittensor_cli/src/commands/liquidity/liquidity.py)Added
add_liquidity_interactive()function that implements the following flow:3. CLI Updates (
bittensor_cli/cli.py)--tao-amountand--alpha-amountoptions to support the new flowliquidity_add()command to delegate to the new interactive function4. Unit Tests (
tests/unit_tests/test_liquidity_utils.py)Added comprehensive unit tests covering:
Benefits
Testing
All unit tests pass successfully:
Note: The e2e test (
test_liquidity.py) requires a running Docker container with a local blockchain node, which is infrastructure-dependent. The unit tests validate the core logic without requiring that infrastructure.Example Usage
Contribution by Gittensor, learn more at https://gittensor.io/