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: unified trade events #910

Open
wants to merge 141 commits into
base: master
Choose a base branch
from
Open

feat: unified trade events #910

wants to merge 141 commits into from

Conversation

Roznovjak
Copy link
Contributor

@Roznovjak Roznovjak commented Sep 20, 2024

Fixes #755

Additional todos:

TODO:

@Roznovjak Roznovjak self-assigned this Sep 20, 2024
pallets/lbp/src/lib.rs Outdated Show resolved Hide resolved
pallets/lbp/src/lib.rs Outdated Show resolved Hide resolved
@enthusiastmartin
Copy link
Contributor

what if we call the new pallet something more generic ... eg. amm-support.

it might be useful for other things, not only one specific trade event.

Copy link

github-actions bot commented Sep 25, 2024

New crates:

  • pallet-support: v1.0.0

Crate versions that have been updated:

  • runtime-integration-tests: v1.26.0 -> v1.27.0
  • hydra-dx-math: v8.2.0 -> v8.3.0
  • pallet-circuit-breaker: v1.1.27 -> v1.1.28
  • pallet-dca: v1.6.4 -> v1.7.0
  • pallet-lbp: v4.8.6 -> v4.10.0
  • pallet-liquidation: v1.0.1 -> v1.0.2
  • pallet-liquidity-mining: v4.4.4 -> v4.4.5
  • pallet-omnipool: v4.3.7 -> v4.5.0
  • pallet-omnipool-liquidity-mining: v2.5.0 -> v2.5.1
  • pallet-otc: v2.0.4 -> v2.1.0
  • pallet-otc-settlements: v1.0.6 -> v1.1.1
  • pallet-referrals: v1.2.7 -> v1.2.8
  • pallet-route-executor: v2.6.3 -> v2.7.0
  • pallet-stableswap: v4.1.1 -> v4.1.2
  • pallet-staking: v4.0.1 -> v4.0.2
  • pallet-transaction-multi-payment: v10.1.3 -> v10.1.4
  • pallet-xyk: v6.6.3 -> v6.7.0
  • primitives: v6.1.0 -> v6.1.1
  • hydradx-adapters: v1.3.9 -> v1.3.10
  • hydradx-runtime: v277.0.0 -> v278.0.0
  • hydradx-traits: v3.10.0 -> v3.11.0

Runtime version has been increased.

Copy link
Contributor

@jak-pan jak-pan left a comment

Choose a reason for hiding this comment

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

Some nitpicks and some missing stuff LBP assetId, OTC flipped accounts, some fees are possibly missing and possible rename

pallets/omnipool/src/lib.rs Outdated Show resolved Hide resolved
let additional_fees_total: Balance = fees
.clone()
.into_iter()
.filter_map(|opt| opt.map(|(balance, _)| balance))
Copy link
Contributor

Choose a reason for hiding this comment

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

since you filter out zero amounts later on, you can do it directly here

Suggested change
.filter_map(|opt| opt.map(|(balance, _)| balance))
.filter_map(|opt| opt.map(|(balance, _)| if balance.is_zero(){
None
}
else{
Some(balance)
}))

something like that should work

Copy link
Contributor

Choose a reason for hiding this comment

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

but that should not really return 0 fee amounts anyway.

Copy link
Contributor

@dmoka dmoka Jan 2, 2025

Choose a reason for hiding this comment

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

i see your point, but here I sum the total, instead of converting them to some entries, so having the current implementation makes more sense imo.

As for the zero amount, it can only happen if we confugre 0% in runtime, possibly no chance, but since it is still possible, I wanna protect from it.


let additional_fee_entries: Vec<Fee<T::AccountId>> = fees
.iter()
.filter_map(|opt| {
Copy link
Contributor

Choose a reason for hiding this comment

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

no need for filter map, just map

Copy link
Contributor

Choose a reason for hiding this comment

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

since tkaen fee can contain optionals, and I wanna filter them out, filter map seems like the better option

pallets/omnipool/src/lib.rs Outdated Show resolved Hide resolved
}];

let additional_fee_entries: Vec<Fee<T::AccountId>> = fees
.iter()
Copy link
Contributor

Choose a reason for hiding this comment

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

no need to iter over references here. you can directly consume the fees. so you avoid clones and stuff.

but that requires my previous comment to filter out zeors previously.

Copy link
Contributor

@dmoka dmoka Jan 2, 2025

Choose a reason for hiding this comment

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

ok I refactored it, containing less filtering, not exactly how you proposed but similar

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.

Unify all trading events into the one generic one
4 participants