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

Feat/new open positions #1731

Merged
merged 155 commits into from
Jan 29, 2025
Merged

Feat/new open positions #1731

merged 155 commits into from
Jan 29, 2025

Conversation

tokdaniel
Copy link
Collaborator

Summary of Changes

Test Data or Screenshots

By submitting this pull request, you are confirming the following to be true:
  • I have reviewed the Contribution Guidelines.
  • I have performed a self-review of my own code.
  • I have updated my repository to match the master at IndexCoop/index-app.
  • I have included test data or screenshots that prove my fix is effective or that my feature works.

Copy link
Collaborator

@0xonramp 0xonramp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM-few smol questions

const pnlPercentage = (pnl / cost) * 100
const sign = Math.sign(pnl)

const entryPrice = data.trade.underlyingAssetUnitPrice ?? 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious, when will this be null-ish? Asking because the entry price/return will show much higher than it is if it does happen to be null-ish

Copy link
Collaborator Author

@tokdaniel tokdaniel Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well technically never, but accoring to the database it can be nullish, and if memory serves this has to do with how prisma types are produced based on the database structure, and then in turn zod types from prisma. Prisma doesnt support a bunch of things weirdly. So in turn this will appear in the types being optional as well. Although I don't like to use afterbang, as I feel like better safe than sorry :D

An example where it could be nullish btw, if for some reason we can't fetch the current eth price, but saving the trade still shouldn't break. Mega edgecase-y

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense - thanks for the explanation 👍

@@ -8,6 +10,7 @@ const UserMetadataContext =
export const UserMetadataProvider = UserMetadataContext.Provider

export const useUserMetadata = () => {
useRefId()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this line do? (return value not being used- seems like a side effect or just unused line?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the value is not being used, but as soon as you arrive, if there is an utm_source, we save that immediately to localstorage. I found this is the best place to do it.

@@ -8,6 +8,10 @@ export default {
darkMode: 'selector',
theme: {
extend: {
screens: {
xs: '475px',
lgn: '1080px',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's lgn for here? seems very close to the default tailwind breakpoint

Copy link
Collaborator Author

@tokdaniel tokdaniel Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in my mind in made sense to name it like this :D but i know its not intuitive. It stands for lg-narrowed, and it is close to the actual lg. But the actual lg proved too broad, between 1024 - 1200something. So I added this for a little fine-tuning. Its hard to deal with columns when we want to show everything.

@@ -43,7 +43,7 @@ export const useQueryParams = <T extends Partial<UseQueryParamsArgs>>(
const sell = searchParams.get('sell') || ''

const queryNetwork =
chains.find((chain) => chain.id === network)?.id ?? chainId ?? 1
chains.find((chain) => chain.id === network)?.id ?? chainId
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe to remove?

Copy link
Collaborator Author

@tokdaniel tokdaniel Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the reason is that useNetwork handles this case, but we already sent 1 if there is no queryParam, which is wrong. This was actually the reason why nothing loaded, when the network queryparam was there, it always tried to load ethereum

@tokdaniel tokdaniel merged commit e16dfd7 into master Jan 29, 2025
3 checks passed
@tokdaniel tokdaniel deleted the feat/new-open-positions branch January 29, 2025 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants