ntropika-labs / potion-protocol

2 stars 3 forks source link

Potion doesn't seem to buy when exp > 1 #151

Open tenelmike opened 2 years ago

tenelmike commented 2 years ago

I was doing the manual testing and had this error happen so I was just putting it in github so it's not lost. This is with the current develop branch: commit a0998133f209ad653bb83268e6b04f5757918053

When I went to buy a potion with an exp > 1 pushing the button did nothing and so I opened up the console and there was an exception:

null:1272 [Vue warn]: Unhandled error during execution of component event handler 
  at <NavButtons current-step=3 is-token-selected=true is-strike-valid=true  ... > 
  at <BaseCard> 
  at <CustomPotionCreation onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy > > 
  at <RouterView> 
  at <BaseLayout enter-class="opacity-0" leave-class="opacity-100" > 
  at <BaseTransition appear=false persisted=false mode=undefined  ... > 
  at <Transition enter-active-class="transition-all" leave-active-class="transition-all" enter-class="opacity-0"  ... > 
  at <App>
warn2 @ null:1272
usePotionLiquidityPoolContract.ts:304 Uncaught (in promise) Error: Error buying from otoken with address 0xE0c909b07AF3473661Fa23Fc1CE11e1cb9A2A8fC: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={"reason":"processing response error","code":"SERVER_ERROR","body":"{\"id\":49,\"jsonrpc\":\"2.0\",\"error\":{\"message\":\"VM Exception while processing transaction: revert Premium higher than max\",\"stack\":\"RuntimeError: VM Exception while processing transaction: revert Premium higher than max\\n    at exactimate (/app/dist/node/1.js:2:144886)\",\"code\":-32000,\"name\":\"RuntimeError\",\"data\":{\"hash\":null,\"programCounter\":889,\"result\":\"0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000175072656d69756d20686967686572207468616e206d6178000000000000000000\",\"reason\":\"Premium higher than max\",\"message\":\"revert\"}}}","error":{"code":-32000,"data":{"hash":null,"programCounter":889,"result":"0x08c379a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000175072656d69756d20686967686572207468616e206d6178000000000000000000","reason":"Premium higher than max","message":"revert"}},"requestBody":"{\"method\":\"eth_estimateGas\",\"params\":[{\"type\":\"0x2\",\"maxFeePerGas\":\"0x59683e10\",\"maxPriorityFeePerGas\":\"0x59682f00\",\"from\":\"0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266\",\"to\":\"0x4ed7c70f96b99c776995fb64377f0d4ab3b0e1c1\",\"data\":\"0x1d292c2e000000000000000000000000e0c909b07af3473661fa23fc1ce11e1cb9a2a8fc00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000007e37a5a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000a85233c63b9ee964add6f2cffe00fd84eb32338f0000000000000000000000009a9f2ccfde556a7e9ff0848998aa4a0cfd8863ae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000005f5e100\"}],\"id\":49,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","url":"http://localhost:8545"}, tx={"data":"0x1d292c2e000000000000000000000000e0c909b07af3473661fa23fc1ce11e1cb9a2a8fc00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000007e37a5a0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb922660000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000002386f26fc10000000000000000000000000000000000000000000000000000016345785d8a0000000000000000000000000000000000000000000000000000016345785d8a00000000000000000000000000000000000000000000000000000de0b6b3a7640000000000000000000000000000a85233c63b9ee964add6f2cffe00fd84eb32338f0000000000000000000000009a9f2ccfde556a7e9ff0848998aa4a0cfd8863ae0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000006400000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000005f5e100","to":{},"from":"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266","type":2,"maxFeePerGas":{"type":"BigNumber","hex":"0x59683e10"},"maxPriorityFeePerGas":{"type":"BigNumber","hex":"0x59682f00"},"nonce":{},"gasLimit":{},"chainId":{}}, code=UNPREDICTABLE_GAS_LIMIT, version=abstract-signer/5.7.0)
    at buyOtokens (usePotionLiquidityPoolContract.ts:304:17)
    at async buyPotions (usePotionLiquidityPoolContract.ts:501:9)
    at async handleBuyOrCreatePotions (useBuyPotions.ts:51:9)

I checked the subgraph and no potion was created either. After pushing the button enough times it eventually worked.

Steps to produce:

  1. Create a Pool with the parameters:
  1. Buy Potion with:
wonderbeel commented 2 years ago

cc @RazorSiM, I think that it is actually a problem with gas estimation that on ganache is problematic, we had the same exact problem on kovan, goerli on other hand is way more stable. It should be a problem only on Potion purchase IIRC, Pools should be completely unaffected by this issue and it is "solvable" trying a couple of times to purchase.

RazorSiM commented 2 years ago

The error is this one: Premium higher than max.

I think it's a router/pools problem.