Skip to content

Commit

Permalink
fix(gas-estimator): Prevent float gas prices (UMAprotocol#2509)
Browse files Browse the repository at this point in the history
Signed-off-by: Nick Pai <[email protected]>
  • Loading branch information
nicholaspai authored Feb 5, 2021
1 parent c91e11b commit ac96ad1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/financial-templates-lib/src/helpers/GasEstimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ class GasEstimator {

// Returns the current fast gas price in Wei, converted from the stored Gwei value.
getCurrentFastPrice() {
return this.lastFastPriceGwei * 1e9;
// Sometimes the multiplication by 1e9 introduces some error into the resulting number,
// so we'll conservatively ceil the result before returning. This output is usually passed into
// a web3 contract call so it MUST be an integer.
return Math.ceil(this.lastFastPriceGwei * 1e9);
}

async _update() {
Expand Down

0 comments on commit ac96ad1

Please sign in to comment.