Delegatecall
Delegatecall is a specialized opcode in the Ethereum Virtual Machine that allows a contract to execute code from another contract while keeping its own state and storage. When a proxy contract uses delegatecall, it runs the logic of the implementation contract but writes any changes to its own storage slots.
This is the fundamental technical primitive that enables upgradeability patterns. It allows the protocol to update its behavior dynamically while ensuring that user balances and margin positions remain safely stored in the proxy contract.
Understanding delegatecall is crucial for auditing smart contract security, as incorrect implementation can lead to storage collisions or unauthorized state modifications.