Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSP-22: Fungible Token standard (WASM ERC20) adoption process #25

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

0xMarkian
Copy link

Hey there!
to all stakeholders of the ERC20 like standard, in the WASM ecosystem. Creating PR to have a space for the discussion of this standard.

At this point in time standard has already passed Draft state and was merged in Call for Feedback status. Accepted is the next stage.

The Supercolony team will be leading the process of adoption. We are going to involve every meaningful stakeholder we know so that this standard is built fully and nothing is missed. We will update this PR with any change that will be agreed upon here or in any other channel.

@Noc2 @alxs @cmichi @athei guys thanks for your support so far! Will continue to expect it going further.

Please do invite WASM ERC20 stakeholders to that space!

@yuelipeng
Copy link

Great work. Patract also second this proposal.

@cmichi
Copy link
Contributor

cmichi commented Sep 23, 2021

Maybe FYI: paritytech/substrate#9757, low-level traits to expose ERC-20-like information about assets in Substrate's pallet-assets are about to be merged.

@PierreOssun
Copy link
Contributor

Hello there,

During the last two months, we contacted every team & project that will benefit from this PSP. All of them agreed on the content as well as the urge to have such standards.

I want to thank everyone who took the time to participate in building this standard with us!

We are ready to merge the PR
@Noc2 @FlorianFranzen

@hskang9
Copy link
Contributor

hskang9 commented Dec 19, 2021

Hello @xgreenx did you try to wrap pallet-assets to wasm ERC20? I suggest to add one =)

@hskang9
Copy link
Contributor

hskang9 commented Dec 19, 2021

If pallet-assets is going to manage polkadot assets with xcm support and wasm ERC20 has no existing infrastructure, why do we need polkadot wasm ERC20 to support? =)

Should I propose another way of token standard that is compatible with interoperability? =)

@xgreenx
Copy link
Contributor

xgreenx commented Dec 19, 2021

Hello @xgreenx did you try to wrap pallet-assets to wasm ERC20? I suggest to add one =)

Hi, yes, it can be implemented with a combination of chain-extension from pallet-contract and pallet-asset. But it is only MVP. Later we will create a thread related to that=)

@hskang9
Copy link
Contributor

hskang9 commented Dec 19, 2021

If pallet-assets is going to manage polkadot assets with xcm support and wasm ERC20 has no existing infrastructure, why do we need polkadot wasm ERC20 to support? =)

Should I propose another way of token standard that is compatible with interoperability? =)

I want to hear an answer for this =)

@hskang9
Copy link
Contributor

hskang9 commented Dec 19, 2021

Hello @xgreenx did you try to wrap pallet-assets to wasm ERC20? I suggest to add one =)

Hi, yes, it can be implemented with a combination of chain-extension from pallet-contract and pallet-asset. But it is only MVP. Later we will create a thread related to that=)

I think you should edit your proposal for support =)

@xgreenx
Copy link
Contributor

xgreenx commented Dec 19, 2021

If pallet-assets is going to manage polkadot assets with xcm support and wasm ERC20 has no existing infrastructure, why do we need polkadot wasm ERC20 to support? =)

Should I propose another way of token standard that is compatible with interoperability? =)

PSP22(wasm ERC20) is needed to define the interface between contracts on the pallet-contract level. Under the hood, it can be implemented via pallet-asset. But the interface is agnostic to implementation. So developers can work with PSP22 and don't worry how it is implemented(via pallet-asset or natively on contract-pallet).

I want to hear an answer for this =)

Answer on what?=) Could you specify your question, please?

I think you should edit your proposal for support =)

For support of what? If you mean support of pallet-asset, then it is not needed. Because it is only implementation, the interface should be agnostic to implementation.

@hskang9
Copy link
Contributor

hskang9 commented Dec 19, 2021

@Noc2 I vote for reconsideration of proposal on wasm ERC20. When Statemint is connected to Polkadot ecosystem, I think pallet-asset is being the primitives of interchain ecosystem. However, the contract of wasm ERC20 is rather limiting what pallet can do in the ecosystem.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 19, 2021

@Noc2 I vote for reconsideration of proposal on wasm ERC20. When Statemint is connected to Polkadot ecosystem, I think pallet-asset is being the primitives of interchain ecosystem. However, the contract of wasm ERC20 is rather limiting what pallet can do in the ecosystem.

How is it limiting pallet-asset, could you describe it, please? PSP22 is only an interface to interact with fungible tokens. It can be implemented via 'pallet-asset` or it can be implemented on contract's level.

The developer of the contract may specify on the contract level the logic of how to mint/burn tokens in the pallet-asset. When that it is not possible via 'pallet-asset'. It is why we have a separate interface on the contract level to hide the implementation.

It doesn't limit the pallet-asset. It only adds the same interface between all contracts to unify a cross-contract communication.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

PSP22 interface limitspallet-assets's other functions, such as mint and burn. @xgreenx I am sure you know what is missing for other functions right now.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

Why are you not adding other pallet-assets functions? why are there functions only for transfer when you can include other functions from pallet-assets as you referred in #30? PSP22 should fully support pallet-assets functions unless they have their own state within a runtime or run in separate runtime, but I see no state specification nor separation. PSP22 is the one contract should implement all interfaces to pallet-assets function for the compatibility.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 20, 2021

PSP22 interface does not support pallet-assets's other functions, such as mint and burn. @xgreenx I am sure you know what is missing for other functions right now.

mint and burn are optional methods of the contract. In most cases, they are used by the owner of the contract to mint and burn tokens. It is not part of cross-contact communication, because contracts don't worry about that method. If you want to mint or burn from another contract, it means that you have permission to do that. If you have permissions, it means that you are an owner of the code of the token. So you know how that contract works and you don't need the standard to communicate with your contract.

Could you describe which other functions do we need to support during cross-contract communication, please?

why are there functions only for transfer when you can include other functions from pallet-assets as you referred in #30?

All public functions mentioned in that comment are supported in that PSP.

PSP22 should fully support pallet-assets functions unless they have their own state within a runtime or run in separate runtime, but I see no state specification nor separation. PSP22 is the one contract should implement all interfaces to pallet-assets function for the compatibility.

The interface contains only methods used during cross-contract communication. Methods like destroy, create, mint, burn and etc are used only by the owner, not by other contracts.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

To add points:

  • Current wasm ERC20 does not support specifications nor interface of xcm-transfer, looking forward to see cross chain communication too.
  • Also for backward compatibility, How do you make it compatible with wasm ERC20 without pallet-asset integration and with integration? Do you have a wrapper that registers the wasm ERC20 into pallet-assets data for compatibility? I think this will cause a lot of chaos in the polkadot ecosystem and raise concerns as polkadot wasm dapp projects wants to go interchain ecosystem.
  • If PSP22 has its own balance state and does not provide Feeless support as referred in Polkadot's native asset, Is there a plan for PSP22 to support feeless infrastructure? For example, cosmwasm in Terra supports multiple fee structure with multiple coins.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

I do not plan to add V2 contract over this and would like to hear your plans first so that I can help according to your design.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 20, 2021

Current wasm ERC20 does not support specifications nor interface of xcm-transfer, looking forward to see cross chain communication too.

PSP22 is an interface that describes how contracts can communicate with each other on the contract layer. That interface is agnostic to implementation.
Also, it is agnostic to XCM, because XCM is done on the pallet-asset layer. If PSP22 is implemented via pallet-asset it supports XCM by default. Because XCM teleports tokens from one parachain to another, so it mints them on the pallet-asset level. If PSP22 implemented via pallet-asset, then PSP22::balance_of will return the balance of account from the pallet-asset.

Also for backward compatibility, How do you make it compatible with wasm ERC20 without pallet-asset integration and with integration? Do you have a wrapper that registers the wasm ERC20 into pallet-assets data for compatibility? I think this will cause a lot of chaos in the polkadot ecosystem and raise concerns as polkadot wasm dapp projects wants to go interchain ecosystem.

If someone created PSP22 without pallet-asset then he can easily migrate to the wrapper. A wrapper is a contract that implements the PSP22 interface + two additional methods to deposit tokens and withdraw them. That wrapper will be implemented via pallet-asset, so any user can move his tokens from the contract layer to the pallet-asset level.

We don't need a separate logic that will register these wrappers. They are self-sufficient.

If PSP22 has its own balance state and does not provide Feeless support as referred in Polkadot's native asset, Is there a plan for PSP22 to support feeless infrastructure? For example, cosmwasm in Terra supports multiple fee structure with multiple coins.

If PSP22 is implemented without pallet-asset, then the cost of usage depends on the spent gas. If PSP22 is implemented via pallet-asset, then the cost of the usage will be equal to the weight of calling host functions from pallet-contract. I don't think that the weight of the host function will be much more than the direct calling of the method from pallet-asset.

I do not plan to add V2 contract over this and would like to hear your plans first so that I can help according to your design.

If you see how we can improve the PSP22, we are happy to discuss that!=)

@Noc2
Copy link
Collaborator

Noc2 commented Dec 20, 2021

Sorry, I’m currently on vacation and haven’t read the complete discussion. I just want to add that ideally asset balances should be held in pallet_assets in the future and not in contract storage as far as I know.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 20, 2021

Sorry, I’m currently on vacation and haven’t read the complete discussion. I just want to add that ideally asset balances should be held in pallet_assets in the future and not in contract storage as far as I know.

It is exactly what we plan to do!=) Everything will be stored in the pallet-asset layer. The wrapper will only call the methods of the pallet.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

Current agnostic interface does not specify pallet-assets layer support. If you think that all assets in smart contract balance state should be in pallet-asset layer, I think you at least need asset id allocated in your contract state to identify balance state in pallet-assets layer.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

Also, I think you also need to add a balanceOf function and specify how an asset balance is retrieved in pallet-asset layer. Will the asset identifier be global across parachains? Or has its own identifier per each parachain?

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

If PSP22 is implemented without pallet-asset, then the cost of usage depends on the spent gas. If PSP22 is implemented via pallet-asset, then the cost of the usage will be equal to the weight of calling host functions from pallet-contract. I don't think that the weight of the host function will be much more than the direct calling of the method from pallet-asset.

Using a smart contract is all about composability. Also using pallet-assets gives the asset balance to be used as gas fee. It still brings much better composability with feeless architecture.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

PSP22 has the compatible interface of using all contract assets in the ecosystem, and it would be great if pallet asset layer support is specified in order to be future proof and provide interoperability.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 20, 2021

Current agnostic interface does not specify pallet-assets layer support.

It is why that PSP is agnostic=) We don't need to specify that.

If you think that all assets in smart contract balance state should be in pallet-asset layer, I think you at least need asset id allocated in your contract state to identify balance state in the module.

Don't go to extremes=) But let's rephrase to: Everything information related to the token will be stored in the pallet-asset layer.

Also, I think you also need to add a balanceOf function and specify how an asset balance is retrieved in pallet-asset layer.

We don't need to specify it, because it is nuances of implementation, not interface.

Will the asset identifier be global across parachains? Or has its own identifier per each parachain?

The creator of the wrapper should specify the asset id during the instantiation of the contract. How to select asset id? If you don't need cross-chain compatibility, then the id should be unique only for parachain. If you want the support of cross-chain compatibility(XCM, for example), then you should use the id from the Statemint parachain.
For better understanding, you can check the wiki.

Using a smart contract is all about composability. Also using pallet-assets gives the asset balance to be used as gas fee. It still brings much better composability with feeless architecture.

In the case of a smart contract, the user pays by native token of the parachain that executes that contract.

PSP22 has the compatible interface of using all contract assets in the ecosystem, and it would be great if pallet asset layer support is specified in order to be future proof and provide interoperability.

We plan to implement PSP22 via pallet-asset in the scope of the 7th milestone of the OpenBrush. If you are worring is that possible to implement, it is possible=) You can read about chain_extension of the pallet-contract. It allow you to interact with substrate -> with other pallets.

During 7th milestone we will provide an implementation of that chain extension and will create a PSP with detailed description of the flow and implementation.

@hskang9
Copy link
Contributor

hskang9 commented Dec 20, 2021

Agnostic interface does not support details in pallet-asset layer compatibility, but I see your quote that it will operate with pallet-asset layer. Maybe it is better to have a separate proposal if you persist on defining interface here for now.

The creator of the wrapper should specify the asset id during the instantiation of the contract. How to select asset id? If you don't need cross-chain compatibility, then the id should be unique only for parachain. If you want the support of cross-chain compatibility(XCM, for example), then you should use the id from the Statemint parachain.
For better understanding, you can check the wiki.

Wrapper standard is missing. Any ideas for adding this proposal?

In the case of a smart contract, the user pays by native token of the parachain that executes that contract.

This is not true in feeless architecture where runtime module can adjust weights and paying asset with the code. Check Karura for example.

We plan to implement PSP22 via pallet-asset in the scope of the 7th milestone of the OpenBrush. If you are worring is that possible to implement, it is possible=) You can read about chain_extension of the pallet-contract. It allow you to interact with substrate -> with other pallets.

The problem is in compatibility, not feasibility. Current proposal has unspecified interface for one possibility where asset identifiers are different in each parachain. I think there should be more than one interface related with pallet-asset layer for resolving different asset identifiers in the 7th milestone.

Do you also think that more generic term to describe PSP22 is needed as it definitely has more features which is not from token? I do think the term “wasm ERC20” is effective, but the term may considered different as feeless architecture starts to take place in polkadot ecosystem.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 21, 2021

Agnostic interface does not support details in pallet-asset layer compatibility, but I see your quote that it will operate with pallet-asset layer. Maybe it is better to have a separate proposal if you persist on defining interface here for now.

I said that PSP22 can be implemented via pallet-asset=) Because PSP22 is designed to be agnostic to the implementation. It is why we don't need to include any details related to pallet-asset.

Wrapper standard is missing. Any ideas for adding this proposal?

The wrapper is an implementation of PSP22 via pallet-asset. It doesn't require standardization, because it still is PSP22.

This is not true in feeless architecture where runtime module can adjust weights and paying asset with the code. Check Karura for example.

Could you elaborate more on that, please? Maybe you can provide the link in the documentation of Karura.

The problem is in compatibility, not feasibility. Current proposal has unspecified interface for one possibility where asset identifiers are different in each parachain. I think there should be more than one interface related with pallet-asset layer for resolving different asset identifiers.

That proposal is not about the compatibility of fungible tokens between different parachains. That proposal is about the definition of the functionality of fungible token across contracts layer of the one parachain.

The interface is agnostic to the implementation. But implementation can use pallet-asset under the hood and it allows to have the compatibility of fungible tokens between different parachains.

asset identifiers are different in each parachain

That affects the instantiation process of the wrapper contract. It is part of workflow and part of pallet-asset. It should be resolved on another layer, not on the contract layer. By yes, better to create a proposal with a standardization of the flow for that.

Do you also think that more generic term to describe PSP22 is needed as it definitely has more features which is not from token? I do think the term “wasm ERC20” is effective, but the term may considered different as feeless architecture starts to take place in polkadot ecosystem.

"WASM ERC20" is mentioned in the name of the pull request to highlight that it is an adaptation of Erc20 in terms of contract-pallet. It is needed to introduce the reader to the context of the PSP. In the PSP we described the differences between Erc20 and PSP22.

@hskang9
Copy link
Contributor

hskang9 commented Dec 21, 2021

The wrapper is an implementation of PSP22 via pallet-asset. It doesn't require standardization, because it still is PSP22.

What if your implementation of PSP22 uses account-balance state within a contract? That is PSP22, but it is not an implementation of PSP22 via pallet-asset. PSP22 provides a unified way to operate fungible assets in smart contract, but it is still an ambiguous standard that currently provides confusion in the contract ecosystem when it comes to pallet-asset related interface and state. Do you have a wrapper standard to connect each PSP22 with different state architecture? Wrapper can be needed for PSP22 without pallet-asset state if they want to be integrated with xcmp standard. Otherwise, the token’s presence is limited to its deployed parachain even when native xcm support is available. This should be necessary if you plan to ship the codes in production before 7th milestone for backward compatibility.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 21, 2021

What if your implementation of PSP22 uses account-balance state within a contract? That is PSP22, but it is not an implementation of PSP22 via pallet-asset. PSP22 provides a unified way to operate fungible assets in smart contract, but it is still an ambiguous standard that currently provides confusion in the contract ecosystem when it comes to pallet-asset related interface and state. Do you have a wrapper standard to connect each PSP22 with different state architecture? Wrapper can be needed for PSP22 without pallet-asset state if they want to be integrated with xcmp standard. Otherwise, the token’s presence is limited to its deployed parachain even when native xcm support is available. This should be necessary if you plan to ship the codes in production before 7th milestone for backward compatibility.

PSP22 is an interface and it doesn't depend on the implementation. When your call PSP22::balance_of it should return the balance of the account. That balance can be stored in the contract state or in the pallet-asset state, it is not important. The same with PSP22::transfer. After transfer, the sender's balance should decrease and the receiver's balance should increase. How that state changed(in contract or in pallet-asset), is not important.
The different state architecture doesn't affect interface and doesn't affect cross-contract communication. The wrapper is still PSP22. The owner of PSP22 with the state in the contract can instantiate a wrapper, that is also PSP22 but with the state in the pallet-asset. And if someone wants to use XCM, he will deposit his tokens to the wrapper and send an XCM message.

Both contracts are PSP22 and it doesn't affect cross-contract communication. We don't need an additional interface for the wrapper=)

@hskang9
Copy link
Contributor

hskang9 commented Dec 21, 2021

I agree wrapper should not be included in PSP22, but it needs a standard to lower the contract development barrier. However, it is clear PSP22 interfaces are affected if pallet-asset is applied. I think each PSP22 should be able to display its different state architecture and asset id registered in each parachain. This requires a new interface for identification whether PSP22's state architecture and asset id in each parachain. Otherwise, the interface may end up executing arbitrarily without considering difference, resulting in sending wrong tokens or face an error when sending PSP22 tokens which has state within its contract.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 21, 2021

I agree wrapper should not be included in PSP22, but it needs a standard to lower the contract development barrier.

The OpenBrush will provide the implementation of PSP22 via pallet-asset. It is part of the 7th milestone.

I think each PSP22 should be able to display its different state architecture and asset id registered in each parachain. This requires a new interface for identification whether PSP22's state architecture and asset id in each parachain.

We also thought about that. And I agree, that maybe some contracts want to know is that PSP22 is integrated with pallet-asset, or not(At the moment I can't come up with the example of that usage, but who knows). For that, in the future, we can create an extension for PSP22 that will help to identify the architecture and some additional information needed for developers(like AssetId).

Later(when XCM and flow for cross-chains communication will be ready) we will create a discussion(maybe a proposal) with our thoughts about that question and we hope that the community will help us to identify: do they need that extension or not and the list of methods that should be in that extension.

Otherwise, the interface may end up executing arbitrarily without considering difference, resulting in sending wrong tokens or face an error when sending PSP22 tokens which has state within its contract.

Maybe you can provide an idea of the contract that can face the problem? In the future that can be a good base for discussion about the extension=)

@hskang9
Copy link
Contributor

hskang9 commented Dec 22, 2021

Maybe you can provide an idea of the contract that can face the problem? In the future that can be a good base for discussion about the extension=)

So you confirm that the interface is not thoroughly considered for interoperability between parachains. In a dex where it supports multiple PSP22s in multiple parachains, A dex needs to know how a token is stored in a user's unit of an account. As PSP22s does not display asset id, A dex does not know how an input token is stored in a user's account. In addition, an asset without designated identifier between parachains can create double-spending attack as contract address does not differentiate tokens anymore. another PSP22 can claim to be existing PSP22 in a different parachain even with the different contract address, because the interface does not care its identification between parachains at all. By having a so-called agnostic or arbitrary interface can bring up irresponsibility and security attacks. It would be interesting to see if PSP22 turns out to be fraudulent by its design because anyone can identify other tokens as same in different chains because the interface claims to be agnostic without on-chain comparison.

@xgreenx
Copy link
Contributor

xgreenx commented Dec 22, 2021

So you confirm that the interface is not thoroughly considered for interoperability between parachains.

I confirmed, that someone maybe want to know the information about the realization of the contract. For example, you are asking about that feature now=)

In a dex where it supports multiple PSP22s in multiple parachains, A dex needs to know how a token is stored in a user's unit of an account. As PSP22s does not display asset id, A dex does not know how an input token is stored in a user's account. In addition, an asset without designated identifier between parachains can create double-spending attack as contract address does not differentiate tokens anymore. another PSP22 can claim to be existing PSP22 in a different parachain even with the different contract address, because the interface does not care its identification between parachains at all. By having a so-called agnostic or arbitrary interface can bring up irresponsibility and security attacks. It would be interesting to see if PSP22 turns out to be fraudulent by its design because anyone can identify other tokens as same in different chains because the interface claims to be agnostic without on-chain comparison.

First of all, you can't create truly cross-parachain DEX on smart contracts. Because it still is a transfer of tokens in pallet-asset of one parachain. Maybe in the future, we will be able to send XCM from smart contracts directly, but it is still a separate step in cross-parachain communication(first you do an exchange of tokens in the scope of one parachain after that you can try to teleport them into another parachain). BTW, it is bad idea to send XCM from smart contract, because smart-contract can't know is that XCM was executed successfully or not.

In most cases DEX on the smart contracts is AMM. It contains pools of liquidity for some tokens. If tokens from that pool are malicious, nobody will use that. You always can create a pair to trade/swap/exchange fake tokens.
That problem is usually handled by UI. The token should be not from the blacklist or should have big liquidity(otherwise UI shows a warning). In the case of the Polkadot, the UI can also check that token is connected to Statemint(Because it means that someone locked 100 DOT to create that token and it is more trusted). Statemint has a list of reservations of amounts for each parachain of some Asset. So we can check that Asset from Statemint is connected to Asset from parachain and Asset from parachain connected to the contract defined in the pair. To get AssetId of the contract UI can use event from pallet-asset. Or, the contract may provide that information by self: The contract can emit an event on creation with AssetId(on contract level) or it can have a method to get AssetId.
But it is still not cross-contract communication. The DEX doesn't use that information to do swaps.

Maybe you have another example or you can find an issue with that?

@hskang9
Copy link
Contributor

hskang9 commented Dec 22, 2021

First of all, you can't create truly cross-parachain DEX on smart contracts. Because it still is a transfer of tokens in pallet-asset of one parachain. Maybe in the future, we will be able to send XCM from smart contracts directly, but it is still a separate step in cross-parachain communication(first you do an exchange of tokens in the scope of one parachain after that you can try to teleport them into another parachain). BTW, it is bad idea to send XCM from smart contract, because smart-contract can't know is that XCM was executed successfully or not.

Yes you can with wrapped assets from different chains and xcmp. Check market solutions out there and try not to isolate yourself, and the transaction involves transfers of tokens in different pallet-asset of multiple parachains through xcm. Other parachains also have access to one chain and create fake tokens without permission.

In most cases DEX on the smart contracts is AMM. It contains pools of liquidity for some tokens. If tokens from that pool are malicious, nobody will use that. You always can create a pair to trade/swap/exchange fake tokens.
That problem is usually handled by UI. The token should be not from the blacklist or should have big liquidity(otherwise UI shows a warning). In the case of the Polkadot, the UI can also check that token is connected to Statemint(Because it means that someone locked 100 DOT to create that token and it is more trusted). Statemint has a list of reservations of amounts for each parachain of some Asset. So we can check that Asset from Statemint is connected to Asset from parachain and Asset from parachain connected to the contract defined in the pair. To get AssetId of the contract UI can use event from pallet-asset. Or, the contract may provide that information by self: The contract can emit an event on creation with AssetId(on contract level) or it can have a method to get AssetId.
But it is still not cross-contract communication. The DEX doesn't use that information to do swaps.

Do you know how AMM works? Are you seriously saying that dex is not cross-contract communication when it needs to transfer output token to the sender using swap? what kind of codebase are you referring to for a dex?

In the case of the Polkadot, the UI can also check that token is connected to Statemint(Because it means that someone locked 100 DOT to create that token and it is more trusted). Statemint has a list of reservations of amounts for each parachain of some Asset. So we can check that Asset from Statemint is connected to Asset from parachain and Asset from parachain connected to the contract defined in the pair. To get AssetId of the contract UI can use event from pallet-asset. Or, the contract may provide that information by self: The contract can emit an event on creation with AssetId(on contract level) or it can have a method to get AssetId.

Oh so a UI has to wait for an event to check if a contract address is pointing to an asset id that user is looking for in Statemint when the asset data may reside in other parachain's pallet-asset. This is really efficient way to check, isn't it? When a DEX can keep a default token list where listing projects claim their token on Github and then verify before making a pair(or let scammers make rug pull pair) through its interface, don't you think it is better working this way as this is the way how most DEXes work? It would be so interesting for dex team to just trust the project team to list their tokens because they claim they connected to a certain asset id but have no way to check in the contract.

Maybe you have another example or you can find an issue with that?

You just isolate yourself in your own code and defy all those wrapped assets and bridge solutions, even xcmp. I cannot convince you to think until you try to realize your situation.

BTW, it is bad idea to send XCM from smart contract, because smart-contract can't know is that XCM was executed successfully or not.

Then why does xcm have error message? Why was XCM made in the first place?

@xgreenx
Copy link
Contributor

xgreenx commented Dec 22, 2021

Yes you can with wrapped assets from different chains and xcmp. Check market solutions out there and try not to isolate yourself, and the transaction involves transfers of tokens in different pallet-asset of multiple parachains through xcm. Other parachains also have access to one chain and create fake tokens without permission.

You just isolate yourself in your own code and defy all those wrapped assets and bridge solutions, even xcmp. I cannot convince you to think until you try to realize your situation.

Could you be more constructive and less aggressive, please?=) Could you provide the link to the documentation of the solution that provides multi-chain liquidity (that means that the price of the pair is based on the combined liquidity of pairs from several parachain. Tha is fully cross-chain DEX)? I only know about solutions that allow transfer tokens between parachains. But it is not fully cross-chain DEX, because you do a swap of tokens in the scope of one parachain, and after, you transfer those tokens to another parachain(I mentioned that kind of solutions in my previous message).

Do you know how AMM works? Are you seriously saying that dex is not cross-contract communication when it needs to transfer output token to the sender using swap? what kind of codebase are you referring to for a dex?

You misunderstood me. You and I are talking in that message about not trusted implementation of fungible tokens and that it can affect the DEX to cause security issues. DEX doesn't check is that trusted PSP22/Erc20 or not. It only does a swap(To do a swap we need PSP22). To use pair or not, decides community and proper UI helps them with that question. Please re-read your message and after, re-read my answer.

Oh so a UI has to wait for an event to check if a contract address is pointing to an asset id that user is looking for in Statemint when the asset data may reside in other parachain's pallet-asset. This is really efficient way to check, isn't it? When a DEX can keep a default token list where listing projects claim their token on Github and then verify before making a pair(or let scammers make rug pull pair) through its interface, don't you think it is better working this way as this is the way how most DEXes work? It would be so interesting for dex team to just trust the project team to list their tokens because they claim they connected to a certain asset id but have no way to check in the contract.

UI doesn't wait for events... UI is using some indexer to get data(for example you can check the solution in Ethereum - Graph Node). It is way how most DApps UI works.

DEX can keep that information, the DEXs team decides the flow of pair creation. But if DEXs team manages that list, that means that this solution is not permissionless.

Could you provide an example of the DEX that does an audit of the created pair? Uniswap and Suchiswap allow everyone to create any pair without audit.

Then why does xcm have error message? Why was XCM made in the first place?

Did you check how XCM is propagated to the destination parachain? The message should be sent to Statemint and after it will be sent to destination parachain. The problem is that it is different blocks when a contract is executed in the scope of one block. The contract can only send an XCM, but the contract can't get the response at the same block because XCM is asynchronous by the concept.

@hskang9
Copy link
Contributor

hskang9 commented Dec 25, 2021

UI doesn't wait for events... UI is using some indexer to get data(for example you can check the solution in Ethereum - Graph Node). It is way how most DApps UI works.

So you expect dapp developers run graph node that is not realized yet just for getting information about a contract? This is just harder than EVM smart contract development. What is the advantage of using wasm then when compared to evm with precompiles on native related functionalities? You are just leveraging previous works without even considering why it appeared, whether the infrastructure exists, and the technical costs to build it. It is just unbelievable that you put a step in this smart contract standard in Polkadot to be "just another smart contract" with "just another" existing UI infrastructure that has not been appeared instead of solving how to make builders develop and contribute to Polkadot's native codebase. You are just making ripoffs without even considering thoroughly about previous works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants