Skip to content

[Chore] Collapse deposit()'s two sequential token transfers into one #374

Description

@collinsezedike

Summary

MeridianVault::deposit transfers USDC from the caller to the vault, then immediately transfers the same amount from the vault to the adapter, as two separate TokenClient::transfer calls.

Motivation

The intermediate vault-owned balance is never used for anything between the two transfers; it exists for exactly one instruction. Each transfer is a separate cross-contract call with its own instruction and resource cost on Soroban, so this doubles the token-transfer overhead of every deposit for no behavioral benefit.

Proposed Solution

Transfer USDC directly from the caller to the adapter in one call, since the adapter address is already known before any transfer happens.

Scope

Field Value
Area Contracts
Protocol affected Both
Network testnet, mainnet
Breaking change? No

Alternatives Considered

Leaving it as-is: works correctly today, but pays unnecessary transaction cost on every deposit.

Acceptance Criteria

  • deposit performs a single caller -> adapter transfer instead of caller -> vault -> adapter
  • Existing deposit tests still pass unmodified (behavior is identical, only the transfer path changes)
  • cargo clippy --all-targets -- -D warnings && cargo test pass

Additional Context

packages/contracts/vault/src/lib.rs, deposit function, the two TokenClient::new(&env, &usdc).transfer(...) calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreBuild, CI, dependency updates, or repository maintenancecontractsInvolves writing or testing Rust/Soroban contracts in packages/contractstrivialSelf-contained task, completable in < 2 hours with no deep protocol knowledge required

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions