Sitelet https://github.com/piekstra/lofty-cli/pull/5
Skip to content

Add lofty account breakeven — fee-inclusive sell price - #5

Merged
piekstra merged 1 commit into
mainfrom
feat/account-breakeven
Jul 28, 2026
Merged

piekstra merged 1 commit into
mainfrom
feat/account-breakeven

Conversation

@piekstra

@piekstra piekstra commented Jul 28, 2026 •

Copy link
Copy Markdown
Owner

Figures in this description are illustrative, not account data.

A position's `costBasis` is what you paid FOR THE TOKENS; the platform buy fee
was charged on top of it, so it is not your true cost. Two fees bracket a round
trip and both come out of the sale:

  trueCost = costBasis x (1 + buyFee)
  ask      = trueCost x (1 + margin) / (1 - sellFee)

Selling at the displayed basis therefore books a loss twice over. `breakeven`
does the arithmetic with fee rates read live from the property (`mtSellFeePct`)
and its AMM pool (`fees.platformSell`), so it reflects the venue actually traded.

The buy fee paid depends on where the tokens were bought, which the API does not
record, so both venues are priced and labelled rather than silently guessing;
`--buy-fee` collapses it to one. `--sell-venue amm` prices an exit into the pool,
`--cost` prices a hypothetical position.

Two shape hazards, both now pinned by contract tests:
- The two fee sources disagree on UNITS — the listing publishes fractions
  (0.035 = 3.5%), the pool percentages (2.5 = 2.5%). Mixing them is a silent
  100x price error. Normalizing also snaps off float dirt (0.035 * 100 would
  otherwise emit 3.4999999999999996 in --json).
- `properties/{id}` wraps its payload in `property`; reading a bare `/liquidity`
  silently dropped every marketplace rate. The parser now accepts both.

12 unit tests over anonymized fixtures plus 1 fixture contract test.

Claude-Session: https://claude.ai/code/session_01J7bz8aijn2Uwv1yF5rUenW
@piekstra
piekstra requested a review from piekstra-dev July 28, 2026 18:20

@piekstra-dev piekstra-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated PR Review

Reviewed commit: a802850eb431
Profile: reviewer - Posting as: piekstra-dev

Summary

Reviewer Findings
policies:conventions 0
documentation:docs 0

Reviewer Coverage

Reviewer Status Inspected Skipped Constraints
policies:conventions complete_broad README.md, src/commands/account.rs unavailable unavailable
documentation:docs complete_broad README.md unavailable unavailable
unassigned incomplete_unassigned unavailable tests/fixture_shapes.rs changed files were not assigned to a selected reviewer

0 PR discussion threads considered. 0 summarized; 0 resolved.


Completed in 2m 01s | $1.43 | claude-sonnet-5 | cr 0.10.268
Field Value
Model claude-sonnet-5
Reviewers policies:conventions, documentation:docs
Engine claude_cli · claude-sonnet-5
Reviewed by cr · piekstra-dev
Duration 2m 01s wall · 3m 12s compute
Cost $1.43
Tokens 72 in / 12.5k out

Per-workstream usage

Workstream Model In Out Cache read Cache create Cost Duration
orchestrator-selection claude-sonnet-5 6 2.1k 37.2k 21.1k $0.17 28s
policies:conventions claude-sonnet-5 32 5.0k 730.5k 78.5k $0.77 1m 13s
documentation:docs claude-sonnet-5 28 5.0k 438.3k 27.1k $0.37 1m 19s
orchestrator-rollup claude-sonnet-5 6 411 60.7k 16.5k $0.12 10s

@piekstra
piekstra merged commit 9642b07 into main Jul 28, 2026
2 checks passed
@piekstra
piekstra deleted the feat/account-breakeven branch July 28, 2026 18:24
piekstra added a commit that referenced this pull request Jul 28, 2026
Three read-only commands for the questions the raw API can't answer directly,
plus one fee correctness fix:

- `account coverage`   — USDC reserved backing bids vs free to spend (#4)
- `account breakeven`  — fee-inclusive sell price; costBasis hides the buy fee (#5)
- `rewards eligibility`— are my orders earning right now, and if not why (#6)
- fix: AMM rates are platform + the pool's LP fee (#7)

All three verified against a live account before release.

Claude-Session: https://claude.ai/code/session_01J7bz8aijn2Uwv1yF5rUenW
piekstra added a commit that referenced this pull request Jul 30, 2026
A position's `costBasis` is what you paid FOR THE TOKENS; the platform buy fee
was charged on top of it, so it is not your true cost. Two fees bracket a round
trip and both come out of the sale:

  trueCost = costBasis x (1 + buyFee)
  ask      = trueCost x (1 + margin) / (1 - sellFee)

Selling at the displayed basis therefore books a loss twice over. `breakeven`
does the arithmetic with fee rates read live from the property (`mtSellFeePct`)
and its AMM pool (`fees.platformSell`), so it reflects the venue actually traded.

The buy fee paid depends on where the tokens were bought, which the API does not
record, so both venues are priced and labelled rather than silently guessing;
`--buy-fee` collapses it to one. `--sell-venue amm` prices an exit into the pool,
`--cost` prices a hypothetical position.

Two shape hazards, both now pinned by contract tests:
- The two fee sources disagree on UNITS — the listing publishes fractions
  (0.035 = 3.5%), the pool percentages (2.5 = 2.5%). Mixing them is a silent
  100x price error. Normalizing also snaps off float dirt (0.035 * 100 would
  otherwise emit 3.4999999999999996 in --json).
- `properties/{id}` wraps its payload in `property`; reading a bare `/liquidity`
  silently dropped every marketplace rate. The parser now accepts both.

12 unit tests over anonymized fixtures plus 1 fixture contract test.
piekstra added a commit that referenced this pull request Jul 30, 2026
Three read-only commands for the questions the raw API can't answer directly,
plus one fee correctness fix:

- `account coverage`   — USDC reserved backing bids vs free to spend (#4)
- `account breakeven`  — fee-inclusive sell price; costBasis hides the buy fee (#5)
- `rewards eligibility`— are my orders earning right now, and if not why (#6)
- fix: AMM rates are platform + the pool's LP fee (#7)

All three verified against a live account before release.
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