duality-labs / duality

Apache License 2.0
10 stars 5 forks source link

Simplify creator/receiever logic on limit orders #308

Closed jcompagni10 closed 1 year ago

jcompagni10 commented 1 year ago

Creator and receiver in Limit Orders - Receiver will receive shares from the creator. (We would suggest explaining this in the Concepts section of your GitBook)

When placing a Limit order: creator initiates the tx and places the deposit - but the LimitOrder is added for the receiver: trancheUser is created for the receiver code

When canceling a LO and withdrawing a filled LO: Limit orders are searched for a creator (in the moment of placing the Limit Order, this was receiver): Withdrawing: getting trancheUser for creator code Canceling: getting tranchUser for creator code and later when sending the calculated amount of shares to be withdrawn or canceled, the amount is sent to the “new” receiver: Withdrawing: send amount to the receiver code Canceling: send the amount to the receiver code

It is unclear: Whether the receiver that could differ from the creator should be defined in the moment of placing the order or It could be defined in the moment of withdrawals and cancellations? Who is in charge of initiating withdrawals and cancellations - by design? Update, from sync meeting: We have discussed the roots of this design-idea (the solidity contracts, and integration issues - where it is enabled to place limit orders in the name of another user). We concluded that, for current Duality implementation, this would be sufficient: PlaceLimitOrder - contains receiver and this will give us the explained feature needed (trancheUser will be the receiver), later for CancelLimitOrder and WithdrawFilledLimitOrder - there is no need to have the receiver propagated, since the initiator of the transaction should be the receiver. This would simplify current design.