Skip to content
Open
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
5 changes: 2 additions & 3 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ async function onCompileComplete() {
}

module.exports = {
mocha: { parallel: false },
onCompileComplete,
skipFiles: [
'abstract/',
'external/',
'interfaces/',
'libraries/',
'mocks/',
'modules/assessment/AssessmentViewer.sol',
'modules/viewer/NexusViewer.sol',
'modules/cover/CoverViewer.sol',
'modules/governance/external',
'modules/legacy',
Expand All @@ -65,6 +64,6 @@ module.exports = {
'utils/',
],
providerOptions: {
default_balance_ether: 100000000,
default_balance_ether: 1000000000,
},
};
2 changes: 1 addition & 1 deletion contracts/abstract/EIP712.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract contract EIP712 {
function recoverSigner(
bytes memory message,
bytes memory signature
) internal view virtual returns (address signer){
) internal view virtual returns (address signer) {
bytes32 digest = ECDSA.toTypedDataHash(DOMAIN_SEPARATOR, keccak256(message));
return ECDSA.recover(digest, signature);
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/abstract/RegistryAware.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ uint constant PAUSE_SWAPS = 1 << 2; // 4
uint constant PAUSE_MEMBERSHIP = 1 << 3; // 8
uint constant PAUSE_ASSESSMENTS = 1 << 4; // 16
uint constant PAUSE_CLAIMS = 1 << 5; // 32
uint constant PAUSE_COVER = 1 << 6; // 64

contract RegistryAware {

Expand Down Expand Up @@ -60,7 +61,6 @@ contract RegistryAware {
_;
}

// TODO: find a better short name for this function
function fetch(uint index) internal view returns (address) {
return registry.getContractAddressByIndex(index);
}
Expand Down
21 changes: 0 additions & 21 deletions contracts/interfaces/IAssessmentViewer.sol

This file was deleted.

63 changes: 41 additions & 22 deletions contracts/interfaces/ICover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity >=0.5.0;

import "./ICoverNFT.sol";
import "./IStakingNFT.sol";
import "./IStakingPoolBeacon.sol";

/* io structs */

Expand Down Expand Up @@ -35,21 +36,6 @@ struct PoolAllocation {
uint24 allocationId;
}

struct LegacyCoverData {
uint24 productId;
uint8 coverAsset;
uint96 amountPaidOut;
}

struct LegacyCoverSegment {
uint96 amount;
uint32 start;
uint32 period; // seconds
uint32 gracePeriod; // seconds
uint24 globalRewardsRatio;
uint24 globalCapacityRatio;
}

struct CoverData {
uint24 productId;
uint8 coverAsset;
Expand All @@ -66,7 +52,25 @@ struct CoverReference {
uint32 latestCoverId; // used only in the original cover (set to 0 in original cover if never edited)
}

interface ICover {
// reinsurance info
struct Ri {
uint24 providerId;
uint96 amount;
}

struct RiConfig {
uint24 nextNonce;
address premiumDestination;
}

struct RiRequest {
uint providerId;
uint amount;
uint premium;
bytes signature;
}

interface ICover is IStakingPoolBeacon {

/* ========== DATA STRUCTURES ========== */

Expand All @@ -92,14 +96,18 @@ interface ICover {

function getCoverData(uint coverId) external view returns (CoverData memory);

function getPoolAllocations(uint coverId) external view returns (PoolAllocation[] memory);
function getCoverRi(uint coverId) external view returns (Ri memory);

function getCoverDataCount() external view returns (uint);
function getCoverDataWithRi(uint coverId) external view returns (CoverData memory, Ri memory);

function getCoverReference(uint coverId) external view returns(CoverReference memory);

function getCoverDataWithReference(uint coverId) external view returns (CoverData memory, CoverReference memory);

function getCoverDataCount() external view returns (uint);

function getPoolAllocations(uint coverId) external view returns (PoolAllocation[] memory);

function getLatestEditCoverData(uint coverId) external view returns (CoverData memory);

function recalculateActiveCoverInAsset(uint coverAsset) external;
Expand Down Expand Up @@ -132,7 +140,13 @@ interface ICover {
address buyer
) external payable returns (uint coverId);

function burnStake(uint coverId, uint amount) external returns (address coverOwner);
function buyCoverWithRi(
BuyCoverParams calldata params,
PoolAllocationRequest[] calldata coverChunkRequests,
RiRequest calldata riRequest
) external payable returns (uint coverId);

function burnStake(uint coverId, uint amount) external;

function coverNFT() external returns (ICoverNFT);

Expand Down Expand Up @@ -188,14 +202,19 @@ interface ICover {

// ETH transfers
error InsufficientEthSent();
error SendingEthToPoolFailed();
error SendingEthToCommissionDestinationFailed();
error ReturningEthRemainderToSenderFailed();
error ETHTransferFailed(address to, uint amount);

// Misc
error ExpiredCoversCannotBeEdited();
error CoverNotYetExpired(uint coverId);
error InsufficientCoverAmountAllocated();
error UnexpectedPoolId();
error AlreadyMigratedCoverData(uint coverId);

// Ri
error InvalidSignature();
error WrongCoverEditEntrypoint();
error RiAmountIsZero();
error InvalidRiConfig();
error UnexpectedRiPremium();
}
46 changes: 7 additions & 39 deletions contracts/mocks/common/TokenControllerMock.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
// SPDX-License-Identifier: GPL-3.0-only

pragma solidity ^0.8.18;
pragma solidity ^0.8.28;

import "../../abstract/MasterAwareV2.sol";
import "../../interfaces/INXMToken.sol";
import "../generic/TokenControllerGeneric.sol";

interface ICover {
function stakingPool(uint poolId) external view returns (address);
}

contract TokenControllerMock is TokenControllerGeneric, MasterAwareV2 {
contract TokenControllerMock is TokenControllerGeneric {

address public addToWhitelistLastCalledWith;
address public removeFromWhitelistLastCalledWith;
Expand All @@ -29,37 +24,25 @@ contract TokenControllerMock is TokenControllerGeneric, MasterAwareV2 {
token = INXMToken(_tokenAddress);
}

function mint(address _member, uint256 _amount) public override onlyInternal {
function mint(address _member, uint256 _amount) public override {
token.mint(_member, _amount);
}

function burnFrom(address _of, uint amount) public override onlyInternal returns (bool) {
function burnFrom(address _of, uint amount) public override returns (bool) {
return token.burnFrom(_of, amount);
}

function addToWhitelist(address _member) public override onlyInternal {
function addToWhitelist(address _member) public override {
addToWhitelistLastCalledWith = _member;
}

function removeFromWhitelist(address _member) public override onlyInternal {
function removeFromWhitelist(address _member) public override {
removeFromWhitelistLastCalledWith = _member;
}

/* ========== DEPENDENCIES ========== */

function cover() internal view returns (ICover) {
return ICover(internalContracts[uint(ID.CO)]);
}

function changeDependentContractAddress() public {
internalContracts[uint(ID.CO)] = master.getLatestAddress("CO");
}

function operatorTransfer(address _from, address _to, uint _value) onlyInternal external override returns (bool) {
require(
msg.sender == master.getLatestAddress("PS") || msg.sender == master.getLatestAddress("CO"),
"Call is only allowed from PooledStaking or Cover address"
);
function operatorTransfer(address _from, address _to, uint _value) external override returns (bool) {
require(token.operatorTransfer(_from, _value), "Operator transfer failed");
require(token.transfer(_to, _value), "Internal transfer failed");
return true;
Expand Down Expand Up @@ -91,11 +74,6 @@ contract TokenControllerMock is TokenControllerGeneric, MasterAwareV2 {
token.burn(amount);
}

function setContractAddresses(address payable coverAddr, address payable tokenAddr) public {
internalContracts[uint(ID.CO)] = coverAddr;
token = INXMToken(tokenAddr);
}

function setStakingPoolManager(uint poolId, address manager) external {
stakingPoolManagers[poolId] = manager;
}
Expand Down Expand Up @@ -143,14 +121,4 @@ contract TokenControllerMock is TokenControllerGeneric, MasterAwareV2 {
return _isStakingPoolManager[manager];
}

/* unused functions */

modifier unused {
require(false, "Unexpected TokenControllerMock call");
_;
}

function burnLockedTokens(address, bytes32, uint256) unused external {}

function releaseLockedTokens(address _of, bytes32 _reason, uint256 _amount) unused external {}
}
24 changes: 22 additions & 2 deletions contracts/mocks/generic/CoverGeneric.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ contract CoverGeneric is ICover {
revert("Unsupported");
}

function getCoverRi(uint) external virtual view returns (Ri memory) {
revert("Unsupported");
}

function getCoverDataWithRi(uint) external virtual view returns (CoverData memory, Ri memory) {
revert("Unsupported");
}

function getPoolAllocations(uint) external virtual view returns (PoolAllocation[] memory) {
revert("Unsupported");
}
Expand Down Expand Up @@ -84,16 +92,24 @@ contract CoverGeneric is ICover {

function executeCoverBuy(
BuyCoverParams calldata /* params */,
PoolAllocationRequest[] calldata, /* coverChunkRequests */
PoolAllocationRequest[] calldata /* coverChunkRequests */,
address /*buyer*/
) external virtual payable returns (uint) {
revert("Unsupported");
}

function buyCoverWithRi(
BuyCoverParams calldata /* params */,
PoolAllocationRequest[] calldata /* coverChunkRequests */,
RiRequest calldata /* riRequest */
) external virtual payable returns (uint) {
revert("Unsupported");
}

function burnStake(
uint /* coverId */,
uint /* amount */
) external virtual returns (address /* coverOwner */) {
) external virtual {
revert("Unsupported");
}

Expand All @@ -116,4 +132,8 @@ contract CoverGeneric is ICover {
function stakingPoolFactory() external virtual view returns (address) {
revert("Unsupported");
}

function stakingPoolImplementation() external virtual view returns (address) {
revert("Unsupported");
}
}
2 changes: 1 addition & 1 deletion contracts/mocks/generic/TokenControllerGeneric.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "../../interfaces/ITokenController.sol";

contract TokenControllerGeneric is ITokenController {

INXMToken public token;
INXMToken public immutable token;

function changeOperator(address) external pure {
revert("changeOperator unsupported");
Expand Down
Loading