-
Notifications
You must be signed in to change notification settings - Fork 11
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
MIPX v1 - New json rpc method for swaps #25
Conversation
Probably worth referencing the related EIP as part of the MIP: https://github.com/tommasini/EIPs/blob/64090fe54761906fc9bde31ad46eb85230de5e8d/EIPS/eip-swap-rpc.md |
Thanks for the review @vandan |
Just sharing some initial thoughts: Is there anything that should be different or more explicit when a swap operation is triggered from a dapp rather than manually in the wallet UI? Can you add more detail to the Motivation section? It would help other developers to understand when and why they should use this method. I'm also curious about what transparency should be provided when something goes wrong. What errors might be returned to the requesting dapp? |
Please set this MIP as |
I assume this method would be limited to accepting ERC-20 tokens, right? Is there anything that should be considered for future flexibility? |
I do like |
Co-authored-by: Vandan <[email protected]>
@vandan @shanejonas Shane Jonas suggestion makes a lot of sense! We can use the same logic as we use on the send transaction rpc method, and use the account connected to the dapp, adding the In the other hand it would be nice to use the current screens with the swaps logic that already exist, what do you think if we ask the user to switch the selected account to account to the new Curious, what do you think it's the best name for the property,
I will add! Thanks!
|
|
Updated motivation section |
@vandan When you say ERC-20 tokens, are you excluding BEP-20 and main tokens? I don't see a reason why limit it to ERC-20 tokens |
Random thought since I'm hearing more about cross-chain DEXs recently. |
I was just thinking about that as well. Planning for some flexibility beyond ERC-20s makes sense to me as well. |
A potentially relevant proposal around chain identifiers from ChainAgnostic: https://github.com/ChainAgnostic/CAIPs/blob/main/CAIPs/caip-2.md |
Could this be made to work in a multichain setting (i.e. using CAIP addresses), or Ethereum only? |
@rekmarks Yes, it's totally be possible to be prepared for that! We could have it on the MIP as a future implementation, since on the mobile app the UI is not prepared for it yet, but when the multichain is implemented we can add this logic without breaking the default behaviour (that uses the network conected to the dapp as the default)
Nevertheless, this was discussed and we talked about making this json rpc because the purpose would be for in first implementation to only redirect to the swaps flow already implemented on the wallet, and not with bridging functionality associated to ship it quicker and test the adoption of it! We were thinking about shipping other json rpc method for bridging/ cross chain swaps when this ones were implemented and the adoption of the builders community was validated. Happy to know your thoughts around this! |
Thanks @tommasini, that sounds good. I mainly wanted to make sure that you guys had multichain in mind. Some notes about your proposed format, just for future reference:
|
MIPs/mip-x.md
Outdated
|
||
```markdown | ||
if (parseChainIdFromCaip10(fromToken.address) !== parseChainIdFromCaip10(toToken.address)) { | ||
throw rpcErrors.invalidParams( | ||
throw rpcErrors.methoddNotSupported( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the double d
in methodd
on purpose? confused since i see you made this change in two different places haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AHAHAHAHHA and I missed this error on two diff places XD
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This MIP generally looks good to me for committing as Status: Draft.
Co-authored-by: jiexi <[email protected]>
throw rpcErrors.invalidParams('Invalid caip-10 user address'); | ||
} | ||
|
||
try { | ||
parsedCaip10FromTokenAddress = parseCaip10Address( | ||
fromToken[0].address, | ||
); | ||
} catch (error) { | ||
throw rpcErrors.invalidParams('Invalid caip-10 fromToken address'); | ||
} | ||
|
||
try { | ||
parsedCaip10ToTokenAddress = parseCaip10Address(toToken.address); | ||
} catch (error) { | ||
throw rpcErrors.invalidParams('Invalid caip-10 toToken address'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe same here: caip-10
-> CAIP-10
? I know these are the actual error messages so maybe not...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section would be clearer in english instead of a try catch code example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few non blocking comments/requests! Ready for draft status for sure!
Co-authored-by: jiexi <[email protected]>
MIP for new json rpc method
wallet_swapAsset