fluidex/dingir-exchange

bug: use rounded up value for amount & price in commit_order

Closed this issue · 5 comments

In frontend and https://github.com/Fluidex/dingir-exchange/blob/master/examples/js/client.ts#L95-L96 we use rounded -up value for amount&price.

But in https://github.com/Fluidex/dingir-exchange/blob/master/src/matchengine/asset/asset_manager.rs#L71 we don't round up the values.

This needs to be consistent for calculating order_hash and verifying the signature.

Usually it will be okay, but sometimes it's buggy.

lispc commented

ok i see. checking sig before checking precision gives misleading/confusing error msg.

ok i see. checking sig before checking precision gives misleading/confusing error msg.

You are right. Your description is more accurate.

In conclusion:

  • check precision before validate signature
  • fix OrderCommitment::hash() logic: adding rounding