Skip to content

[Docs] Document AdapterSwapUnsafe in the vault error code table #423

Description

@collinsezedike

Summary

apps/docs/architecture/vault-contract.md's error code table (around lines 140-150) lists error codes 1 through 9 but is missing AdapterSwapUnsafe = 10, defined in packages/contracts/vault/src/lib.rs and actively enforced in set_adapter (rejects the call while the vault still has shares outstanding, tested by set_adapter_fails_with_shares_outstanding). The doc's set_adapter section also currently describes migrating funds out first as only the caller's responsibility, without mentioning that the contract itself now rejects an unsafe swap.

Motivation

This doc is the reference for anyone integrating against the vault (off-chain indexers, other contributors writing adapters, or a future reviewer trying to understand set_adapter's safety guarantees). A missing error variant means someone reading the docs alone would not know this failure mode exists or what triggers it.

Proposed Solution

  • Add AdapterSwapUnsafe = 10 to the error code table, with a short description matching the enum's doc comment in vault/src/lib.rs ("set_adapter was called while the vault still has shares outstanding").
  • Update the set_adapter section to note that the contract enforces this itself, not just documents it as caller responsibility.

Scope

Field Value
Area Docs
Protocol affected None
Network N/A
Breaking change? No

Alternatives Considered

Leaving the table as-is: rejected, since it's a factual gap against the shipped contract, not a stylistic choice.

Acceptance Criteria

  • Error code table includes AdapterSwapUnsafe = 10 with an accurate description
  • set_adapter section mentions the contract-level enforcement, not just caller responsibility

Additional Context

Verified against packages/contracts/vault/src/lib.rs (enum definition, set_adapter implementation, and the set_adapter_fails_with_shares_outstanding test).

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcontractsInvolves writing or testing Rust/Soroban contracts in packages/contractsdocsDocumentation, guides, README, inline docs, or ADRstrivialSelf-contained task, completable in < 2 hours with no deep protocol knowledge required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions