Hi everyone,
I'm a Solidity developer currently studying OpenZeppelin. I'm trying to clone the same implementation contract twice within the same function, but when I try to do so only the first clone I'm trying to make actually is "usable": the other one has some sort of error that doesn't allow me to interact with it using ABI.
Please find attached the code I've written:
// SPDX-License-Identifier: UNLICENSE
// Author: Stilgar
pragma solidity ^0.8.0;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "./CaladanToken.sol";
contract CaladanPool is OwnableUpgradeable {
string public poolName;
uint public earnedReward = 0;
uint public strikePrice;
address public rewardToken;
address public shortTokenAddress;
address public longTokenAddress;
function initialize(string memory _poolName, uint _strikePrice, address tokenImplementation) virtual initializer public {
// initilaize PoolName and tracked Strike Price
poolName = _poolName;
strikePrice = _strikePrice;
// clone and create a LONG pool token
longTokenAddress = Clones.clone(tokenImplementation);
CaladanToken longToken = CaladanToken(longTokenAddress);
string memory longName = string(abi.encodePacked("LONG-",_poolName));
longToken.initialize(longName, longName);
// clone and create a SHORT pool token
shortTokenAddress = Clones.clone(tokenImplementation);
CaladanToken shortToken = CaladanToken(shortTokenAddress);
string memory nameSymbol = string(abi.encodePacked("SHORT-",_poolName));
shortToken.initialize(nameSymbol, nameSymbol);
__Ownable_init();
}
}```