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

Improvement, add info in the SwapERC20 event to track the exchange ratio of pair. #1341

Open
Jason-Zhangxin-Chen opened this issue Nov 1, 2024 · 4 comments

Comments

@Jason-Zhangxin-Chen
Copy link

Hi, is it possible to add such info in the SwapERC20 event, thus that we can track the orderbooks and aggregate the exchange ratio of pairs from airswap network easily?

emit SwapERC20(nonce, signerWallet, signerToken, signerAmount, senderToken, senderAmount);
@dmosites
Copy link
Contributor

dmosites commented Nov 1, 2024

Hello, this info was removed from the event log to improve gas efficiency. It can be derived from Transfer events on the same transaction, which is done for example in getFullSwapERC20 available in @airswap/utils.
https://github.com/airswap/airswap-protocols/blob/develop/tools/utils/src/swap-erc20.ts#L354

@Jason-Zhangxin-Chen
Copy link
Author

Thank you so much, @dmosites. Just a few more questions:

@dmosites
Copy link
Contributor

Thanks for following up @Jason-Zhangxin-Chen. It's possible for there to be multiple swaps and therefore multiple SwapERC20 events in the same transaction, though this is not common today. The respective Transfer events generally precede the SwapERC20 events, so we could ensure that the helper function takes that into account. As for pairing sender and recipient, the helper function would map msg.sender to recipient and should be able to do so by looking at the inputs to the function call. If this sounds right we'll take a look at making those changes. Thank you!

@Jason-Zhangxin-Chen
Copy link
Author

@dmosites , thank you so much for the feedback. Yeah, I think as for the pairing of sender and recipient, it would be great to update the helper function, please let me know when you have this PR ready, I will also review it. Thank you in advance.

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

No branches or pull requests

2 participants