Skip to content

feat(vault): expose the current maximum redeemable shares - #19

Merged
Kami-no-san merged 1 commit into
YieldAnchor:mainfrom
rahulatrkm:feat/max-redeemable-shares
Oct 18, 2026
Merged

Kami-no-san merged 1 commit into
YieldAnchor:mainfrom
rahulatrkm:feat/max-redeemable-shares

Conversation

@rahulatrkm

Copy link
Copy Markdown
Contributor

Closes #6

Change

Add read-only max_redeemable and YieldVaultClient.maxRedeemable(): Promise<Amount>, with the wire name exported from shared constants and registered in the existing client method map. The result is a vault-wide share ceiling, not an asset amount or a per-user balance.

When liquidity is below accounted assets, the exact inverse of redemption's floor rounding is ceil((liquidity + 1) * totalShares / totalAssets) - 1. This uses the existing checked arithmetic helpers, avoiding intermediate overflow. Fully funded vaults are capped at total shares; empty, paused or zero-liquidity vaults return zero. Pending simulated yield is included without mutating accrual state.

Limits

The bound applies at the current ledger timestamp only. It reserves no liquidity and introduces no guessed delay margin. Callers must also cap by their own shares and allow for time, other transactions and pauses before submission. Existing deployed contracts do not gain the new method automatically.

Verification

  • Six focused contract tests cover empty/funded/unfunded/paused states, the exact 93-versus-94-share boundary for 100 liquid / 108 accounted / 100 shares, and large i128 amounts.
  • Four additional client cases verify exact Amount decoding, no-argument simulation without signing, and malformed-result rejection.
  • Full pnpm test: 230 passed, including 19 contract and 66 client tests.
  • Full typecheck, formatting and application/package builds: passed.
  • Lint: exit 0, with three pre-existing warnings in unchanged wallet code.
  • Strict Clippy, release Wasm build, and git diff --check: passed.

No live Testnet deployment, wallet or real funds were used. This branch starts from upstream main and does not include the constructor change in draft #13.

Prepared and tested by GitHub Copilot on behalf of rahulatrkm. Independent human review is not claimed. No bounty or payment claim is attached.

@Kami-no-san
Kami-no-san merged commit 7709056 into YieldAnchor:main Oct 18, 2026
2 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.

feat: add a max_redeemable view so redemptions can be sized safely

2 participants