paritytech / cumulus

Write Parachains on Substrate
GNU General Public License v3.0
618 stars 378 forks source link

DEX pallet for the Statemint/Statemine #1226

Closed Mr-Leshiy closed 2 years ago

Mr-Leshiy commented 2 years ago

Is it ongoing plan to add or implement for the Statemint/Statemine blockchain some DEX pallet functionality to allow buy or sell some assets in the secure, transparent and trustless manner ? Or if it will be implemented by the community will be the chance to add it into the current Statemint/Statemine blockchain version.

joepetrowski commented 2 years ago

It's something that's been vaguely in the plan for Statemint for about a year, but on which I've had some second thoughts. DEXs naturally compete with each other and dilute assets. Adding another DEX in Statemint could be detrimental to ones on other parachains. In my opinion, we can harness the competitive nature of DEXs to still provide DEX capability within Statemint.

The idea I currently have in mind is a pallet that allows accounts to register their intent to acquire some asset with the intent to relinquish an unspecified amount of some other asset. DEXs on other parachains (or even just normal accounts) could then send offers to fulfill the demanded asset for a specified amount of the other. Multiple offers would compete, and the requester could choose the best one. This harnesses the competitive nature of DEXs, without diluting existing ones, and provides effectively zero-slippage means of acquisition.

There are various details to work out like how to hold offerers accountable for fulfillment and how long requests should live on-chain. I'm also still open to other ideas if someone thinks there is a better solution.

Mr-Leshiy commented 2 years ago

@joepetrowski , got it, thanks for the explanation. But what do you think also about the some DEX solution for the NFT from the uniques pallet ? To allow users create orders for sell and for others to accept this order and purchase a NFT asset, or even more sophisticated logic which is provided on the current NFT marketplace solutions.

xlc commented 2 years ago

I don't think we want common good parachains implements all the DeFi protocols. There are already many alternatives on other parachains. Maybe not all of them are on the same level of security, transparency, trustlessness but users should be able to evaluate and pick the one they want to use, instead demand a common good parachain for that.

joepetrowski commented 2 years ago

Sorry for the very slow responses here.

I still think that ideally application logic for exchanging NFTs should generally go into other parachains (the market should provide the best solution to application challenges, and Statemint should serve as the low-level primitives/repository for assets to live).

This is a bit challenging (if not impossible) with XCM v2, but v3 supports asset locking and an interface for dealing with uniques. It should be quite easy for multiple parachains to have applications that place a lock on a user's NFT in order to handle it in its application, and then send a batch( unlock(), transfer() ) as the result of some application logic.

joepetrowski commented 2 years ago

There are also quite a few improvements coming to the Uniques pallet. WIP PR here, although @jsidorenko mentioned to me that this may be superseded by another PR.

jsidorenko commented 2 years ago

In the next coming days, I'm planning to open a PR with the basic buy&sell methods for NFTs

Mr-Leshiy commented 2 years ago

Thanks for the answers, guys !

https://github.com/paritytech/substrate/pull/11217, great generally it is something that I am looking for. Is it going to be added into the Statemint ?

I still think that ideally application logic for exchanging NFTs should generally go into other parachains (the market should provide the best solution to application challenges, and Statemint should serve as the low-level primitives/repository for assets to live). This is a bit challenging (if not impossible) with XCM v2, but v3 supports asset locking and an interface for dealing with uniques. It should be quite easy for multiple parachains to have applications that place a lock on a user's NFT in order to handle it in its application, and then send a batch( unlock(), transfer() ) as the result of some application logic.

But doesn't mean with the said before that for the parachain would be much more appropriate to add uniques pallet into their own runtime and extend its functionality by their own, without usage of the Statemint/Statemine ? I don't want to say that Statemint should have all sophisticated logic but in case of some basic usage of the uniques assets as trading, seems more appropriate to add into the Statemint itself.

joepetrowski commented 2 years ago

It looks like @jsidorenko will put that into the Uniques pallet and then governance will decide :). I would definitely like to see more applications harness XCM, but if other parachain/application developers want this feature then I'm happy to include it.

Mr-Leshiy commented 2 years ago

Understood, thanks for discussion! Actually I don't have any questions. Do you I need to close this issue ?

joepetrowski commented 2 years ago

I can close it, but yeah good discussion! I actually mentioned the acquisition mechanism in this other issue, so it is something we're looking into. Some current work on governance includes significant changes to how the Treasury works so this would probably come after that gets added, but actually this pallet that I mentioned in the first comment here is something that could be worked on in parallel.

Polkadot-Forum commented 1 year ago

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/statemint-update-roadmap/1200/16

Polkadot-Forum commented 1 year ago

This issue has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/statemint-update-roadmap/1200/24