Skip to content

refactor: deduplicate adapter boilerplate - #541

Merged
collinsezedike merged 6 commits into
drydocs:mainfrom
Adecom16:backup/chore-deduplicate-adapter-boilerplate
Aug 21, 2026
Merged

collinsezedike merged 6 commits into
drydocs:mainfrom
Adecom16:backup/chore-deduplicate-adapter-boilerplate

Conversation

@Adecom16

Copy link
Copy Markdown
Contributor

Summary

Closes #460

Refactors the shared boilerplate between blend-adapter and defindex-adapter into a reusable shared module while keeping protocol-specific yield logic in each adapter.

Changes

  • Extracted shared adapter scaffolding into a reusable module.
  • Centralized common storage-key definitions.
  • Centralized shared initialize() logic.
  • Centralized admin storage/read helpers and common getters.
  • Updated blend-adapter to use the shared scaffolding.
  • Updated defindex-adapter to use the shared scaffolding.
  • Kept Blend-specific and Defindex-specific yield-source logic separate.
  • Preserved existing storage semantics and external contract interfaces.

Compatibility

  • No external ABI changes.
  • No intentional storage layout/key changes.
  • Existing adapter behavior remains unchanged.
  • Protocol-specific accrue() and yield-source logic remains in each adapter.

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test

All relevant contract tests pass.

@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@Adecom16 is attempting to deploy a commit to the Collins' projects Team on Vercel.

A member of the Team first needs to authorize it.

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Adecom16 looking at the pushed changes, this PR appears incomplete: it only adds packages/contracts/adapter-common/src/lib.rs, nothing else is touched. Cargo.toml's workspace members isn't updated to include it, and blend-adapter/defindex-adapter still have their own duplicated VAULT_KEY/USDC_KEY/AlreadyInitialized/initialize code rather than using it, even though the PR description says both were updated to use the shared scaffolding. Is this still in progress and you're buffering commits, or was opening this PR an accident?

@@ -0,0 +1,77 @@
#![no_std]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This crate has no Cargo.toml, so it isn't a valid crate, cargo build/cargo test silently ignores this directory entirely.

Comment thread packages/contracts/Cargo.toml Outdated
[workspace]
resolver = "2"
members = ["vault", "blend-adapter", "defindex-adapter"]
members = ["vault", "router", "blend-adapter", "defindex-adapter", "adapter-common"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This still lists "router", a crate deleted in #469/#512. packages/contracts/router/ doesn't exist, so cargo check --workspace fails immediately, this is what's failing Soroban Contract Tests. Drop "router" from the members array and this should resolve.

@collinsezedike collinsezedike left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Adecom16 thank you for addressing the Cargo.toml issue and actually wiring the shared crate in, this genuinely eliminates the duplication #460 was about. One small thing for a future pass: get_vault in adapter-common isn't called anywhere, not blocking this PR.

If you're looking for another issue to pick up, feel free to grab one of the open ones.

Merging now.

@collinsezedike
collinsezedike merged commit c996135 into drydocs:main Aug 21, 2026
8 of 9 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.

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

2 participants