ethers-provider-flashbots-bundle icon indicating copy to clipboard operation
ethers-provider-flashbots-bundle copied to clipboard

signBundle bundle used too little gas

Open maooricio opened this issue 3 years ago • 5 comments

Hi, well I don't know if this provider is only for transfers transactions, if so, my question doesn't have a point. But, if this module was built to support contract interactions so I want to know if I am doing something wrong. I have the following code:

const GWEI = 10n ** 9n
const CHAIN_ID = 5
const FLASHBOTS_ENDPOINT = 'https://relay-goerli.flashbots.net'
const provider = new providers.InfuraProvider('goerli', process.env.INFURA_API_KEY)
const signer = Wallet.createRandom()
const flashbot = await FlashbotsBundleProvider.create(provider, signer, FLASHBOTS_ENDPOINT)
const valueToSendParsed = utils.parseEther('0.01')
const encodedData = '0x7ff36ab500000000000000000000000000000000000000000000000016498f36d4b30300000000000000000000000000000000000000000000000000000000000000008000000000000000000000000054a1c450e8cf7dcde904aa9340375ced46d1cc8c00000000000000000000000000000000000000000000000000000180b94bcbd00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000b4fbf271143f4fbf7b91a5ded31805e42b2208d60000000000000000000000009fffb5a9f5c6a55fa802318ff49936e672399b56'

const signedTx = await flashbot.signBundle([
      {
        signer: wallet,
        transaction: {
          chainId: CHAIN_ID,
          // EIP 1559 transaction
          type: 2,
          value: valueToSendParsed,
          data: encodedData,
          maxFeePerGas: GWEI * 3n,
          maxPriorityFeePerGas: GWEI * 2n,
          gasLimit: 300000,
          to: process.env.ROUTER_CONTRACT_ADDRESS
        }
      }
   ])

The method signBundle always return body="{\"error\":{\"message\":\"bundle used too little gas, must use at least 42000\"}}", no matter if I increase the gas limit of the transaction. The data of the transaction is a swap of a DEX router. What am I doing wron? In advance thanks

maooricio avatar May 12 '22 19:05 maooricio

Having the same issue, were you able to solve it?

a180024 avatar Jun 15 '22 11:06 a180024

No yet, I am still waiting for an answer

maooricio avatar Jun 15 '22 13:06 maooricio

was an error on my side, i didn't have enough funds for swapping

a180024 avatar Jun 15 '22 14:06 a180024

It worked to you? If so, would you please share your code in order to see what is wrong with mine? Or do you see something wrong in the code that I shared?

maooricio avatar Jun 15 '22 15:06 maooricio

variable names might be hard to see but generally the same other than maxPriorityFeePerGas and maxFeePerGas. what went wrong for me was i didn't have enough funds in the separate swap contract i was using

  const baseFeePerGas = block.baseFeePerGas; 
  const maxBaseFeePerGas = FlashbotsBundleProvider.getMaxBaseFeeInFutureBlock(
    baseFeePerGas,
    1
  );

a180024 avatar Jun 15 '22 19:06 a180024