@gearbox-protocol/periphery-v3 1.7.0-next.37 → 1.7.0-next.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -55,7 +55,7 @@ contract CreditAccountCompressor is ICreditAccountCompressor, SanityCheckTrait {
|
|
|
55
55
|
|
|
56
56
|
/// @notice Constructor
|
|
57
57
|
/// @param addressProvider_ Address provider contract address
|
|
58
|
-
constructor(address addressProvider_) nonZeroAddress(
|
|
58
|
+
constructor(address addressProvider_) nonZeroAddress(addressProvider_) {
|
|
59
59
|
if (addressProvider_.code.length == 0) {
|
|
60
60
|
revert InvalidAddressProviderException();
|
|
61
61
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Foundation, 2024.
|
|
4
|
+
pragma solidity ^0.8.23;
|
|
5
|
+
|
|
6
|
+
import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol";
|
|
7
|
+
import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol";
|
|
8
|
+
import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
|
|
9
|
+
import {IPoolV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolV3.sol";
|
|
10
|
+
|
|
11
|
+
import {IContractsRegisterLegacy} from
|
|
12
|
+
"@gearbox-protocol/governance/contracts/market/legacy/MarketConfiguratorLegacy.sol";
|
|
13
|
+
import {ACL} from "@gearbox-protocol/governance/contracts/market/ACL.sol";
|
|
14
|
+
import {ContractsRegister} from "@gearbox-protocol/governance/contracts/market/ContractsRegister.sol";
|
|
15
|
+
|
|
16
|
+
/// @dev Extremely dumbed-down version of `MarketConfiguratorLegacy` that is just enough to let compressors work
|
|
17
|
+
contract MarketConfigurator {
|
|
18
|
+
string public name;
|
|
19
|
+
address public immutable acl;
|
|
20
|
+
address public immutable treasury;
|
|
21
|
+
address public immutable contractsRegister;
|
|
22
|
+
|
|
23
|
+
constructor(string memory name_, address acl_, address contractsRegister_, address treasury_) {
|
|
24
|
+
name = name_;
|
|
25
|
+
acl = acl_;
|
|
26
|
+
contractsRegister = address(new ContractsRegister(address(new ACL())));
|
|
27
|
+
treasury = treasury_;
|
|
28
|
+
|
|
29
|
+
address[] memory pools = IContractsRegisterLegacy(contractsRegister_).getPools();
|
|
30
|
+
uint256 numPools = pools.length;
|
|
31
|
+
for (uint256 i; i < numPools; ++i) {
|
|
32
|
+
address pool = pools[i];
|
|
33
|
+
if (!_isV3Contract(pool)) continue;
|
|
34
|
+
|
|
35
|
+
address[] memory creditManagers = IPoolV3(pool).creditManagers();
|
|
36
|
+
uint256 numCreditManagers = creditManagers.length;
|
|
37
|
+
if (numCreditManagers == 0) continue;
|
|
38
|
+
|
|
39
|
+
address priceOracle = _priceOracle(creditManagers[0]);
|
|
40
|
+
// NOTE: v3.0.x contracts don't have loss policies set so we don't bother with them here
|
|
41
|
+
address lossPolicy = address(1);
|
|
42
|
+
|
|
43
|
+
ContractsRegister(contractsRegister).registerMarket(pool, priceOracle, lossPolicy);
|
|
44
|
+
for (uint256 j; j < numCreditManagers; ++j) {
|
|
45
|
+
ContractsRegister(contractsRegister).registerCreditSuite(creditManagers[j]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _isV3Contract(address contract_) internal view returns (bool) {
|
|
51
|
+
try IVersion(contract_).version() returns (uint256 version_) {
|
|
52
|
+
return version_ >= 300 && version_ < 400;
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function _priceOracle(address creditManager) internal view returns (address) {
|
|
59
|
+
return ICreditManagerV3(creditManager).priceOracle();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _lossLiquidator(address creditManager) internal view returns (address) {
|
|
63
|
+
return ICreditFacadeV3(ICreditManagerV3(creditManager).creditFacade()).lossLiquidator();
|
|
64
|
+
}
|
|
65
|
+
}
|
package/package.json
CHANGED