-
Couldn't load subscription status.
- Fork 4
Updates open short table #425
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| }); | ||
| }, | ||
| }), | ||
| columnHelper.accessor("hyperdriveAddress", { |
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 doesn't use the hyperdrive address, but an accessor string is required for the columnhelper.
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.
Curious where this comes from, can we not call it "currentValue"?
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.
Found the issue here, column helper has a display method that just renders whatever you want and you don't have to provide an accessor, which for us comes from OpenShort type.
| return ( | ||
| <> | ||
| {children({ showModal })} | ||
| {children && children({ showModal })} |
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.
total nit, but optional calling is nice here: {children?.()}
| header: `Size (hy${hyperdrive.baseToken.symbol})`, | ||
| cell: (bondAmount) => { | ||
| const bondAmountValue = bondAmount.getValue(); | ||
| return dnum.format([bondAmountValue, hyperdrive.baseToken.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.
minor: We can use our formatBalance() utility for this, it's meant to help keep the dnum dependency contained.
| }); | ||
| }, | ||
| }), | ||
| columnHelper.accessor("hyperdriveAddress", { |
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.
Curious where this comes from, can we not call it "currentValue"?
| }); | ||
| const currentValue = | ||
| baseAmountOut && | ||
| dnum.format( |
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.
Same here, formatBalance
| return ( | ||
| <tr | ||
| key={row.id} | ||
| className="h-16 cursor-pointer grid-cols-4 items-center text-sm text-base-content even:bg-secondary/5 md:text-h6" |
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.
Let's add a hover as well, daisy-hover should do it
| const { address: account } = useAccount(); | ||
| const readHyperdrive = useReadHyperdrive(hyperdrive.address); | ||
| const queryEnabled = !!readHyperdrive && !!account; | ||
| const { data: shorts } = useQuery({ | ||
| queryKey: makeQueryKey("shortPositions", { account }), | ||
| queryFn: queryEnabled | ||
| ? () => readHyperdrive?.getOpenShorts({ account }) | ||
| : undefined, | ||
| enabled: queryEnabled, | ||
| }); |
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.
Can we avoid the parent having to fetch all this data and move this into the OpenShortTable intead?
| }: OpenOrdersTableProps): ReactElement { | ||
| const tableInstance = useReactTable({ | ||
| columns: columns(hyperdrive), | ||
| data: shorts, |
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.
Seems like if we move the data fetching into this commponent, it'd be okay to use [] while shorts is still fetching, wyt?
This PR updates the open short table to use react-table. It implements 3 of the 5 columns that will ultimately be present for the trading competition. Those missing are hy-token price at open, and accrued yield. This also make the whole row clickable and removes the close position button in favor of the one on the modal.
