fluidex / circuits

GNU Affero General Public License v3.0
10 stars 5 forks source link

AMOUNT signal can not be shared by spotTrade and other Tx #188

Closed noel2004 closed 2 years ago

noel2004 commented 2 years ago

Current both spotTrade and some other Tx like deposit / transfer all have used the AMOUNT signal:

This sharing of signal would cause issues when we have induced data availability because we need to send an number which has been encoded into 40bit to AMOUNT signal so it can be encoded into part of on-chain data.

However, the amount that order1 sending to order2 inside spotTrade tx may not always be able to being expressed with a 40bit encoded number. consider following case (suppose the prec. of token is 6):

  1. An order has put to sell with 40000.000000
  2. It has be spotted with an order which buy 99.999999, now the unfilled amount become 39900.000001
  3. It has be filled with another order, so in this spotTrade Tx, the amount would be 39900.000001, which has be exceed the 35bit significand

To resolve such issue we should include another signal (maybe just name it 'AMOUNT1') for recording the transfer amounts in a spotTrade Tx. The number inside this signal should NOT be encoded into 40bit float number.