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: cf_pool_swap_rate_v3 with broker fee and DCA support #5386

Merged
merged 4 commits into from
Nov 7, 2024

Conversation

syan095
Copy link
Contributor

@syan095 syan095 commented Nov 6, 2024

Pull Request

Closes: PRO-1690

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

Add a V3 for cf_pool_swap_rate_v3 call that will consider broker and affiliate fees as well as DCA.

and affiliate fees as well as DCA.

WIP: Need to write tests
@syan095 syan095 requested a review from dandanlen as a code owner November 6, 2024 08:37
@syan095 syan095 marked this pull request as draft November 6, 2024 08:37
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

Attention: Patch coverage is 13.39286% with 97 lines in your changes missing coverage. Please review.

Project coverage is 71%. Comparing base (9842dea) to head (f0c0a71).
Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
state-chain/runtime/src/lib.rs 6% 0 Missing and 50 partials ⚠️
state-chain/custom-rpc/src/lib.rs 2% 47 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #5386    +/-   ##
======================================
- Coverage     72%     71%    -0%     
======================================
  Files        486     486            
  Lines      85863   85806    -57     
  Branches   85863   85806    -57     
======================================
- Hits       61515   61331   -184     
- Misses     21533   21612    +79     
- Partials    2815    2863    +48     

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

state-chain/custom-rpc/src/lib.rs Outdated Show resolved Hide resolved
state-chain/custom-rpc/src/lib.rs Outdated Show resolved Hide resolved
state-chain/runtime/src/lib.rs Show resolved Hide resolved
Used `try_execute_without_violations` instead of `swap_with_network_fee`
to estimate swap result.
@syan095 syan095 marked this pull request as ready for review November 7, 2024 07:44
* origin/main:
  feat: add version and affiliates to UTXO encoding (#5385)
  chore: bump all versions to 1.8.0 and remove old migrations. (#5327)
  feat: update custom_rpc, runtime_api and broker api for broker level screening (#5341)
  tests: Bouncer test for broker level screening (#5377)
  Feat: Private Broker Channel Witnessing (#5383)

# Conflicts:
#	state-chain/runtime/src/lib.rs
@syan095 syan095 requested a review from dandanlen November 7, 2024 08:39
@kylezs
Copy link
Contributor

kylezs commented Nov 7, 2024

Should we explicitly deprecate cf_pool_swap_rate now? and then delete it at a later date?

@dandanlen
Copy link
Collaborator

I'm making some changes. Going to version the runtime rpc.

- remove v3 types/methods
- add versioning to runtime api
- avoid clone
}

#[derive(Serialize, Deserialize, Clone)]
pub struct RpcSwapOutputV3 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I removed this type because it just adds a new field, which is considered a non-breaking change in the json api.

Comment on lines +221 to +235
// READ THIS BEFORE UPDATING THIS TRAIT:
//
// ## When changing an existing method:
// - Bump the api_version of the trait, for example from #[api_version(2)] to #[api_version(3)].
// - Annotate the old method with #[changed_in($VERSION)] where $VERSION is the *new* api_version,
// for example #[changed_in(3)].
// - Handle the old method in the custom rpc implementation using runtime_api().api_version().
//
// ## When adding a new method:
// - Bump the api_version of the trait, for example from #[api_version(2)] to #[api_version(3)].
// - Create a dummy method with the same name, but no args and no return value.
// - Annotate the dummy method with #[changed_in($VERSION)] where $VERSION is the *new*
// api_version.
// - Handle the dummy method gracefully in the custom rpc implementation using
// runtime_api().api_version().
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've been meaning to add this - now seems like a good time.

Comment on lines +271 to 272
#[changed_in(2)]
fn cf_pool_simulate_swap(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we can remove this entirely after the next release.

@dandanlen dandanlen changed the title WIP: Add cf_pool_swap_rate_v3 with broker fee and DCA support feat: cf_pool_swap_rate_v3 with broker fee and DCA support Nov 7, 2024
@dandanlen dandanlen requested a review from kylezs November 7, 2024 12:45
@dandanlen dandanlen added this pull request to the merge queue Nov 7, 2024
kylezs added a commit that referenced this pull request Nov 7, 2024
* Add a V3 for `cf_pool_swap_rate_v3` call that will consider broker
and affiliate fees as well as DCA.

WIP: Need to write tests

* Removed Affiliate fees
Used `try_execute_without_violations` instead of `swap_with_network_fee`
to estimate swap result.

* fix:

- remove v3 types/methods
- add versioning to runtime api
- avoid clone

---------

Co-authored-by: Daniel <daniel@chainflip.io>
Merged via the queue into main with commit edd093e Nov 7, 2024
49 checks passed
@dandanlen dandanlen deleted the feat/get-swap-rate-v3 branch November 7, 2024 14:27
dandanlen added a commit that referenced this pull request Nov 7, 2024
* Add a V3 for `cf_pool_swap_rate_v3` call that will consider broker
and affiliate fees as well as DCA.

WIP: Need to write tests

* Removed Affiliate fees
Used `try_execute_without_violations` instead of `swap_with_network_fee`
to estimate swap result.

* fix:

- remove v3 types/methods
- add versioning to runtime api
- avoid clone

---------

Co-authored-by: Daniel <daniel@chainflip.io>
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