Skip to content

chore: Implement VedaAdapter#166

Merged
MoMannn merged 30 commits into
mainfrom
chore-veda-adapter
May 29, 2026
Merged

chore: Implement VedaAdapter#166
MoMannn merged 30 commits into
mainfrom
chore-veda-adapter

Conversation

@MoMannn
Copy link
Copy Markdown
Member

@MoMannn MoMannn commented Mar 2, 2026

What?

  • Adds VedaAdapter.sol — a new adapter contract for delegation-based deposits and withdrawals on Veda BoringVault
  • Adds IVedaTeller.sol — minimal interface for Veda's TellerWithMultiAssetSupport
  • Adds VedaLending.t.sol — comprehensive test suite (fork tests, happy paths, input validation, events, batch operations, edge cases, 3-level delegation chain, terms validation, replay prevention, slippage protection, alternative delegator)
  • Adds BatchDepositExecuted and BatchWithdrawExecuted events for off-chain indexing of batch operations

Why?

  • Enables users to deposit into and withdraw from Veda BoringVaults through the delegation framework, without requiring direct token approvals
  • Allows operators to execute vault operations on behalf of users via the redelegation pattern, with fine-grained control over tokens, amounts, and who can redeem

How?

  • Uses the redelegation pattern (user → operator → adapter) consistent with DelegationMetaSwapAdapter
  • Parses deposit token/amount and withdrawal share amount from the leaf delegation's caveat terms via a shared _parseERC20TransferTerms helper, which validates that terms are at least 52 bytes (ERC20TransferAmountEnforcer format) before reading with assembly
  • On deposit: redeems the delegation chain to transfer tokens to the adapter, approves the BoringVault, and calls the 5-arg teller.deposit() to mint shares directly to the root delegator
  • On withdraw: redeems the delegation chain to transfer vault shares to the adapter, then calls teller.withdraw() to burn shares and send the desired underlying output asset to the root delegator. The output token is passed as a function parameter (distinct from the vault share token in the caveat)
  • Supports batched operations via depositByDelegationBatch / withdrawByDelegationBatch, each emitting a batch-level event alongside per-stream DepositExecuted / WithdrawExecuted events
  • Includes withdrawEmergency (owner-only) for recovering tokens accidentally sent to the contract

Note

  • Tests are being run on a mainnet fork of Arbitrum on a deployment of Veda protocol

Note

High Risk
New on-chain path moves user ERC20 and vault shares with permissionless depositByDelegation / withdrawByDelegation; safety depends on correct delegation caveats and Teller authorization, not caller identity.

Overview
Adds VedaAdapter, a delegation-driven bridge to Veda BoringVault deposit and withdraw flows (same redeem-then-call pattern as the MetaSwap adapter). Operators redeem a user → operator → adapter chain via DelegationManager, pull depositToken or vault shares into the adapter, then call IVedaTeller so assets/shares land on the root delegator. Amounts come from caveats[0] (ERC20TransferAmountEnforcer terms, 52-byte check); batch entrypoints and owner withdrawEmergency / ensureAllowance are included.

Also adds DeployVedaAdapter (CREATE2 + env knobs), .env.example Veda vars, chain 143 broadcast artifacts, and VedaLending.t.sol (Arbitrum fork). CI tests gain ARBITRUM_RPC_URL and RPC_API_KEY.

Reviewed by Cursor Bugbot for commit e2227ef. Bugbot is set up for automated code reviews on this repo. Configure here.

@MoMannn MoMannn requested a review from a team as a code owner March 2, 2026 10:34
Comment thread src/helpers/VedaAdapter.sol Outdated
@MoMannn MoMannn requested a review from hanzel98 March 30, 2026 09:52
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread test/helpers/VedaLending.t.sol Outdated
@MoMannn MoMannn requested a review from McOso April 2, 2026 07:39
Comment thread script/DeployVedaAdapter.s.sol Outdated
Comment thread src/helpers/interfaces/IVedaTeller.sol
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread src/helpers/VedaAdapter.sol
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread src/helpers/VedaAdapter.sol Outdated
Comment thread src/helpers/VedaAdapter.sol Outdated
@MoMannn MoMannn requested review from McOso and hanzel98 April 7, 2026 07:59
Comment thread src/helpers/VedaAdapter.sol
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ede87fa. Configure here.

Comment thread test/helpers/VedaLending.t.sol
@MoMannn MoMannn merged commit 1bdb8a3 into main May 29, 2026
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.

3 participants