Skip to content
LogoLogo

Adapter Management

Before capital can be allocated, the desired adapter must first be added to the vault's Universal Delegator.

Each Vault V2 has its own Universal Delegator responsible for managing the set of available adapters. Once added, adapters can be configured, allocated to, and removed by accounts with the appropriate permissions.

Add an Adapter

The helper script calls the Universal Delegator's addAdapter() function.

AddAdapterBase.s.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
 
import {IVaultV2} from "../../../../src/interfaces/vault/IVaultV2.sol";
import {IUniversalDelegator} from "../../../../src/interfaces/delegator/IUniversalDelegator.sol";
import {Logs} from "../../../utils/Logs.sol";
import {ScriptBase} from "../../../utils/ScriptBase.s.sol";
 
contract AddAdapterBaseScript is ScriptBase {
    function runBase(address vault, address adapter) public virtual returns (bytes memory data, address target) {
        target = IVaultV2(vault).delegator();
        data = abi.encodeCall(IUniversalDelegator.addAdapter, (adapter));
        sendTransaction(target, data);
 
        Logs.log(
            string.concat("Add adapter", "\n    vault:", vm.toString(vault), "\n    adapter:", vm.toString(adapter))
        );
        Logs.logSimulationLink(target, data);
    }
}

The deployment script specifies the vault and adapter addresses:

AddAdapter.s.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
 
import "./base/AddAdapterBase.s.sol";
 
contract AddAdapterScript is AddAdapterBaseScript {
    address constant VAULT = 0x0000000000000000000000000000000000000000;
    address constant ADAPTER = 0x0000000000000000000000000000000000000000;
 
    function run() public {
        runBase(VAULT, ADAPTER);
    }
}

Parameters

ParameterDescription
VAULTAddress of the Vault V2.
ADAPTERAddress of the adapter to add to the Universal Delegator.

Deploy

Run:

forge script script/delegator/AddAdapter.s.sol:AddAdapterScript \
    --rpc-url=RPC \
    --account=ACCOUNT \
    --sender=SENDER \
    --broadcast

Replace:

PlaceholderDescription
RPCRPC endpoint.
ACCOUNTFoundry account.
SENDERAddress holding the addAdapterRoleHolder role.

Verify

  1. Open the Vault V2 contract.
  2. Read delegator() to obtain the Universal Delegator address.
  3. Open the Universal Delegator contract.
  4. Verify the adapter was successfully added using the available read methods or emitted events.