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
14 changes: 8 additions & 6 deletions contracts/modules/cover/Cover.sol
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard {
require(params.amount > 0, "Cover: amount = 0");

uint segmentId;
uint previousRewardsRatio;

AllocationRequest memory allocationRequest;

Expand Down Expand Up @@ -266,8 +265,6 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard {
allocationRequest.previousExpiration = lastSegment.start + lastSegment.period;
allocationRequest.previousRewardsRatio = lastSegment.globalRewardsRatio;

previousRewardsRatio = lastSegment.globalRewardsRatio;

// mark previous cover as ending now
_coverSegments[coverId][segmentId - 1].period = (block.timestamp - lastSegment.start).toUint32();
}
Expand Down Expand Up @@ -342,7 +339,7 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard {
vars.refund =
previousPoolAllocation.premiumInNXM
* (allocationRequest.previousExpiration - block.timestamp) // remaining period
/ allocationRequest.previousExpiration - allocationRequest.previousStart; // previous period
/ (allocationRequest.previousExpiration - allocationRequest.previousStart); // previous period
}

// converting asset amount to nxm and rounding up to the nearest NXM_PER_ALLOCATION_UNIT
Expand Down Expand Up @@ -428,6 +425,8 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard {
require(ok, "Cover: Sending ETH to commission destination failed.");
}

// TODO: send eth to pool

return;
}

Expand Down Expand Up @@ -514,9 +513,12 @@ contract Cover is ICover, MasterAwareV2, IStakingPoolBeacon, ReentrancyGuard {

PoolAllocation memory allocation = allocations[i];

// TODO: use the global capacity ratio that we had at cover buy time
uint burnAmountInNXM = allocation.coverAmountInNXM
* burnAmount / segment.amount
* GLOBAL_CAPACITY_DENOMINATOR / globalCapacityRatio;
* burnAmount
* GLOBAL_CAPACITY_DENOMINATOR
/ segment.amount
/ globalCapacityRatio;

stakingPool(i).burnStake(burnAmountInNXM);

Expand Down
1 change: 1 addition & 0 deletions contracts/modules/staking/StakingPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ contract StakingPool is IStakingPool, ERC721 {
uint expiration
) internal returns (uint[] memory activeAllocations) {

// TODO: coverTrancheAllocations is never set
uint packedCoverTrancheAllocation = coverTrancheAllocations[coverId];
activeAllocations = getActiveAllocations(productId);

Expand Down
4 changes: 4 additions & 0 deletions contracts/modules/staking/StakingTypesLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ pragma solidity ^0.8.16;
// 5 * 48 + 16 = 256
type TrancheAllocationGroup is uint;

// group ids: ________0_________|_________1_________|_________3__ ...
// tranche ids: 0 1 2 3 4 | 5 6 7 8 9 | 10 11 12 ...
// active tranches: \________________________________/

// 8 x (uint32 expiringAllocation)
type TrancheGroupBucket is uint;

Expand Down