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

Refs #454 -- Added multicall-in-router.md to general/build/smart-contracts/gas-optimization #619

Merged
merged 5 commits into from
Jun 28, 2024

Conversation

jackleeio
Copy link
Contributor

@jackleeio jackleeio commented Jun 14, 2024

Pre-flight checklist


This change is Reviewable

Copy link

vercel bot commented Jun 14, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
conflux-documentation ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 27, 2024 4:00pm

Copy link
Collaborator

@darwintree darwintree left a comment

Choose a reason for hiding this comment

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

I'm not familiar with this approach and I would wonder how much it can be saved to use multicall. From my institution I think not much can be saved.

Another improvement is that the multicall contract address can be found here

@jackleeio
Copy link
Contributor Author

The gas savings depend on the complexity of the functions and use cases. In simpler examples, like the ones in my initial demo code, the savings are less apparent due to basic operations and the overhead of multicall itself. Therefore, multicall's loop and result handling overhead are more pronounced.

However, in real-world scenarios, such as with Uniswap Router and Compound Bulker, multicall batches complex operations into a single transaction, significantly reducing gas costs.

@darwintree
Copy link
Collaborator

The gas savings depend on the complexity of the functions and use cases. In simpler examples, like the ones in my initial demo code, the savings are less apparent due to basic operations and the overhead of multicall itself. Therefore, multicall's loop and result handling overhead are more pronounced.

However, in real-world scenarios, such as with Uniswap Router and Compound Bulker, multicall batches complex operations into a single transaction, significantly reducing gas costs.

That makes sense but without some specific data this pr might not be merged from my end

@jackleeio jackleeio force-pushed the issue#454multicallRouter branch from 65c0b76 to e5a0b19 Compare June 27, 2024 15:58
@jackleeio
Copy link
Contributor Author

Updated the example code, the results of running the test script are as follows:

[PASS] testIndividualCalls() (gas: 166259)
[PASS] testMulticall() (gas: 139753)

@darwintree darwintree merged commit b067d9a into Conflux-Chain:main Jun 28, 2024
2 checks passed
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.

2 participants