mangrovedao/mangrove.js

Non sensible error, when MangroveOrder fails

Opened this issue · 1 comments

Describe the bug
When running a FoK order using MangroveOrder and giving a price that you know is not high enough for the order to go through, then the error returned is not usable. You either have to take the transaction hash and run it with cast run <hash> or do something like this:

let result = await market.buy({
  volume: 2000,
  price: 1.00425999,
  mangroveOrder: { fillOrKill: true },
}).catch( e =>  a=e);


let callResult = await mgv._provider.call(a.transaction);
mgv.orderContract.interface.decodeFunctionResult(
  "take",
  callResult
)

To Reproduce
Make sure to use a volume and price that makes the order fail.
let result = await market.buy({ volume: 2000, price: 1.00425999, mangroveOrder: { fillOrKill: true }, })

Expected behavior
It should have a usable return value. In this case it should be the revert reason given by take; "mgvOrder/mo/noPartialFill" (Note: the revert reason name may have changed"

Additional context
The issue can maybe be resolved by using this package: https://www.npmjs.com/package/eth-revert-reason

This is closely related to #186.