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

Improve cart gas estimates for DAI, aDAI, cDAI, and ANT #6961

Merged
merged 2 commits into from
Jun 24, 2020

Conversation

mds1
Copy link
Contributor

@mds1 mds1 commented Jun 23, 2020

This PR has two changes in regards to gas estimates

Changes for Carts with ANT, aDAI, or cDAI

The current default estimate for token donations is 100k per donation, but this is insufficient for some tokens:

  • A standard ANT transfer costs up to 131k gas, so for ANT donations we add some margin and now use a value of 170k gas
  • An aDAI transfer can vary in gas cost depending on your address status in the platform (e.g. if you are borrowing it might be more costly than if you're not borrowing). The Aave team suggested a gas limit of 500k per transfer which they say should be more than enough
  • If transferring cDAI in MetaMask, the gas limit is automatically set to 400k. So we add a bit of margin here and use 450k gas per transfer

Changes for Carts that Only Use DAI

If a cart is all Dai (which is about 75% of checkouts), we use a linear regression to estimate the gas price based on actual transaction data.

The raw data was obtained using the script located at this repo: https://github.com/mds1/Gitcoin-Checkout-Gas-Analysis

That script does the following:

  1. Finds all cart checkout transactions that only use Dai
  2. For a given number of donations, generate a data set that only keeps the transactions that used the most gas
  3. Plot those results in Plotly

We then used the Plotly Chart Studio to generate a linear best fit line, then tweak the result so the results are more conservative than a typical best fit line (because we'd rather overestimate gas costs than underestimate). This chart can be found in Plotly Chart Studio here: https://plotly.com/~mds1/7/number-of-donations-vs-gas-used-all/

This gave us a new curve of gasLimit = 25000 * n + 125000; where n is number of donations in a transaction. For 1 donation we use a special case and set the estimate to 80k to avoid overestimating too much (in practice this will not really be seen since the default contribution to Gitcoin means there's two donations when you choose one grant).

Some comparisons are shown below:

# of Donations Per Tx Old Estimate New Estimate True Value
1 100k 80k 44k
2 200k 175k 84k
3 300k 200k 122k
5 500k 250k 181k
9 900k 350k 296k
15 1.5M 500k 396k
25 2.5M 750k 658k
40 4.0M 1.125M 1.04M

cc @owocki @apbendi

@thelostone-mc thelostone-mc changed the base branch from master to stable June 24, 2020 12:45
@thelostone-mc thelostone-mc merged commit fb08dda into gitcoinco:stable Jun 24, 2020
octavioamu added a commit that referenced this pull request Jun 24, 2020
* Fix Firefox issue that showed red border for decimal inputs in cart (#6958)

* New Grants txn Failed Email (#6791)

* setup web preview url

* implement render_grant_txn_failed

* build template grant_txn_failed.html

* management command for grant_txn_failed_email

* fix missing returns after resolving conflicts

* add bulk_add_url

* move email specific style to grant_txn_failed.html

* new approval checker helper script

* fix comparing strings on allowance

* fix featured bounty and balance checker

* fix eslint card.js

* Improve cart gas estimates for DAI, aDAI, cDAI, and ANT (#6961)

* Quotation on Profile handle (#6957)

* Improve cart gas estimates for DAI, aDAI, cDAI, and ANT

Co-authored-by: Paul <[email protected]>

* wallet improvments (#6952)

* wallet improvments

* avoid form submission

* bounty requesting wallet

* quest js dupe

* Fix for bottomVisible method scope. (#6964)

* fix for projects, the bottomVisible method was defined incorrectly

* fixes for paginaiton of projects, as well as sorting by winners as default

* restoring docker-compose

* Update manifest.json

reverting manifest changes

* Update top_nav.html

revert top nav changes

* position the loading screen better inside the project directory

* formalizes the types of conversion rates in the DB

* 1 thing

* fixes A few annoying
things about kudso

1. now proudly shows the kudos artist
2. allows u to mind them in one fell swoop + change onwnership
3. stores the IPFS metadata in our DB for future keeping

Co-authored-by: Matt <[email protected]>
Co-authored-by: Sebastian T F <[email protected]>
Co-authored-by: Owocki <[email protected]>
Co-authored-by: Paul <[email protected]>
Co-authored-by: Andrew Redden <[email protected]>
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