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

feature/PRO-1038/pool-fee-rpc #4459

Merged
merged 19 commits into from
Feb 21, 2024
Merged

feature/PRO-1038/pool-fee-rpc #4459

merged 19 commits into from
Feb 21, 2024

Conversation

Janislav
Copy link
Contributor

@Janislav Janislav commented Jan 26, 2024

Pull Request

Closes: PRO-xxx

Checklist

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

  • I am confident that the code works.
  • I have updated documentation where appropriate.

Summary

Please include a succinct description of the purpose and content of the PR. What problem does it solve, and how? Link issues, discussions, other PRs, and anything else that will help the reviewer.

Copy link

codecov bot commented Jan 26, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (cb12b67) 73% compared to head (3864f7e) 73%.
Report is 6 commits behind head on main.

❗ Current head 3864f7e differs from pull request most recent head ccc1415. Consider uploading reports for the commit ccc1415 to get more accurate results

Files Patch % Lines
state-chain/runtime/src/lib.rs 18% 0 Missing and 9 partials ⚠️
state-chain/pallets/cf-pools/src/lib.rs 88% 0 Missing and 1 partial ⚠️
state-chain/pallets/cf-pools/src/mock.rs 92% 0 Missing and 1 partial ⚠️
state-chain/traits/src/mocks/lp_balance.rs 0% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #4459    +/-   ##
======================================
- Coverage     73%     73%    -0%     
======================================
  Files        401     397     -4     
  Lines      68209   67846   -363     
  Branches   68209   67846   -363     
======================================
- Hits       49617   49221   -396     
- Misses     15964   15988    +24     
- Partials    2628    2637     +9     

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

@Janislav
Copy link
Contributor Author

Docs are updated here: chainflip-io/chainflip-docs#181

@Janislav Janislav marked this pull request as ready for review January 31, 2024 13:39
@Janislav Janislav requested a review from a team as a code owner January 31, 2024 13:39
@Janislav Janislav requested review from jerryafr, acdibble and AlastairHolmes and removed request for a team January 31, 2024 13:39
@@ -1157,6 +1157,14 @@ pub struct PoolInfo {
/// The fee taken, when range orders are used, from swap inputs that contributes to liquidity
/// provider earnings
pub range_order_fee_hundredth_pips: u32,
/// The total fees earned in this pool by range orders.
pub range_order_total_fees_earned: SideMap<Amount>,
Copy link
Contributor Author

@Janislav Janislav Feb 1, 2024

Choose a reason for hiding this comment

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

Not sure about the return value here. Maybe something scalar would make more sense? Same for all the over new added fields.

Copy link
Contributor

Choose a reason for hiding this comment

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

So we can use SideMap as you have here, and in the other PR of yours we will change it to PairMap (or whatever we call it).

@AlastairHolmes
Copy link
Contributor

So the fees aren't all taken in a single asset, so HistoricalEarnedFees needs to be a double map.

@Janislav
Copy link
Contributor Author

Janislav commented Feb 8, 2024

Okay, interesting. I somehow remembered that we only collect LP fees in USDC. Probably this has changed in the meantime.

@AlastairHolmes
Copy link
Contributor

Okay, interesting. I somehow remembered that we only collect LP fees in USDC. Probably this has changed in the meantime.

thats the network fee

@Janislav
Copy link
Contributor Author

Janislav commented Feb 8, 2024

Yeah, I know that. I think in the very early design (first Whitewater), it was like that 🤔. Anyway - ill change it 😅

@@ -75,6 +75,7 @@ pub struct AuctionState {
pub struct LiquidityProviderInfo {
pub refund_addresses: Vec<(ForeignChain, Option<ForeignChainAddress>)>,
pub balances: Vec<(Asset, AssetAmount)>,
pub earned_fees: BTreeMap<ForeignChain, Vec<(Asset, AssetAmount)>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the new any::AssetMap?

@@ -139,6 +139,11 @@ pub mod pallet {
pub type FreeBalances<T: Config> =
StorageDoubleMap<_, Twox64Concat, T::AccountId, Identity, Asset, AssetAmount>;

#[pallet::storage]
/// Historical earned fees for an account. Map: AccountId => AssetAmount
pub type HistoricalEarnedFees<T: Config> =
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually we could use the AssetMap here too.

Copy link
Contributor

Choose a reason for hiding this comment

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

And use a StorageMap instead.

asset_pair.assets()[(!order.to_sold_side()).into()],
collected_fees,
)?;
let asset = asset_pair.assets()[(!order.to_sold_side()).into()];
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to add the recording of fees into inner_update_range_order too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I do this.

Copy link
Contributor

@AlastairHolmes AlastairHolmes left a comment

Choose a reason for hiding this comment

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

Ok, sorry that took a while, once all the comments I've made are addressed, I'm happy for this to be merged.

@@ -1520,6 +1528,7 @@ impl<T: Config> Pallet<T> {
.try_map(|(asset, collected_fees)| {
AssetAmount::try_from(collected_fees).map_err(Into::into).and_then(
|collected_fees| {
T::LpBalance::record_fees(lp, collected_fees, asset);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AlastairHolmes that's the place where I have to add record the fees for range orders, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry not sure how I could have missed that

@Janislav Janislav merged commit 38f4443 into main Feb 21, 2024
41 of 42 checks passed
@Janislav Janislav deleted the feature/pro-1038/pool-fee-rpc branch February 21, 2024 17:10
syan095 added a commit that referenced this pull request Feb 26, 2024
…ero-liquidity

* origin/main: (28 commits)
  feat(custom-rpc): add broker info [WEB-925] (#4560)
  chore: upgrade solana version (#4567)
  fix: continuous adapter (PRO-684) (#4503)
  fix: Wait for ThresholdSignature success before switching to NewKeysActivated (#4534)
  chore: remove un-needed serde derives from EncodedAddress (#4565)
  fix: more lenient max deposit fee in bouncer test (#4564)
  chore: build persa bins instead of fetch (#4554)
  feat: deploy L2 contracts upon localnet startup and send L2 TXs 📑 (#4558)
  feat: debug logs on runtime upgrade test (#4556)
  feature/PRO-1038/pool-fee-rpc (#4459)
  chore: update bootnodes in chainspec ✨ (#4456)
  fix: allow test coverage to run (#4555)
  refactor/pro-1160/remove-side-side-map (#4489)
  fix: activate missing migrations (#4550)
  chore: remove cf-build (#4551)
  feat: extensible multi-key rotator (#4546)
  fix: ensure channel open fee can be paid in benchmarks (#4544)
  feat: bump substrate deps to polkadot-sdk 1.6 (#4504)
  fix: upgrade-test should restart the chainflip-nodes on an incompatible upgrade (#4490)
  test: add small v3 migration test (#4543)
  ...

# Conflicts:
#	state-chain/pallets/cf-pools/src/tests.rs
syan095 added a commit that referenced this pull request Feb 26, 2024
…-price

* origin/main:
  feat(custom-rpc): add broker info [WEB-925] (#4560)
  chore: upgrade solana version (#4567)
  fix: continuous adapter (PRO-684) (#4503)
  fix: Wait for ThresholdSignature success before switching to NewKeysActivated (#4534)
  chore: remove un-needed serde derives from EncodedAddress (#4565)
  fix: more lenient max deposit fee in bouncer test (#4564)
  chore: build persa bins instead of fetch (#4554)
  feat: deploy L2 contracts upon localnet startup and send L2 TXs 📑 (#4558)
  feat: debug logs on runtime upgrade test (#4556)
  feature/PRO-1038/pool-fee-rpc (#4459)
  chore: update bootnodes in chainspec ✨ (#4456)
  fix: allow test coverage to run (#4555)
  refactor/pro-1160/remove-side-side-map (#4489)
  fix: activate missing migrations (#4550)
  chore: remove cf-build (#4551)

# Conflicts:
#	state-chain/pallets/cf-pools/src/lib.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.

2 participants