Urgent.News

What's breaking now, across thousands of outlets.

Tech

Staking rewards are just an accumulator (Vyper ๐Ÿ)

Staking rewards look complicated. They are not. I went through a pile of articles on staking, and the mechanism is simpler than I expected. If you are going to ship a staking pool, you need to understand this model. The naive way First thought: an offchain bot that pays everyone every block. @bot.on_ ( chain . blocks ) def distribute_rewards ( block ): for staker in stakers : token . transfer (โ€ฆ

Staking rewards are frequently described as an accumulator, but in reality, they are a simpler mechanism that lives on-chain. Rather than paying out rewards every block through an offchain bot, the model can be implemented by tracking each staked token's accrued earnings over time and settling users only when they interact with the pool.

To implement this on-chain staking rewards system, you can use Vyper, a Python-like language for writing smart contracts on the Ethereum blockchain. The process involves storing the total supply of staked tokens, the balance of staked tokens for each user, the index representing the accrued rewards, the reward rate, and the timestamp of the last period update.

By tracking the accumulated rewards per token and maintaining offset values for each user, you ensure that every staker is paid accurately for the time they have been in the pool, without any penalties for periods of inactivity. This simplifies the staking rewards process and eliminates the need for complex onchain gas calculations or live bots.

Written by urgent.news from Dev.to's reporting โ€” not their text. Machine-written โ€” may contain errors; check the original before relying on it.

Read the original at dev.to โ†’

More in Tech

If your file-guard hook is registered on Read, it never sees cat

I wrote a PreToolUse hook to keep one file out of the model's context. Registered it on Read , exit 2. Asked Claude Code to read the file with the Read tool. It stopped. Good.

  • File-guard hook blocks access on Read via cat
  • Hook fails to fire on Read via Read tool
  • Deny rule applies per-file, not command-specific

What an Embeddable Paycheck Calculator Taught Me About Iframes, Privacy, and Honest UX

Most โ€œembed this toolโ€ features are really small integration projects: install a script, create an account, obtain a key, add a container, and hope the host site's CSS does not win a specificityโ€ฆ

  • Embeddable Paycheck Calculator uses iframes for seamless integration
  • Calculator runs calculations in browser, not sending data to server
  • UX includes accessibility features and clear financial limitations

More from Wednesday 2 September โ†’