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

RigoBlock / v3-contracts / 13261352678

11 Feb 2025 10:59AM UTC coverage: 84.94% (+2.6%) from 82.368%
13261352678

Pull #622

github

web-flow
Merge f22d260e3 into 08bd3b51b
Pull Request #622: feat: automated nav

761 of 962 branches covered (79.11%)

Branch coverage included in aggregate %.

523 of 711 new or added lines in 28 files covered. (73.56%)

18 existing lines in 5 files now uncovered.

1698 of 1933 relevant lines covered (87.84%)

44.05 hits per line

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

97.3
/contracts/protocol/core/state/MixinPoolState.sol
1
// SPDX-License-Identifier: Apache 2.0
2
pragma solidity >=0.8.0 <0.9.0;
3

4
import {MixinPoolValue} from "../state/MixinPoolValue.sol";
5
import {IRigoblockV3PoolState} from "../../interfaces/pool/IRigoblockV3PoolState.sol";
6
import {Pool} from "../../libraries/EnumerableSet.sol";
7

8
abstract contract MixinPoolState is MixinPoolValue {
9
    /*
10
     * EXTERNAL VIEW METHODS
11
     */
12
    /// @dev Returns how many pool tokens a user holds.
13
    /// @param who Address of the target account.
14
    /// @return Number of pool.
15
    function balanceOf(address who) external view override returns (uint256) {
16
        return accounts().userAccounts[who].userBalance;
9✔
17
    }
18

19
    /// @inheritdoc IRigoblockV3PoolState
20
    /// @dev Grg staking and UniV3 positions will not be returned by default.
21
    function getActiveApplications() external view override returns (uint256 packedApplications) {
NEW
22
        return _getActiveApplications();
×
23
    }
24

25
    /// @inheritdoc IRigoblockV3PoolState
26
    function getActiveTokens() external view override returns (ActiveTokens memory tokens) {
27
        return _getActiveTokens();
22✔
28
    }
29

30
    /// @inheritdoc IRigoblockV3PoolState
31
    function getPoolStorage()
32
        external
33
        view
34
        override
35
        returns (ReturnedPool memory poolInitParams, PoolParams memory poolVariables, PoolTokens memory poolTokensInfo)
36
    {
37
        return (getPool(), getPoolParams(), getPoolTokens());
4✔
38
    }
39

40
    function getUserAccount(address who) external view override returns (UserAccount memory) {
41
        return accounts().userAccounts[who];
2✔
42
    }
43

44
    /// @inheritdoc IRigoblockV3PoolState
45
    function name() external view override returns (string memory) {
46
        return pool().name;
4✔
47
    }
48

49
    /// @inheritdoc IRigoblockV3PoolState
50
    function owner() external view override returns (address) {
51
        return pool().owner;
50✔
52
    }
53

54
    /// @inheritdoc IRigoblockV3PoolState
55
    function totalSupply() external view override returns (uint256) {
56
        return poolTokens().totalSupply;
14✔
57
    }
58

59
    /*
60
     * PUBLIC VIEW METHODS
61
     */
62
    /// @notice Decimals are initialized at proxy creation.
63
    /// @return Number of decimals.
64
    function decimals() public view override returns (uint8) {
65
        return pool().decimals;
97✔
66
    }
67

68
    /// @inheritdoc IRigoblockV3PoolState
69
    function getPool() public view override returns (ReturnedPool memory) {
70
        Pool memory pool = pool();
202✔
71
        // we return symbol as string, omit unlocked as always true
72
        return
202✔
73
            ReturnedPool({
74
                name: pool.name,
75
                symbol: symbol(),
76
                decimals: pool.decimals,
77
                owner: pool.owner,
78
                baseToken: pool.baseToken
79
            });
80
    }
81

82
    /// @inheritdoc IRigoblockV3PoolState
83
    function getPoolParams() public view override returns (PoolParams memory) {
84
        return
20✔
85
            PoolParams({
86
                minPeriod: _getMinPeriod(),
87
                spread: _getSpread(),
88
                transactionFee: poolParams().transactionFee,
89
                feeCollector: _getFeeCollector(),
90
                kycProvider: poolParams().kycProvider
91
            });
92
    }
93

94
    /// @inheritdoc IRigoblockV3PoolState
95
    function getPoolTokens() public view override returns (PoolTokens memory) {
96
        uint256 unitaryValue = poolTokens().unitaryValue;
24✔
97
        return
24✔
98
            PoolTokens({
99
                unitaryValue: unitaryValue != 0 ? unitaryValue : 10 ** pool().decimals,
100
                totalSupply: poolTokens().totalSupply
101
            });
102
    }
103

104
    /// @inheritdoc IRigoblockV3PoolState
105
    function symbol() public view override returns (string memory) {
106
        bytes8 _symbol = pool().symbol;
206✔
107
        uint8 i = 0;
206✔
108
        while (i < 8 && _symbol[i] != 0) {
206✔
109
            i++;
206✔
110
        }
111
        bytes memory bytesArray = new bytes(i);
206✔
112
        for (i = 0; i < 8 && _symbol[i] != 0; i++) {
206✔
113
            bytesArray[i] = _symbol[i];
206✔
114
        }
115
        return string(bytesArray);
206✔
116
    }
117

118
    /*
119
     * INTERNAL VIEW METHODS
120
     */
121
    function _getActiveApplications() internal view override returns (uint256) {
122
        return activeApplications().packedApplications;
54✔
123
    }
124

125
    function _getFeeCollector() internal view override returns (address) {
126
        address feeCollector = poolParams().feeCollector;
27✔
127
        return feeCollector != _ZERO_ADDRESS ? feeCollector : pool().owner;
27✔
128
    }
129

130
    function _getMinPeriod() internal view override returns (uint48) {
131
        uint48 minPeriod = poolParams().minPeriod;
78✔
132
        return minPeriod != 0 ? minPeriod : _MAX_LOCKUP;
78✔
133
    }
134

135
    function _getSpread() internal view override returns (uint16) {
136
        uint16 spread = poolParams().spread;
28✔
137
        return spread != 0 ? spread : _MAX_SPREAD;
28✔
138
    }
139

140
    function _getActiveTokens() private view returns (ActiveTokens memory tokens) {
141
        tokens.activeTokens = activeTokensSet().addresses;
22✔
142
        tokens.baseToken = pool().baseToken;
22✔
143
    }
144
}
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

© 2025 Coveralls, Inc