Support self-appreciating vote-lock vaults (vlRSR) - #29
Conversation
- 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
📝 WalkthroughWalkthroughThe 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. ChangesVote-lock SDK support
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
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (17)
.changeset/vote-lock-self-appreciating.mdapps/docs/src/pages/react-sdk/index-dtf-hooks.mdxapps/docs/src/pages/sdk/vote-lock.mdxdocs/index-dtf/vote-lock.mddocs/wiki/progress.mdpackages/react-sdk/src/index-dtf-extra-hooks.tspackages/react-sdk/src/index-dtf-query-options.tspackages/react-sdk/src/index.tspackages/react-sdk/src/query-keys.test.tspackages/react-sdk/src/query-keys.tspackages/sdk/src/index-dtf/index.tspackages/sdk/src/index-dtf/vote-lock/builders.tspackages/sdk/src/index-dtf/vote-lock/index.tspackages/sdk/src/index-dtf/vote-lock/namespace.tspackages/sdk/src/index-dtf/vote-lock/ref.tspackages/sdk/src/index-dtf/vote-lock/vote-lock.test.tspackages/sdk/src/index.ts
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
VoteLockStatecarried 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.VoteLockStategainsshareBalance(vaultbalanceOf) andexchangeRate(convertToAssets(10^decimals), display-only — exact conversions go throughpreviewRedeem/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
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
Documentation
Tests