Skip to content
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: charging broker fee per chunk and in USDC #5161

Merged
merged 14 commits into from
Aug 22, 2024

Conversation

msgmaxim
Copy link
Contributor

@msgmaxim msgmaxim commented Aug 16, 2024

Pull Request

Closes: PRO-1540 and PRO-1483

Checklist

Please conduct a thorough self-review before opening the PR.

  • I am confident that the code works.
  • I have written sufficient tests.
  • I have written and tested required migrations.
  • I have updated documentation where appropriate.

Summary

The PR is indended to be reviewed by individual commits

  • Broker fee now behaves exactly like network fee, charged at the same time (once we have intermediate amount) and in USDC.
  • Moved broker_fee field from SwapRequested to SwapExecuted (FYI @zoheb391 and @acdibble). Don't think there are any other implications for the product, other than brokers noticing that only their USDC balance is changing.
  • Updated tests; swap_broker_fee_subtracted_from_swap_amount was mostly a duplicate so I merged it with expect_earned_fees_to_be_recorded.
  • Also, as discussed, combined Ccm and Regular variants from SwapRequestState into UserSwap. Didn't really result in code deduplication, but at least we no longer repeat swap parameters (like the newly added broker_fees).

Edit: Updated broker fee tests in bouncer. Because all fees are charged in USDC I ended up leaving only a test for one asset (as opposed to all assets). Keeping all assets seems no longer necessary, and wouldn't be trivial (would likely require running the tests sequentially or with multiple broker account).

Copy link

codecov bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 92.98246% with 28 lines in your changes missing coverage. Please review.

Project coverage is 70%. Comparing base (fb4385c) to head (03a5c06).
Report is 3 commits behind head on main.

Files Patch % Lines
state-chain/pallets/cf-swapping/src/lib.rs 88% 21 Missing and 5 partials ⚠️
state-chain/pallets/cf-swapping/src/tests.rs 99% 2 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #5161    +/-   ##
======================================
- Coverage     70%     70%    -0%     
======================================
  Files        481     481            
  Lines      85760   85829    +69     
  Branches   85760   85829    +69     
======================================
- Hits       60207   60106   -101     
- Misses     22286   22452   +166     
- Partials    3267    3271     +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@j4m1ef0rd j4m1ef0rd left a comment

Choose a reason for hiding this comment

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

LGTM, but i will let Dan approve.

@dandanlen dandanlen added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit 0f94008 Aug 22, 2024
48 checks passed
@dandanlen dandanlen deleted the feat/broker-fee-per-chunk branch August 22, 2024 22:05
syan095 added a commit that referenced this pull request Aug 22, 2024
…ovide-shared-data

* origin/main:
  feature: Added benchmark for delete vote (#5189)
  Feat: charging broker fee per chunk and in USDC (#5161)
  Feat: solana deployments (#5188)
  chore: bouncer add check for solana nonces (#5185)

# Conflicts:
#	state-chain/pallets/cf-elections/src/benchmarking.rs
#	state-chain/pallets/cf-elections/src/weights.rs
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.

3 participants