Vault implementation deploy

Deploying the Vault implementation requires passing 2 arrays of the same length: selectors and logicAddresses.

  • the array of selectors must be sorted

  • a selector must match an address with the same index.

During the deployment, data is created from the arrays and stored as bytecode of the contract logicsAndSelectorsAddress:.

function selectors and logic addresses are stored as bytes data:
selector . address, where "." - concatination

sample:

0xaaaaaaaa <- selector
0xffffffffffffffffffffffffffffffffffffffff <- address

0xaaaaaaaaffffffffffffffffffffffffffffffffffffffff <- one element

When calling any function on vault in the fallback function, the bytecode of the logicsAndSelectorsAddress contract is copied into memory and a binary search is used to find the address to which delegatecall should be made.

If the length of the logicsAndSelectorsAddress contract bytecode is < 24 or the _getAddress method returns address(0): the call will revert with Vault_FunctionDoesNotExist()

Last updated