Skip to content

Support self-appreciating vote-lock vaults (vlRSR) - #29

Merged
lcamargof merged 1 commit into
mainfrom
feature/vote-lock-self-appreciating
Jul 31, 2026
Merged

Support self-appreciating vote-lock vaults (vlRSR)#29
lcamargof merged 1 commit into
mainfrom
feature/vote-lock-self-appreciating

Conversation

@lcamargof

@lcamargof lcamargof commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

vlRSR on BSC is the first self-appreciating StakingVault: rewards are converted to RSR by its tokenJar and stream back into the vault, so the share/asset exchange rate grows over time (currently ~1.019). The SDK previously had no way to quote or execute share-denominated unlocks, and VoteLockState carried no share balance or rate.

Changes

@reserve-protocol/sdk

  • prepareVoteLockRedeem({ stToken, chainId, shares, account })redeem(shares, account, account) calldata. Registered on the namespace, ref, and both barrels.
  • VoteLockState gains shareBalance (vault balanceOf) and exchangeRate (convertToAssets(10^decimals), display-only — exact conversions go through previewRedeem/maxWithdraw). Both read in the existing state multicall, still one round-trip.

@reserve-protocol/react-sdk

  • useIndexDtfVoteLockPreviewDeposit / useIndexDtfVoteLockPreviewRedeem (hook / query options / query key triple, LIVE_STALE_TIME, bigint-normalized keys).

Docs

  • Unlock flow rewritten for the universal redeem(shares) path — Register now uses it for every vault (legacy 1:1 included; previews are exact in both cases).

Tests

  • vote-lock.test.ts: redeem calldata shape, extended 8-slot multicall order pinned, shareBalance/exchangeRate mapping against a 1.01875-rate fixture.
  • query-keys.test.ts: bigint amount/shares normalization in the new preview keys.

Changeset included (patch → 0.5.1). Register consumes via local link until this is published.

Summary by CodeRabbit

  • New Features

    • Added vote-lock support for self-appreciating vaults using share-denominated redemptions.
    • Added vote-lock state for share balances and exchange rates.
    • Added SDK support for preparing vote-lock redemption transactions.
    • Added React hooks and query options for previewing vote-lock deposits and redemptions.
    • Updated unlock flows to preserve the redeemed underlying amount in escrow.
  • Documentation

    • Updated vote-lock builder documentation and release progress tracking.
  • Tests

    • Added coverage for redemption calls, vault state, previews, and normalized query keys.

- prepareVoteLockRedeem builder for shares-denominated unlocks
- VoteLockState.shareBalance + exchangeRate (same single multicall)
- useIndexDtfVoteLockPreviewDeposit / useIndexDtfVoteLockPreviewRedeem hooks
- unlock flow docs updated to the universal redeem(shares) path
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The SDK now reads vote-lock share balances and exchange rates, prepares share-denominated redemptions, and exposes these APIs publicly. The React SDK adds deposit and redeem preview hooks. Documentation, tests, and release records describe the new vault support.

Changes

Vote-lock SDK support

Layer / File(s) Summary
SDK vote-lock state and redemption
packages/sdk/src/index-dtf/vote-lock/..., packages/sdk/src/index-dtf/index.ts, packages/sdk/src/index.ts
VoteLockState now includes share balance and exchange rate. The SDK prepares redeem(shares, account, account) calls and exposes the builder through namespaces, references, and public exports. Tests cover state reads and call construction.
React vote-lock preview queries
packages/react-sdk/src/index-dtf-query-options.ts, packages/react-sdk/src/index-dtf-extra-hooks.ts, packages/react-sdk/src/query-keys.ts, packages/react-sdk/src/query-keys.test.ts, packages/react-sdk/src/index.ts
The React SDK adds deposit and redeem preview query keys, query options, hooks, exports, and bigint normalization tests.
Documentation and release records
docs/index-dtf/vote-lock.md, apps/docs/src/pages/sdk/vote-lock.mdx, apps/docs/src/pages/react-sdk/index-dtf-hooks.mdx, docs/wiki/progress.md, .changeset/vote-lock-self-appreciating.md
The documentation describes share-based unlocking and the new builder. The progress ledger and changeset record the release.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Application
  participant VoteLockRef
  participant prepareVoteLockRedeem
  participant StakingVault
  Application->>VoteLockRef: prepareVoteLockRedeem(shares, account)
  VoteLockRef->>prepareVoteLockRedeem: add bound chainId
  prepareVoteLockRedeem->>StakingVault: build redeem(shares, account, account)
  StakingVault-->>Application: prepared contract call
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the pull request's main change: support for self-appreciating vote-lock vaults.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/vote-lock-self-appreciating

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/react-sdk/src/index-dtf-query-options.ts`:
- Around line 243-273: Update the package metadata and release configuration for
`@reserve-protocol/react-sdk` and `@reserve-protocol/sdk` so both are released with
consistent versions. Replace the react-sdk workspace:* dependency on
`@reserve-protocol/sdk` with the published SDK version that includes
readVoteLockPreviewDeposit and readVoteLockPreviewRedeem, ensuring the generated
package manifests pin that version.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 50016556-3656-491b-a55b-0167c6af2957

📥 Commits

Reviewing files that changed from the base of the PR and between 9231139 and a33a5ae.

📒 Files selected for processing (17)
  • .changeset/vote-lock-self-appreciating.md
  • apps/docs/src/pages/react-sdk/index-dtf-hooks.mdx
  • apps/docs/src/pages/sdk/vote-lock.mdx
  • docs/index-dtf/vote-lock.md
  • docs/wiki/progress.md
  • packages/react-sdk/src/index-dtf-extra-hooks.ts
  • packages/react-sdk/src/index-dtf-query-options.ts
  • packages/react-sdk/src/index.ts
  • packages/react-sdk/src/query-keys.test.ts
  • packages/react-sdk/src/query-keys.ts
  • packages/sdk/src/index-dtf/index.ts
  • packages/sdk/src/index-dtf/vote-lock/builders.ts
  • packages/sdk/src/index-dtf/vote-lock/index.ts
  • packages/sdk/src/index-dtf/vote-lock/namespace.ts
  • packages/sdk/src/index-dtf/vote-lock/ref.ts
  • packages/sdk/src/index-dtf/vote-lock/vote-lock.test.ts
  • packages/sdk/src/index.ts

Comment thread packages/react-sdk/src/index-dtf-query-options.ts
@lcamargof
lcamargof merged commit 4f3b74e into main Jul 31, 2026
3 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

Development

Successfully merging this pull request may close these issues.

1 participant