Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions contracts/mocks/Disposables/DisposableCover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]);
}
}
Expand All @@ -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]);
}
}
Expand All @@ -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];
}
}

Expand Down
Empty file added test/integration/Cover/index.js
Empty file.
55 changes: 41 additions & 14 deletions test/integration/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we also have this line on :481


await enrollMember(this.contracts, ethersAccounts.members, ethersAccounts.defaultSender);

const DEFAULT_POOL_FEE = '5'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check to see if your editor is using our .eslintrc? It's best to avoid unnecessary changes in the future when someone will auto-fix this on save.


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);
}

Expand Down
5 changes: 2 additions & 3 deletions test/integration/utils/enroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down