Skip to content

Core yielder#962

Draft
gemdev111 wants to merge 4 commits intomainfrom
core-yielder
Draft

Core yielder#962
gemdev111 wants to merge 4 commits intomainfrom
core-yielder

Conversation

@gemdev111
Copy link
Contributor

No description provided.

gemdev111 and others added 3 commits February 17, 2026 00:51
- New types: EarnProviderType, YieldProvider, EarnType, EarnTransaction, EarnData
- Add provider_type field to DelegationValidator
- Add earn field to Balance
- Add EarnDeposit/EarnWithdraw transaction types
- Add Earn variant to TransactionInputType
- Add earn_data to TransactionLoadMetadata::Evm
- Update gemstone FFI remote types and conversions
Handle Earn input type in get_transaction_params and get_extra_fee_gas_limit
(preload_mapper), preserve earn_data in map_transaction_load (preload), and
add get_earn_data stub on GemGateway for future yielder integration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@semanticdiff-com
Copy link

semanticdiff-com bot commented Feb 19, 2026

Review changes with  SemanticDiff

Changed Files
File Status
  crates/gem_cosmos/src/provider/preload_mapper.rs  84% smaller
  crates/gem_solana/src/provider/preload_mapper.rs  84% smaller
  crates/gem_sui/src/provider/preload_mapper.rs  80% smaller
  crates/primitives/src/transaction.rs  68% smaller
  crates/primitives/src/lib.rs  15% smaller
  gemstone/src/models/transaction.rs  10% smaller
  crates/gem_aptos/src/rpc/client.rs  3% smaller
  apps/daemon/src/pusher/pusher.rs  2% smaller
  crates/gem_sui/src/provider/staking_mapper.rs  1% smaller
  crates/gem_tron/src/provider/staking_mapper.rs  1% smaller
  crates/gem_hypercore/src/signer/core_signer.rs  1% smaller
  gemstone/src/models/stake.rs  1% smaller
  crates/gem_evm/src/provider/preload_mapper.rs  1% smaller
  crates/gem_aptos/src/provider/staking_mapper.rs  0% smaller
  crates/gem_cosmos/src/provider/staking_mapper.rs  0% smaller
  crates/gem_evm/src/provider/staking_ethereum.rs  0% smaller
  crates/gem_evm/src/provider/staking_monad.rs  0% smaller
  crates/gem_evm/src/provider/staking_smartchain.rs  0% smaller
  crates/gem_hypercore/src/provider/staking_mapper.rs  0% smaller
  crates/gem_solana/src/provider/staking_mapper.rs  0% smaller
  crates/gem_tron/src/provider/balances_mapper.rs  0% smaller
  crates/gem_tron/src/provider/preload_mapper.rs  0% smaller
  crates/primitives/src/asset_balance.rs  0% smaller
  crates/primitives/src/delegation.rs  0% smaller
  crates/primitives/src/earn_data.rs  0% smaller
  crates/primitives/src/earn_provider_type.rs  0% smaller
  crates/primitives/src/earn_transaction.rs  0% smaller
  crates/primitives/src/earn_type.rs  0% smaller
  crates/primitives/src/testkit/delegation_mock.rs  0% smaller
  crates/primitives/src/transaction_input_type.rs  0% smaller
  crates/primitives/src/transaction_type.rs  0% smaller
  crates/primitives/src/yield_provider.rs  0% smaller
  gemstone/src/gateway/mod.rs  0% smaller
  gemstone/src/models/balance.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 introduces foundational support for 'Earn' functionality across the platform, distinguishing it from existing 'Stake' operations. It involves adding new data structures and transaction types to represent earn deposits and withdrawals, updating core balance and transaction metadata, and integrating these changes into various blockchain providers. The modifications ensure that the system can properly categorize, process, and track yield-generating activities, setting the stage for future expansion of earn features.

Highlights

  • Introduction of 'Earn' Functionality: New types and enums have been introduced to support 'Earn' operations, including EarnData, EarnType, EarnProviderType, EarnTransaction, and YieldProvider. This establishes a distinct framework for yield-generating activities separate from traditional staking.
  • Transaction Type Expansion: The TransactionType enum has been extended with EarnDeposit and EarnWithdraw variants, and TransactionInputType now includes an Earn variant to categorize these new operations. This ensures proper classification and handling of earn-related transactions throughout the system.
  • Balance and Metadata Updates: The Balance struct in primitives now includes an earn field to track earned assets, and TransactionLoadMetadata::Evm has been updated to incorporate earn_data. This allows for comprehensive tracking and metadata association for earn activities.
  • Cross-Chain Provider Integration: Various chain-specific providers (Aptos, Cosmos, EVM, Hypercore, Solana, Sui, Tron) have been updated to recognize and handle the new Earn transaction input type and to assign EarnProviderType::Stake to existing staking validators, laying the groundwork for broader earn support.
  • Gateway API Expansion: The GemGateway has been extended with placeholder methods (get_earn_data, get_earn_providers, get_earn_positions) to expose the new earn functionality through the API, preparing for client-side integration.

🧠 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
  • apps/daemon/src/pusher/pusher.rs
    • Extended TransactionType matching to include EarnDeposit and EarnWithdraw.
  • crates/gem_aptos/src/provider/staking_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_aptos/src/rpc/client.rs
    • Added TransactionInputType::Earn to the unimplemented!() gas estimation logic.
  • crates/gem_cosmos/src/provider/preload_mapper.rs
    • Included TransactionInputType::Earn in get_fee and get_gas_limit match arms for various chains.
  • crates/gem_cosmos/src/provider/staking_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_evm/src/provider/preload.rs
    • Modified TransactionLoadMetadata::Evm handling to include earn_data when processing TransactionInputType::Earn.
  • crates/gem_evm/src/provider/preload_mapper.rs
    • Initialized earn_data to None in TransactionLoadMetadata::Evm.
    • Implemented get_transaction_params logic for TransactionInputType::Earn to extract contract address, call data, and handle approvals.
    • Added get_extra_fee_gas_limit logic for TransactionInputType::Earn to retrieve gas limits from earn_data.
    • Assigned EarnProviderType::Stake to DelegationValidator instances in tests.
  • crates/gem_evm/src/provider/staking_ethereum.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_evm/src/provider/staking_monad.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_evm/src/provider/staking_smartchain.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_hypercore/src/provider/staking_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_hypercore/src/signer/core_signer.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to DelegationValidator instances in tests.
  • crates/gem_solana/src/provider/preload_mapper.rs
    • Included TransactionInputType::Earn in get_gas_limit and get_multiple_of match arms.
  • crates/gem_solana/src/provider/staking_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_sui/src/provider/preload_mapper.rs
    • Included TransactionInputType::Earn in get_gas_limit match arm.
  • crates/gem_sui/src/provider/staking_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/gem_tron/src/provider/balances_mapper.rs
    • Added earn field initialized to 0u32 in new_stake_balance.
  • crates/gem_tron/src/provider/preload_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to DelegationValidator instances in tests.
  • crates/gem_tron/src/provider/staking_mapper.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mapped DelegationValidator instances.
  • crates/primitives/src/asset_balance.rs
    • Added earn field to the Balance struct.
    • Implemented new_earn constructor for AssetBalance.
    • Initialized the new earn field to 0u32 in existing Balance constructors.
  • crates/primitives/src/delegation.rs
    • Imported EarnProviderType.
    • Added provider_type: EarnProviderType field to DelegationValidator struct.
  • crates/primitives/src/earn_data.rs
    • Added new file defining the EarnData struct for earn transaction details.
  • crates/primitives/src/earn_provider_type.rs
    • Added new file defining the EarnProviderType enum (Stake, Earn).
  • crates/primitives/src/earn_transaction.rs
    • Added new file defining the EarnTransaction struct.
  • crates/primitives/src/earn_type.rs
    • Added new file defining the EarnType enum (Deposit, Withdraw).
  • crates/primitives/src/lib.rs
    • Updated module imports and re-exports to include new earn related modules and reordered stake_type.
  • crates/primitives/src/testkit/delegation_mock.rs
    • Imported EarnProviderType.
    • Assigned EarnProviderType::Stake to mocked DelegationValidator instances.
  • crates/primitives/src/transaction.rs
    • Included EarnDeposit and EarnWithdraw in get_asset_ids and get_asset_addresses match arms.
  • crates/primitives/src/transaction_input_type.rs
    • Imported EarnType.
    • Added Earn(Asset, EarnType) variant to TransactionInputType enum.
    • Updated get_asset, get_asset_id, and get_transaction_type methods to handle the new Earn variant.
  • crates/primitives/src/transaction_load_metadata.rs
    • Imported EarnData.
    • Added earn_data: Option<EarnData> field to TransactionLoadMetadata::Evm variant.
  • crates/primitives/src/transaction_type.rs
    • Added EarnDeposit and EarnWithdraw variants to the TransactionType enum.
  • crates/primitives/src/yield_provider.rs
    • Added new file defining the YieldProvider enum (Yo).
  • gemstone/src/gateway/mod.rs
    • Added placeholder get_earn_data, get_earn_providers, and get_earn_positions methods.
  • gemstone/src/models/balance.rs
    • Added earn: GemBigUint field to the GemBalance struct.
  • gemstone/src/models/stake.rs
    • Imported EarnProviderType.
    • Added GemEarnProviderType type alias and uniffi::remote(Enum) definition.
    • Added provider_type: GemEarnProviderType field to GemDelegationValidator.
  • gemstone/src/models/transaction.rs
    • Imported EarnData and EarnType.
    • Added GemEarnData and GemEarnType type aliases and uniffi::remote definitions.
    • Added Earn variant to GemTransactionInputType.
    • Updated From implementations for TransactionLoadMetadata and TransactionInputType to include earn-related fields.
    • Added EarnDeposit and EarnWithdraw to GemTransactionType.
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

The pull request introduces the core infrastructure for 'Earn' functionality across multiple blockchain providers and primitives. The implementation is generally consistent with existing staking patterns. However, there are several critical issues to address, including the use of todo!() and unimplemented!() in production code paths which will cause panics, potential compilation errors due to missing or incorrect hex crate usage in EVM providers, and the use of unstable Rust features (let_chains) that may not be consistent with the project's toolchain. Additionally, some placeholder values in the new enums should be finalized.

nonce,
chain_id,
stake_data: Some(StakeData {
data: if params.data.is_empty() { None } else { Some(hex::encode(&params.data)) },
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The hex crate is used here but it doesn't seem to be imported in this file, which will likely lead to a compilation error. Based on other files in this crate, you should use alloy_primitives::hex.

Suggested change
data: if params.data.is_empty() { None } else { Some(hex::encode(&params.data)) },
data: if params.data.is_empty() { None } else { Some(alloy_primitives::hex::encode(&params.data)) },

if let Some(approval) = &earn_data.approval {
Ok(TransactionParams::new(approval.token.clone(), encode_erc20_approve(&approval.spender)?, BigInt::from(0)))
} else {
Ok(TransactionParams::new(contract_address.clone(), hex::decode(call_data_hex)?, value))
Copy link
Contributor

Choose a reason for hiding this comment

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

high

hex::decode is used here without a corresponding import. Since alloy_primitives::hex is used elsewhere in this file (e.g., lines 40 and 96), it's better to use the full path or add the import to avoid compilation errors.

Suggested change
Ok(TransactionParams::new(contract_address.clone(), hex::decode(call_data_hex)?, value))
Ok(TransactionParams::new(contract_address.clone(), alloy_primitives::hex::decode(call_data_hex)?, value))

Ok(Message { title, message: Some(message) })
}
TransactionType::AssetActivation | TransactionType::PerpetualModifyPosition => todo!(),
TransactionType::AssetActivation | TransactionType::PerpetualModifyPosition | TransactionType::EarnDeposit | TransactionType::EarnWithdraw => todo!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using todo!() in a daemon service is risky as it will cause a panic if an EarnDeposit or EarnWithdraw transaction is encountered. It's better to handle these types gracefully, for example by returning a generic message or a specific error, to ensure service stability.

}
TransactionInputType::Swap(_, _, _) | TransactionInputType::Stake(_, _) | TransactionInputType::TokenApprove(_, _) | TransactionInputType::Generic(_, _, _) => Ok(1500),
TransactionInputType::Perpetual(_, _) => unimplemented!(),
TransactionInputType::Perpetual(_, _) | TransactionInputType::Earn(_, _) => unimplemented!(),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using unimplemented!() in the RPC client will cause the application to panic at runtime when processing Earn transactions. Consider returning a Result::Err instead to allow for graceful error handling.

Comment on lines 202 to 207
if let TransactionLoadMetadata::Evm { earn_data: Some(ref ed), .. } = input.metadata
&& ed.approval.is_some()
&& let Some(ref gas_limit) = ed.gas_limit
{
return Ok(BigInt::from_str_radix(gas_limit, 10)?);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This block uses 'let chains' syntax (&& let), which is a relatively recent Rust feature. The existing code in this file (e.g., lines 191-195) uses nested if let statements. For consistency and to ensure compatibility with the project's current Rust toolchain, it's recommended to stick to nested if let blocks.

Suggested change
if let TransactionLoadMetadata::Evm { earn_data: Some(ref ed), .. } = input.metadata
&& ed.approval.is_some()
&& let Some(ref gas_limit) = ed.gas_limit
{
return Ok(BigInt::from_str_radix(gas_limit, 10)?);
}
if let TransactionLoadMetadata::Evm { earn_data: Some(ref ed), .. } = input.metadata {
if ed.approval.is_some() {
if let Some(ref gas_limit) = ed.gas_limit {
return Ok(BigInt::from_str_radix(gas_limit, 10)?);
}
}
}

#[serde(rename_all = "lowercase")]
#[strum(serialize_all = "lowercase")]
pub enum YieldProvider {
Yo,
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The variant Yo appears to be a placeholder. Please replace it with actual yield provider names or remove it if it's not yet implemented.

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.

1 participant

Comments