Skip to content

fix: sync periodically and only mint if budget ran out#63

Merged
mfontanini merged 2 commits intomainfrom
fix/sync-mint
Jan 30, 2026
Merged

fix: sync periodically and only mint if budget ran out#63
mfontanini merged 2 commits intomainfrom
fix/sync-mint

Conversation

@mfontanini
Copy link
Member

This changes the keeper logic so that:

  • We only mint if we ran out of funds in L2 to avoid adding up to the budget if we still have some to spend.
  • Calls sync periodically if we have a new deposit we haven't accounted for. This ensures we don't sit around without syncing for too long. This also allows simplifying the code quite a bit since we don't have to account for syncing on a per reward distribution basis.

@mfontanini mfontanini merged commit 2de8dea into main Jan 30, 2026
1 check passed
@mfontanini mfontanini deleted the fix/sync-mint branch January 30, 2026 21:01
let has_new_deposit = balance > accounted;

let token_ctx = self.fetch_token_context(reward_address).await?;
let should_unlock = if remaining > U256::ZERO {
Copy link
Member

@jcabrero jcabrero Feb 2, 2026

Choose a reason for hiding this comment

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

If the remaining rewards are 0 (which, though being extremely unlikely, it is feasible), would we never unlock rewards? If rewards are 0, we're always getting should_unlock = false and thus never executing reward_policy.sync()

Copy link
Member Author

Choose a reason for hiding this comment

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

remaining points to the rewards that are locked and need unlocking. If those are 0 then it means the keeper hasn't done the mint call on the L1 contract. Which is fine, eventually it should do that. Once we run out budget, a few lines above, this cache is reset so I think we're safe. I do want to change this caching thing because I find it a bit confusing but I think it's functionally correct now. Maybe @tlitre wants to have another look.

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