Skip to content

test: add sell protocol fee recipient balance regression#340

Merged
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
wheval:fix/issues-296
May 29, 2026
Merged

test: add sell protocol fee recipient balance regression#340
Chucks1093 merged 2 commits into
accesslayerorg:mainfrom
wheval:fix/issues-296

Conversation

@wheval
Copy link
Copy Markdown
Contributor

@wheval wheval commented May 29, 2026

Summary

Adds a regression test that verifies the protocol fee recipient balance increases by the correct amount after a sell, and wires sell execution to accrue that balance.

Purpose / Motivation

Sell event and quote tests confirm fee fields are computed, but they do not prove the protocol fee recipient actually receives the fee. A direct balance assertion closes that gap and guards against regressions where fees are calculated but not credited.

Changes Made

  • Add regression test for protocol fee recipient receiving correct amount on sell #296: Add regression test for protocol fee recipient receiving correct amount on sell
  • Credit the configured protocol fee recipient balance during sell_key using the current fee config and key price
  • Add get_protocol_recipient_balance read method for test and indexer visibility
  • New integration tests assert balance before/after sell matches the bps-derived protocol fee and the sell quote

How to Test

  1. From the repo root, run cargo test --test sell_protocol_fee_recipient_balance.
  2. Confirm both tests pass:
    • test_sell_increases_protocol_fee_recipient_balance_by_bps_fee
    • test_sell_protocol_fee_recipient_balance_accumulates_across_two_sells
  3. Run cargo test --workspace to confirm no regressions in existing sell and fee tests.

Expected: protocol fee recipient balance is 0 before the first sell and increases by floor(price * protocol_bps / 10_000) after each sell.

Breaking Changes

  • None for callers that do not set a protocol fee recipient.
  • When a protocol fee recipient, key price, and fee config are all configured, sell_key now accrues the protocol fee share to get_protocol_recipient_balance.

Related Issues

Closes #296

Checklist

  • Code builds successfully
  • Tests added/updated
  • No console errors
  • Documentation updated (if needed)

Credit protocol fees to recipient balance on sell and assert the
increase matches the bps-derived fee amount.

Closes accesslayerorg#296
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@wheval Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093 Chucks1093 merged commit e7a902e into accesslayerorg:main May 29, 2026
1 check passed
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.

Add regression test for protocol fee recipient receiving correct amount on sell

2 participants