-
Notifications
You must be signed in to change notification settings - Fork 15
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
Conversation
Codecov ReportAttention:
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. |
Docs are updated here: chainflip-io/chainflip-docs#181 |
@@ -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>, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
So the fees aren't all taken in a single asset, so HistoricalEarnedFees needs to be a double map. |
Okay, interesting. I somehow remembered that we only collect LP fees in USDC. Probably this has changed in the meantime. |
thats the network fee |
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)>>, |
There was a problem hiding this comment.
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> = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
…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
…-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
Pull Request
Closes: PRO-xxx
Checklist
Please conduct a thorough self-review before opening the PR.
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.