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

Implement swaps in Solana #19474

Closed
bbondy opened this issue Nov 16, 2021 · 5 comments · Fixed by brave/brave-core#14298
Closed

Implement swaps in Solana #19474

bbondy opened this issue Nov 16, 2021 · 5 comments · Fixed by brave/brave-core#14298
Assignees
Labels
feature/web3/wallet/core feature/web3/wallet/solana feature/web3/wallet Integrating Ethereum+ wallet support OS/Android Fixes related to Android browser functionality OS/Desktop OS/iOS Fixes related to iOS browser functionality priority/P3 The next thing for us to work on. It'll ride the trains. QA Pass-Win64 QA/Yes release-notes/include

Comments

@bbondy
Copy link
Member

bbondy commented Nov 16, 2021

Possibly with https://docs.jup.ag/jupiter-api-beta/using-the-api-v1

@bbondy bbondy added priority/P3 The next thing for us to work on. It'll ride the trains. QA/No release-notes/exclude feature/web3/wallet Integrating Ethereum+ wallet support OS/Android Fixes related to Android browser functionality OS/Desktop feature/web3/wallet/solana labels Nov 16, 2021
@bbondy bbondy added feature/web3/wallet/core OS/iOS Fixes related to iOS browser functionality labels Mar 16, 2022
@aman-m1
Copy link

aman-m1 commented May 28, 2022

Any update/progress here @bbondy?

@bbondy
Copy link
Member Author

bbondy commented May 29, 2022

Finishing up on Dapps then I believe this is the next biggest Solana item.

@onyb
Copy link
Member

onyb commented May 31, 2022

Technical spec

Define mojom structs to model the following jup.ag response

Unlike 0x, Jupiter returns several routes in the data array, instead of a single route. The route object in the first index is the most cost-effective one, but we can expose all the other routes for presentational purpose.

⚠️ Amounts and prices in Jupiter are not represented as strings in the JSON response.

API to fetch a quote

This is equivalent to the /swap/v1/price endpoint of 0x API.

Example SOL -> USDC

API to build a transaction from a quote

This is equivalent to the /swap/v1/quote endpoint of 0x API.

POST https://quote-api.jup.ag/v1/swap
{
  route: routes[0],  // the route object to use
  userPublicKey: "foo" ,  // user public key to be used for the swap
  feeAccount: "xxxx"  // fees will be collected here
}

Response:
Depending on the route, the API will return between 1 to 3 transaction objects. At minimumm, swapTransaction will always be in the JSON response. The transactions must be signed and settled sequentially.

{
  setupTransaction: {...},
  swapTransaction: {...},
  cleanupTransaction: {...},
}

@onyb
Copy link
Member

onyb commented Aug 11, 2022

Test plan

  1. Test the swap flow on Solana network => demo video in Jupiter desktop integration for Solana swaps brave-core#14298.
  2. Check whether fees are received in https://solscan.io/account/8eekKfUAGSJbq3CdA2TmHb8tKuyzd5gtEas3MYAtXzrT.
  3. Check whether slippage settings can be changed.
  4. Check if UI displays "Insufficient liquidity" error for illiquid pairs. Ex, SOL -> wBAT
  5. Verify that 0x swap is free of regressions.

@srirambv
Copy link
Contributor

Verification passed on

Brave 1.44.97 Chromium: 106.0.5249.55 (Official Build) (64-bit)
Revision 4d5f098fca6ab7f4b6b7c240be3d9593c2357709-refs/branch-heads/5249@{#531}
OS Windows 11 Version 21H2 (Build 22000.978)
  • Verified test plan from #19474 (comment)
  • Verified Swap flow works as shown in PR
  • Verified able to successfully submit transaction for SOL -> USDC with Transaction 1/3 ,Transaction 2/3Transaction 3/3
  • Verified able to change slippage charge
  • Verified UI displays "Insufficient liquidity" error for illiquid pair SOL -> wBBTC
  • Verified able to Swap with 0x without issues BAT -> USDC
Confirmation Insufficient liquidity
image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/web3/wallet/core feature/web3/wallet/solana feature/web3/wallet Integrating Ethereum+ wallet support OS/Android Fixes related to Android browser functionality OS/Desktop OS/iOS Fixes related to iOS browser functionality priority/P3 The next thing for us to work on. It'll ride the trains. QA Pass-Win64 QA/Yes release-notes/include
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants