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

Fetch openlongs from transfer single events #1157

Merged
merged 21 commits into from
Jun 7, 2024
Merged

Conversation

jackburrus
Copy link
Contributor

@jackburrus jackburrus commented Jun 7, 2024

This is the first in a series of PR's that migrates our openlongs table to fetch the data from transfer single events. This will be useful to show positions that have been transferred to a users wallet from another address. A few things to note:

  1. This creates two new functions inside ReadHyperdrive. The first fetches all longs received by a user, the second fetches the long details using the assetId. If the user received the long from an address other than the ZERO_ADDRESS the bond details can't be calculated.
  2. We should come up with a more scalable naming structure for some of these functions and types. This is what I have in mind: "[Status][PositionType]Position[Action]". For example: "OpenLongPositionReceived" or "OpenLongPositionSent". Curious your thoughts @DannyDelott.
  3. I will implement these readhyperdrive methods in the table in the next PR.

Copy link

changeset-bot bot commented Jun 7, 2024

⚠️ No Changeset found

Latest commit: 7e3b1a6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jun 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
hyperdrive-monorepo-hyperdrive-trading ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 7:24pm
hyperdrive-sepolia-production ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 7:24pm
hyperdrive-sepolia-staging ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 7:24pm
testnet-v1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2024 7:24pm
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
hyperdrive-js ⬜️ Ignored (Inspect) Visit Preview Jun 7, 2024 7:24pm
trading-competition ⬜️ Ignored (Inspect) Visit Preview Jun 7, 2024 7:24pm

Copy link
Contributor

@DannyDelott DannyDelott left a comment

Choose a reason for hiding this comment

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

Nice, What do you think about:

getOpenLongs and getOpenLongDetails as the two names? I feel like the word "Position" in there isn't clarifying anything

const allLongs = await readHyperdrive.getOpenLongPositions({
account,
});
allLongs.forEach(async (long) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: We should use Promise.all + Array.map for this, otherwise openLongPositionsReceived will be returned before the asynchronous operations inside the loop have finished.

@jackburrus
Copy link
Contributor Author

Nice, What do you think about:

getOpenLongs and getOpenLongDetails as the two names? I feel like the word "Position" in there isn't clarifying anything

Agreed, position doesn't add anything.

@jackburrus jackburrus deleted the jack-splits-open-long branch June 7, 2024 22:41
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.

2 participants