PartyB
The SymmioPartyB
contract acts as a management contract for solvers or "Party B" . This contract allows for controlled interaction with the Symmio platform and external addresses for managing roles, permissions, and .
Constructor
Sets up initial state, disabling initializers to ensure proper contract upgrades.
Operations: Calls
_disableInitializers()
to prepare the contract for the upgrade-safe initialization pattern.
initialize()
Properly initializes the contract with roles and the address of the Symmio platform.
Parameters:
admin
: The administrator's address that will receive initial roles.symmioAddress_
: The address of the Symmio platform this contract will interact with.
Operations:
Initializes the contract as pausable and with access control features.
Grants
DEFAULT_ADMIN_ROLE
,TRUSTED_ROLE
,MANAGER_ROLE
,PAUSER_ROLE
, andUNPAUSER_ROLE
to the admin.Sets the initial Symmio address.
setSymmioAddress()
Updates the address of the Symmio platform to which calls are forwarded.
Access Control: Only accessible by users with DEFAULT_ADMIN_ROLE
.
Parameters:
addr
: New address for the Symmio platform.
Operations: Updates symmioAddress
and emits the SetSymmioAddress
event.
setRestrictedSelector()
Manages access control by setting restrictions on specific function selectors.
Access Control: Requires DEFAULT_ADMIN_ROLE
.
Parameters:
selector
: The function selector to restrict or unrestrict.state
: Boolean value indicating whether the selector is restricted.
Operations: Updates the restrictedSelectors
mapping and emits the SetRestrictedSelector
event.
setMulticastWhitelist()
Manages a whitelist of addresses allowed to be called through multicasting. This allows functions on multiple contracts to be called at the same time.
Access Control: Requires
MANAGER_ROLE
.Parameters:
addr
: The address to whitelist or remove from whitelist.state
: Boolean indicating whether to add (true) or remove (false) from the whitelist.
Operations: Updates the
multicastWhitelist
mapping and emits theSetMulticastWhitelist
event.
_approve()
Approves a token amount to the Symmio address. Only accessible by users with TRUSTED_ROLE
and when the contract is not paused.
Parameters:
token
: ERC20 token address.amount
: Amount of tokens to approve.
_executeCall()
Executes a call to a specified address with provided call data.
Parameters:
destAddress
: Destination address for the call.callData
: The data to be sent in the call.
This function ensures that the destination address is not zero and that the call data is at least 4 bytes (minimum size for a function selector).
Depending on the function selector extracted from the call data:
If the function is restricted (as per
restrictedSelectors
), the caller must have aMANAGER_ROLE
.Otherwise, either the
MANAGER_ROLE
orTRUSTED_ROLE
is required.
If the destination address is not the Symmio platform, it checks whether the address is whitelisted for calls. The call is made using the low-level call
function, and successful execution is required; otherwise, it reverts.
_call()
Executes multiple calls to the Symmio address. Iterates over _callDatas
and executes each using _executeCall
.
Parameters:
_callDatas
: An array of call data bytes to be executed.
_multicastCall()
Enables the solver to interact with multiple contracts in a single transaction.
It checks that the arrays of destination addresses and call data have the same length to ensure each address has corresponding call data then iterates through each address and associated call data, executing each via the _executeCall
function.
withdrawERC20()
Allows withdrawal of ERC20 tokens to the caller's address. Requires MANAGER_ROLE
and transfers specified amount of tokens to the caller.
Parameters:
token
: The ERC20 token address.amount
: The amount of tokens to withdraw.
pause() and unpause()
Controls the pausing and unpausing of the contract. Requires PAUSER_ROLE
for pausing and UNPAUSER_ROLE
for unpausing.
Last updated