diff --git a/contracts/mocks/Disposables/DisposableCover.sol b/contracts/mocks/Disposables/DisposableCover.sol index 2537bd101a..f8dcb9506b 100644 --- a/contracts/mocks/Disposables/DisposableCover.sol +++ b/contracts/mocks/Disposables/DisposableCover.sol @@ -12,21 +12,22 @@ contract DisposableCover is MasterAwareV2 { /* ========== STATE VARIABLES ========== */ - Product[] public products; - ProductType[] public productTypes; + Product[] internal _products; + ProductType[] internal _productTypes; - CoverData[] private coverData; + CoverData[] private _coverData; mapping(uint => mapping(uint => PoolAllocation[])) public coverSegmentAllocations; /* Each Cover has an array of segments. A new segment is created everytime a cover is edited to deliniate the different cover periods. */ - mapping(uint => CoverSegment[]) coverSegments; + mapping(uint => CoverSegment[]) private _coverSegments; + uint24 public globalCapacityRatio; uint24 public globalRewardsRatio; - uint64 public stakingPoolCounter; + uint64 public stakingPoolCount; /* bit map representing which assets are globally supported for paying for and for paying out covers @@ -35,13 +36,19 @@ contract DisposableCover is MasterAwareV2 { */ uint32 public coverAssetsFallback; + // Global active cover amount per asset. + mapping(uint24 => uint) public totalActiveCoverInAsset; + + bool public coverAmountTrackingEnabled; + bool public activeCoverAmountCommitted; + function addProducts( Product[] calldata newProducts, string[] calldata ipfsMetadata ) external { - uint initialProuctsCount = products.length; + uint initialProuctsCount = _products.length; for (uint i = 0; i < newProducts.length; i++) { - products.push(newProducts[i]); + _products.push(newProducts[i]); emit ProductUpserted(initialProuctsCount + i, ipfsMetadata[i]); } } @@ -50,9 +57,9 @@ contract DisposableCover is MasterAwareV2 { ProductType[] calldata newProductTypes, string[] calldata ipfsMetadata ) public { - uint initialProuctTypesCount = productTypes.length; + uint initialProuctTypesCount = _productTypes.length; for (uint i = 0; i < newProductTypes.length; i++) { - productTypes.push(newProductTypes[i]); + _productTypes.push(newProductTypes[i]); emit ProductTypeUpserted(initialProuctTypesCount + i, ipfsMetadata[i]); } } @@ -63,7 +70,7 @@ contract DisposableCover is MasterAwareV2 { ) public { require(productIds.length == initialPriceRatios.length, "Cover: Array lengths must not be different"); for (uint i = 0; i < productIds.length; i++) { - products[productIds[i]].initialPriceRatio = initialPriceRatios[i]; + _products[productIds[i]].initialPriceRatio = initialPriceRatios[i]; } } diff --git a/test/integration/Cover/index.js b/test/integration/Cover/index.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/setup.js b/test/integration/setup.js index 5b85cd5332..8366ca7680 100644 --- a/test/integration/setup.js +++ b/test/integration/setup.js @@ -77,6 +77,9 @@ async function setup () { const IndividualClaims = artifacts.require('IndividualClaims'); const Assessment = artifacts.require('Assessment'); + const signers = await ethers.getSigners(); + const ethersAccounts = getAccounts(signers); + // external const WETH9 = artifacts.require('WETH9'); const CSMockSettlement = artifacts.require('CSMockSettlement'); @@ -165,7 +168,11 @@ async function setup () { const as = await deployProxy(DisposableAssessment, []); const cl = await deployProxy(CoverMigrator, []); - const cover = await deployProxy(DisposableCover, []); + const coverUtilsLib = await CoverUtilsLib.new(); + await Cover.link(coverUtilsLib); + + let cover = await deployProxy(DisposableCover, []); + const coverNFT = await CoverNFT.new('Nexus Mutual Cover', 'NMC', cover.address); const stakingPool = await IntegrationMockStakingPool.new(tk.address, cover.address, tc.address, mr.address); @@ -211,6 +218,9 @@ async function setup () { [owner], // advisory board members ); + await mr.setKycAuthAddress(ethersAccounts.defaultSender.address); + + await pc.initialize(mr.address); for (const category of proposalCategories) { @@ -320,15 +330,16 @@ async function setup () { await upgradeProxy(yt.address, YieldTokenIncidents, [tk.address, coverNFT.address]); await upgradeProxy(as.address, Assessment, [master.address]); - const coverUtilsLib = await CoverUtilsLib.new(); - await Cover.link(coverUtilsLib); + await upgradeProxy(cover.address, Cover, [ qd.address, productsV1.address, - stakingPool.address, coverNFT.address, + stakingPool.address, cover.address, ]); + + cover = await Cover.at(cover.address); // // { // const params = {} @@ -431,26 +442,42 @@ async function setup () { ethToDaiRate, }; - this.contractType = contractType; - const kycAuthSigner = ''; - await enrollMember(this.contracts, members, kycAuthSigner); + this.contractType = contractType; - const signers = await ethers.getSigners(); this.withEthers = web3ToEthers(this, signers); + await enrollMember(this.contracts, ethersAccounts.members, ethersAccounts.defaultSender); + + const DEFAULT_POOL_FEE = '5' + + const DEFAULT_PRODUCT_INITIALIZATION = [ + { + productId: 0, + weight: 100, + initialPrice: 1000, + targetPrice: 1000 + } + ] + for (let i = 0; i < 3; i++) { - const tx = await this.withEthers.contracts.cover.createStakingPool(stakingPoolManagers[i]); + const tx = await this.withEthers.contracts.cover.createStakingPool( + stakingPoolManagers[i], + false, // isPrivatePool, + DEFAULT_POOL_FEE, // initialPoolFee + DEFAULT_POOL_FEE, // maxPoolFee, + DEFAULT_PRODUCT_INITIALIZATION, + '0', // depositAmount, + '0', // trancheId + ); const receipt = await tx.wait(); - const { stakingPoolAddress } = receipt.events[0].args; + const stakingPoolAddress = await cover.stakingPool(i); const stakingPoolInstance = await IntegrationMockStakingPool.at(stakingPoolAddress); - await stakingPoolInstance.setPrice(0, 100); - await stakingPoolInstance.setPrice(1, 100); - await stakingPoolInstance.setPrice(2, 100); - await stakingPoolInstance.setPrice(3, 100); + this.contracts['stakingPool' + i] = stakingPoolInstance; } + this.withEthers = web3ToEthers(this, signers); } diff --git a/test/integration/utils/enroll.js b/test/integration/utils/enroll.js index 2db883d2de..6ce3f0856c 100644 --- a/test/integration/utils/enroll.js +++ b/test/integration/utils/enroll.js @@ -41,9 +41,8 @@ async function enrollMember ({ mr, tk, tc }, members, kycAuthSigner, options = { value: JOINING_FEE, }); - - await tk.approve(tc.address, MAX_UINT256, { from: member }); - await tk.transfer(member, toBN(initialTokens)); + await tk.approve(tc.address, MAX_UINT256, { from: member.address }); + await tk.transfer(member.address, toBN(initialTokens)); } }