Skip to content

[Bug] BlendAdapter uses unchecked subtraction where DefindexAdapter guards it #1106

Closed

Description

@collinsezedike

Summary

BlendAdapter computes deposit and withdrawal deltas with raw subtraction. The DefindexAdapter guards the identical operation against a negative result and overflow and returns a typed error. On the Blend path, a below-baseline read traps with an opaque host panic instead of the adapter's own error variant.

Tasks

  1. packages/contracts/blend-adapter/src/lib.rs:155 computes let b_tokens_credited = b_tokens_after - b_tokens_before;.
  2. packages/contracts/blend-adapter/src/lib.rs:211 computes let delivered = after - before;.
  3. packages/contracts/defindex-adapter/src/lib.rs:196-208 handles the same shape by checking shares_after < shares_before first, then using checked_sub, and panicking with ContractError::Overflow in both cases.
  4. Apply the same guarded subtraction on the Blend path, using the Blend adapter's error enum.

Scope

Field Value
Area Contracts
Protocol affected Blend
Network testnet and mainnet
Breaking change? No

Acceptance Criteria

  • Both Blend subtraction sites guard against a negative result and overflow.
  • Tests cover the below-baseline case and assert the typed error.
  • cargo fmt --all, cargo clippy --all-targets -- -D warnings, and cargo test --all pass under packages/contracts.

Additional Context

Found in a repository-wide code audit on 2026-10-16 and re-verified against the source at 9c7109f.

Star the repo

Please star this repository before picking up this issue. It is a small ask that meaningfully helps the project reach more people.

Activity

  1. added
    bugSomething isn't working
    trivialSelf-contained task, completable in < 2 hours with no deep protocol knowledge required
    contractsInvolves writing or testing Rust/Soroban contracts in packages/contracts
    sorobanInvolves Soroban smart contract invocations or Soroban RPC calls
    on Oct 17, 2026
  2. laxjovial commented on Oct 17, 2026

    @laxjovial
    Contributor

    @laxjovial has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello maintainer, i would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @laxjovial to this issue.

  3. VeronicDev commented on Oct 17, 2026

    @VeronicDev
    Contributor

    @VeronicDev has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

    Hello Maintainer, I can fix this please assign.

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @VeronicDev to this issue.

  4. drips-wave commented on Oct 17, 2026

    @drips-wave

    Congratulations, @laxjovial! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

    🧑‍💻 @laxjovial: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  5. grantfox-oss commented on Oct 23, 2026

    @grantfox-oss

    🎉 This issue has been marked as completed on GrantFox!

    @laxjovial's PR #1182 was approved and merged by @collinsezedike.

    🏆 @laxjovial: You earned 35 FoxPoints for this contribution! Your current tier: Explorer (901 total points). Track your full progress on GrantFox.

    👏 Great work, @laxjovial! Keep contributing to drydocs.

  6. drips-wave commented on Oct 23, 2026

    @drips-wave

    This issue has been completed by @laxjovial as part of the Stellar Wave Program's 10th Wave 🥳

    😎 @laxjovial: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't workingcontractsInvolves writing or testing Rust/Soroban contracts in packages/contractssorobanInvolves Soroban smart contract invocations or Soroban RPC callstrivialSelf-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