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(exchange)!: Update IntentionResolvedDirectTradeFees event #262

Conversation

unordered-set
Copy link
Contributor

Add intention_id to the IntentionResolvedDirectTradeFees event.
This commit resolves #248.

This change changes the signature of the IntentionResolvedDirectTradeFees event.
I think it does it for good - to be similar to IntentionResolvedDirectTrade

Description

The change is pretty straightforward, on each direct match we have access to two intentions and by the fee: true flag we already know all of the tranansactions which are taking part in taking the fees. Also those transactions has a field from. So, by matching that from field with intention data we are computing the intention IDs.

In my opinion it is a pretty robust way of doing things. Because I didn't touch the matching rules, and also, the change will adopt itself to any further changes in the fees rules.

Related Issue

Fixes: #248

Motivation and Context

That missing field is pretty important to any tools which want to drill down into the transaction costs. Otherwise they all will have the same snippet of decyphering other emitted events.

How Has This Been Tested?

Run tests locally. Worked. Unbelivable. Broke tests, verified they got broken. Fixed back.

Checklist:

  • [v] I have updated the documentation if necessary.
  • I have added tests to cover my changes, regression test if fixing an issue.
  • [v] This is a breaking change.

@unordered-set unordered-set force-pushed the feat/add-intention-id-to-fee-event branch 3 times, most recently from 0482012 to c71e596 Compare May 25, 2021 23:39
Copy link
Contributor

@enthusiastmartin enthusiastmartin left a comment

Choose a reason for hiding this comment

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

looks ok to me.

Add intention_id to the IntentionResolvedDirectTradeFees event.
This commit resolves galacticcouncil#248.
@unordered-set unordered-set force-pushed the feat/add-intention-id-to-fee-event branch from c71e596 to 35d8ba4 Compare May 26, 2021 21:25
@@ -260,9 +261,10 @@ impl<'a, T: Config> DirectTradeData<'a, T> {
}

/// Send pallet event after a fee is transferred.
fn send_trade_fee_event(from: &T::AccountId, to: &T::AccountId, asset: AssetId, amount: Balance) {
fn send_trade_fee_event(from: &T::AccountId, intention: &Intention<T>, to: &T::AccountId, asset: AssetId, amount: Balance) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we only send fee from one side?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

it is sent for each intention/transaction. you can see it in the tests.

@enthusiastmartin enthusiastmartin merged commit 7ab0578 into galacticcouncil:master May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntentionId should be added to event's data
3 participants