Skip to content

Integration earn appraoch, unify stake+yield#928

Open
gemdev111 wants to merge 1 commit intoyielderfrom
yielder+earn
Open

Integration earn appraoch, unify stake+yield#928
gemdev111 wants to merge 1 commit intoyielderfrom
yielder+earn

Conversation

@gemdev111
Copy link
Contributor

@gemdev111 gemdev111 commented Feb 5, 2026

Stake, mappers in progress. deprecation mark for now

@gemdev111 gemdev111 self-assigned this Feb 5, 2026
@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 5, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  crates/yielder/src/lib.rs  64% smaller
  crates/primitives/src/lib.rs  42% smaller
  crates/yielder/src/provider.rs  40% smaller
  crates/yielder/src/models.rs  28% smaller
  crates/yielder/src/yo/provider.rs  26% smaller
  crates/primitives/src/earn_position.rs  13% smaller
  crates/primitives/src/delegation.rs  0% smaller
  crates/primitives/src/earn_action.rs  0% smaller
  crates/primitives/src/earn_data.rs  0% smaller
  crates/primitives/src/earn_position_base.rs  0% smaller
  crates/primitives/src/earn_provider.rs  0% smaller
  gemstone/src/gem_yielder/mod.rs  0% smaller
  gemstone/src/gem_yielder/remote_types.rs  0% smaller
  gemstone/src/models/earn.rs  0% smaller
  gemstone/src/models/mod.rs  0% smaller

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gemdev111, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request undertakes a significant architectural refactoring to unify the concepts of staking and yielding into a cohesive 'earn' system. It introduces a set of new, more generic data structures, such as EarnPositionBase and a generalized EarnProvider, designed to handle various earning mechanisms consistently. Concurrently, older, more specific types related to delegation and earn actions are being deprecated, with clear migration paths established through new type definitions and conversion traits across the primitives, yielder, and gemstone crates. The goal is to create a more robust and extensible foundation for future earning-related features.

Highlights

  • Unified Earn Approach: Introduced a new, unified 'earn' framework to consolidate staking and yield functionalities under common data structures, improving consistency and extensibility.
  • Deprecation of Legacy Types: Existing types like Delegation, EarnAction, and EarnData have been marked as deprecated, guiding developers towards the new, generalized Earn types.
  • Refactored Earn Position and Provider Models: The EarnPosition struct now composes a new EarnPositionBase for core data, and EarnProvider has been generalized into a struct capable of representing both stake and yield providers via EarnProviderType.
  • UFFI Compatibility for New Earn Types: New UFFI-compatible GemEarn types have been introduced in the gemstone crate, mirroring the core primitives changes for cross-language interoperability.
  • Migration Paths for Deprecated Types: Explicit From trait implementations have been added to facilitate the conversion from deprecated Delegation types to their new Earn counterparts.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crates/primitives/src/delegation.rs
    • Added imports for EarnPositionBase, EarnPositionState, EarnProvider, and EarnProviderType.
    • Marked Delegation, DelegationBase, DelegationValidator, and DelegationState as deprecated, suggesting new Earn types.
    • Implemented From trait for converting DelegationState to EarnPositionState, DelegationBase to EarnPositionBase, and DelegationValidator to EarnProvider.
  • crates/primitives/src/earn_action.rs
    • Marked EarnAction as deprecated, recommending EarnYieldType.
    • Introduced a new EarnYieldType enum with Deposit and Withdraw variants, including a provider_id.
  • crates/primitives/src/earn_data.rs
    • Marked EarnData as deprecated, suggesting the use of transaction-specific data.
  • crates/primitives/src/earn_position.rs
    • Refactored EarnPosition struct to embed EarnPositionBase and simplify its fields, removing direct BigInt usage.
  • crates/primitives/src/earn_position_base.rs
    • Added a new file defining EarnPositionState enum and EarnPositionBase struct for common earn position data.
  • crates/primitives/src/earn_provider.rs
    • Renamed the old EarnProvider enum to YieldProvider.
    • Introduced a new EarnProviderType enum (Stake, Yield).
    • Defined a new EarnProvider struct to represent both stake and yield providers, including new_stake and new_yield constructor methods.
  • crates/primitives/src/lib.rs
    • Updated pub use statements to export the new EarnProvider, EarnProviderType, YieldProvider, EarnPositionBase, EarnPositionState, and EarnYieldType.
    • Added pub mod earn_position_base;.
  • crates/yielder/src/lib.rs
    • Updated pub use statements to expose EarnPositionBase instead of YieldPosition.
  • crates/yielder/src/models.rs
    • Removed direct primitives imports for EarnPosition and EarnProvider.
    • Added pub use statements for primitives::YieldProvider and primitives::EarnPositionBase.
    • Removed YieldProvider and YieldPosition type aliases.
  • crates/yielder/src/provider.rs
    • Updated YieldProviderClient and Yielder traits/implementations to use EarnPositionBase for position-related methods.
  • crates/yielder/src/yo/provider.rs
    • Updated imports to use BigUint, EarnPositionBase, EarnPositionState.
    • Modified the positions method to return and construct EarnPositionBase instead of YieldPosition.
  • gemstone/src/gem_yielder/mod.rs
    • Updated method signatures to use GemYieldProvider and GemEarnPositionBase.
  • gemstone/src/gem_yielder/remote_types.rs
    • Removed GemEarnPosition type alias and record definition.
    • Renamed GemEarnProvider to GemYieldProvider and updated its usage.
    • Added pub use for new GemEarnPositionBase, GemEarnPositionState, GemEarnProvider, GemEarnProviderType from gemstone::models::earn.
  • gemstone/src/models/earn.rs
    • Added a new file defining UFFI-compatible GemEarnProviderType, GemEarnProvider, GemEarnPositionState, GemEarnPositionBase, and GemEarnYieldType.
  • gemstone/src/models/mod.rs
    • Added pub mod earn; and pub use earn::*; to expose the new earn models.
Activity
  • The author is actively working on integrating staking functionalities into the new unified earn approach, with deprecation markers already in place for older structures.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant and well-structured refactoring to unify staking and yielding functionalities under a common 'earn' abstraction. New types like EarnPosition, EarnPositionBase, and EarnProvider are introduced, and existing Delegation types are deprecated and mapped to these new structures using From implementations. The changes are consistently applied across the primitives, yielder, and gemstone crates. The new structure is cleaner and improves separation of concerns. I have one minor suggestion for code clarity.

rewards: BigUint::ZERO,
unlock_date: None,
position_id: format!("{}-{}", self.provider(), request.asset_id),
provider_id: self.provider().to_string(),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To improve clarity and avoid calling self.provider() twice (once on line 120 inside format! and again here), you could store its string representation in a variable before this block.

For example:

let provider_id = self.provider().to_string();
Ok(EarnPositionBase {
    // ... other fields
    position_id: format!("{}-{}", provider_id, request.asset_id),
    provider_id,
})

AwaitingWithdrawal,
}

impl From<DelegationState> for EarnPositionState {
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need two states? if they are the same

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