I sent this transaction with 74 GWEI and 185421 gas limit. So far my calculations: 74 * 185421 -> about 6.6 USD, at the time of writing.
The screenshot above shows 1.04 USD. Below it says gas used ~15%.
What's going on? Why does the transaction stop at 15% of the limit (if I understand this correctly)?
INSUFFICIENT_OUTPUT_AMOUNTis thrown from the contract function, not from the transaction.
It therefore has nothing to do with your gas-limit and gas-price configuration, and it most certainly has nothing to do with ETH/USD price.
This error-message tells you that the output amount is smaller than the minimum that you've requested for (in the
amountOutMininput parameter which you have passed to this function).
You can observe all of this in the contract source code on GitHub.
My problem was actually that I wasn't using `JSBI.toNumber` on the amount returned by uniswap to convert it to an actual number, so it was sending a ridiculously high amount. It makes sense to switch to Typescript. JS is too dangerous for this.
@Ixx: Never use `toNumber` on anything returned from a web3 call without asserting first that it is not larger than `Number.MAX_SAFE_INTEGER`.
More generally, I would recommend to avoid even that suggestion, and use only `BN` objects throughout your code. That is, unless it is designated for display purpose, in which case, you can and should use `toString()`.