gitcoinco / gitcoinco/web

Fix checkout recommendation based on gas cost

Open
#9,426 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
776
PR merge metrics
No merged PRs in 30d

Description

There are two issues with the current gas cost recommendations:

1. The [polygon gas estimation](https://github.com/gitcoinco/web/blob/gr11/app/assets/v2/js/cart-ethereum-polygon.js#L336-L384) is missing the cost of an L1 deposit the user doesn’t have sufficient balance. There should a section [like this](https://github.com/gitcoinco/web/blob/d41c1a6cb2abee0a23f5e9990bce2ebc6c9dcd72/app/assets/v2/js/cart-ethereum-zksync.js#L283-L294) part of the zkSync estimate

2. The `checkoutRecommendation()` logic in `cart.js` is incorrect. When it was just L1 and zksync, we compared gas usage directly, and this is ok because zksync gas price is directly tied to L1. But now with Polygon, you can no longer just compare gas usage directly because Polygon and L1 will have the same gas usage, but on Polygon gas cost is lower. You can fix this by updating the checkout recommendation to compare USD cost as follows:
1. costL1 = estimateL1 * basefee * eth/usd (basefee is a good enough estimate of current gas price)
2. costZkSync = estimateZkSync * basefee * eth/usd (you should verify this zkSync estimation approach with the zkSync team to make sure there’s no concept of L2 gas price they have that I’m forgetting, and to ensure basefee is a sufficient estimate for what they charge when you checkout)
3. costPolygon = estimatePolygon * 2 gwei * matic/usd (polygon transactions can almost always be less than 2 gwei AFAIK so just hardcode it for simplicity)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.