-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CoverProducts + createStakingPool refactoring
- Loading branch information
1 parent
069a815
commit f6e39d5
Showing
56 changed files
with
1,839 additions
and
1,547 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
pragma solidity >=0.5.0; | ||
|
||
import "./ICover.sol"; | ||
|
||
/* ========== DATA STRUCTURES ========== */ | ||
|
||
struct ProductParam { | ||
string productName; | ||
uint productId; | ||
string ipfsMetadata; | ||
Product product; | ||
uint[] allowedPools; | ||
} | ||
|
||
struct ProductTypeParam { | ||
string productTypeName; | ||
uint productTypeId; | ||
string ipfsMetadata; | ||
ProductType productType; | ||
} | ||
|
||
interface ICoverProducts { | ||
|
||
/* ========== VIEWS ========== */ | ||
|
||
function allowedPoolsCount(uint productId) external view returns (uint); | ||
|
||
function products(uint id) external view returns (Product memory); | ||
|
||
function productNames(uint productId) external view returns (string memory); | ||
|
||
function productsCount() external view returns (uint); | ||
|
||
function productTypesCount() external view returns (uint); | ||
|
||
function productTypes(uint id) external view returns (ProductType memory); | ||
|
||
function getProducts() external view returns (Product[] memory); | ||
|
||
function isPoolAllowed(uint productId, uint poolId) external view returns (bool); | ||
|
||
function requirePoolIsAllowed(uint[] calldata productIds, uint poolId) external view; | ||
|
||
/* === MUTATIVE FUNCTIONS ==== */ | ||
|
||
function setProductTypes(ProductTypeParam[] calldata productTypes) external; | ||
|
||
function setProducts(ProductParam[] calldata params) external; | ||
|
||
|
||
/* ========== EVENTS ========== */ | ||
|
||
event ProductSet(uint id, string ipfsMetadata); | ||
event ProductTypeSet(uint id, string ipfsMetadata); | ||
|
||
// Products | ||
error ProductDoesntExist(); | ||
error ProductTypeNotFound(); | ||
error ProductDeprecated(); | ||
error InvalidProductType(); | ||
error UnexpectedProductId(); | ||
error PoolNotAllowedForThisProduct(uint productId); | ||
|
||
// Cover and payment assets | ||
error UnsupportedCoverAssets(); | ||
error UnexpectedEthSent(); | ||
|
||
// Price & Commission | ||
error PriceExceedsMaxPremiumInAsset(); | ||
error TargetPriceBelowGlobalMinPriceRatio(); | ||
error InitialPriceRatioBelowGlobalMinPriceRatio(); | ||
error InitialPriceRatioAbove100Percent(); | ||
error CommissionRateTooHigh(); | ||
|
||
// Misc | ||
error CapacityReductionRatioAbove100Percent(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
pragma solidity ^0.8.18; | ||
|
||
import "../../interfaces/ICover.sol"; | ||
import "../../interfaces/ICoverNFT.sol"; | ||
|
||
|
||
contract CLMockCoverProducts { | ||
|
||
Product[] internal _products; | ||
mapping(uint => uint) capacityFactors; | ||
|
||
ProductType[] internal _productTypes; | ||
|
||
|
||
function products(uint id) external view returns (Product memory) { | ||
return _products[id]; | ||
} | ||
|
||
function productTypes(uint id) external view returns (ProductType memory) { | ||
return _productTypes[id]; | ||
} | ||
|
||
|
||
function addProductType( | ||
uint8 claimMethod, | ||
uint32 gracePeriod, | ||
uint16 /*burnRatio*/ | ||
) external { | ||
_productTypes.push(ProductType( | ||
claimMethod, | ||
gracePeriod | ||
)); | ||
} | ||
|
||
function addProduct(Product calldata product) external { | ||
_products.push(product); | ||
} | ||
} |
Oops, something went wrong.