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

IndexCoop / index-coop-smart-contracts / 5be55ea0-6126-44e3-8993-1d8cecdfa204

23 Nov 2023 03:47AM UTC coverage: 46.877% (-30.4%) from 77.323%
5be55ea0-6126-44e3-8993-1d8cecdfa204

push

circleci

web-flow
Global optimistic auction rebalance extension (#154)

* feat: GlobalAuctionRebalanceExtension contract, tests & utils

* test: adds cases that increase coverage to 100%

* feat: prevent intialization when not ready.

* chore(deps): add @uma/core as devDep

* ref(AuctionRebalance): startRebalance overridable

* ref(OptimisticAuction): adds Initial contract.

* feat: setProductSettings, proposeRebalance, override startRebalance.

* chore(deps): remove @uma/core dev dep.

* test: derive unit test template for GlobalOptimisticAuctionRebalanceExtension from GlobalAuctionRebalanceExtension.

* test: update deployment helper and barrel.

* refactor: remove unused param from constructor.

* chore(deps): add base58 encode/decode lib.

* feat: add OOV3 mock.

* test: extends to cover propose rebalance path.

* refactor: add events, update docstrings.

 fix assertedProducts update.

* feat: emit events, simplify tracking assertion id relationships, refactor out bonds.

* docs: update contract natspec description.

* fix: add virtual keyword back and removed extra imports in utils.

* ref: refactor and doc updates.

580 of 1354 branches covered (0.0%)

Branch coverage included in aggregate %.

59 of 80 new or added lines in 2 files covered. (73.75%)

1087 existing lines in 25 files now uncovered.

1724 of 3561 relevant lines covered (48.41%)

16.19 hits per line

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

38.46
/contracts/manager/BaseManager.sol
1
/*
2
    Copyright 2021 Set Labs Inc.
3

4
    Licensed under the Apache License, Version 2.0 (the "License");
5
    you may not use this file except in compliance with the License.
6
    You may obtain a copy of the License at
7

8
    http://www.apache.org/licenses/LICENSE-2.0
9

10
    Unless required by applicable law or agreed to in writing, software
11
    distributed under the License is distributed on an "AS IS" BASIS,
12
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
    See the License for the specific language governing permissions and
14
    limitations under the License.
15

16
    SPDX-License-Identifier: Apache License, Version 2.0
17
*/
18

19
pragma solidity 0.6.10;
20

21
import { Address } from "@openzeppelin/contracts/utils/Address.sol";
22

23
import { AddressArrayUtils } from "../lib/AddressArrayUtils.sol";
24
import { IAdapter } from "../interfaces/IAdapter.sol";
25
import { ISetToken } from "../interfaces/ISetToken.sol";
26

27

28
/**
29
 * @title BaseManager
30
 * @author Set Protocol
31
 *
32
 * Smart contract manager that contains permissions and admin functionality
33
 */
34
contract BaseManager {
35
    using Address for address;
36
    using AddressArrayUtils for address[];
37

38
    /* ============ Events ============ */
39

40
    event AdapterAdded(
41
        address _adapter
42
    );
43

44
    event AdapterRemoved(
45
        address _adapter
46
    );
47

48
    event MethodologistChanged(
49
        address _oldMethodologist,
50
        address _newMethodologist
51
    );
52

53
    event OperatorChanged(
54
        address _oldOperator,
55
        address _newOperator
56
    );
57

58
    /* ============ Modifiers ============ */
59

60
    /**
61
     * Throws if the sender is not the SetToken operator
62
     */
63
    modifier onlyOperator() {
64
        require(msg.sender == operator, "Must be operator");
3!
65
        _;
66
    }
67

68
    /**
69
     * Throws if the sender is not the SetToken methodologist
70
     */
71
    modifier onlyMethodologist() {
UNCOV
72
        require(msg.sender == methodologist, "Must be methodologist");
×
73
        _;
74
    }
75

76
    /**
77
     * Throws if the sender is not a listed adapter
78
     */
79
    modifier onlyAdapter() {
80
        require(isAdapter[msg.sender], "Must be adapter");
20!
81
        _;
82
    }
83

84
    /* ============ State Variables ============ */
85

86
    // Instance of SetToken
87
    ISetToken public setToken;
88

89
    // Array of listed adapters
90
    address[] internal adapters;
91

92
    // Mapping to check if adapter is added
93
    mapping(address => bool) public isAdapter;
94

95
    // Address of operator which typically executes manager only functions on Set Protocol modules
96
    address public operator;
97

98
    // Address of methodologist which serves as providing methodology for the index
99
    address public methodologist;
100

101
    /* ============ Constructor ============ */
102

103
    constructor(
104
        ISetToken _setToken,
105
        address _operator,
106
        address _methodologist
107
    )
108
        public
109
    {
110
        setToken = _setToken;
12✔
111
        operator = _operator;
12✔
112
        methodologist = _methodologist;
12✔
113
    }
114

115
    /* ============ External Functions ============ */
116

117
    /**
118
     * MUTUAL UPGRADE: Update the SetToken manager address. Operator and Methodologist must each call
119
     * this function to execute the update.
120
     *
121
     * @param _newManager           New manager address
122
     */
123
    function setManager(address _newManager) external onlyOperator {
UNCOV
124
        require(_newManager != address(0), "Zero address not valid");
×
UNCOV
125
        setToken.setManager(_newManager);
×
126
    }
127

128
    /**
129
     * MUTUAL UPGRADE: Add a new adapter that the BaseManager can call.
130
     *
131
     * @param _adapter           New adapter to add
132
     */
133
    function addAdapter(address _adapter) external onlyOperator {
134
        require(!isAdapter[_adapter], "Adapter already exists");
3!
135
        require(address(IAdapter(_adapter).manager()) == address(this), "Adapter manager invalid");
3!
136

137
        adapters.push(_adapter);
3✔
138

139
        isAdapter[_adapter] = true;
3✔
140

141
        emit AdapterAdded(_adapter);
3✔
142
    }
143

144
    /**
145
     * MUTUAL UPGRADE: Remove an existing adapter tracked by the BaseManager.
146
     *
147
     * @param _adapter           Old adapter to remove
148
     */
149
    function removeAdapter(address _adapter) external onlyOperator {
UNCOV
150
        require(isAdapter[_adapter], "Adapter does not exist");
×
151

UNCOV
152
        adapters.removeStorage(_adapter);
×
153

UNCOV
154
        isAdapter[_adapter] = false;
×
155

UNCOV
156
        emit AdapterRemoved(_adapter);
×
157
    }
158

159
    /**
160
     * ADAPTER ONLY: Interact with a module registered on the SetToken.
161
     *
162
     * @param _module           Module to interact with
163
     * @param _data             Byte data of function to call in module
164
     */
165
    function interactManager(address _module, bytes calldata _data) external onlyAdapter {
166
        // Invoke call to module, assume value will always be 0
167
        _module.functionCallWithValue(_data, 0);
20✔
168
    }
169

170
    /**
171
     * OPERATOR ONLY: Add a new module to the SetToken.
172
     *
173
     * @param _module           New module to add
174
     */
175
    function addModule(address _module) external onlyOperator {
UNCOV
176
        setToken.addModule(_module);
×
177
    }
178

179
    /**
180
     * OPERATOR ONLY: Remove a new module from the SetToken.
181
     *
182
     * @param _module           Module to remove
183
     */
184
    function removeModule(address _module) external onlyOperator {
UNCOV
185
        setToken.removeModule(_module);
×
186
    }
187

188
    /**
189
     * METHODOLOGIST ONLY: Update the methodologist address
190
     *
191
     * @param _newMethodologist           New methodologist address
192
     */
193
    function setMethodologist(address _newMethodologist) external onlyMethodologist {
UNCOV
194
        emit MethodologistChanged(methodologist, _newMethodologist);
×
195

UNCOV
196
        methodologist = _newMethodologist;
×
197
    }
198

199
    /**
200
     * OPERATOR ONLY: Update the operator address
201
     *
202
     * @param _newOperator           New operator address
203
     */
204
    function setOperator(address _newOperator) external onlyOperator {
UNCOV
205
        emit OperatorChanged(operator, _newOperator);
×
206

UNCOV
207
        operator = _newOperator;
×
208
    }
209

210
    /* ============ External Getters ============ */
211

212
    function getAdapters() external view returns(address[] memory) {
UNCOV
213
        return adapters;
×
214
    }
215
}
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