@gearbox-protocol/periphery-v3 1.7.0-next.40 → 1.7.0-next.42
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.
- package/contracts/compressors/CreditAccountCompressor.sol +5 -4
- package/contracts/compressors/CreditSuiteCompressor.sol +5 -0
- package/contracts/compressors/MarketCompressor.sol +23 -9
- package/contracts/libraries/Literals.sol +11 -0
- package/contracts/migration/MarketConfigurator.sol +1 -1
- package/contracts/test/ForkTest.sol +1 -1
- package/package.json +5 -3
|
@@ -19,7 +19,7 @@ import {PERCENTAGE_FACTOR} from "@gearbox-protocol/core-v3/contracts/libraries/C
|
|
|
19
19
|
import {SanityCheckTrait} from "@gearbox-protocol/core-v3/contracts/traits/SanityCheckTrait.sol";
|
|
20
20
|
import {ICreditAccountCompressor} from "../interfaces/ICreditAccountCompressor.sol";
|
|
21
21
|
|
|
22
|
-
import {IContractsRegister} from "@gearbox-protocol/governance/contracts/interfaces/
|
|
22
|
+
import {IContractsRegister} from "@gearbox-protocol/governance/contracts/interfaces/IContractsRegister.sol";
|
|
23
23
|
import {IAddressProvider} from "@gearbox-protocol/governance/contracts/interfaces/IAddressProvider.sol";
|
|
24
24
|
import {IMarketConfigurator} from "@gearbox-protocol/governance/contracts/interfaces/IMarketConfigurator.sol";
|
|
25
25
|
import {IMarketConfiguratorFactory} from
|
|
@@ -33,17 +33,18 @@ import {CreditAccountData, TokenInfo} from "../types/CreditAccountState.sol";
|
|
|
33
33
|
import {CreditAccountFilter, MarketFilter} from "../types/Filters.sol";
|
|
34
34
|
|
|
35
35
|
import {Contains} from "../libraries/Contains.sol";
|
|
36
|
-
|
|
36
|
+
import {AP_CREDIT_ACCOUNT_COMPRESSOR} from "../libraries/Literals.sol";
|
|
37
37
|
/// @title Credit account compressor
|
|
38
38
|
/// @notice Allows to fetch data on all credit accounts matching certain criteria in an efficient manner
|
|
39
39
|
/// @dev The contract is not gas optimized and is thus not recommended for on-chain use
|
|
40
40
|
/// @dev Querying functions try to process as many accounts as possible and stop when they get close to gas limit
|
|
41
|
+
|
|
41
42
|
contract CreditAccountCompressor is ICreditAccountCompressor, SanityCheckTrait {
|
|
42
43
|
using Contains for address[];
|
|
43
44
|
|
|
44
45
|
/// @notice Contract version
|
|
45
46
|
uint256 public constant override version = 3_10;
|
|
46
|
-
bytes32 public constant override contractType =
|
|
47
|
+
bytes32 public constant override contractType = AP_CREDIT_ACCOUNT_COMPRESSOR;
|
|
47
48
|
|
|
48
49
|
/// @notice Address provider contract address
|
|
49
50
|
address public immutable addressProvider;
|
|
@@ -270,7 +271,7 @@ contract CreditAccountCompressor is ICreditAccountCompressor, SanityCheckTrait {
|
|
|
270
271
|
data.creditFacade = ICreditManagerV3(creditManager).creditFacade();
|
|
271
272
|
data.underlying = ICreditManagerV3(creditManager).underlying();
|
|
272
273
|
data.owner = ICreditManagerV3(creditManager).getBorrowerOrRevert(creditAccount);
|
|
273
|
-
data.expirationDate = ICreditFacadeV3(
|
|
274
|
+
data.expirationDate = ICreditFacadeV3(data.creditFacade).expirationDate();
|
|
274
275
|
|
|
275
276
|
CollateralDebtData memory cdd =
|
|
276
277
|
ICreditManagerV3(creditManager).calcDebtAndCollateral(creditAccount, CollateralCalcTask.DEBT_ONLY);
|
|
@@ -16,9 +16,14 @@ import {CreditSuiteData} from "../types/CreditSuiteData.sol";
|
|
|
16
16
|
|
|
17
17
|
import {AdapterCompressor} from "./AdapterCompressor.sol";
|
|
18
18
|
|
|
19
|
+
import {AP_CREDIT_SUITE_COMPRESSOR} from "../libraries/Literals.sol";
|
|
20
|
+
|
|
19
21
|
contract CreditSuiteCompressor {
|
|
20
22
|
AdapterCompressor adapterCompressor;
|
|
21
23
|
|
|
24
|
+
uint256 public constant version = 3_10;
|
|
25
|
+
bytes32 public constant contractType = AP_CREDIT_SUITE_COMPRESSOR;
|
|
26
|
+
|
|
22
27
|
constructor() {
|
|
23
28
|
adapterCompressor = new AdapterCompressor();
|
|
24
29
|
}
|
|
@@ -10,8 +10,8 @@ import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/I
|
|
|
10
10
|
import {IPoolQuotaKeeperV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolQuotaKeeperV3.sol";
|
|
11
11
|
import {IPoolV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolV3.sol";
|
|
12
12
|
|
|
13
|
-
import {IACL} from "@gearbox-protocol/governance/contracts/interfaces/
|
|
14
|
-
import {IContractsRegister} from "@gearbox-protocol/governance/contracts/interfaces/
|
|
13
|
+
import {IACL} from "@gearbox-protocol/governance/contracts/interfaces/IACL.sol";
|
|
14
|
+
import {IContractsRegister} from "@gearbox-protocol/governance/contracts/interfaces/IContractsRegister.sol";
|
|
15
15
|
import {IAddressProvider} from "@gearbox-protocol/governance/contracts/interfaces/IAddressProvider.sol";
|
|
16
16
|
import {IMarketConfigurator} from "@gearbox-protocol/governance/contracts/interfaces/IMarketConfigurator.sol";
|
|
17
17
|
import {IMarketConfiguratorFactory} from
|
|
@@ -41,6 +41,13 @@ import {PoolState} from "../types/PoolState.sol";
|
|
|
41
41
|
import {PriceOracleState} from "../types/PriceOracleState.sol";
|
|
42
42
|
|
|
43
43
|
import {IMarketCompressor} from "../interfaces/IMarketCompressor.sol";
|
|
44
|
+
import {
|
|
45
|
+
AP_MARKET_COMPRESSOR,
|
|
46
|
+
AP_POOL_COMPRESSOR,
|
|
47
|
+
AP_TOKEN_COMPRESSOR,
|
|
48
|
+
AP_PRICE_FEED_COMPRESSOR,
|
|
49
|
+
AP_CREDIT_SUITE_COMPRESSOR
|
|
50
|
+
} from "../libraries/Literals.sol";
|
|
44
51
|
|
|
45
52
|
/// @title Data compressor 3.0.
|
|
46
53
|
/// @notice Collects data from various contracts for use in the dApp
|
|
@@ -49,7 +56,7 @@ contract MarketCompressor is IMarketCompressor {
|
|
|
49
56
|
using Contains for address[];
|
|
50
57
|
|
|
51
58
|
uint256 public constant version = 3_10;
|
|
52
|
-
bytes32 public constant contractType =
|
|
59
|
+
bytes32 public constant contractType = AP_MARKET_COMPRESSOR;
|
|
53
60
|
|
|
54
61
|
address public immutable addressProvider;
|
|
55
62
|
address public immutable marketConfiguratorFactory;
|
|
@@ -64,15 +71,22 @@ contract MarketCompressor is IMarketCompressor {
|
|
|
64
71
|
address configurator;
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
constructor(address addressProvider_
|
|
74
|
+
constructor(address addressProvider_) {
|
|
68
75
|
addressProvider = addressProvider_;
|
|
76
|
+
|
|
77
|
+
// TODO: change to normal discovery
|
|
78
|
+
|
|
69
79
|
marketConfiguratorFactory =
|
|
70
80
|
IAddressProvider(addressProvider_).getAddressOrRevert(AP_MARKET_CONFIGURATOR_FACTORY, NO_VERSION_CONTROL);
|
|
71
81
|
|
|
72
|
-
poolCompressor =
|
|
73
|
-
tokenCompressor =
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
poolCompressor = PoolCompressor(IAddressProvider(addressProvider_).getAddressOrRevert(AP_POOL_COMPRESSOR, 3_10));
|
|
83
|
+
tokenCompressor =
|
|
84
|
+
TokenCompressor(IAddressProvider(addressProvider_).getAddressOrRevert(AP_TOKEN_COMPRESSOR, 3_10));
|
|
85
|
+
creditSuiteCompressor = CreditSuiteCompressor(
|
|
86
|
+
IAddressProvider(addressProvider_).getAddressOrRevert(AP_CREDIT_SUITE_COMPRESSOR, 3_10)
|
|
87
|
+
);
|
|
88
|
+
priceOracleCompressor =
|
|
89
|
+
PriceFeedCompressor(IAddressProvider(addressProvider_).getAddressOrRevert(AP_PRICE_FEED_COMPRESSOR, 3_10));
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
function getMarkets(MarketFilter memory filter) external view returns (MarketData[] memory result) {
|
|
@@ -170,7 +184,7 @@ contract MarketCompressor is IMarketCompressor {
|
|
|
170
184
|
|
|
171
185
|
function _getLossPolicy(address pool, address configurator) internal view returns (address) {
|
|
172
186
|
address contractsRegister = IMarketConfigurator(configurator).contractsRegister();
|
|
173
|
-
return IContractsRegister(contractsRegister).
|
|
187
|
+
return IContractsRegister(contractsRegister).getLossPolicy(pool);
|
|
174
188
|
}
|
|
175
189
|
|
|
176
190
|
/// @dev Pools discovery
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Foundation, 2024.
|
|
4
|
+
pragma solidity ^0.8.17;
|
|
5
|
+
|
|
6
|
+
bytes32 constant AP_MARKET_COMPRESSOR = "MARKET_COMPRESSOR";
|
|
7
|
+
bytes32 constant AP_POOL_COMPRESSOR = "POOL_COMPRESSOR";
|
|
8
|
+
bytes32 constant AP_TOKEN_COMPRESSOR = "TOKEN_COMPRESSOR";
|
|
9
|
+
bytes32 constant AP_PRICE_FEED_COMPRESSOR = "PRICE_FEED_COMPRESSOR";
|
|
10
|
+
bytes32 constant AP_CREDIT_ACCOUNT_COMPRESSOR = "CREDIT_ACCOUNT_COMPRESSOR";
|
|
11
|
+
bytes32 constant AP_CREDIT_SUITE_COMPRESSOR = "CREDIT_SUITE_COMPRESSOR";
|
|
@@ -26,7 +26,7 @@ contract MarketConfigurator {
|
|
|
26
26
|
|
|
27
27
|
constructor(string memory name_, address acl_, address contractsRegister_, address treasury_) {
|
|
28
28
|
name = name_;
|
|
29
|
-
acl = address(new ACL());
|
|
29
|
+
acl = address(new ACL(address(this)));
|
|
30
30
|
contractsRegister = address(new ContractsRegister(acl));
|
|
31
31
|
treasury = treasury_;
|
|
32
32
|
|
|
@@ -43,7 +43,7 @@ abstract contract ForkTest is Test {
|
|
|
43
43
|
|
|
44
44
|
addressProvider = IAddressProvider(vm.envAddress("FORK_ADDRESS_PROVIDER"));
|
|
45
45
|
|
|
46
|
-
acl = new ACL();
|
|
46
|
+
acl = new ACL(address(this));
|
|
47
47
|
aclLegacy = IACLLegacy(addressProvider.getAddressOrRevert(AP_ACL, NO_VERSION_CONTROL));
|
|
48
48
|
register = IContractsRegister(addressProvider.getAddressOrRevert(AP_CONTRACTS_REGISTER, NO_VERSION_CONTROL));
|
|
49
49
|
configurator = Ownable(address(aclLegacy)).owner();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/periphery-v3",
|
|
3
|
-
"version": "1.7.0-next.
|
|
3
|
+
"version": "1.7.0-next.42",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": "git@github.com:Gearbox-protocol/periphery-v3.git",
|
|
6
6
|
"author": "Mikael <26343374+0xmikko@users.noreply.github.com>",
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
"@commitlint/config-conventional": "17.6.0",
|
|
21
21
|
"@gearbox-protocol/sdk-gov": "^2.18.2",
|
|
22
22
|
"@openzeppelin/contracts": "^4.9.3",
|
|
23
|
-
"@redstone-finance/evm-connector": "^0.
|
|
23
|
+
"@redstone-finance/evm-connector": "^0.2.5",
|
|
24
|
+
"@wagmi/cli": "^2.2.0",
|
|
24
25
|
"ds-test": "dapphub/ds-test",
|
|
25
26
|
"forge-std": "foundry-rs/forge-std"
|
|
26
27
|
},
|
|
@@ -33,5 +34,6 @@
|
|
|
33
34
|
"lint-staged": {
|
|
34
35
|
"*.sol": "forge fmt",
|
|
35
36
|
"*.{json,md}": "prettier --write"
|
|
36
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"packageManager": "pnpm@9.15.4+sha512.b2dc20e2fc72b3e18848459b37359a32064663e5627a51e4c74b2c29dd8e8e0491483c3abb40789cfd578bf362fb6ba8261b05f0387d76792ed6e23ea3b1b6a0"
|
|
37
39
|
}
|