[PAY-456] Add sagas for exchanging SOL to AUDIO#1651
Conversation
| inputUiAmount?: string | ||
| outputUiAmount?: string | ||
| quoteStatus: QuoteStatus | ||
| exchangeStatus: ExchangeStatus |
There was a problem hiding this comment.
arguably we'll only ever support an exchange from SOL => AUDIO, so this could potentially be a top level status and swaps can be quotes
There was a problem hiding this comment.
did this. lmk what think
| return `0x${addr.substring(2, 4)}...${addr.substr(addr.length - 5)}` | ||
| } | ||
|
|
||
| export const convertJSBIToUiString = (amount: JSBI, decimals: number) => { |
There was a problem hiding this comment.
this JSBI thing is a new one. I think it belongs here, but let me know if not
| @@ -0,0 +1,40 @@ | |||
| export type JupiterTokenListing = { | |||
There was a problem hiding this comment.
I might add a comment that these are copy/pasted from the results of getting the token listens via the Jupiter API. I figured they're not going to change, why query for them?
|
Preview this change https://demo.audius.co/mjp-cb-onramp-sagas |
dylanjeffers
left a comment
There was a problem hiding this comment.
wow really amazing job, prob makes sense for another monetization dev to review
| state.swaps[inputTokenSymbol][outputTokenSymbol].exchangeStatus = | ||
| ExchangeStatus.WAITING | ||
| }, | ||
| exchange: ( |
There was a problem hiding this comment.
i think this is fine, but would it be helpful to know what we are exchanging? seems like... exchanging tokens? i guess exchanging is fine, but yeah just thinkin
| state.swaps[inputTokenSymbol][outputTokenSymbol].exchangeStatus = | ||
| ExchangeStatus.FAILED | ||
| }, | ||
| quote: ( |
There was a problem hiding this comment.
RE: exchange and quote, I left these as verbs intentionally to differentiate from selectors or fetchers, and to indicate that they're more like commands than actions
|
|
||
| export default function sagas() { | ||
| return [watchQuote, watchExchange, watchExchangeAfterBalanceChange] | ||
| } |
There was a problem hiding this comment.
wildness, awesome job!
…ruction generation to AudiusBackend, used typed version of AudiusBackend
|
Preview this change https://demo.audius.co/mjp-cb-onramp-sagas |
|
Preview this change https://demo.audius.co/mjp-cb-onramp-sagas |
|
Preview this change https://demo.audius.co/mjp-cb-onramp-sagas |
sddioulde
left a comment
There was a problem hiding this comment.
looks great and pristine!
| "@fingerprintjs/fingerprintjs-pro": "3.5.6", | ||
| "@hcaptcha/react-hcaptcha": "0.3.6", | ||
| "@juggle/resize-observer": "^3.3.1", | ||
| "@jup-ag/core": "^2.0.0-beta.3", |
There was a problem hiding this comment.
should we drop the caret and use the exact version?
| "@reduxjs/toolkit": "1.3.4", | ||
| "@sentry/browser": "6.16.1", | ||
| "@sentry/integrations": "6.16.1", | ||
| "@solana/spl-token": "^0.1.6", |
There was a problem hiding this comment.
same comment as above regarding version
| transactionHandler | ||
| }) | ||
| const account = yield* select(getAccountUser) | ||
| if (!account?.userBank) { |
There was a problem hiding this comment.
maybe do this check in the first few lines of the function so we don't have to init TransactionHandler or call doSwap
| return `0x${addr.substring(2, 4)}...${addr.substr(addr.length - 5)}` | ||
| } | ||
|
|
||
| export const convertJSBIToUiString = (amount: JSBI, decimals: number) => { |
There was a problem hiding this comment.
Maybe a comment about what this is / why we need it?
| * @returns the result of the transaction handler handleTransaction call | ||
| */ | ||
| function* sendTransaction( | ||
| name: string, |
There was a problem hiding this comment.
nit: would be nice to have object args for this guy
|
Preview this change https://demo.audius.co/mjp-cb-onramp-sagas |
|
Superceded by #1666 |
Description
(don't worry, it's not actually as big as it looks - the 1k+ lines are from the package-lock.json)
Adds the sagas responsible for using the Jupiter Aggregator Core SDK to exchange a user's SOL for AUDIO. Uses the following actions:
ui/buy-audio/quote- get the quote to/from any pair ofUSDC (SPL),AUDIOorSOLui/buy-audio/exchange- exchange fromSOLtoAUDIOui/buy-audio/exchangeAfterBalanceChange- watches for a balance change in the user's wallet, thenputsaui/buy-audio/exchangeaction with the entire balance of the wallet less the min balance required for a swapDragons
Is there anything the reviewer should be on the lookout for? Are there any dangerous changes?
So, so many... ❗
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide repro instructions & any configuration.
Tested using some prototype UI w/ Coinbase Pay and the Redux dev tools. It works most of the time, though lately it isn't working due to potentially some state issue with my user wallet.
How will this change be monitored?
For features that are critical or could fail silently please describe the monitoring/alerting being added.
Feature Flags
Are all new features properly feature flagged? Describe added feature flags.
Completely uncalled from anywhere in code. Can add feature flags as an extra safety if wanted?