View Source: contracts/core/cxToken/cxTokenFactory.sol
↗ Extends: ICxTokenFactory, Recoverable
cxTokenFactory
Deploys new instances of cxTokens on demand.
- constructor(IStore store)
- deploy(bytes32 coverKey, bytes32 productKey, string tokenName, uint256 expiryDate)
- version()
- getName()
Constructs this contract
function (IStore store) public nonpayable Recoverable
Arguments
Name | Type | Description |
---|---|---|
store | IStore | Provide the store contract instance |
Source Code
constructor(IStore store) Recoverable(store) {}
Deploys a new instance of cxTokens
function deploy(bytes32 coverKey, bytes32 productKey, string tokenName, uint256 expiryDate) external nonpayable nonReentrant
returns(deployed address)
Arguments
Name | Type | Description |
---|---|---|
coverKey | bytes32 | Enter the cover key related to this cxToken instance |
productKey | bytes32 | Enter the product key related to this cxToken instance |
tokenName | string | |
expiryDate | uint256 | Specify the expiry date of this cxToken instance |
Source Code
function deploy(
bytes32 coverKey,
bytes32 productKey,
string calldata tokenName,
uint256 expiryDate
) external override nonReentrant returns (address deployed) {
s.mustNotBePaused();
s.senderMustBePolicyContract();
s.mustBeValidCoverKey(coverKey);
s.mustBeSupportedProductOrEmpty(coverKey, productKey);
require(expiryDate > 0, "Please specify expiry date");
(bytes memory bytecode, bytes32 salt) = cxTokenFactoryLibV1.getByteCodeInternal(s, coverKey, productKey, tokenName, expiryDate);
require(s.getAddress(salt) == address(0), "Already deployed");
// solhint-disable-next-line
assembly {
deployed := create2(
callvalue(), // wei sent with current call
// Actual code starts after skipping the first 32 bytes
add(bytecode, 0x20),
mload(bytecode), // Load the size of code contained in the first 32 bytes
salt // Salt from function arguments
)
if iszero(extcodesize(deployed)) {
// @suppress-revert This is correct usage
revert(0, 0)
}
}
s.setAddress(salt, deployed);
s.setBoolByKeys(ProtoUtilV1.NS_COVER_CXTOKEN, deployed, true);
s.setAddressArrayByKeys(ProtoUtilV1.NS_COVER_CXTOKEN, coverKey, productKey, deployed);
emit CxTokenDeployed(deployed, s, coverKey, productKey, tokenName, expiryDate);
}
Version number of this contract
function version() external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|
Source Code
function version() external pure override returns (bytes32) {
return "v0.1";
}
Name of this contract
function getName() external pure
returns(bytes32)
Arguments
Name | Type | Description |
---|
Source Code
function getName() external pure override returns (bytes32) {
return ProtoUtilV1.CNAME_CXTOKEN_FACTORY;
}
- AaveStrategy
- AccessControl
- AccessControlLibV1
- Address
- BaseLibV1
- BokkyPooBahsDateTimeLibrary
- BondPool
- BondPoolBase
- BondPoolLibV1
- CompoundStrategy
- Context
- Cover
- CoverBase
- CoverLibV1
- CoverReassurance
- CoverStake
- CoverUtilV1
- cxToken
- cxTokenFactory
- cxTokenFactoryLibV1
- Delayable
- Destroyable
- ERC165
- ERC20
- FakeAaveLendingPool
- FakeCompoundStablecoinDelegator
- FakePriceOracle
- FakeRecoverable
- FakeStore
- FakeToken
- FakeUniswapPair
- FakeUniswapV2FactoryLike
- FakeUniswapV2PairLike
- FakeUniswapV2RouterLike
- FaultyAaveLendingPool
- FaultyCompoundStablecoinDelegator
- Finalization
- ForceEther
- Governance
- GovernanceUtilV1
- IAaveV2LendingPoolLike
- IAccessControl
- IBondPool
- IClaimsProcessor
- ICompoundERC20DelegatorLike
- ICover
- ICoverReassurance
- ICoverStake
- ICxToken
- ICxTokenFactory
- IERC165
- IERC20
- IERC20Detailed
- IERC20Metadata
- IERC3156FlashBorrower
- IERC3156FlashLender
- IFinalization
- IGovernance
- ILendingStrategy
- ILiquidityEngine
- IMember
- INeptuneRouterV1
- InvalidStrategy
- IPausable
- IPolicy
- IPolicyAdmin
- IPriceOracle
- IProtocol
- IRecoverable
- IReporter
- IResolution
- IResolvable
- IStakingPools
- IStore
- IStoreLike
- IUniswapV2FactoryLike
- IUniswapV2PairLike
- IUniswapV2RouterLike
- IUnstakable
- IVault
- IVaultDelegate
- IVaultFactory
- IWitness
- LiquidityEngine
- MaliciousToken
- MockAccessControlUser
- MockCoverUtilUser
- MockCxToken
- MockCxTokenPolicy
- MockCxTokenStore
- MockFlashBorrower
- MockLiquidityEngineUser
- MockProcessorStore
- MockProcessorStoreLib
- MockProtocol
- MockRegistryClient
- MockStore
- MockStoreKeyUtilUser
- MockValidationLibUser
- MockVault
- MockVaultLibUser
- NeptuneRouterV1
- NPM
- NpmDistributor
- NTransferUtilV2
- NTransferUtilV2Intermediate
- Ownable
- Pausable
- Policy
- PolicyAdmin
- PolicyHelperV1
- PoorMansERC20
- POT
- PriceLibV1
- Processor
- ProtoBase
- Protocol
- ProtoUtilV1
- Recoverable
- ReentrancyGuard
- RegistryLibV1
- Reporter
- Resolution
- Resolvable
- RoutineInvokerLibV1
- SafeERC20
- StakingPoolBase
- StakingPoolCoreLibV1
- StakingPoolInfo
- StakingPoolLibV1
- StakingPoolReward
- StakingPools
- Store
- StoreBase
- StoreKeyUtil
- StrategyLibV1
- Strings
- TimelockController
- Unstakable
- ValidationLibV1
- Vault
- VaultBase
- VaultDelegate
- VaultDelegateBase
- VaultDelegateWithFlashLoan
- VaultFactory
- VaultFactoryLibV1
- VaultLibV1
- VaultLiquidity
- VaultStrategy
- WithFlashLoan
- WithPausability
- WithRecovery
- Witness