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

NTRN-188 refactor dex module keeper #400

Merged
merged 6 commits into from
Jan 25, 2024
Merged

NTRN-188 refactor dex module keeper #400

merged 6 commits into from
Jan 25, 2024

Conversation

quasisamurai
Copy link
Contributor

TASK

Get poolByID is currently inefficient.It currently makes an unnecessary call to k.GetPoolIDByParams as part of k.GetPool

This code should be refactored.

I also refactored InitPool & SetPool functions because I can

return types.NewPool(pairID, centerTickIndexNormalized, fee, poolID)
}

func (k Keeper) initializePoolMetadata(
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe move this to keeper/pool_metadata.go ?

@@ -85,7 +118,6 @@ func (k Keeper) GetPool(
case lowerTickFound && !upperTickFound:
upperTick = types.NewPoolReservesFromCounterpart(lowerTick)
case !lowerTickFound && !upperTickFound:
// Pool has already been initialized before so we can safely assume that pool creation doesn't throw an error
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just personal preference, but I like comments explaining why we chose to use a method that panics. Otherwise, it can look like a mistake to someone later.

return poolID
}

func (k Keeper) storePoolID(
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we call this storePoolIDRef? Seems a bit more clear.

pr0n00gler
pr0n00gler previously approved these changes Jan 14, 2024
@pr0n00gler pr0n00gler merged commit 6c65c3f into main Jan 25, 2024
8 checks passed
@pr0n00gler pr0n00gler deleted the chore/refactor-dex branch August 7, 2024 08:31
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