tdex-network / tdex-daemon

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

Trade protocol: Add a GET /market/price #668

Closed tiero closed 1 year ago

tiero commented 1 year ago

We should introduce a new method on the public Trader interface that returns the current spot price, how much 1 unit of the base is worth in quote, and the minimum amount needed to be bought/sold for it.

All strategies should return these two datas under the hood.

This will allow clients (ie. tdex app or tdex analytics) to fetch spot price for any possible trading pair combination, regardless of different precisions.

This requires a change to trade protocol and the TDEX specs, although in NOT a breaking change since clients are (ab)using the /trade/preview for the purpose of knowing the spot price of a market

altafan commented 1 year ago

All strategies should return these two datas under the hood.

Strategies already implement an API for the spot price but it's basically not used in the rest of the codebase, therefore adding this should be straightforward.

IMO, to support the min traded amount, it's more correct to add new fields to the market domain rather than making changes to the formula interface. It's something related to a market more than it is to a strategy.

But beside that, shall we make this info required for opening a market? Otherwise, what should a client do in case a market's min traded amount is 0 when it fetches the spot price?

tiero commented 1 year ago

It's something related to a market more than it is to a strategy.

Yes but I mean this public API should return both, the spot price and his minAmount (most of the time should be 1)

shall we make this info required for opening a market?

Ideally, we should calculate and infer based on the precision of the assets given when creating a market

tiero commented 1 year ago

A new method in the trade protocol was added https://github.com/tdex-network/tdex-protobuf/pull/73

A PR for the tdex daemon is currently being reviewed https://github.com/tdex-network/tdex-daemon/pull/669

It's not breaking change, eventually we will have it in tdex-analytics as well

altafan commented 1 year ago

closed by #669.