Skip to content

feat: add active stake check, analytics getters, enriched lock_assets… - #268

Open
ExcelDsigN-tech wants to merge 1 commit into
SmartDropLabs:mainfrom
ExcelDsigN-tech:feat/farming-pool-fixes-and-analytics-getters
Open

feat: add active stake check, analytics getters, enriched lock_assets…#268
ExcelDsigN-tech wants to merge 1 commit into
SmartDropLabs:mainfrom
ExcelDsigN-tech:feat/farming-pool-fixes-and-analytics-getters

Conversation

@ExcelDsigN-tech

Copy link
Copy Markdown

feat: Active stake guard, analytics getters, enriched lock_assets event, and position credit fixes

Closes #237, Closes #240, Closes #242, Closes #264

Overview

Adds operational safeguards and observability features to the FarmingPool smart contract, while resolving a position credit accounting bug where boost multipliers were incorrectly applied to locked-position accruals.

Feature Summary

  • Added an active stake check to set_boost to prevent callers without staked or locked assets from configuring boost
  • Implemented new analytics getters: active_stake_count and credit_rate_change_count
  • Enriched event payloads for locked and rate_set to expose position totals and ledger sequence numbers to indexers
  • Corrected position credit calculations so boost multipliers apply solely to the legacy UserStake path
  • Updated project documentation (docs/events.md) to reflect the new event schemas

Technical Implementation

  • Active Stake Guard & Boost Fixes (soroban/contracts/farming-pool/src/lib.rs):
    • Updated set_boost to verify active stake or locked assets before allowing boost updates
    • Removed boost multiplier application from position credit logic across calculate_credits, get_user_position, and get_credits
    • Fixed checkpoint_position to ensure accrued position credits are added to total_distributed_credits
  • Analytics Trackers & Storage (soroban/contracts/farming-pool/src/types.rs, src/lib.rs):
    • Added DataKey::ActiveStakeCount and DataKey::CreditRateChangeCount variants to storage keys
    • Implemented active_stake_count() -> u32 tracking users with active positions (incremented on stake/lock_assets, decremented on unstake/unlock_assets)
    • Implemented credit_rate_change_count() -> u32 tracking historical admin calls to set_credit_rate
  • Event Schema Enriched (soroban/contracts/farming-pool/src/lib.rs, docs/events.md):
    • Updated locked event topic/data schema to (user, amount, total_position)
    • Updated rate_set event topic/data schema to (old_rate, new_rate, ledger_sequence)
    • Documented schema modifications in docs/events.md

Test Coverage

  • 139 / 144 unit and integration tests passing (soroban/contracts/farming-pool/src/test.rs)
  • Added unit tests verifying active stake guards, new analytics getter behavior, and enriched event schemas
  • Confirmed 5 pre-existing failures remain unrelated to this branch (2 batch whitelist SDK panic message format mismatches, 3 unpause event history retention assertion mismatches)

Checklists

  • Enforce active stake check prior to executing set_boost
  • Implement active_stake_count and credit_rate_change_count analytics getters
  • Update locked and rate_set event schemas with extra contextual fields
  • Fix position credit accrual calculations and boost multiplier scope
  • Ensure checkpoint_position properly updates total_distributed_credits
  • Update docs/events.md with revised event structures

… event, and fix position credit accounting

- set_boost now rejects callers with no active stake (stake or lock_assets)
- add active_stake_count() getter tracking lock/unlock lifecycle
- add credit_rate_change_count() getter tracking admin rate changes
- lock_assets event now emits (user, amount, total_position) instead of just (user, amount)
- set_credit_rate event now includes ledger_sequence as third field
- checkpoint_position now tracks position credits in total_distributed_credits
- position credits no longer apply boost multiplier (boost only affects stake credits)
- fix test assertions to match new event shapes and Soroban test env behavior
@netlify

netlify Bot commented Aug 29, 2026

Copy link
Copy Markdown

Deploy Preview for sdcontracts ready!

Name Link
🔨 Latest commit 678f00b
🔍 Latest deploy log https://app.netlify.com/projects/sdcontracts/deploys/6a923c8fc39a890008963f04
😎 Deploy Preview https://deploy-preview-268--sdcontracts.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@drips-wave

drips-wave Bot commented Aug 29, 2026

Copy link
Copy Markdown

@ExcelDsigN-tech Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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

Labels

None yet

Projects

None yet

1 participant