• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NexusMutual / smart-contracts / #1660

09 Dec 2025 10:52AM UTC coverage: 5.251% (-64.5%) from 69.75%
#1660

Pull #1504

MilGard91
fix: use encoded data for the buyCoverWithRi method
Pull Request #1504: feat: add data and deadline to buyCoverWithRi signature

65 of 1714 branches covered (3.79%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 1 file covered. (100.0%)

1980 existing lines in 24 files now uncovered.

177 of 2895 relevant lines covered (6.11%)

0.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/contracts/modules/staking/StakingTypesLib.sol
1
// SPDX-License-Identifier: GPL-3.0-only
2

3
pragma solidity ^0.8.18;
4

5
// 5 x uint48 activeAllocation + 1 x uint16 lastBucketId
6
// 5 * 48 + 16 = 256
7
type TrancheAllocationGroup is uint;
8

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

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

16
library StakingTypesLib {
17

18
  // TrancheAllocationGroup
19

20
  function getLastBucketId(TrancheAllocationGroup items) internal pure returns (uint16) {
UNCOV
21
    return uint16(TrancheAllocationGroup.unwrap(items));
×
22
  }
23

24
  function setLastBucketId(
25
    TrancheAllocationGroup items,
26
    uint16 lastBucketId
27
  ) internal pure returns (TrancheAllocationGroup) {
28
    // applying the mask using binary AND to clear target item's bits
UNCOV
29
    uint mask = ~(uint(type(uint16).max));
×
UNCOV
30
    uint underlying = TrancheAllocationGroup.unwrap(items);
×
UNCOV
31
    return TrancheAllocationGroup.wrap(underlying & mask | uint(lastBucketId));
×
32
  }
33

34
  function getItemAt(
35
    TrancheAllocationGroup items,
36
    uint index
37
  ) internal pure returns (uint48 allocation) {
UNCOV
38
    uint underlying = TrancheAllocationGroup.unwrap(items);
×
UNCOV
39
    return uint48(underlying >> (index * 48 + 16));
×
40
  }
41

42
  // heads up: does not mutate the TrancheAllocationGroup but returns a new one instead
43
  function setItemAt(
44
    TrancheAllocationGroup items,
45
    uint index,
46
    uint48 allocation
47
  ) internal pure returns (TrancheAllocationGroup) {
48
    // applying the mask using binary AND to clear target item's bits
UNCOV
49
    uint mask = ~(uint(type(uint64).max) << (index * 48 + 16));
×
UNCOV
50
    uint item = uint(allocation) << (index * 48 + 16);
×
UNCOV
51
    uint underlying = TrancheAllocationGroup.unwrap(items) & mask | item;
×
UNCOV
52
    return TrancheAllocationGroup.wrap(underlying);
×
53
  }
54

55
  // TrancheGroupBucket
56

57
  function getItemAt(
58
    TrancheGroupBucket items,
59
    uint index
60
  ) internal pure returns (uint32) {
UNCOV
61
    uint underlying = TrancheGroupBucket.unwrap(items);
×
UNCOV
62
    return uint32(underlying >> (index * 32));
×
63
  }
64

65
  // heads up: does not mutate the TrancheGroupBucket but returns a new one instead
66
  function setItemAt(
67
    TrancheGroupBucket items,
68
    uint index,
69
    uint32 value
70
  ) internal pure returns (TrancheGroupBucket) {
71
    // applying the mask using binary AND to clear target item's bits
UNCOV
72
    uint mask = ~(uint(type(uint32).max) << (index * 32));
×
UNCOV
73
    uint itemUnderlying = uint(value) << (index * 32);
×
UNCOV
74
    uint groupUnderlying = TrancheGroupBucket.unwrap(items) & mask | itemUnderlying;
×
UNCOV
75
    return TrancheGroupBucket.wrap(groupUnderlying);
×
76
  }
77

78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc