MultiAccount

In order to place trades using a SYMM frontend solution or otherwise, it's necessary to create a sub-account using a MultiAccount contract that is whitelisted to interact with the hedger. Users are required to provide a name as an input parameter when they create a sub-account. All positions on a sub-account are in CROSS, but positions between sub-accounts are ISOLATED.

MultiAccount Contract Functions

Initialization and Setup

initialize()

Initializes the MultiAccount contract with roles and addresses necessary for operation.

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

        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(PAUSER_ROLE, admin);
        _grantRole(UNPAUSER_ROLE, admin);
        _grantRole(SETTER_ROLE, admin);
        accountsAdmin = admin;
        symmioAddress = symmioAddress_;
        accountImplementation = accountImplementation_;
    }
  • Parameters:

    • admin: The administrator's address who will have default and control roles.

    • symmioAddress_: Address of the Symmio platform to interact with.

    • accountImplementation_: Bytecode for the account implementation to be used (SymmioPartyA).

Account Management

addAccount()

Creates a new sub-account for a user with a specified name.

Parameters:

  • name: Name of the sub-account.

Emits: AddAccount event upon successful creation.

editAccountName()

Allows the owner to change the name of an existing sub-account.

Parameters:

  • accountAddress: Address of the account to rename.

  • name: New name for the account.

Emits: EditAccountName event.

depositForAccount()

Deposits funds into a sub-account from the owner's balance.

Parameters:

  • account: Address of the sub-account.

  • amount: Amount to deposit.

Emits: DepositForAccount event.

depositAndAllocateForAccount()

Deposits funds into a sub-account and allocates them for trading.

Parameters:

  • account: Address of the sub-account.

  • amount: Amount to deposit and allocate.

Emits: DepositForAccount and AllocateForAccount events.

withdrawFromAccount()

Withdraws funds from a sub-account back to the owner's address.

Parameters:

  • account: Address of the sub-account.

  • amount: Amount to withdraw.

Emits: WithdrawFromAccount event.

Access Control

delegateAccess()

Allows the owner of a sub-account to delegate control over specific functions to another address.

Parameters:

  • account: Address of the sub-account.

  • target: Address to which access is delegated.

  • selector: Function selector for which access is granted.

  • state: Boolean to enable or disable access. true sets the delegation state to enabled, allowing the delegate to call the specified function on behalf of the sub-account

Emits: DelegateAccess event.

delegateAccesses()

Batch version of delegateAccess for multiple function selectors.

Parameters:

  • account, target, selector[], and state as in delegateAccess.

Emits: DelegateAccess event for each selector.

Configuration and Address Management

setAccountImplementation()

Sets new account implementation bytecode.

Parameters:

  • accountImplementation_: New bytecode for account implementation.

Emits: SetAccountImplementation event.

setSymmioAddress()

Updates the address of the Symmio platform.

Parameters:

addr: New address for the Symmio platform.

Emits: SetSymmioAddress event.

Pausable Functionality

pause()

Pauses all pausable actions in the contract, preventing execution. Only callable by addresses with the PAUSER_ROLE.

unpause()

Resumes all actions in the contract after being paused. Only callable by addresses with the UNPAUSER_ROLE.

Internal and Utility Functions

_deployPartyA()

Deploys a new sub-account using the current account implementation.

Returns: Address of the newly deployed account.

_deployContract()

Internal function to deploy contracts using the create2 opcode.

Parameters:

  • bytecode: Compiled bytecode of the contract.

  • salt: Salt used for create2 to determine the address.

Returns: Address of the deployed contract.

_call()

Internal function to invoke methods on other contracts.

Parameters:

  • account: Account from which the call is made.

  • _callDatas[]: Array of call data to be executed.

Executes multiple calls in a single transaction if authorized.

View Functions

getAccountsLength()

Returns the number of accounts owned by a user.

Parameters:

  • user: Address of the user.

Returns: Number of accounts.

getAccounts()

Retrieves a list of sub-accounts owned by a user.

Parameters:

  • user: Owner's address.

  • start: Start index for pagination.

  • size: Number of accounts to return.

Returns: Array of Account structs.

Last updated