Skip to content

[Chore] Deduplicate adapter boilerplate between blend-adapter and defindex-adapter #460

Description

@collinsezedike

Summary

blend-adapter and defindex-adapter both implement the vault's YieldAdapterInterface, but they duplicate storage-key definitions, initialize(), and admin/pool-getter boilerplate rather than sharing a common base. The two contracts' actual yield-source logic legitimately differs (that shouldn't be merged), but the surrounding scaffolding is copy-pasted.

Motivation

Right now a change to the shared scaffolding (e.g. how the admin address is stored, or how require_auth() is applied on init) has to be made twice and can silently drift between the two contracts. This is maintenance risk, not a correctness bug today, but it's the kind of thing that turns into a real inconsistency the next time someone touches one adapter without remembering to mirror the other.

Proposed Solution

Extract the shared scaffolding (storage keys, initialize(), admin storage/read helpers, any other boilerplate common to both adapters) into a shared crate or module under packages/contracts that both blend-adapter and defindex-adapter depend on. Each adapter keeps its own yield-source-specific logic (accrue(), rate conversion, pool/vault interaction) implementing the interface on top of the shared base.

Scope

Field Value
Area Contracts
Protocol affected Both
Network testnet
Breaking change? No (internal structure only, same ABI)

Alternatives Considered

Leaving the duplication as-is: acceptable short-term since both adapters are small and the interface keeps them aligned externally, but doesn't scale if a third adapter is added.

Acceptance Criteria

  • Shared scaffolding (storage keys, initialize(), admin helpers) lives in one place, not two
  • blend-adapter and defindex-adapter still pass their full existing test suites unmodified in behavior
  • No change to either contract's external ABI or deployed interface
  • cargo clippy --all-targets -- -D warnings, cargo fmt --all -- --check, and cargo test pass in packages/contracts

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreBuild, CI, dependency updates, or repository maintenancecontractsInvolves writing or testing Rust/Soroban contracts in packages/contractshardComplex implementation spanning multiple packages or involving Soroban contracts

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions