Skip to content

getters: last_checkpoint_ledger (#255), vesting_dates (#256), emergency_withdrawal_count (#257), upgrade_count (#258) - #265

Merged
ritaifeoluwa merged 1 commit into
SmartDropLabs:mainfrom
thefadah:sd-255-258-getters
Aug 28, 2026
Merged

getters: last_checkpoint_ledger (#255), vesting_dates (#256), emergency_withdrawal_count (#257), upgrade_count (#258)#265
ritaifeoluwa merged 1 commit into
SmartDropLabs:mainfrom
thefadah:sd-255-258-getters

Conversation

@thefadah

Copy link
Copy Markdown
Contributor

Four small analytics/UX getters requested across the farming-pool, vesting-wallet, and factory contracts.

#255last_checkpoint_ledger on FarmingPool

checkpoint() resets UserStake.start_ledger to the current ledger on every stake / unstake / set_boost, so it is the origin the user's next credit accrual is measured from — it just wasn't exposed.

pub fn last_checkpoint_ledger(env: Env, user: Address) -> Option<u32>

Returns that ledger, or None when the user has no active continuous stake.

#256vesting_dates on the vesting wallet

The three schedule ledgers were only reachable one private getter at a time.

pub fn vesting_dates(env: Env) -> Result<(u32, u32, u32), VestingError>

Returns (start_ledger, cliff_ledger, end_ledger) in a single read, require_initialized-gated like get_vesting_schedule.

#257emergency_withdrawal_count on FarmingPool

New DataKey::EmergencyWithdrawalCount, incremented on each successful emergency_withdraw (right before the emrg_exit event), exposed via:

pub fn emergency_withdrawal_count(env: Env) -> u32

#258upgrade_count on Factory

New DataKey::UpgradeCount, incremented on each successful upgrade_pool (right before the pool_upg event), exposed via:

pub fn upgrade_count(env: Env) -> Result<u32, FactoryError>

Incidental

farming-pool/src/lib.rs already calls env.storage().instance().get/set(&DataKey::StakedUserCount, …) in increment_staked_user_count / decrement_staked_user_count, but DataKey::StakedUserCount was never declared in the enum. Added it. #[contracttype] enum keys encode by variant name, so adding variants does not change any existing on-chain key.

Not built or tested locally.

Closes #255
Closes #256
Closes #257
Closes #258

…martDropLabs#256), emergency_withdrawal_count (SmartDropLabs#257), upgrade_count (SmartDropLabs#258)

- SmartDropLabs#255: farming-pool gains `last_checkpoint_ledger(user) -> Option<u32>`,
  returning `UserStake.start_ledger` (which `checkpoint` resets on every
  stake/unstake/set_boost) or None when the user has no active stake.

- SmartDropLabs#256: vesting-wallet gains `vesting_dates() -> Result<(u32, u32, u32),
  VestingError>` returning (start, cliff, end) in one read for schedule
  display; `require_initialized` gated like the other views.

- SmartDropLabs#257: farming-pool now keeps `DataKey::EmergencyWithdrawalCount`,
  incremented on each successful `emergency_withdraw`, exposed via
  `emergency_withdrawal_count() -> u32` for risk monitoring.

- SmartDropLabs#258: factory now keeps `DataKey::UpgradeCount`, incremented on each
  successful `upgrade_pool`, exposed via `upgrade_count() -> Result<u32,
  FactoryError>` for version tracking.

Also adds the missing `DataKey::StakedUserCount` variant to farming-pool's
enum — `increment_staked_user_count` / `decrement_staked_user_count` already
reference it but it was never declared.

Not built or tested locally.
@netlify

netlify Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploy Preview for sdcontracts ready!

Name Link
🔨 Latest commit c645cbd
🔍 Latest deploy log https://app.netlify.com/projects/sdcontracts/deploys/6a92007278189f000811afd4
😎 Deploy Preview https://deploy-preview-265--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 28, 2026

Copy link
Copy Markdown

@thefadah 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

@ritaifeoluwa
ritaifeoluwa merged commit 4a05af9 into SmartDropLabs:main Aug 28, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants