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 125 commits into
base: master
Choose a base branch
from
Open

feat: unified trade events #910

wants to merge 125 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.

Comment on lines 58 to 59
who: T::AccountId,
pool: PoolType<AssetId>,
Copy link
Contributor

@enthusiastmartin enthusiastmartin Sep 25, 2024

Choose a reason for hiding this comment

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

after discussion with @jak-pan , we suggest:

Suggested change
who: T::AccountId,
pool: PoolType<AssetId>,
swapper: T::AccountId,
filler: T::AccountId, // ICE acc, Omnipool acc, stablepool acc, xyk account etc..
type: FillerType,
enum FillerType {
    Omnipool,
    Stableswap,
    XYK,
    LBP,
    OTC,
    ICE,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Who is filler in OTC?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

type is a keyword, cannot be used

Copy link
Contributor

Choose a reason for hiding this comment

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

Who is filler in OTC?

the one filling order

Copy link
Contributor

Choose a reason for hiding this comment

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

isn't it the one who owns the order?

Copy link

github-actions bot commented Sep 25, 2024

Crate versions that have not been updated:

  • pallet-referrals: v1.2.7
  • pallet-staking: v4.0.1
  • hydradx-runtime: v277.0.0

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-route-executor: v2.6.3 -> v2.7.0
  • pallet-stableswap: v4.1.1 -> v4.1.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-traits: v3.10.0 -> v3.11.0

Runtime version has not been increased.

RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped {
swapper: ALICE.into(),
filler: Omnipool::protocol_account(),
filler_type: pallet_amm_support::types::Filler::Omnipool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice if this had more complex route since it's integration test but I guess we can do that separately.

operation: pallet_amm_support::types::TradeOperation::ExactOut,
inputs: vec![Asset::new(HDX, 140421094367051)],
outputs: vec![Asset::new(LRNA, 70210545436437)],
fees: vec![Fee::new(LRNA, 35105272718, Omnipool::protocol_account()),],
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens with referrals, should we see it here?

Copy link
Contributor

Choose a reason for hiding this comment

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

(Just OT question, doesn't fit context)

fees: vec![Fee::new(LRNA::get(), 24590163934, Omnipool::protocol_account()),],
operation_id: vec![
ExecutionType::Xcm(topic_id, 0),
ExecutionType::XcmExchange(1),
Copy link
Contributor

Choose a reason for hiding this comment

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

No topic here?

Copy link
Contributor

Choose a reason for hiding this comment

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

the API of AssetExchange does the full xcm instructions, so can't have the topic ID easily

	_origin: Option<&Location>,
	give: AssetsInHolding,
	want: &Assets,
	maximal: bool,

What we could maybe do is to read the topic from our stack storage, as at this point, the Xcm([u8; 32], IncrementalIdType) should be there. Not sure if it is always there, otherwise we could do use Optional type. WDYT?

last_two_swapped_events,
vec![
RuntimeEvent::AmmSupport(pallet_amm_support::Event::Swapped {
swapper: TempAccountForXcmAssetExchange::get(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get original acc or just this temp acc

Copy link
Contributor

Choose a reason for hiding this comment

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

unfortunately only the temp acc as the actual trade happens by that account (on behalf of user), that's how we could implement asset exchange back then.

operation: TradeOperation::ExactIn,
inputs: vec![Asset::new(LRNA, 1205165959)],
outputs: vec![Asset::new(DAI, 26663424573622008)],
fees: vec![Fee::new(DAI, 70524156750724, Omnipool::protocol_account())],
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like we're missing referral fees here

pallet_amm_support::Event::Swapped {
swapper: BOB.into(),
filler: LBP::get_pair_id(pallet_lbp::types::AssetPair::new(DAI, HDX)),
filler_type: pallet_amm_support::types::Filler::LBP,
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we have shareToken here?

@@ -129,7 +129,7 @@ pub fn calculate_shares<const D: u8>(
amplification: Balance,
share_issuance: Balance,
fee: Permill,
) -> Option<Balance> {
) -> Option<(Balance, Vec<Balance>)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like breaking change.

Copy link
Contributor

Choose a reason for hiding this comment

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

UI should be notified updated and ready for this.

}
.into(),
pallet_amm_support::Event::Swapped {
swapper: OtcSettlements::account_id(),
Copy link
Contributor

Choose a reason for hiding this comment

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

This is flipped. You are filling existing swap (order)

amount_in: order.amount_in,
amount_out: order.amount_out,
fee,
});

pallet_amm_support::Pallet::<T>::deposit_trade_event(
who,
Copy link
Contributor

Choose a reason for hiding this comment

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

flipped

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

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