-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: full wire-up #44
Conversation
04d40a9
to
e4984f7
Compare
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.
Fundamentally excellent. Nothing blocking considering we are still very much in WIP mode, but a number of comments to tackle either in this PR, or we can ticked for follow-ups.
In addition to the comments throughout the PR I noticed a few trivial things during functional testing:
- Error handling needed (e.g. invalid address for ChainId causing a
400
etc) - Disable "Start transaction" when form not ready
- Center "To get this" skeleton
- The assets on the
/status
page (whilst waiting for a deposit) need to show the chainId/logo (I was super confused trying to remember if my quote was for Arbitrum ETH or Mainnet ETH) - We need a way to get back to the asset selection page after doing a swap, so the user can do another swap after their wonderful experience!
return fromBaseUnit(quote.egressAmountNative, buyAsset.precision) | ||
}, [quote?.egressAmountNative, buyAsset]) | ||
|
||
const rate = useMemo(() => { |
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 might be missing something, but it's not clear to me why we need market data at all here.
We seem to use it to calculate the rate, but we already get that for free on the quote (estimatedPrice
).
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.
Indeed we are, nice catch! Base implementation before wiring up cf data used Coingecko for rate... With that being said, I don't think we really need it anymore, the only time we will default to it would be:
- In empty state
![image](https://private-user-images.githubusercontent.com/17035424/411487362-2ae8174b-2c6b-4ee6-ac47-04605fedefd7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODU2MjgsIm5iZiI6MTczOTI4NTMyOCwicGF0aCI6Ii8xNzAzNTQyNC80MTE0ODczNjItMmFlODE3NGItMmM2Yi00ZWU2LWFjNDctMDQ2MDVmZWRlZmQ3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE0NDg0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTcxNzIwYWQ5MjIyMjlhYTIxZGY4OWYzOWU4ODQ1YjE1NGMyZDcxN2Q4ZDVhODNjY2ZmMzliMzYzYmRlMDkxZjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.l9cOmCeU1v_LOjWQZj3FWnePUeQrGLYegbsyZmIa8zA)
- In an invalid sell amount state
![image](https://private-user-images.githubusercontent.com/17035424/411487569-66ef7945-35ad-4901-9e40-05ae6b0102c9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyODU2MjgsIm5iZiI6MTczOTI4NTMyOCwicGF0aCI6Ii8xNzAzNTQyNC80MTE0ODc1NjktNjZlZjc5NDUtMzVhZC00OTAxLTllNDAtMDVhZTZiMDEwMmM5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDE0NDg0OFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIzMTNhMjFhOWExODc2NzQ2ZTZjYjk4MWFhMzY4ZTI1YWY4YTM2ZGM4YjBmZGFiM2ZiOWFkYjBkN2JiNDI5MTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.KXD95O9foG-UC-B2icepcRGkyqfSgANjwHpD_yyRfJk)
I think both of these can and should be solved by proper empty states 🙏🏽
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.
- Removal of rate consumption a915749
https://jam.dev/c/8afd03e3-5c14-46eb-bc27-4e8f972fafb0
- Hide rate when no quote and animate 0256fcf
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.
FYI @0xApotheosis the queries still exist as we do need rate still for summing up various fees as USD in status route, but they're now fully removed in the input one!
og/src/components/Status/Status.tsx
Lines 307 to 344 in 8c0a9fd
// Collect feeAssetIds | |
const feeAssetIds = useMemo(() => { | |
if (!quote?.includedFees) return [] | |
return [ | |
...new Set( | |
quote.includedFees | |
.filter(fee => fee.type !== 'broker') | |
.map(fee => chainflipToAssetId[fee.asset]) | |
.filter(Boolean), | |
), | |
] | |
}, [quote?.includedFees]) | |
// Ensure we have market-data for all fee assets so we can sum em up | |
const feeMarketData = useQueries({ | |
queries: feeAssetIds.map(assetId => ({ | |
...reactQueries.marketData.byAssetId(assetId), | |
})), | |
}) | |
// And finally, do sum em up | |
const protocolFeesFiat = useMemo(() => { | |
if (!quote?.includedFees) return '0' | |
return quote.includedFees | |
.filter(fee => fee.type !== 'broker') | |
.reduce((total, fee) => { | |
const assetId = chainflipToAssetId[fee.asset] | |
if (!assetId) return total | |
const marketData = feeMarketData[feeAssetIds.indexOf(assetId)]?.data | |
if (marketData?.price) { | |
return total.plus(bnOrZero(fee.amount).times(marketData.price)) | |
} | |
return total | |
}, bnOrZero(0)) | |
.toString() | |
}, [quote?.includedFees, feeMarketData, feeAssetIds]) |
Description
Baseline:
🇵🇱 :
Issue