Proxy not working with WBNB.withdraw and giving consistant error

208 views Asked by At

Here are:

And here are:

As you can see, I call the swap method of the smart contract with a value of 1 BNB. This method:

  1. receives 1 BNB.
  2. deposits the 1 BNB into the WBNB contract. At this moment, 1 WBNB lies in the proxy.
  3. withdraws the 1 WBNB. At this moment, 1 BNB lies in the proxy.
  4. sends the 1 BNB back to the user.

The transaction seems to fail at the end of step 3.

Moreover, if I directly call the implementation contract, it works.

So the issue seems to be coming specifically from the proxy. But after many hours of debugging, I have no idea why this fails… can someone please help?

1

There are 1 answers

0
thks173 On

Inside the withdraw function of WBNB contract, it uses transfer to send BNB. With transfer, there is a fixed gas limit of 2300 gas, which is enough to complete the transfer operation, normally.

But when you call it behind a proxy, the proxy must perform an extra SLOAD operation to fetch the implementation address. The SLOAD has an increased price since EIP1884, making the total price exceeds 2300, causing the transaction to fail.