Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
51d0a34
CoverProducts + createStakingPool refactoring
danoctavian Aug 1, 2023
c1d05be
remove index.js, not needed any more
MilGard91 Aug 4, 2023
c45e56e
fix PR issues
danoctavian Aug 26, 2023
d1212fd
remove fix that is relevant only for edit implementation
danoctavian Aug 27, 2023
b99d959
remove duplicate GLOBAL_MIN_PRICE_RATIO
danoctavian Aug 27, 2023
3d52a5d
add migration for product and product types
danoctavian Aug 28, 2023
9552409
Fix test setup
MilGard91 Dec 7, 2023
1994927
Rename allowedPools var
MilGard91 Dec 7, 2023
f265865
Add LegacyCover and clean Cover contract
MilGard91 Dec 11, 2023
37cc169
Add DisposableCoverProducts contract
MilGard91 Dec 14, 2023
497fded
Fix duplicate definition
MilGard91 Dec 18, 2023
d16c545
Fix failing test after rebase
MilGard91 Mar 14, 2024
dfcfa8b
--wip-- [skip ci]
shark0der Apr 1, 2024
7f26f0f
--wip-- [skip ci]
shark0der Apr 2, 2024
c15a76d
--wip-- [skip ci]
shark0der Apr 7, 2024
16016ea
Restructure mocks directory
MilGard91 Apr 8, 2024
e7a793f
Add generic contracts
MilGard91 Apr 8, 2024
20088c5
Assessment Mocks inherit Generics
MilGard91 Apr 8, 2024
5c9a57f
Claims module mocks inherit Generics
MilGard91 Apr 9, 2024
94bfe68
Cover module mocks inherit Generics
MilGard91 Apr 9, 2024
a1a9438
Cover Migrator Mocks module mocks inherit Generics
MilGard91 Apr 9, 2024
4033188
CoverProducts module mocks inherit Generics
MilGard91 Apr 9, 2024
4b885a7
CoverViewer module mocks inherit Generics
MilGard91 Apr 9, 2024
95dd046
Incidents module mocks inherit Generics
MilGard91 Apr 9, 2024
39a140a
Master module mocks inherit Generics
MilGard91 Apr 9, 2024
c0cb549
MCR module mocks inherit Generics
MilGard91 Apr 9, 2024
54a6ff1
MemberRoles module mocks inherit Generics
MilGard91 Apr 9, 2024
55e6eea
Pool module mocks inherit Generics
MilGard91 Apr 9, 2024
4d1180a
Ramm module mocks inherit Generics
MilGard91 Apr 9, 2024
f7cc498
Staking NFT module mocks inherit Generics
MilGard91 Apr 9, 2024
7a0d245
StakingPool module mocks inherit Generics
MilGard91 Apr 9, 2024
9bb53ac
Staking Product module mocks inherit Generics
MilGard91 Apr 9, 2024
187081c
SwapOperator module mocks inherit Generics
MilGard91 Apr 9, 2024
634f0f9
TokenController module mocks inherit Generics
MilGard91 Apr 9, 2024
7ab0fe3
Common Mocks inherit Generics
MilGard91 Apr 9, 2024
a91fbcc
Fix recalculateEffectiveWeightsForAllProducts tests
MilGard91 Apr 15, 2024
0aea28b
Rename CoverMock contracts
MilGard91 Apr 15, 2024
109e9ba
Rename Ramm Mock contracts
MilGard91 Apr 15, 2024
c16e075
Remove mock test from Cover unit tests
MilGard91 Apr 15, 2024
9edb264
Clean up StakingProduct tests
MilGard91 Apr 16, 2024
2b63bbb
Remove INXMToken from generics directory
MilGard91 Apr 25, 2024
e2b316d
Rename MMockNewContract to MSMockNewContract
MilGard91 Apr 25, 2024
7d156fe
Instead of calling cover mock, call staking pool directly
MilGard91 Apr 25, 2024
a960b21
Rename StakingPool Mocks
MilGard91 Apr 25, 2024
34b0ad2
Rename StakingPool Mocks
MilGard91 May 2, 2024
b247f6a
Fix generics
MilGard91 Jun 12, 2024
e2baa68
Add `recalculateActiveCoverInAsset` to Cover contract
MilGard91 Mar 14, 2024
77e79c8
Add `totalActiveCoverInAsset` and `activeCoverExpirationBuckets` upda…
MilGard91 Mar 14, 2024
725ff7d
Add update for `lastBucketUpdateId` in `recalculateActiveCoverInAsset…
MilGard91 Jun 12, 2024
1685dc8
Add `recalculateActiveCoverInAsset` to CoverGeneric
MilGard91 Jun 12, 2024
2c8352a
Separate `allowedPool` from fixed price check
MilGard91 Jun 17, 2024
75564c1
Add and fix tests
MilGard91 Jun 17, 2024
9845b27
Add gas optimization in the allowed pools check
MilGard91 Jun 18, 2024
98eaf0b
Add allowed pools migration to migrateCoverData
MilGard91 Jun 13, 2024
1d0c3e7
Removing old tests, fork tests will be covering the migration
MilGard91 Jun 17, 2024
80fab34
Add tests for migrating cover data
MilGard91 Jun 18, 2024
0d5e460
Add `changeStakingPoolFactoryOperator` to StakingProducts
MilGard91 Jun 17, 2024
c328290
Add extended interface for StakingPoolFactory
MilGard91 Jun 17, 2024
ea5dfe8
Extend CoverNFT interfaces with method to change NFT descriptor
MilGard91 Jun 17, 2024
92720a0
Add `changeNFTDescriptor` and `changeStakingPoolFactoryOperator` meth…
MilGard91 Jun 17, 2024
9d61ba6
Add tests for `changeNFTDescriptor`
MilGard91 Jun 17, 2024
4561539
Add tests for `changeStakingPoolFactoryOperator`
MilGard91 Jun 17, 2024
e459467
Rename `IExtendedStakingPoolFactory` to `ICompleteStakingPoolFactory`…
MilGard91 Jun 17, 2024
9bafd74
Add comment for `ICompleteStakingPoolFactory`
MilGard91 Jun 17, 2024
21d0a3a
Use the immutable cover contract address when resolving the cover() dep
shark0der Jun 18, 2024
9c26d6b
Add functions to swap SPF operator role and NFT descriptors
shark0der Jun 18, 2024
4288799
Add check if operator already changed
MilGard91 Jun 19, 2024
8a5e83b
Change operator to StakingProducts automatically without passing an a…
MilGard91 Jun 19, 2024
4adad82
Fix tests
MilGard91 Jun 19, 2024
8054daf
Remove redundant error from SPF operator changing functions
shark0der Jun 19, 2024
5eaee01
Fix the modifiers for the nft descriptor changing functions
shark0der Jun 19, 2024
430948a
Fix SPF interface conflicts
shark0der Jun 19, 2024
e5cbf11
Fix changeNFTDescriptor tests
MilGard91 Jun 19, 2024
7e642c8
Remove `changeStakingPoolFactoryOperator` onlyInternal modifier
MilGard91 Jun 19, 2024
fa9e2b1
Move most structs to interfaces
shark0der Jun 20, 2024
2c435f7
Cleanup IndividualClaims contract
MilGard91 Jun 18, 2024
eaca6ab
Cleanup YieldTokenIncidents contract
MilGard91 Jun 18, 2024
08c19dc
Cleanup Cover contract
MilGard91 Jun 18, 2024
b6cb640
Cleanup CoverNFTDescriptor contract
MilGard91 Jun 18, 2024
1e09a6a
Cleanup CoverProducts contract
MilGard91 Jun 18, 2024
c5f4a2d
Cleanup StakingPool contract
MilGard91 Jun 18, 2024
55a086c
Cleanup StakingProducts contract
MilGard91 Jun 19, 2024
c062fe8
Fix linting
MilGard91 Jun 24, 2024
70ca1cc
Re-add initialize products tests
shark0der Jun 28, 2024
19db0d0
Add fork tests
MilGard91 Jun 11, 2024
6d08a43
Variable rename
shark0der Jul 1, 2024
70ce066
Merge pull request #1148 from NexusMutual/feature/cover-products-fork
shark0der Jul 2, 2024
2d7fd1f
Partially cleanup the mocks
shark0der Jul 3, 2024
0c29539
Fix off by one in `recalculateActiveCoverInAsset`
shark0der Jul 4, 2024
da68d2c
Remove deprecated productNames(), fix licenses, add minor text changes
shark0der Jul 4, 2024
b8d8be9
Remove CoverMigrator.sol, LegacyGateway.sol, PricesV1.sol and Product…
roxdanila Jul 4, 2024
09db7af
Fix lint and remove commented lines
roxdanila Jul 4, 2024
3a752c9
Fix layout tests
roxdanila Jul 4, 2024
ea9e5f9
Put back GW in the MasterAwareV1 ID enum + more cleanups
roxdanila Jul 4, 2024
451c2ae
More cleanups of unused interfaces and remove ProductsV1.sol contract
roxdanila Jul 4, 2024
9a516f8
Remove IBrightUnionDistributor.sol
roxdanila Jul 4, 2024
d3eb2cf
Add product and product type metadata setters and getters
shark0der Jul 8, 2024
db66e4f
Cleanup Cover and CoverProducts custom errors and events
shark0der Jul 8, 2024
bb91de7
Rename the `ProductDoesntExist` error to `ProductNotFound` in Cover.sol
shark0der Jul 8, 2024
82b1ee7
Fix the cover buy tests related to the ProductDeprecated error
shark0der Jul 8, 2024
3263495
Add metadata functions to the interface and implement them in the mock
shark0der Jul 8, 2024
57b5bf9
Fix metadata update logic
shark0der Jul 8, 2024
a01862b
Fix setProducts tests
shark0der Jul 8, 2024
4a1fbda
Fix setProductTypes tests
shark0der Jul 9, 2024
372119d
Fix integration buyCover test
shark0der Jul 9, 2024
83d3564
Add forgotten await
shark0der Jul 9, 2024
870166f
Add cover products metadata tests
shark0der Jul 9, 2024
bd2aced
Skip product metadata update if the ipfs hash is empty when calling s…
shark0der Jul 9, 2024
baae9ea
Add metadata migration script
shark0der Jul 9, 2024
83ff653
Only keep the latest metadata update in the metadata migration script
shark0der Jul 10, 2024
42d7582
Merge pull request #1171 from NexusMutual/feat/move-ipfs-hashes-to-st…
shark0der Jul 10, 2024
68e3f78
Remove overriding `this` with implementation contracts
shark0der Jul 11, 2024
4aa3afb
Gas optimization
MilGard91 Jul 17, 2024
f964900
Fix fork tests
MilGard91 Jul 17, 2024
2240cee
Remove unused private constants
MilGard91 Jul 17, 2024
390a388
Add check if allowed pool is 0
MilGard91 Jul 17, 2024
7e36266
Change exposure of `productNames` from public to internal
MilGard91 Jul 17, 2024
5deb021
Add calculation for `yearlyBucketsCount` instead of hardcoding it
MilGard91 Jul 17, 2024
00a844d
Add events for setting products and product types
MilGard91 Jul 17, 2024
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
3 changes: 2 additions & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ module.exports = {
'abstract/',
'external/',
'interfaces/',
'libraries/',
'mocks/',
'modules/assessment/AssessmentViews.sol',
'modules/cover/CoverViewer.sol',
'modules/cover/ProductsV1.sol',
'modules/governance/external',
'modules/legacy',
'modules/staking/StakingViewer.sol',
'modules/token/external',
'utils/',
],
Expand Down
32 changes: 0 additions & 32 deletions Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions contracts/interfaces/IBrightUnionDistributor.sol

This file was deleted.

17 changes: 17 additions & 0 deletions contracts/interfaces/ICompleteStakingPoolFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity >=0.5.0;

import "./IStakingPoolFactory.sol";

/**
* @dev IStakingPoolFactory is missing the changeOperator() and operator() functions.
* @dev Any change to the original interface will affect staking pool addresses
* @dev This interface is created to add the missing functions so it can be used in other contracts.
*/
interface ICompleteStakingPoolFactory is IStakingPoolFactory {

function operator() external view returns (address);

function changeOperator(address newOperator) external;
}
158 changes: 34 additions & 124 deletions contracts/interfaces/ICover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,21 @@ pragma solidity >=0.5.0;
import "./ICoverNFT.sol";
import "./IStakingNFT.sol";
import "./IStakingPool.sol";
import "./IStakingPoolFactory.sol";
import "./ICompleteStakingPoolFactory.sol";

/* ========== DATA STRUCTURES ========== */
/* io structs */

enum ClaimMethod {
IndividualClaims,
YieldTokenIncidents
}

// Basically CoverStatus from QuotationData.sol but with the extra Migrated status to avoid
// polluting Cover.sol state layout with new status variables.
enum LegacyCoverStatus {
Active,
ClaimAccepted,
ClaimDenied,
CoverExpired,
ClaimSubmitted,
Requested,
Migrated
}

/* io structs */

struct PoolAllocationRequest {
uint40 poolId;
bool skip;
uint coverAmountInAsset;
}

struct RequestAllocationVariables {
uint previousPoolAllocationsLength;
uint previousPremiumInNXM;
uint refund;
uint coverAmountInNXM;
}

struct BuyCoverParams {
uint coverId;
address owner;
Expand All @@ -55,28 +34,6 @@ struct BuyCoverParams {
string ipfsData;
}

struct ProductParam {
string productName;
uint productId;
string ipfsMetadata;
Product product;
uint[] allowedPools;
}

struct ProductTypeParam {
string productTypeName;
uint productTypeId;
string ipfsMetadata;
ProductType productType;
}

struct ProductInitializationParams {
uint productId;
uint8 weight;
uint96 initialPrice;
uint96 targetPrice;
}

/* storage structs */

struct PoolAllocation {
Expand All @@ -101,31 +58,27 @@ struct CoverSegment {
uint24 globalCapacityRatio;
}

struct Product {
uint16 productType;
address yieldTokenAddress;
// cover assets bitmap. each bit represents whether the asset with
// the index of that bit is enabled as a cover asset for this product
uint32 coverAssets;
uint16 initialPriceRatio;
uint16 capacityReductionRatio;
bool isDeprecated;
bool useFixedPrice;
}
interface ICover {

struct ProductType {
uint8 claimMethod;
uint32 gracePeriod;
}
/* ========== DATA STRUCTURES ========== */

struct ActiveCover {
// Global active cover amount per asset.
uint192 totalActiveCoverInAsset;
// The last time activeCoverExpirationBuckets was updated
uint64 lastBucketUpdateId;
}
/* internal structs */

interface ICover {
struct RequestAllocationVariables {
uint previousPoolAllocationsLength;
uint previousPremiumInNXM;
uint refund;
uint coverAmountInNXM;
}

/* storage structs */

struct ActiveCover {
// Global active cover amount per asset.
uint192 totalActiveCoverInAsset;
// The last time activeCoverExpirationBuckets was updated
uint64 lastBucketUpdateId;
}

/* ========== VIEWS ========== */

Expand All @@ -142,82 +95,49 @@ interface ICover {
uint segmentId
) external view returns (CoverSegment memory);

function products(uint id) external view returns (Product memory);

function productTypes(uint id) external view returns (ProductType memory);

function stakingPool(uint index) external view returns (IStakingPool);

function productNames(uint productId) external view returns (string memory);

function productsCount() external view returns (uint);

function productTypesCount() external view returns (uint);
function recalculateActiveCoverInAsset(uint coverAsset) external;

function totalActiveCoverInAsset(uint coverAsset) external view returns (uint);

function globalCapacityRatio() external view returns (uint);
function getGlobalCapacityRatio() external view returns (uint);

function globalRewardsRatio() external view returns (uint);
function getGlobalRewardsRatio() external view returns (uint);

function getPriceAndCapacityRatios(uint[] calldata productIds) external view returns (
function getGlobalMinPriceRatio() external pure returns (uint);

function getGlobalCapacityAndPriceRatios() external view returns (
uint _globalCapacityRatio,
uint _globalMinPriceRatio,
uint[] memory _initialPriceRatios,
uint[] memory _capacityReductionRatios
uint _globalMinPriceRatio
);

/* === MUTATIVE FUNCTIONS ==== */
function GLOBAL_MIN_PRICE_RATIO() external view returns (uint);

function addLegacyCover(
uint productId,
uint coverAsset,
uint amount,
uint start,
uint period,
address newOwner
) external returns (uint coverId);
/* === MUTATIVE FUNCTIONS ==== */

function buyCover(
BuyCoverParams calldata params,
PoolAllocationRequest[] calldata coverChunkRequests
) external payable returns (uint coverId);

function setProductTypes(ProductTypeParam[] calldata productTypes) external;

function setProducts(ProductParam[] calldata params) external;

function burnStake(
uint coverId,
uint segmentId,
uint amount
) external returns (address coverOwner);

function changeStakingPoolFactoryOperator() external;

function coverNFT() external returns (ICoverNFT);

function stakingNFT() external returns (IStakingNFT);

function stakingPoolFactory() external returns (IStakingPoolFactory);

function createStakingPool(
bool isPrivatePool,
uint initialPoolFee,
uint maxPoolFee,
ProductInitializationParams[] calldata productInitParams,
string calldata ipfsDescriptionHash
) external returns (uint poolId, address stakingPoolAddress);

function isPoolAllowed(uint productId, uint poolId) external returns (bool);
function requirePoolIsAllowed(uint[] calldata productIds, uint poolId) external view;
function stakingPoolFactory() external returns (ICompleteStakingPoolFactory);

/* ========== EVENTS ========== */

event ProductSet(uint id, string ipfsMetadata);
event ProductTypeSet(uint id, string ipfsMetadata);
event CoverEdited(uint indexed coverId, uint indexed productId, uint indexed segmentId, address buyer, string ipfsMetadata);

// Auth
error OnlyMemberRolesCanOperateTransfer();
error OnlyOwnerOrApproved();

// Cover details
Expand All @@ -227,26 +147,19 @@ interface ICover {
error CoverAmountIsZero();

// Products
error ProductDoesntExist();
error ProductTypeNotFound();
error ProductDoesntExistOrIsDeprecated();
error InvalidProductType();
error ProductNotFound();
error ProductDeprecated();
error UnexpectedProductId();
error PoolNotAllowedForThisProduct(uint productId);

// Cover and payment assets
error CoverAssetNotSupported();
error InvalidPaymentAsset();
error UnexpectedCoverAsset();
error UnsupportedCoverAssets();
error UnexpectedEthSent();
error EditNotSupported();

// Price & Commission
error PriceExceedsMaxPremiumInAsset();
error TargetPriceBelowGlobalMinPriceRatio();
error InitialPriceRatioBelowGlobalMinPriceRatio();
error InitialPriceRatioAbove100Percent();
error CommissionRateTooHigh();

// ETH transfers
Expand All @@ -256,11 +169,8 @@ interface ICover {
error ReturningEthRemainderToSenderFailed();

// Misc
error AlreadyInitialized();
error ExpiredCoversCannotBeEdited();
error CoverNotYetExpired(uint coverId);
error CoverAlreadyExpired(uint coverId);
error InsufficientCoverAmountAllocated();
error UnexpectedPoolId();
error CapacityReductionRatioAbove100Percent();
}
2 changes: 1 addition & 1 deletion contracts/interfaces/ICoverBroker.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;
pragma solidity >=0.5.0;

import "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";

Expand Down
15 changes: 0 additions & 15 deletions contracts/interfaces/ICoverMigrator.sol

This file was deleted.

2 changes: 2 additions & 0 deletions contracts/interfaces/ICoverNFT.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ interface ICoverNFT is IERC721 {

function changeOperator(address newOperator) external;

function changeNFTDescriptor(address newNFTDescriptor) external;

function totalSupply() external view returns (uint);

function name() external view returns (string memory);
Expand Down
Loading