Controller
Overview
The Controller contract serves as a centralized access control mechanism for managing interactions between various protocols integrated within the system. Specifically, this controller interacts with Perpetual Market Protocols, Derivatives Market Protocols, and Spot Market Protocols to ensure that only authorized actions are executed via the Account Manager's exec
function.
The controller plays a pivotal role in checking the validity of transactions, ensuring that operations involving external protocols such as MUX, Avantisfi, Derive, and Uniswap can only proceed if they meet specific conditions. These conditions may include authorization checks, validation of the target protocol, and other business logic requirements defined by the protocol's rules.
It works with multiple protocol integrations, including:
Perpetual Market Protocols: MUX, Avantisfi, and Perp
Option Market Protocol: Derive Protocol
Spot Market Protocol: Uniswap
canCall
The canCall
function in the controller is invoked by the Account Manager's exec
function. This function determines whether the call to the target protocol should be allowed based on the logic implemented in the controller.
function canCall(
address target,
bool condition,
bytes calldata data
)
external
returns (bool, address[] memory, address[] memory)
target
: The address of the contract being called (e.g., MUX, Avantisfi, Derive, Uniswap).condition
: A boolean indicating whether the call should be allowed under certain conditions (e.g., sufficient balance, proper permissions).data
: The function call data to be executed by the target contract.
Last updated