-
Notifications
You must be signed in to change notification settings - Fork 1
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
refetch short data on new block #1121
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
|
/> | ||
} | ||
disclaimer={(() => { | ||
if (traderDeposit && !!amountOfBondsToShortAsBigInt) { | ||
if (!amountOfBondsToShortAsBigInt) { |
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 had to reorganize this disclaimer, so i'm going to write out this ternary logic here just to double check my work.
- If the user has not input a short amount (!amountOfBondsToShortAsBigInt) -> don't show the disclaimer.
- If the user has input an amount, but that amount makes the hasEnoughLiquidity become falsy -> only show the pool limit exceeded note.
- In all other cases where the user has input an amount -> show the disclaimer, but ensure a skeleton is shown only on the stats that are being refetched on new blocks.
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 was super helpful. I think we should capture this in the code either by pulling the conditions out into nicely named variables and/or adding code comments.
@@ -68,7 +67,7 @@ export function OpenLongPreview({ | |||
<LabelValue | |||
label="You receive" | |||
value={ | |||
openLongPreviewStatus === "loading" ? ( | |||
openLongPreviewStatus === "loading" && long.bondAmount ? ( |
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 realized that if the user has not input an amount for longs, we want to show the default value.
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.
Hm, i'm curious why the preview status would be loading if there was no input amount. Are we not turning off the preview hook in this case?
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'll check it out because I was confused too. I console logged it and without any input the status was still 'loading'
if (traderDeposit && !!amountOfBondsToShortAsBigInt) { | ||
if (!amountOfBondsToShortAsBigInt) { | ||
return null; | ||
} else if (!!amountOfBondsToShortAsBigInt && !hasEnoughLiquidity) { |
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.
nit: no need for the else-if
/> | ||
} | ||
disclaimer={(() => { | ||
if (traderDeposit && !!amountOfBondsToShortAsBigInt) { | ||
if (!amountOfBondsToShortAsBigInt) { |
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 was super helpful. I think we should capture this in the code either by pulling the conditions out into nicely named variables and/or adding code comments.
Pool limit exceeded. Max short size is{" "} | ||
{formatBalance({ | ||
balance: maxBondsOut || 0n, | ||
decimals: hyperdrive.decimals, |
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.
nit: I see it was like this before, but while we're here can we add the missing places
and includeCommas
args to formatBalance?
hy{baseToken.symbol} | ||
</p> | ||
); | ||
} else { |
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.
nit: no need for the else
@@ -68,7 +67,7 @@ export function OpenLongPreview({ | |||
<LabelValue | |||
label="You receive" | |||
value={ | |||
openLongPreviewStatus === "loading" ? ( | |||
openLongPreviewStatus === "loading" && long.bondAmount ? ( |
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.
Hm, i'm curious why the preview status would be loading if there was no input amount. Are we not turning off the preview hook in this case?
This PR refetches the short preview data on new blocks. Below is a screenshot of what the 'fetching' state looks like on the preview.
![Screenshot 2024-05-31 at 3 24 18 PM](https://private-user-images.githubusercontent.com/22210106/335732545-aa54751d-ea5b-49a2-a4b5-13327e52e12a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzMzODksIm5iZiI6MTczOTA3MzA4OSwicGF0aCI6Ii8yMjIxMDEwNi8zMzU3MzI1NDUtYWE1NDc1MWQtZWE1Yi00OWEyLWE0YjUtMTMzMjdlNTJlMTJhLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAzNTEyOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNjZTMxMWUyODA1ZmVlYjJlNzI5ZmU5YzVmOTFjOGQzZjY5ZDg4Y2EzYzQ1YjUzMzBmMWMxMDUxNTM3MDJiZGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.IOX7et89ar8Er0Dxer9zvhw2PTfZgCcjtNIQLpzlveQ)