Replies: 2 comments 1 reply
-
First, a rhetorical question: Q: What gives an ERC20 that represents a Cosmos token value? Now, your question:
The process is as follows:
This can be counterintuitive because people expect the DeployERC20 call to Ethereum to have been generated by the Cosmos module itself. However, this would be an unnecessary step. Now, to the actual values of those arguments. In an earlier version of Gravity, we tried to match "name", "symbol" and "decimals" to the Cosmos token's metadata. However, this was an unending source of trouble. There isn't a clean correspondence. In my opinion the Cosmos metadata format is bad. Is "Display" a full name, or is it a symbol? Is "Description" the full name, or is it a blurb or something? There's a whole array of possible denominations, which would need to be searched through with certain heuristics to find out which corresponds to the "decimals" field. Worst of all, there are no constraints or guidance on how Cosmos token creators set these fields. Also, on IBC tokens, IIRC most of this stuff isn't set at all. We have a very simple path when there is no metadata: name = Cosmos denom, symbol = "", decimals = 0. For an IBC token, this will result in an ERC20 with an IBC hashed denom as a name, and 0 decimals, leading to very large numbers being displayed. It will look like crap in most Ethereum wallets, but it is the only thing that can be done. Perhaps in the future, Ethereum wallets and apps can call some sort of endpoint to get the real name, decimals, and maybe symbol from Cosmos. You can read the procedure here: https://github.com/cosmos/gravity-bridge/blob/main/module/x/gravity/keeper/ethereum_event_handler.go#L91 |
Beta Was this translation helpful? Give feedback.
-
Thanks @okwme for writting this up! I just want to state that I believe this is entirely a UX problem. Specifically, a UX problem when receiving IBC assets. These assets do not have any metadata on chain unless they're added on the fly, which Umee and Somm do. However, they don't know what exponent(s) to use in the metadata. Hence, when those IBC assets are eventually bridged over to Ethereum, their decimal value by default will be zero and wallets will display very large values. |
Beta Was this translation helpful? Give feedback.
-
This is a topic that came up with @alexanderbez I wanted to highlight for the IBC team. It sounds like there may already be some solutions in place according to @jackzampolin. One thing I was struggling to understand is whether this is a UX problem or a state machine problem. The scenario is as follows:
The gravity bridge uses an ERC20 contract on ethereum to mint representations of Cosmos Coins on Ethereum. ERC20 has
string name
,string symbol
anduint256 decimals
as part of the on-chain metadata. Thedecimals
is used to render theuint256
with precision (Eth uses 18 decimals but it varies between ERC20s). Coin types in the Cosmos SDK include similar metadata likestring denom
anduint32 exponent
that provide the contents when deploying the ERC20 (this is wheredenom
=atom
andexponent
=6
). However when assets come over IBC they no longer have this metadata and so all IBC coins would be deployed withdecimal
(exponent
) =0
. Ethereum interfaces don't know to trace the asset back to Cosmos and then further via IBC.My biggest question is what is the process of deploying the ERC20 contract on Ethereum? Is this something that the validators come to consensus on and deploy somehow collectively? Is it single validator's responsibility? Is it a user's responsibility? Whoever actually deploys the contract might have the ability to trace the original IBC asset and get the relevant metadata, but it would happen outside the state machine. Not sure if that matters tho since I don't know that part of the process well enough.
Beta Was this translation helpful? Give feedback.
All reactions