Skip to content

Sip 58 emit exchange entry settlements #553

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

Merged
merged 22 commits into from
Jul 3, 2020

Conversation

jacko125
Copy link
Contributor

No description provided.


// ========== EVENTS ==========

event ExchangeEntryAppended(
Copy link
Contributor

Choose a reason for hiding this comment

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

these events all need the timestamp of the original exchange, it was in the spec: https://sips.synthetix.io/sips/sip-58

This is what the dapps will use to try to connect the reclaim/rebates to the exchanges themselves cc @clementbalestrat

Copy link
Contributor Author

@jacko125 jacko125 Jun 18, 2020

Choose a reason for hiding this comment

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

@justinjmoses I realised that for events the better pattern is to use the block timestamp the event was emitted in (dapps can check the block.timestamp) instead of adding an extra timestamp to the data.

@codecov
Copy link

codecov bot commented Jun 18, 2020

Codecov Report

Merging #553 into develop will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #553   +/-   ##
========================================
  Coverage    99.44%   99.44%           
========================================
  Files           44       44           
  Lines         2712     2726   +14     
  Branches       378      378           
========================================
+ Hits          2697     2711   +14     
  Misses          15       15           
Impacted Files Coverage Δ
contracts/ExchangeState.sol 100.00% <ø> (ø)
contracts/Exchanger.sol 98.60% <100.00%> (+0.15%) ⬆️
contracts/Synthetix.sol 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d99cc48...2619bfe. Read the comment docs.

@jacko125 jacko125 marked this pull request as ready for review June 18, 2020 03:46
uint256 amountReceived,
uint256 exchangeFeeRate,
uint256 roundIdForSrc,
uint256 roundIdForDest
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't think it's worth just emitting the block.timestamp as well to aid in event correlation?

Copy link
Contributor Author

@jacko125 jacko125 Jun 24, 2020

Choose a reason for hiding this comment

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

I think it's easy for the dapps / synthetix exchange to correlate ExchangeEntryAppended event using the block + timestamp it was included in. @clementbalestrat any thoughts on this?

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 supposed to be the same?

Copy link
Contributor

Choose a reason for hiding this comment

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

The question is do we include timestamp in the ExchangeEntryAppended event to match the one in ExchangeEntrySettled or does the dApp simply lookup the timestamp via an evm call to block.timestamp for ExchangeEntryAppended. I think more the former to be explicit, but we want your input @clementbalestrat

Copy link
Contributor

@hav-noms hav-noms left a comment

Choose a reason for hiding this comment

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

Approved with the dedupe

}

mapping(address => mapping(bytes32 => ExchangeEntry[])) public exchanges;
mapping(address => mapping(bytes32 => IExchangeState.ExchangeEntry[])) public exchanges;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@justinjmoses If ExchangeState isn't redeployed it should be fine. The updated IExchangeState interface will be compiled when the new Exchanger contract is deployed.

Copy link
Contributor

@jjgonecrypto jjgonecrypto left a comment

Choose a reason for hiding this comment

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

Great work Jacko! 🚀 💯 🌔 :shipit:

I'll work on fixing the gas reports shortly.

@jjgonecrypto
Copy link
Contributor

Updated. Please take a look

@jjgonecrypto
Copy link
Contributor

Gas reports look pretty good! Just a heads up to not merge this into develop yet - let's wait until after the release on Tuesday in case we need to run a hotfix through develop

new web3.utils.BN(0),
new web3.utils.BN(1),
new web3.utils.BN(3),
exchangeTime + 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

How do you know it's +1? Is it due to how buidler evm mines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, buidler evm increments each txn / block by 1 second

@jacko125 jacko125 merged commit 508337a into develop Jul 3, 2020
@jacko125 jacko125 deleted the sip-58-emit-exchange-entry-settlements branch July 3, 2020 01:49
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.

4 participants