tdex-network / tdex-daemon

Go implementation of the TDEX Beta Daemon
https://tdex.network
MIT License
11 stars 13 forks source link

Allow fragmenting only one asset of the pair for already funded markets #524

Closed altafan closed 2 years ago

altafan commented 2 years ago

Before this, every market fragmentation required to send both assets to the fragmenter account. Now, this behavior is maintained only in case the market has zero balance, otherwise the operator is allowed to fragment funds of only one asset of the pair.

Please @tiero review this.

tiero commented 2 years ago

I was thinking that maybe we should allow unbalanced from the start maybe: ie. want to sell NFT or just sell one side of the pair? since we declare the asset hahses now should not be a problem?

Eventually if trader tries to buy the 0 valued side, it will simply get error of not enough liquidity.

What do you think?

tiero commented 2 years ago

It should be possible to deposit only one asset of the pair via deposit/claim

altafan commented 2 years ago

I think the daemon shouldn't behave like that until it supports UNBALANCED strategy.

Well the pluggable already works. For the BALANCED I understand that 0 can't work for x * y formula. Even if we had the unbalanced already, how would work? The daemon will make BALANCED not activable or simply we will return an error?, ie having a dependency between strategy and balances

altafan commented 2 years ago

Well the pluggable already works

Correct.

For the BALANCED I understand that 0 can't work for x * y formula. Even if we had the unbalanced already, how would work? The daemon will make BALANCED not activable or simply we will return an error?, ie having a dependency between strategy and balances

It would just be up to the user to change the strategy of the market BEFORE sending the splitting the funds sent to the fragmenter. After all, this is what the operator has to do also for a market with pluggable strategy.

I'm going to add a check to "enable" the behavior of the description ONLY for markets with balanced strategy.

All other strategies should always allow single asset fragmentations without such restrictions.

tiero commented 2 years ago

the user to change the strategy of the market BEFORE

But we should make sure this does not become footgun ie. when we verify the deposit in case of BALANCED strategy, we should alert user with a clear instruction what to do next: change the strategy and claim again should be able to recover for this situation.

Not clear if this is the current behavior

altafan commented 2 years ago

@tiero while increasing the verbosity of the error messages, I took the opportunity to address also other issues regarding marginal bugs:

altafan commented 2 years ago

@tiero I pushed a new commit 52dca41 in order to close #514.