Skip to content

chore: Implement VedaAdapter#166

Open
MoMannn wants to merge 25 commits intomainfrom
chore-veda-adapter
Open

chore: Implement VedaAdapter#166
MoMannn wants to merge 25 commits intomainfrom
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

Medium Risk
Adds a new onchain adapter that moves ERC20s/vault shares via delegation redemption and interacts with external Veda contracts; incorrect delegation assumptions or allowance/emergency paths could cause fund loss or integration breakage.

Overview
Adds a new VedaAdapter helper contract that redeems delegation chains to perform Veda BoringVault deposits/withdrawals (including batch variants), emitting per-operation and batch-level events and providing owner-only ensureAllowance and withdrawEmergency safety valves.

Introduces the minimal IVedaTeller interface, a DeployVedaAdapter forge script, and an extensive Arbitrum-fork test suite (VedaLending.t.sol) covering happy paths, validation/revert cases, event emission, batching, and replay/terms checks. CI and .env.example are updated to supply Arbitrum/RPC env vars needed for fork tests and deployment config.

Reviewed by Cursor Bugbot for commit edf55c3. 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
@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
* @param _amount The amount of tokens to recover
* @param _recipient The address to receive the recovered tokens
*/
function withdrawEmergency(IERC20 _token, uint256 _amount, address _recipient) external onlyOwner {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm im thinking we get rid of this function. It doesnt seem possible for tokens to be left in this contract without the tx reverting, since it's atomic. If we remove, it really makes the adapter clean and lightweight, removes the need for owner / state.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is in case of someone sending tokens directly to the contract (mistaking it for EOA).

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
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 adb6c64. Configure here.

Comment thread src/helpers/VedaAdapter.sol
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