Skip to content

Duplicated scoring/sorting/risk logic across provider adapters #6

Description

@silicon-intern-ready

Problem

The functions scoreOpportunity, clamp, hashOpportunity/opportunityID, sortYield, and riskOrder are copy-pasted identically across three packages:

  • internal/providers/aave/client.go
  • internal/providers/morpho/client.go
  • internal/providers/defillama/client.go

This violates DRY and makes it easy for the implementations to drift. If the scoring formula or sort tiebreakers are updated in one provider but not the others, yield rankings will be inconsistent.

Suggested Fix

Extract shared yield scoring, sorting, and risk utilities into a common package (e.g., internal/providers/scoring/ or internal/yield/) and have all three adapters import from there.

Files Affected

  • internal/providers/aave/client.goscoreOpportunity, clamp, hashOpportunity, sortYield, riskOrder
  • internal/providers/morpho/client.go — same functions
  • internal/providers/defillama/client.go — same functions (named opportunityID instead of hashOpportunity)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions