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

Order pools on Dashboard by Investment Capacity #325

Merged
merged 6 commits into from
Aug 17, 2021

Conversation

onnovisser
Copy link
Collaborator

@onnovisser onnovisser commented Aug 10, 2021

Now hides the pool list until the data from the subgraph and multicall have been fetched, because it needs the additional data to sort and otherwise the pools in the list jump around when it eventually gets sorted

Closes #322

@onnovisser onnovisser requested a review from hieronx August 11, 2021 07:15
@github-actions
Copy link

github-actions bot commented Aug 11, 2021

🚀 Deployed on https://pr-325--dev-tinlake.netlify.app

@onnovisser onnovisser requested review from jpangelle and removed request for hieronx August 16, 2021 08:27
Comment on lines 218 to 224
const updatesPerPool: any = {}
Object.entries(multicallData).forEach(([type, value]) => {
const poolId = type.split('.')[0]
const key = type.split('.')[1]
if (!(poolId in updatesPerPool)) updatesPerPool[poolId] = {}
updatesPerPool[poolId][key] = value
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I was toying around with reduce so that this can be a "pure" operation rather than declaring an object with any and then adding stuff to it. Do you think this any better?

const updatesPerPool = Object.entries(multicallData).reduce(
  (updates, [type, value]) => {
    const [poolId, key] = type.split('.');

    if (!(poolId in updates)) {
      updates[poolId] = {};
    }

    updates[poolId][key] = value;

    return updates;
  },
  {},
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nice yeah would be better. Updated! Still needed any inside the loop though but at least the result is typed better now.

const updatesPerPool: { [key: string]: State } = Object.entries(multicallData).reduce(
        (updates: any, [type, value]) => {
          const [poolId, key] = type.split('.')

          if (!(poolId in updates)) {
            updates[poolId] = {}
          }

          updates[poolId][key] = value

          return updates
        },
        {}
      )

Copy link
Contributor

@jpangelle jpangelle left a comment

Choose a reason for hiding this comment

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

one comment, no blockers 👍

@onnovisser onnovisser merged commit ba8c451 into main Aug 17, 2021
@onnovisser onnovisser deleted the sort-pools-by-capacity branch August 17, 2021 08:05
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.

Order pools on Dashboard by Investment Capacity
2 participants