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

BE-636-get-incentive | Pool Incentive helper method #576

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

deividaspetraitis
Copy link
Collaborator

@deividaspetraitis deividaspetraitis commented Dec 2, 2024

This PR represents a smaller, more focused part of bigger PR #553 implementing sorting, filtering, pagination and search functionality for /pools endpoint. For bigger implementation picture refer to mentioned PR and for more context please refer to BE-636.

This PR adds Incentive helper method for Pool computing and returning its incentive type used for WithMarketIncentives filter.

Summary by CodeRabbit

  • New Features

    • Introduced an IncentiveType field to enhance the MockRoutablePool functionality.
    • Added an Incentive() method to retrieve incentive types based on APR data in the PoolI interface and its implementation.
  • Bug Fixes

    • Improved handling of incentive types to ensure accurate returns based on APR conditions.

Adds Incentive helper method for Pool computing and returning its
incentive type.
@deividaspetraitis deividaspetraitis self-assigned this Dec 2, 2024
Copy link

sonarqubecloud bot commented Dec 2, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

Copy link
Contributor

coderabbitai bot commented Dec 2, 2024

Walkthrough

The pull request introduces changes to enhance the MockRoutablePool struct and the PoolI interface by adding a new field and method related to incentives. In domain/mocks/pool_mock.go, a field IncentiveType is added to the struct, along with a method to retrieve its value. Similarly, in sqsdomain/pools.go, the Incentive() method is added to the PoolI interface and its implementation in PoolWrapper, determining the incentive type based on APR data. Import statements are also updated in both files.

Changes

File Path Change Summary
domain/mocks/pool_mock.go - Added field: IncentiveType api.IncentiveType in MockRoutablePool struct.
- Added method: func (mp *MockRoutablePool) Incentive() api.IncentiveType.
- Updated import statements to include the new api package and reorganized dependencies.
sqsdomain/pools.go - Added method: Incentive() api.IncentiveType in PoolI interface.
- Added method: func (p *PoolWrapper) Incentive() api.IncentiveType.
- Modified import statements, including a new path for the api package and reordered others.

Possibly related PRs

  • BE-648 | Test pools: include 0 liquidity pools #562: The changes in this PR involve modifications to pool data retrieval, which may indirectly relate to the incentive functionality introduced in the main PR, but there is no direct connection to the Incentive() method or the MockRoutablePool struct.

Suggested labels

A:backport/v27.x

Suggested reviewers

  • cryptomatictrader
  • p0mvn

Poem

🐰 In the fields where bunnies play,
New incentives hop into the fray!
With pools that gleam and numbers bright,
We gather data, oh what a sight!
A little change, a joyful cheer,
For every hop, the rewards draw near! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (4)
sqsdomain/pools.go (3)

51-52: Enhance method documentation

The documentation comment could be more descriptive by including details about possible return values and their significance.

-	// Incentive returns the incentive type for the pool
+	// Incentive returns the incentive type for the pool based on APR data.
+	// Returns one of:
+	// - IncentiveType_SUPERFLUID: If pool has non-zero SuperfluidAPR
+	// - IncentiveType_OSMOSIS: If pool has non-zero OsmosisAPR
+	// - IncentiveType_BOOST: If pool has non-zero BoostAPR
+	// - IncentiveType_NONE: If no APR values are set

230-250: Add nil check and document priority order

The implementation is clean but could benefit from two improvements:

  1. Add a nil check for APR data
  2. Document the priority order of incentive types
 // Incentive implements PoolI.
 func (p *PoolWrapper) Incentive() api.IncentiveType {
 	apr := p.GetAPRData()
+	// If APR data is not available, return NONE
+	if apr.Status.Error != nil {
+		return api.IncentiveType_NONE
+	}
 
+	// Check APR ranges in priority order:
+	// 1. Superfluid
+	// 2. Osmosis
+	// 3. Boost
 	checks := []struct {
 		apr       sqspassthroughdomain.PoolDataRange
 		incentive api.IncentiveType

12-17: Format imports using goimports

The import statements need to be formatted according to the standard Go import grouping.

Run goimports on the file to automatically organize imports into groups:

  1. Standard library
  2. External packages
  3. Internal packages
domain/mocks/pool_mock.go (1)

Line range hint 256-270: Add IncentiveType to deepCopyPool

The deepCopyPool function should include the new IncentiveType field to ensure complete pool copies.

 return &MockRoutablePool{
 	ID:               mp.ID,
 	Denoms:           newDenoms,
 	PoolLiquidityCap: newPoolLiquidityCap,
 	PoolType:         mp.PoolType,
+	IncentiveType:    mp.IncentiveType,
 
 	// Note these are not deep copied.
 	ChainPoolModel: mp.ChainPoolModel,
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f80d793 and 53c1e8c.

⛔ Files ignored due to path filters (1)
  • sqsdomain/pools_test.go is excluded by !**/*_test.go
📒 Files selected for processing (2)
  • domain/mocks/pool_mock.go (3 hunks)
  • sqsdomain/pools.go (3 hunks)
🧰 Additional context used
🪛 golangci-lint (1.62.2)
sqsdomain/pools.go

229-229: File is not goimports-ed

(goimports)

🔇 Additional comments (2)
domain/mocks/pool_mock.go (2)

36-36: LGTM!

The IncentiveType field is correctly added to support the new interface method.


182-184: LGTM!

The implementation correctly returns the mock value, suitable for testing purposes.

@deividaspetraitis deividaspetraitis merged commit 40e4a6e into v27.x Dec 2, 2024
8 of 9 checks passed
@deividaspetraitis deividaspetraitis deleted the BE-636-get-incentive branch December 2, 2024 07:24
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