Insdadapp Console flash loan

Hello Academy! ,
Today i tryed flash loan on instadapp to long my ETH and i have problems with my script after specifying gas price and limit still running in to error
Warning! Error encountered during contract execution [Out of gas]
here is one of my transactions:

      let borrowAmount = 100; // 20 DAI
      let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "dai"); // borrow flash loan and swap via Oasis

      let slippage = 2; // 2% slippage.
      let dai_address = dsa.tokens.info.dai.address;
      let eth_address = dsa.tokens.info.eth.address;

      let buyDetail = await dsa.oasis.getBuyAmount("ETH", "DAI", borrowAmount, slippage);

      let spells = dsa.Spell();

      spells.add({
        connector: "instapool",
        method: "flashBorrow",
        args: [dai_address, borrowAmtInWei, 0, 0]
      });

      spells.add({
        connector: "oasis",
        method: "sell",
        args: [eth_address, dai_address, borrowAmtInWei, buyDetail.unitAmt, 0, 0]
      });

      spells.add({
        connector: "compound",
        method: "deposit",
        args: [eth_address, "-1", 0, 0]
      });

      spells.add({
        connector: "compound",
        method: "borrow",
        args: [dai_address, borrowAmtInWei, 0, 0]
      });

      spells.add({
        connector: "instapool",
        method: "flashPayback",
        args: [dai_address, 0, 0]
      });
      dsa.cast({
        'spells' : spells,
        'gasPrice' : web3.utils.toWei('24','gwei'),'gas':'1000000'
      }).then(console.log)

Why still im out of gas even with this huge limits?

Hi @Lukasz
Seeing the code I think the instance is missing
await dsa.setInstance (instanceID);
at the beginning of it. And on the lines
spells: spells,
gasPrice: web3.utils.toWei ('24 ‘,’ gwei ‘), gas:’ 1000000 ’
they go without quotes.
The gas limit can also be placed in Metamask when sending the Tx

Still facing this same error https://etherscan.io/tx/0x036b68df740cfda4d2dde7c7bd2c449b37b513e1918fb84aec053c7d5c15c17d

  dsa.cast({
        'spells' : spells,
        'gasPrice' : web3.utils.toWei(28,'gwei'),'gas':1000000
      }).then(console.log

Uncaught Error: Please pass numbers as strings or BN objects to avoid precision errors.
    at Object.toWei (web3.min.js:1)
    at <anonymous>:45:33
toWei @ web3.min.js:1

this one didn’t work. I setup gas price in metamask aswell, even if is very high still this same out of gas error. What else can be wrong?

EDIT: i push it through instadapp.io and seems my gas limit was way too low
https://etherscan.io/tx/0x7a85519346ad51ceda89421e60010db04e996b3588f0c5a224caa9c65f396f0b

1 Like

Excellent !!
did you run flashloan from instadapp.io?

Yes :slight_smile: all successfully. Thanks for help.

1 Like