From 5e621b9007b846bb82a19a39fbff8b92b39090de Mon Sep 17 00:00:00 2001 From: mds <17163988+mds1@users.noreply.github.com> Date: Fri, 19 Jun 2020 07:42:54 -0700 Subject: [PATCH] Fix gas estimates for ANT, aDAI, and cDAI --- app/assets/v2/js/cart.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index adc07492285..04043c577f4 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -224,9 +224,22 @@ Vue.component('grants-cart', { // donation (i.e. one item in the cart). Because gas prices go down with batched // transactions, whereas this assumes they're constant, this gives us a conservative estimate const gasLimit = this.donationInputs.reduce((accumulator, currentValue) => { - return currentValue.token === ETH_ADDRESS - ? accumulator + 50000// ETH donation gas estimate - : accumulator + 100000; // token donation gas estimate + const tokenAddr = currentValue.token.toLowerCase(); + + if (currentValue.token === ETH_ADDRESS) { + return accumulator + 50000; // ETH donation gas estimate + + } else if (tokenAddr === '0x960b236A07cf122663c4303350609A66A7B288C0'.toLowerCase()) { + return accumulator + 170000; // ANT donation gas estimate + + } else if (tokenAddr === '0xfC1E690f61EFd961294b3e1Ce3313fBD8aa4f85d'.toLowerCase()) { + return accumulator + 500000; // aDAI donation gas estimate + + } else if (tokenAddr === '0x5d3a536E4D6DbD6114cc1Ead35777bAB948E3643'.toLowerCase()) { + return accumulator + 450000; // cDAI donation gas estimate + + } + return accumulator + 100000; // generic token donation gas estimate }, 0); return gasLimit;