LogoLogo
  • Overview
    • Introduction
    • Table of Contents
  • Token Information
    • Symmio Foundation
  • Protocol Architecture
    • Protocol Introduction
    • Technical Documentation
      • Building an Application with SYMM
        • Introduction and Diamond Explainer
        • Querying Info from the SYMM Diamond
        • MultiAccount
        • Creating an Account and Depositing Funds
        • Sending a Quote
        • Closing a Quote
        • Instant Trading
          • Instant Login (EOA)
          • Instant Login (Account Abstraction)
          • Sending a Quote (Instant Open)
          • Sending a Quote (Instant Close)
        • Frequently Used Queries
      • Solver Docs
        • Solver Docs (github)
        • Solver Implementation Guide (High Level Overview)
        • Building a Solver on SYMMIO
          • 1. Intent Creation
          • 2. Seeing the Intent
          • 3. Hedging Off-Chain
          • 4. Opening/Closing a Position On-Chain
          • Creating the APIs
            • GET Contract Symbols
            • GET Open Interest
            • GET Notional Cap
            • GET Price Range
            • GET Error Codes
            • GET Get Locked Params
            • GET Get Funding Info
            • POST Position State
          • Solver Flow Summary Example
          • Recommended Architecture for Solvers
          • Glossary
        • Conditional Orders Handler
        • Rasa Solver TP/SL Implementation
        • Instant Trading
          • Instant Trading (Solvers)
          • Rasa Instant Trading Implementation
          • Instant Trading Condition Checks
        • Fetching Gas Prices Script
        • How to Add a Market as a Solver
        • Verifying Account Abstracted Instant Actions (ERC-4337)
      • Frontend Docs
        • Setting up a Frontend with SYMMIO
        • Frontend SDK Setup Guide
        • MultiAccount Deployment Guide
        • Instant Trading (Frontends)
          • Account Abstracted Instant Actions (Frontends)
        • Implement a Trading Bot on Symmio (OLD)
          • Setup
          • Creating a Sub-Account
          • Minting Collateral Tokens (Optional)
          • Depositing and Allocating Tokens
          • Obtaining Muon Signatures
          • Sending a Quote
          • Monitoring Price for Execution
      • Contract Docs
        • SYMMIO CORE v0.82
        • Contracts Documentation 0.8.2
          • Main Flow
          • The SYMM Diamond
          • Facets
            • Account Facet
            • Control Facet
            • Funding Rate Facet
            • PartyA Facet
            • PartyB Facet
            • Liquidation Facet
            • View Facet
          • MultiAccount
            • PartyA
            • PartyB
          • SYMM App (Muon)
            • LibMuon
            • MuonStorage
        • Contracts Documentation 0.8.3
          • Facets
            • Control Facet
            • Account Facet
            • PartyA Facet
            • PartyB Facet
            • View Facet
            • Bridge Facet
            • Liquidation Facet (Implementation)
          • Modified Events
          • New Events
          • MuonStorage
        • Contracts Documentation 0.8.4
          • Main Flow (0.8.4)
          • The SYMM Diamond (0.8.4)
          • Facets
            • Account Facet (0.8.4)
            • Bridge Facet (0.8.4)
            • Control Facet (0.8.4)
            • Force Actions Facet (0.8.4)
            • Funding Rate Facet (0.8.4)
            • Liquidations Facet (0.8.4)
            • PartyA Facet (0.8.4)
            • PartyB Group Actions Facet (0.8.4)
            • PartyB Quote Actions Facet (0.8.4)
            • PartyB Position Actions Facet (0.8.4)
            • Settlement Facet (0.8.4)
            • View Facet (0.8.4)
          • MultiAccount (0.8.4)
            • SymmioPartyA
            • SymmioPartyB
          • SYMM App (Muon)
            • LibMuon (0.8.4)
            • MuonStorage (0.8.4)
      • Contract Addresses / Solver Endpoints
        • Mantle
        • Mode
        • IOTA
        • Base
        • BSC
        • Arbitrum
        • Polygon
        • Berachain
        • Solver Endpoints and Addresses
          • Perps Hub
          • Rasa Capital
          • Zenith
      • How to Query our Contracts
      • Muon API Queries
      • Solver Error Codes
      • Interacting with SYMMIO Contracts
    • Protocol higher level architecture
      • 12-Hour Fraud Proof Window
      • PartyB
      • Solver Settings
      • Max Leverage
      • Maintenance Margin (CVA) Calculations
    • Symmio Whitepaper
  • Building on Symmio
    • Builders introduction
    • Solving for Symmio
      • Solver documentation
      • Solver - Example Flow
    • Trading Fees
      • Perps - Settlement Costs
      • Pair Trading - Settlement costs
    • Exchanges (Frontends)
      • Frontend Introduction
      • SDK - SYMM client
      • Trade on Symmio
  • Legal & Brand & Security
    • Security (Audits / Bugbounty)
      • Bug bounty / Coverage
        • How to contact ?
      • Audits
        • SYMM - V0.8 - 0.81
          • Sherlock Audit - Jun 15, 2023
          • Smart State - Jul 2, 2023
        • SYMM - 0.82
          • Sherlock Audit -Aug 30, 2023
        • SYMM - 0.83
          • Sherlock Audit - Jun 17, 2024
        • SYMM - 0.84
          • Sherlock Audit - Oct 3, 2024
        • Vaults
          • Sherlock Audit - Jan 2, 2024
    • Terms of Service & Licensing
      • TRADEMARK & COPYRIGHT NOTICE
      • CONTACT US
      • TERMS OF SERVICE
      • FRONTEND LICENSE
        • Frontend Modifications
        • Frontend Use Grants
      • CONTRACT LICENSE
        • Contract Use Grants
        • Contract Modifications
    • Brand - Assets Logos
Powered by GitBook
LogoLogo

All rights to the people (c) 2023 Symmetry Labs A.G.

On this page
  • Constructor
  • initialize()
  • setSymmioAddress()
  • setRestrictedSelector()
  • setMulticastWhitelist()
  • _approve()
  • _executeCall()
  • _call()
  • _multicastCall()
  • withdrawERC20()
  • pause() and unpause()
  1. Protocol Architecture
  2. Technical Documentation
  3. Contract Docs
  4. Contracts Documentation 0.8.2
  5. MultiAccount

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 and permissions.

Constructor

Sets up initial state, disabling initializers to ensure proper contract upgrades.

    /// @custom:oz-upgrades-unsafe-allow constructor
    constructor() {
        _disableInitializers();
    }
  • 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.

    function initialize(address admin, address symmioAddress_) public initializer {
        __Pausable_init();
        __AccessControl_init();

        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(TRUSTED_ROLE, admin);
        _grantRole(MANAGER_ROLE, admin);
        symmioAddress = symmioAddress_;
    }

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, and UNPAUSER_ROLE to the admin.

  • Sets the initial Symmio address.

setSymmioAddress()

Updates the address of the Symmio platform to which calls are forwarded.

    function setSymmioAddress(address addr) external onlyRole(DEFAULT_ADMIN_ROLE) {
        emit SetSymmioAddress(symmioAddress, addr);
        symmioAddress = addr;
    }

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.

    function setRestrictedSelector(bytes4 selector, bool state) external onlyRole(DEFAULT_ADMIN_ROLE) {
        restrictedSelectors[selector] = state;
        emit SetRestrictedSelector(selector, state);
    }

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.

    function setMulticastWhitelist(address addr, bool state) external onlyRole(MANAGER_ROLE) {
        require(addr != address(this), "SymmioPartyB: Invalid address");
        multicastWhitelist[addr] = state;
        emit SetMulticastWhitelist(addr, state);
    }
  • 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 the SetMulticastWhitelist event.

_approve()

Approves a token amount to the Symmio address. Only accessible by users with TRUSTED_ROLE and when the contract is not paused.

    function _approve(address token, uint256 amount) external onlyRole(TRUSTED_ROLE) whenNotPaused {
        require(IERC20Upgradeable(token).approve(symmioAddress, amount), "SymmioPartyB: Not approved");
    }

Parameters:

  • token: ERC20 token address.

  • amount: Amount of tokens to approve.

_executeCall()

Executes a call to a specified address with provided call data.

    function _executeCall(address destAddress, bytes memory callData) internal {
        require(destAddress != address(0), "SymmioPartyB: Invalid address");
        require(callData.length >= 4, "SymmioPartyB: Invalid call data");

        if (destAddress == symmioAddress) {
            bytes4 functionSelector;
            assembly {
                functionSelector := mload(add(callData, 0x20))
            }
            if (restrictedSelectors[functionSelector]) {
                _checkRole(MANAGER_ROLE, msg.sender);
            } else {
                require(hasRole(MANAGER_ROLE, msg.sender) || hasRole(TRUSTED_ROLE, msg.sender), "SymmioPartyB: Invalid access");
            }
        } else {
            require(multicastWhitelist[destAddress], "SymmioPartyB: Destination address is not whitelisted");
            _checkRole(TRUSTED_ROLE, msg.sender);
        }

        (bool success, ) = destAddress.call{ value: 0 }(callData);
        require(success, "SymmioPartyB: Execution reverted");
    }
  • 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 a MANAGER_ROLE.

  • Otherwise, either the MANAGER_ROLE or TRUSTED_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.

    function _call(bytes[] calldata _callDatas) external whenNotPaused {
        for (uint8 i; i < _callDatas.length; i++) _executeCall(symmioAddress, _callDatas[i]);
    }

Parameters:

  • _callDatas: An array of call data bytes to be executed.

_multicastCall()

Enables the solver to interact with multiple contracts in a single transaction.

    function _multicastCall(address[] calldata destAddresses, bytes[] calldata _callDatas) external whenNotPaused {
        require(destAddresses.length == _callDatas.length, "SymmioPartyB: Array length mismatch");

        for (uint8 i; i < _callDatas.length; i++) _executeCall(destAddresses[i], _callDatas[i]);
    }

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.

    function withdrawERC20(address token, uint256 amount) external onlyRole(MANAGER_ROLE) {
        require(IERC20Upgradeable(token).transfer(msg.sender, amount), "SymmioPartyB: Not transferred");
    }
  • 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.

    function pause() external onlyRole(PAUSER_ROLE) {
        _pause();
    }

    function unpause() external onlyRole(UNPAUSER_ROLE) {
        _unpause();
    }
PreviousPartyANextSYMM App (Muon)

Last updated 3 months ago