How do you manage state in proxy contracts?

Hello. Im trying to call a function from my factory to my deployed proxy with this snippet:

  // Starts a Pre-Sale
  function _startPresale(uint32 activeFrom, uint32 activeUntil, uint _id) 
    ERC1967Proxy eventProxyToStart = getEventProxyById(_id);
    (bool success,) = address(eventProxyToStart).delegatecall(abi.encodeWithSignature("startPreSale(uint32,uint32)", activeFrom, activeUntil));
    require(success, "FAILED");
    emit PreSaleCreated(

The following is the code in the implementation contract I am delegatecalling:

  // Set a presale 
  function startPreSale(uint32 _activeFrom, uint32 _activeUntil)
      uint256[] memory eventIndexes,
      EventLibrary.Event[] memory events
    ) = getUpdatedEvents();
    for (uint256 i = 0; i < eventIndexes.length; i++) {
      if (
        idToEvent[eventIndexes[i]].eventState !=
      ) {
        revert("All events must be deactivated to start a pre-sale");
      if (_activeFrom | _activeUntil >= idToEvent[eventIndexes[i]].startDate) {
          "Pre-sale must start and end before the start date"
      idToEvent[eventIndexes[i]].eventState ==
      contractToSaleTrack[address(this)].eventContract = address(this);
      contractToSaleTrack[address(this)].organizer = msg.sender;
      contractToSaleTrack[address(this)].saleState = MarketPlaceLibrary
      contractToSaleTrack[address(this)].activeFrom = _activeFrom;
      contractToSaleTrack[address(this)].activeUntil = _activeUntil;
    emit MarketPlaceLibrary.EventSeriesStateChange(

I understand this factory needs to use delegateCall due to the fact that it is a proxy. Am I right?
In order to interact with the proxy, I deploy a contract of type Implementation to the address I get from the proxy creation and it gets initialized well from the factory.

The startPreSale call from the factory executes without exceptions but when I check the state variables in the proxy contract instance they are being partially stored so the return value are not right. I notice that some of the variables in the proxy deployed were not saved because the initialize function was called outside of the contract so there are variables that didn't get written. I assume data is not being recorded due to delegatecall. How do I deal with this parallelism in the writing of variables?

All in all, I want to be able to call functions directly in the proxy contract and also call others from the factory but having consistency in the state variables each contract has defined in its own.

:computer: Environment


Sorry for the late reply.

No, the proxy handles the delegatecall itself. You need to interact with it like a normal contract. So if eventProxyAddress is the address of the proxy, and I'll assume the implementation is a contract called Event, then you simply have to do something like this: Event(eventProxyAddress).startPreSale(1, 2). Note that this is just a normal function call.