fix(indexer): best/worst trade PnL aggregates (#344) #848

Merged
PlasticDigits merged 5 commits from local1/344-best-trade-pnl into main 2026-06-09 07:44:30 +00:00
PlasticDigits commented 2026-06-09 06:53:27 +00:00 (Migrated from gitlab.com)

Summary

  • Nullable best_trade_pnl / worst_trade_pnl; fix GREATEST(0, loss) bug
  • Trader UI shows N/A when unset

Test plan

  • cargo test --lib (indexer)
  • npm test -- traderProfilePayload.test.ts
  • /trader/:addr after losing trades shows least-negative best or N/A

Docs

Merge after prior stacked MRs.


Note

Medium Risk
Changes trader aggregate SQL on every swap and runs a one-time migration backfill; incorrect CASE logic could skew leaderboard/profile stats until corrected.

Overview
Fixes #344: trader best/worst per-trade realized P&L no longer default to 0, which made all-loss wallets show 0 as “best trade” instead of the least-negative loss.

The indexer makes best_trade_pnl / worst_trade_pnl nullable (migration drops defaults/NOT NULL and backfills rows stuck at 0). update_trader_pnl now uses CASE logic so first trade and legacy 0 rows can recover sensible extrema; API TraderResponse exposes JSON null when unset. The dApp preserves null in parseIndexerTraderPayload, PnlValue renders N/A, and the Charts leaderboard uses PnlValue for P&L sorts. docs/indexer-invariants.md documents the behavior.

Reviewed by Cursor Bugbot for commit 3f7ca07066. Bugbot is set up for automated code reviews on this repo. Configure here.

## Summary - Nullable `best_trade_pnl` / `worst_trade_pnl`; fix `GREATEST(0, loss)` bug - Trader UI shows N/A when unset ## Test plan - [ ] `cargo test --lib` (indexer) - [ ] `npm test -- traderProfilePayload.test.ts` - [ ] `/trader/:addr` after losing trades shows least-negative best or N/A ## Docs - [docs/indexer-invariants.md](docs/indexer-invariants.md) **Merge after prior stacked MRs.** <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes trader aggregate SQL on every swap and runs a one-time migration backfill; incorrect CASE logic could skew leaderboard/profile stats until corrected. > > **Overview** > Fixes **#344**: trader **best/worst per-trade realized P&amp;L** no longer default to **0**, which made all-loss wallets show **0** as “best trade” instead of the least-negative loss. > > The indexer makes `best_trade_pnl` / `worst_trade_pnl` **nullable** (migration drops defaults/NOT NULL and backfills rows stuck at 0). **`update_trader_pnl`** now uses **CASE** logic so first trade and legacy **0** rows can recover sensible extrema; API **`TraderResponse`** exposes JSON **`null`** when unset. The dApp **preserves null** in `parseIndexerTraderPayload`, **`PnlValue`** renders **N/A**, and the Charts **leaderboard** uses **`PnlValue`** for P&amp;L sorts. **`docs/indexer-invariants.md`** documents the behavior. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3f7ca07066c0b16aab72f651f4239f5f656ebfe4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
ghost1 commented 2026-06-09 06:53:40 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-09 06:53:46 +00:00 (Migrated from gitlab.com)

mentioned in issue #344

mentioned in issue #344
ghost1 commented 2026-06-09 06:53:52 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-09 06:54:41 +00:00 (Migrated from gitlab.com)
Stale Security Review comment
Stale Security Review comment
Stale Security Review comment

Cursor Bugbot has reviewed your changes and found 4 potential issues.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.

Reviewed by Cursor Bugbot for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure here.

<details> <summary>Stale Security Review comment</summary> <details> <summary>Stale Security Review comment</summary> <details> <summary>Stale Security Review comment</summary> <!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes and found 4 potential issues.<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot). A cloud agent has been kicked off to fix the reported issues. <!-- BUGBOT_AUTOFIX_AGENT_LINK --></sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> </details> </details> </details>
ghost1 commented 2026-06-09 06:54:42 +00:00 (Migrated from gitlab.com)

Wrap deposit uses net amount

High Severity

Native-wrap liquidity applies post-tax net units to wrap_deposit coins, but treasury expects the user’s gross native deposit. CW20 allowances match the net amount, so the tx can succeed while attaching less native than the UI amount and minting less wrapped token than the user intended.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure here.

### Wrap deposit uses net amount **High Severity** <!-- DESCRIPTION START --> Native-wrap liquidity applies post-tax net units to `wrap_deposit` coins, but treasury expects the user’s gross native deposit. CW20 allowances match the net amount, so the tx can succeed while attaching less native than the UI amount and minting less wrapped token than the user intended. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: b53e90c7-9a44-4075-aec4-15db175068d4 --> <!-- LOCATIONS START frontend-dapp/src/pages/PoolPage.tsx#L306-L324 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmZiZTFkNDI0LTI0Y2UtNDQ2Ny1iNzUyLTUzOTI1MDhlZWZiMyIsImVuY3J5cHRpb25LZXkiOiIzMnR0LUN3QkM2Z1RDRG4wamVrX0tqd01uT2xONW4wdTVzYm5uMXlNcUpFIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmZiZTFkNDI0LTI0Y2UtNDQ2Ny1iNzUyLTUzOTI1MDhlZWZiMyIsImVuY3J5cHRpb25LZXkiOiIzMnR0LUN3QkM2Z1RDRG4wamVrX0tqd01uT2xONW4wdTVzYm5uMXlNcUpFIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjRhMDgxMmNkMDg3MTUyNzEyODk0OTg2ZDI2Y2Q4ODU5Zjc0YzFkNzEiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 06:54:42 +00:00 (Migrated from gitlab.com)

Tax cache ignores denom

Medium Severity

LCD tax params are cached for 60s in a single global entry without storing the denom. A later call for another native denom (e.g. uusd after uluna) can reuse the first denom’s tax cap and compute the wrong net minted amount.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure here.

### Tax cache ignores denom **Medium Severity** <!-- DESCRIPTION START --> LCD tax params are cached for 60s in a single global entry without storing the denom. A later call for another native denom (e.g. `uusd` after `uluna`) can reuse the first denom’s tax cap and compute the wrong net minted amount. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 071614df-6d90-4f4e-9f29-aeeb8ebb6176 --> <!-- LOCATIONS START frontend-dapp/src/utils/nativeTransferTax.ts#L49-L52 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjE4NWRkOTc5LTU1NzQtNDQyMC05NWQ4LTk0NDJiYWNhZjQyOCIsImVuY3J5cHRpb25LZXkiOiJYYS1zQXQwOHlHWk1XeG9aLWFYY2lkMEFENGJzYXVCck5YWk1ZTkRFX05RIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjE4NWRkOTc5LTU1NzQtNDQyMC05NWQ4LTk0NDJiYWNhZjQyOCIsImVuY3J5cHRpb25LZXkiOiJYYS1zQXQwOHlHWk1XeG9aLWFYY2lkMEFENGJzYXVCck5YWk1ZTkRFX05RIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjRhMDgxMmNkMDg3MTUyNzEyODk0OTg2ZDI2Y2Q4ODU5Zjc0YzFkNzEiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 06:54:42 +00:00 (Migrated from gitlab.com)

Leaderboard null PnL shows zero

Low Severity

Nullable best_trade_pnl / worst_trade_pnl are coerced to '' for the leaderboard, then parseFloat and formatNum treat that as zero. Traders with unset aggregates show 0 and positive coloring instead of N/A, unlike PnlValue on the profile.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure here.

### Leaderboard null PnL shows zero **Low Severity** <!-- DESCRIPTION START --> Nullable `best_trade_pnl` / `worst_trade_pnl` are coerced to `''` for the leaderboard, then `parseFloat` and `formatNum` treat that as zero. Traders with unset aggregates show `0` and positive coloring instead of **N/A**, unlike `PnlValue` on the profile. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: f268f1e5-fc43-4eb0-995a-3951334962df --> <!-- LOCATIONS START frontend-dapp/src/pages/ChartsPage.tsx#L585-L591 frontend-dapp/src/pages/ChartsPage.tsx#L538-L567 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`frontend-dapp/src/pages/ChartsPage.tsx#L538-L567`](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-//blob/4a0812cd087152712894986d26cd8859f74c1d71/frontend-dapp/src/pages/ChartsPage.tsx#L538-L567) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjU5NzM1MjExLWY0MjMtNDEyNS1hMmIyLTdkYjhlMDAxYzk3YSIsImVuY3J5cHRpb25LZXkiOiJQbjVKMVFFOFl0RnFlOTBQOURQRzlMeVhRbWhOS0RoVUliUkpaRFlhc1c4IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjU5NzM1MjExLWY0MjMtNDEyNS1hMmIyLTdkYjhlMDAxYzk3YSIsImVuY3J5cHRpb25LZXkiOiJQbjVKMVFFOFl0RnFlOTBQOURQRzlMeVhRbWhOS0RoVUliUkpaRFlhc1c4IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjRhMDgxMmNkMDg3MTUyNzEyODk0OTg2ZDI2Y2Q4ODU5Zjc0YzFkNzEiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 06:54:42 +00:00 (Migrated from gitlab.com)

Max reserve skips unwrap gas

Medium Severity

estimateNativeSwapUlunaFeesTotal now adds unwrap gas when needsUnwrapOutput is set, but native Max hints on the swap page still omit that flag. Max spend can reserve too little LUNC for wrap + router + unwrap paths and lead to insufficient-fee or out-of-gas failures.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure here.

### Max reserve skips unwrap gas **Medium Severity** <!-- DESCRIPTION START --> `estimateNativeSwapUlunaFeesTotal` now adds unwrap gas when `needsUnwrapOutput` is set, but native **Max** hints on the swap page still omit that flag. Max spend can reserve too little LUNC for wrap + router + unwrap paths and lead to insufficient-fee or out-of-gas failures. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: cfbc9c0f-5e81-484d-992d-22b1c7ca37da --> <!-- LOCATIONS START frontend-dapp/src/pages/SwapPage.tsx#L283-L289 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjljMTFkZTQwLThmMDAtNDM3YS1hZTllLWM3YzU3NzdjNTE1NCIsImVuY3J5cHRpb25LZXkiOiJIaXZIY21UVDQ1YXFxWnBoZGw2a01KXzZ3SVRfVFlpeldTbmotbHNwMzJ3IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjljMTFkZTQwLThmMDAtNDM3YS1hZTllLWM3YzU3NzdjNTE1NCIsImVuY3J5cHRpb25LZXkiOiJIaXZIY21UVDQ1YXFxWnBoZGw2a01KXzZ3SVRfVFlpeldTbmotbHNwMzJ3IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjRhMDgxMmNkMDg3MTUyNzEyODk0OTg2ZDI2Y2Q4ODU5Zjc0YzFkNzEiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4a0812cd087152712894986d26cd8859f74c1d71. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 06:59:11 +00:00 (Migrated from gitlab.com)

changed this line in version 2 of the diff

changed this line in [version 2 of the diff](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/130/diffs?diff_id=1841275469&start_sha=4a0812cd087152712894986d26cd8859f74c1d71#c4637ed432728b2070e4a79b23301c3b9d26346c_52_52)
ghost1 commented 2026-06-09 06:59:11 +00:00 (Migrated from gitlab.com)

added 1 commit

  • 548886b2 - Fix wrap deposit gross amounts, tax cache denom, leaderboard N/A, swap Max unwrap gas

Compare with previous version

added 1 commit <ul><li>548886b2 - Fix wrap deposit gross amounts, tax cache denom, leaderboard N/A, swap Max unwrap gas</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/130/diffs?diff_id=1841275469&start_sha=4a0812cd087152712894986d26cd8859f74c1d71)
ghost1 commented 2026-06-09 06:59:29 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-09 06:59:41 +00:00 (Migrated from gitlab.com)

resolved all threads

resolved all threads
ghost1 commented 2026-06-09 07:00:36 +00:00 (Migrated from gitlab.com)
Stale Security Review comment
Stale Security Review comment

Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.

Reviewed by Cursor Bugbot for commit 548886b239fd3b31a10480b339deec8e934520d5. Configure here.

<details> <summary>Stale Security Review comment</summary> <details> <summary>Stale Security Review comment</summary> <!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes and found 2 potential issues.<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot). A cloud agent has been kicked off to fix the reported issues. <!-- BUGBOT_AUTOFIX_AGENT_LINK --></sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 548886b239fd3b31a10480b339deec8e934520d5. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> </details> </details>
ghost1 commented 2026-06-09 07:00:37 +00:00 (Migrated from gitlab.com)

Migration nulls valid zero PnL

Low Severity

The backfill sets best_trade_pnl or worst_trade_pnl to NULL whenever the stored value is 0 and total_realized_pnl is non-zero. A trader whose best or worst single trade was exactly break-even (0) matches that pattern and loses a valid zero in favor of API null / UI N/A.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 548886b239fd3b31a10480b339deec8e934520d5. Configure here.

### Migration nulls valid zero PnL **Low Severity** <!-- DESCRIPTION START --> The backfill sets `best_trade_pnl` or `worst_trade_pnl` to NULL whenever the stored value is `0` and `total_realized_pnl` is non-zero. A trader whose best or worst single trade was exactly break-even (`0`) matches that pattern and loses a valid zero in favor of API `null` / UI N/A. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 39f1a51b-617d-44e0-826a-a8394cfb1f52 --> <!-- LOCATIONS START indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L8-L12 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjNiYmNjMzM4LTY3YTQtNDY4Yi1hYjBiLWRiNGQ5ZGVlNjk1MiIsImVuY3J5cHRpb25LZXkiOiJ6bUVJZUJUaHZtRWdzSWNmdzY2UU0xNXFvejgzeTZiRTFubmh0YUVNZG5vIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjNiYmNjMzM4LTY3YTQtNDY4Yi1hYjBiLWRiNGQ5ZGVlNjk1MiIsImVuY3J5cHRpb25LZXkiOiJ6bUVJZUJUaHZtRWdzSWNmdzY2UU0xNXFvejgzeTZiRTFubmh0YUVNZG5vIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjU0ODg4NmIyMzlmZDNiMzFhMTA0ODBiMzM5ZGVlYzhlOTM0NTIwZDUiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 548886b239fd3b31a10480b339deec8e934520d5. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 07:00:37 +00:00 (Migrated from gitlab.com)

Native preflight uses gross offer

Medium Severity

For native-input swap quotes, simulateNativeSwap and executeNativeSwap now simulate and send the post–burn-tax CW20 amount, but preflightSwapRouteSpread still seeds the first hop with gross rawInputAmount. Hop spread and max-spread gating can disagree with what actually executes.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 548886b239fd3b31a10480b339deec8e934520d5. Configure here.

### Native preflight uses gross offer **Medium Severity** <!-- DESCRIPTION START --> For native-input swap quotes, `simulateNativeSwap` and `executeNativeSwap` now simulate and send the post–burn-tax CW20 amount, but `preflightSwapRouteSpread` still seeds the first hop with gross `rawInputAmount`. Hop spread and max-spread gating can disagree with what actually executes. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 2d8b9339-4669-42dc-9ee8-e1dc924975af --> <!-- LOCATIONS START frontend-dapp/src/pages/SwapPage.tsx#L395-L405 LOCATIONS END --> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90Ojk0YTI4NTRlLTUwYTItNDM1ZC04ZDcyLTI2ODBmMWUzNWZlZiIsImVuY3J5cHRpb25LZXkiOiJGNlNrRy01T0t2NDJpQ3h3V3M2aXBoTVdqNkdlMmdrclFxVVRTOHZJU1M4IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90Ojk0YTI4NTRlLTUwYTItNDM1ZC04ZDcyLTI2ODBmMWUzNWZlZiIsImVuY3J5cHRpb25LZXkiOiJGNlNrRy01T0t2NDJpQ3h3V3M2aXBoTVdqNkdlMmdrclFxVVRTOHZJU1M4IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjU0ODg4NmIyMzlmZDNiMzFhMTA0ODBiMzM5ZGVlYzhlOTM0NTIwZDUiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 548886b239fd3b31a10480b339deec8e934520d5. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 07:06:52 +00:00 (Migrated from gitlab.com)

changed this line in version 4 of the diff

changed this line in [version 4 of the diff](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/130/diffs?diff_id=1841288418&start_sha=548886b239fd3b31a10480b339deec8e934520d5#7e7a427a6fd314c7948d2f0fdc672244b8c8700c_12_24)
ghost1 commented 2026-06-09 07:06:52 +00:00 (Migrated from gitlab.com)

added 1 commit

  • c2a8643a - fix: native preflight net offer and preserve break-even PnL in migration

Compare with previous version

added 1 commit <ul><li>c2a8643a - fix: native preflight net offer and preserve break-even PnL in migration</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/130/diffs?diff_id=1841288418&start_sha=548886b239fd3b31a10480b339deec8e934520d5)
ghost1 commented 2026-06-09 07:07:09 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
PlasticDigits commented 2026-06-09 07:31:48 +00:00 (Migrated from gitlab.com)

changed this file in version 7 of the diff

changed this file in version 7 of the diff
PlasticDigits commented 2026-06-09 07:31:48 +00:00 (Migrated from gitlab.com)

changed this file in version 7 of the diff

changed this file in version 7 of the diff
PlasticDigits commented 2026-06-09 07:31:48 +00:00 (Migrated from gitlab.com)

added 14 commits

  • c2a8643a...b511e77e - 10 commits from branch main
  • b10b8a0f - fix(indexer): nullable best/worst trade PnL aggregates (#344)
  • c063446c - Fix wrap deposit gross amounts, tax cache denom, leaderboard N/A, swap Max unwrap gas
  • 80de4937 - fix: native preflight net offer and preserve break-even PnL in migration
  • 4b963d49 - fix(frontend): drop duplicate nativeTransferTax import after rebase

Compare with previous version

added 14 commits <ul><li>c2a8643a...b511e77e - 10 commits from branch <code>main</code></li><li>b10b8a0f - fix(indexer): nullable best/worst trade PnL aggregates (#344)</li><li>c063446c - Fix wrap deposit gross amounts, tax cache denom, leaderboard N/A, swap Max unwrap gas</li><li>80de4937 - fix: native preflight net offer and preserve break-even PnL in migration</li><li>4b963d49 - fix(frontend): drop duplicate nativeTransferTax import after rebase</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/130/diffs?diff_id=1841338276&start_sha=c2a8643a5ab171d5fe380c6dc332858a02b2eb82)
ghost1 commented 2026-06-09 07:32:02 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-09 07:35:36 +00:00 (Migrated from gitlab.com)
Stale Security Review comment

Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issues.

Reviewed by Cursor Bugbot for commit 4b963d4980. Configure here.

<details> <summary>Stale Security Review comment</summary> <!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes and found 2 potential issues.<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>Bugbot Autofix is [ON](https://www.cursor.com/dashboard/bugbot). A cloud agent has been kicked off to fix the reported issues. <!-- BUGBOT_AUTOFIX_AGENT_LINK --></sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4b963d498009b961c1b6266ab576cc25d124c674. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> </details>
ghost1 commented 2026-06-09 07:35:37 +00:00 (Migrated from gitlab.com)

Zero best PnL still pinned

High Severity

update_trader_pnl only treats unset best_trade_pnl when the column is SQL NULL. Rows that still have the legacy sentinel 0 use GREATEST(best_trade_pnl, $2), so a negative trade PnL leaves best_trade_pnl at 0. The migration does not clear every erroneous 0 (e.g. one realized loss among many buys), so the original all-loss pinning bug can persist after deploy.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4b963d4980. Configure here.

### Zero best PnL still pinned **High Severity** <!-- DESCRIPTION START --> `update_trader_pnl` only treats unset `best_trade_pnl` when the column is SQL `NULL`. Rows that still have the legacy sentinel `0` use `GREATEST(best_trade_pnl, $2)`, so a negative trade PnL leaves `best_trade_pnl` at `0`. The migration does not clear every erroneous `0` (e.g. one realized loss among many buys), so the original all-loss pinning bug can persist after deploy. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: ce07e3c6-a639-45d4-89ea-39635e885d6d --> <!-- LOCATIONS START indexer/src/db/queries/positions.rs#L88-L92 indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L17-L22 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L17-L22`](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-//blob/4b963d498009b961c1b6266ab576cc25d124c674/indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L17-L22) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90Ojg3ZTM2ZTBmLWU0NTYtNDNlMS1hMzNjLTBlYmQxMDI2MDEwOCIsImVuY3J5cHRpb25LZXkiOiJuZVFSUEh4MXBTLW1nOWpIUGlMaXVpajc0c2hEWW1BSkQtNVl5NGlabHlnIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90Ojg3ZTM2ZTBmLWU0NTYtNDNlMS1hMzNjLTBlYmQxMDI2MDEwOCIsImVuY3J5cHRpb25LZXkiOiJuZVFSUEh4MXBTLW1nOWpIUGlMaXVpajc0c2hEWW1BSkQtNVl5NGlabHlnIiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjRiOTYzZDQ5ODAwOWI5NjFjMWI2MjY2YWI1NzZjYzI1ZDEyNGM2NzQiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4b963d498009b961c1b6266ab576cc25d124c674. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 07:35:37 +00:00 (Migrated from gitlab.com)

Null best resets on one trade

Medium Severity

When the migration sets best_trade_pnl to NULL for multi-trade rows, the next update_trader_pnl assigns best_trade_pnl to only the latest trade’s PnL instead of the max across prior closes. Historical least-negative losses are dropped until a full re-aggregate runs.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4b963d4980. Configure here.

### Null best resets on one trade **Medium Severity** <!-- DESCRIPTION START --> When the migration sets `best_trade_pnl` to `NULL` for multi-trade rows, the next `update_trader_pnl` assigns `best_trade_pnl` to only the latest trade’s PnL instead of the max across prior closes. Historical least-negative losses are dropped until a full re-aggregate runs. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 985f437b-285d-434c-bb5d-57c722e2352c --> <!-- LOCATIONS START indexer/src/db/queries/positions.rs#L88-L91 indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L17-L22 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L17-L22`](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-//blob/4b963d498009b961c1b6266ab576cc25d124c674/indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L17-L22) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFiZjNhMmQxLWZmZTYtNGZhZS1hMzA5LTJlOWNlNzZiZDA5YyIsImVuY3J5cHRpb25LZXkiOiJIQnBJUzBJNHUzbktoTUsyRnZvSWJaVXF6NGxWcTNBcG9JTUx5enhwUTI0IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmFiZjNhMmQxLWZmZTYtNGZhZS1hMzA5LTJlOWNlNzZiZDA5YyIsImVuY3J5cHRpb25LZXkiOiJIQnBJUzBJNHUzbktoTUsyRnZvSWJaVXF6NGxWcTNBcG9JTUx5enhwUTI0IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjRiOTYzZDQ5ODAwOWI5NjFjMWI2MjY2YWI1NzZjYzI1ZDEyNGM2NzQiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4b963d498009b961c1b6266ab576cc25d124c674. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 07:43:34 +00:00 (Migrated from gitlab.com)

added 1 commit

  • 3f7ca070 - fix(indexer): backfill and update legacy best_trade_pnl sentinel zero

Compare with previous version

added 1 commit <ul><li>3f7ca070 - fix(indexer): backfill and update legacy best_trade_pnl sentinel zero</li></ul> [Compare with previous version](/PlasticDigits/cl8y-dex-terraclassic/-/merge_requests/130/diffs?diff_id=1841362198&start_sha=4b963d498009b961c1b6266ab576cc25d124c674)
ghost1 commented 2026-06-09 07:43:47 +00:00 (Migrated from gitlab.com)

changed the description

changed the description
ghost1 commented 2026-06-09 07:44:22 +00:00 (Migrated from gitlab.com)

resolved all threads

resolved all threads
PlasticDigits (Migrated from gitlab.com) merged commit 1c37ef869c into main 2026-06-09 07:44:30 +00:00
PlasticDigits commented 2026-06-09 07:44:31 +00:00 (Migrated from gitlab.com)

mentioned in commit 1c37ef869c

mentioned in commit 1c37ef869cc39cd2a3424c2deacc938833025218
ghost1 commented 2026-06-09 07:45:59 +00:00 (Migrated from gitlab.com)

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.

Reviewed by Cursor Bugbot for commit 3f7ca07066. Configure here.

<!-- BUGBOT_REVIEW --> Cursor Bugbot has reviewed your changes and found 1 potential issue. <!-- BUGBOT_FIX_ALL --> <a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTozNTJjODQ1YS04MGFlLTRlM2QtYmI4Ny04Y2YwY2UyMGMzNzIiLCJlbmNyeXB0aW9uS2V5IjoiSmlkVE1TOVNFZVJwa3VmWkRkUHpCQl83WnByQ1lLd0Exbm1Cby12U05tZyIsImJyYW5jaCI6ImxvY2FsMS8zNDQtYmVzdC10cmFkZS1wbmwiLCJyZXBvT3duZXIiOiJQbGFzdGljRGlnaXRzIiwicmVwb05hbWUiOiJjbDh5LWRleC10ZXJyYWNsYXNzaWMifX0" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <!-- /BUGBOT_FIX_ALL --> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN --> <sup>Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.</sup> <!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END --> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3f7ca07066c0b16aab72f651f4239f5f656ebfe4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
ghost1 commented 2026-06-09 07:46:00 +00:00 (Migrated from gitlab.com)

Break-even best PnL overwritten

Medium Severity

The legacy-repair branch treats total_realized_pnl = worst_trade_pnl as if the only realized trade were the worst loss. After a losing close and a break-even close (best_trade_pnl still 0), that sets best_trade_pnl to the worst loss instead of 0, skewing profiles and best-trade leaderboard rows.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3f7ca07066. Configure here.

### Break-even best PnL overwritten **Medium Severity** <!-- DESCRIPTION START --> The legacy-repair branch treats `total_realized_pnl = worst_trade_pnl` as if the only realized trade were the worst loss. After a losing close and a break-even close (`best_trade_pnl` still 0), that sets `best_trade_pnl` to the worst loss instead of 0, skewing profiles and best-trade leaderboard rows. <!-- DESCRIPTION END --> <!-- BUGBOT_BUG_ID: 77721999-8a37-4287-872c-da1f03a84bcb --> <!-- LOCATIONS START indexer/src/db/queries/positions.rs#L90-L95 indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L16-L21 LOCATIONS END --> <details> <summary>Additional Locations (1)</summary> - [`indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L16-L21`](https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-//blob/3f7ca07066c0b16aab72f651f4239f5f656ebfe4/indexer/migrations/20260609120000_fix_trader_best_worst_pnl_null.sql#L16-L21) </details> <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjYwODVjNGQ1LTE4OGEtNGU1Yi05ZGMwLWY0NzRmZjc3ZWRmZCIsImVuY3J5cHRpb25LZXkiOiItc0txMV9NSTNFMW1fdHNZNDhqWnRmVHlnaVlVUTZnbGpEX2JoV0loVFI4IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OjYwODVjNGQ1LTE4OGEtNGU1Yi05ZGMwLWY0NzRmZjc3ZWRmZCIsImVuY3J5cHRpb25LZXkiOiItc0txMV9NSTNFMW1fdHNZNDhqWnRmVHlnaVlVUTZnbGpEX2JoV0loVFI4IiwiYnJhbmNoIjoibG9jYWwxLzM0NC1iZXN0LXRyYWRlLXBubCIsInJlcG9Pd25lciI6IlBsYXN0aWNEaWdpdHMiLCJyZXBvTmFtZSI6ImNsOHktZGV4LXRlcnJhY2xhc3NpYyIsInByTnVtYmVyIjoxMzAsImNvbW1pdFNoYSI6IjNmN2NhMDcwNjZjMGIxNmFhYjcyZjY1MWY0MjM5ZjVmNjU2ZWJmZTQiLCJwcm92aWRlciI6ImdpdGxhYiIsImhvc3RuYW1lIjoiZ2l0bGFiLmNvbSJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 3f7ca07066c0b16aab72f651f4239f5f656ebfe4. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup>
PlasticDigits commented 2026-06-09 07:52:36 +00:00 (Migrated from gitlab.com)

mentioned in merge request !850

mentioned in merge request !850
PlasticDigits commented 2026-06-09 07:53:32 +00:00 (Migrated from gitlab.com)

resolved all threads

resolved all threads
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
code/cl8y-dex-terraclassic!848
No description provided.