Repository navigation
fix/Show an LP executor's earned fees in its detail view instead of the transaction fee #263
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
Open
lgrawet
wants to merge
3
commits into
hummingbot:main
Choose a base branch
from
lgrawet:fix/lp-cumulative-fees-display
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| """The executor detail view must report LP fee *income*, not the tx fee. | ||
|
|
||
| An LP executor fills ``cum_fees_quote`` with what the open/close transactions | ||
| cost on-chain, and puts the fee income it actually earned in | ||
| ``custom_info.fees_earned_quote``. Reading the first as "Cumulative Fees" showed | ||
| a live DJT-USDC band as $0.000023 when it had earned $0.074624 — three orders of | ||
| magnitude off, on the one number that says whether a band is worth keeping. | ||
|
|
||
| An LP executor therefore reads ``fees_earned_quote`` and nothing else: its | ||
| ``cum_fees_quote`` is a cost, so it never backs the earned figure — when the | ||
| field is absent the income is simply unknown, not the tx fee. A non-LP executor | ||
| (CEX order, position, grid…) has no ``custom_info`` twin and its | ||
| ``cum_fees_quote`` *is* its fee, so it reports that as "Fees Paid". The two | ||
| labels stay distinct so a client cannot read a paid fee as income. | ||
| """ | ||
|
|
||
| from mcp_servers.hummingbot_api.formatters.executors import format_executor_detail | ||
|
|
||
| _TX_FEE = 0.000022815 | ||
| _EARNED = 0.0746235531801429 | ||
|
|
||
|
|
||
| def _lp(custom_info): | ||
| return { | ||
| "id": "DvpnJsPK", | ||
| "type": "lp_executor", | ||
| "status": "RUNNING", | ||
| "connector_name": "solana-mainnet-beta", | ||
| "trading_pair": "DJT-USDC", | ||
| "cum_fees_quote": _TX_FEE, | ||
| "custom_info": custom_info, | ||
| } | ||
|
|
||
|
|
||
| def test_lp_detail_shows_earned_fees_not_the_transaction_fee(): | ||
| out = format_executor_detail(_lp({"fees_earned_quote": _EARNED, "tx_fee": _TX_FEE})) | ||
| assert "Fees Earned: $0.074624" in out | ||
| assert "$0.000023" not in out | ||
|
|
||
|
|
||
| def test_a_band_that_earned_nothing_shows_zero_not_its_tx_fee(): | ||
| out = format_executor_detail(_lp({"fees_earned_quote": 0.0, "tx_fee": _TX_FEE})) | ||
| assert "Fees Earned: $0.000000" in out | ||
| assert "$0.000023" not in out | ||
|
|
||
|
|
||
| def test_an_lp_executor_without_the_earned_field_prints_no_fee_line(): | ||
| out = format_executor_detail(_lp({"tx_fee": _TX_FEE})) | ||
| assert "Fees Earned" not in out | ||
| assert "Fees Paid" not in out | ||
| assert "$0.000023" not in out | ||
|
|
||
|
|
||
| def test_a_non_lp_executor_reports_its_cum_fees_as_fees_paid(): | ||
| out = format_executor_detail( | ||
| { | ||
| "id": "y", | ||
| "type": "position_executor", | ||
| "status": "RUNNING", | ||
| "cum_fees_quote": 1.23, | ||
| } | ||
| ) | ||
| assert "Fees Paid: $1.23" in out | ||
| assert "Fees Earned" not in out | ||
|
|
||
|
|
||
| def test_an_executor_with_neither_field_prints_no_fee_line(): | ||
| out = format_executor_detail( | ||
| {"id": "z", "type": "position_executor", "status": "RUNNING"} | ||
| ) | ||
| assert "Fees Earned" not in out | ||
| assert "Fees Paid" not in out |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If an LP executor stores its type in
config.type, this check reads only top-level fields and treats it as a non-LP executor. The detail view then hides its earned fees and shows its on-chain transaction cost as “Fees Paid.” Resolve the type from the config too, and test that payload shape.