@gearbox-protocol/periphery-v3 1.7.0-next.28 → 1.7.0-next.30
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/AdapterCompressor.sol +75 -22
- package/contracts/compressors/PoolCompressor.sol +7 -2
- package/contracts/interfaces/IAdapterCompressor.sol +12 -0
- package/contracts/interfaces/IMarketCompressor.sol +5 -0
- package/contracts/types/MarketData.sol +1 -1
- package/package.json +1 -1
|
@@ -3,24 +3,63 @@
|
|
|
3
3
|
// (c) Gearbox Holdings, 2024
|
|
4
4
|
pragma solidity ^0.8.17;
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {AdapterType} from "@gearbox-protocol/sdk-gov/contracts/AdapterType.sol";
|
|
7
7
|
import {ContractAdapter} from "../types/MarketData.sol";
|
|
8
|
-
import {
|
|
8
|
+
import {IAdapterCompressor} from "../interfaces/IAdapterCompressor.sol";
|
|
9
9
|
import {ICreditConfiguratorV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditConfiguratorV3.sol";
|
|
10
|
-
import {
|
|
10
|
+
import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
|
|
11
|
+
import {IStateSerializer} from "../interfaces/IStateSerializer.sol";
|
|
12
|
+
import {IVersion} from "../interfaces/IVersion.sol";
|
|
13
|
+
|
|
14
|
+
interface ILegacyAdapter {
|
|
15
|
+
function _gearboxAdapterVersion() external view returns (uint16);
|
|
16
|
+
function _gearboxAdapterType() external view returns (uint8);
|
|
17
|
+
}
|
|
11
18
|
|
|
12
|
-
|
|
13
|
-
/// @notice Collects data from different adapter types
|
|
14
|
-
contract AdaptgerCompressorV3 {
|
|
15
|
-
// Contract version
|
|
19
|
+
contract AdapterCompressor is IAdapterCompressor {
|
|
16
20
|
uint256 public constant version = 3_10;
|
|
21
|
+
bytes32 public constant override contractType = "ADAPTER_COMPRESSOR";
|
|
22
|
+
|
|
23
|
+
mapping(uint8 => bytes32) public contractTypes;
|
|
17
24
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
);
|
|
25
|
+
constructor() {
|
|
26
|
+
contractTypes[uint8(AdapterType.ABSTRACT)] = "AD_ABSTRACT";
|
|
27
|
+
contractTypes[uint8(AdapterType.UNISWAP_V2_ROUTER)] = "AD_UNISWAP_V2_ROUTER";
|
|
28
|
+
contractTypes[uint8(AdapterType.UNISWAP_V3_ROUTER)] = "AD_UNISWAP_V3_ROUTER";
|
|
29
|
+
contractTypes[uint8(AdapterType.CURVE_V1_EXCHANGE_ONLY)] = "AD_CURVE_V1_EXCHANGE_ONLY";
|
|
30
|
+
contractTypes[uint8(AdapterType.YEARN_V2)] = "AD_YEARN_V2";
|
|
31
|
+
contractTypes[uint8(AdapterType.CURVE_V1_2ASSETS)] = "AD_CURVE_V1_2ASSETS";
|
|
32
|
+
contractTypes[uint8(AdapterType.CURVE_V1_3ASSETS)] = "AD_CURVE_V1_3ASSETS";
|
|
33
|
+
contractTypes[uint8(AdapterType.CURVE_V1_4ASSETS)] = "AD_CURVE_V1_4ASSETS";
|
|
34
|
+
contractTypes[uint8(AdapterType.CURVE_V1_STECRV_POOL)] = "AD_CURVE_V1_STECRV_POOL";
|
|
35
|
+
contractTypes[uint8(AdapterType.CURVE_V1_WRAPPER)] = "AD_CURVE_V1_WRAPPER";
|
|
36
|
+
contractTypes[uint8(AdapterType.CONVEX_V1_BASE_REWARD_POOL)] = "AD_CONVEX_V1_BASE_REWARD_POOL";
|
|
37
|
+
contractTypes[uint8(AdapterType.CONVEX_V1_BOOSTER)] = "AD_CONVEX_V1_BOOSTER";
|
|
38
|
+
contractTypes[uint8(AdapterType.CONVEX_V1_CLAIM_ZAP)] = "AD_CONVEX_V1_CLAIM_ZAP";
|
|
39
|
+
contractTypes[uint8(AdapterType.LIDO_V1)] = "AD_LIDO_V1";
|
|
40
|
+
contractTypes[uint8(AdapterType.UNIVERSAL)] = "AD_UNIVERSAL";
|
|
41
|
+
contractTypes[uint8(AdapterType.LIDO_WSTETH_V1)] = "AD_LIDO_WSTETH_V1";
|
|
42
|
+
contractTypes[uint8(AdapterType.BALANCER_VAULT)] = "AD_BALANCER_VAULT";
|
|
43
|
+
contractTypes[uint8(AdapterType.AAVE_V2_LENDING_POOL)] = "AD_AAVE_V2_LENDING_POOL";
|
|
44
|
+
contractTypes[uint8(AdapterType.AAVE_V2_WRAPPED_ATOKEN)] = "AD_AAVE_V2_WRAPPED_ATOKEN";
|
|
45
|
+
contractTypes[uint8(AdapterType.COMPOUND_V2_CERC20)] = "AD_COMPOUND_V2_CERC20";
|
|
46
|
+
contractTypes[uint8(AdapterType.COMPOUND_V2_CETHER)] = "AD_COMPOUND_V2_CETHER";
|
|
47
|
+
contractTypes[uint8(AdapterType.ERC4626_VAULT)] = "AD_ERC4626_VAULT";
|
|
48
|
+
contractTypes[uint8(AdapterType.VELODROME_V2_ROUTER)] = "AD_VELODROME_V2_ROUTER";
|
|
49
|
+
contractTypes[uint8(AdapterType.CURVE_STABLE_NG)] = "AD_CURVE_STABLE_NG";
|
|
50
|
+
contractTypes[uint8(AdapterType.CAMELOT_V3_ROUTER)] = "AD_CAMELOT_V3_ROUTER";
|
|
51
|
+
contractTypes[uint8(AdapterType.CONVEX_L2_BOOSTER)] = "AD_CONVEX_L2_BOOSTER";
|
|
52
|
+
contractTypes[uint8(AdapterType.CONVEX_L2_REWARD_POOL)] = "AD_CONVEX_L2_REWARD_POOL";
|
|
53
|
+
contractTypes[uint8(AdapterType.AAVE_V3_LENDING_POOL)] = "AD_AAVE_V3_LENDING_POOL";
|
|
54
|
+
contractTypes[uint8(AdapterType.ZIRCUIT_POOL)] = "AD_ZIRCUIT_POOL";
|
|
55
|
+
contractTypes[uint8(AdapterType.SYMBIOTIC_DEFAULT_COLLATERAL)] = "AD_SYMBIOTIC_DEFAULT_COLLATERAL";
|
|
56
|
+
contractTypes[uint8(AdapterType.MELLOW_LRT_VAULT)] = "AD_MELLOW_LRT_VAULT";
|
|
57
|
+
contractTypes[uint8(AdapterType.PENDLE_ROUTER)] = "AD_PENDLE_ROUTER";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getContractAdapters(address creditManager) external view returns (ContractAdapter[] memory adapters) {
|
|
61
|
+
ICreditConfiguratorV3 creditConfigurator =
|
|
62
|
+
ICreditConfiguratorV3(ICreditManagerV3(creditManager).creditConfigurator());
|
|
24
63
|
|
|
25
64
|
address[] memory allowedAdapters = creditConfigurator.allowedAdapters();
|
|
26
65
|
uint256 len = allowedAdapters.length;
|
|
@@ -30,17 +69,31 @@ contract AdaptgerCompressorV3 {
|
|
|
30
69
|
|
|
31
70
|
unchecked {
|
|
32
71
|
for (uint256 i = 0; i < len; ++i) {
|
|
33
|
-
address
|
|
72
|
+
address adapter = allowedAdapters[i];
|
|
73
|
+
adapters[i].baseParams.addr = adapter;
|
|
74
|
+
try IVersion(adapter).contractType() returns (bytes32 adapterType) {
|
|
75
|
+
adapters[i].baseParams.contractType = adapterType;
|
|
76
|
+
} catch {
|
|
77
|
+
try ILegacyAdapter(adapter)._gearboxAdapterType() returns (uint8 adapterType) {
|
|
78
|
+
adapters[i].baseParams.contractType = contractTypes[adapterType];
|
|
79
|
+
} catch {
|
|
80
|
+
adapters[i].baseParams.contractType = "AD_ABSTRACT";
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try IVersion(adapter).version() returns (uint256 v) {
|
|
85
|
+
adapters[i].baseParams.version = v;
|
|
86
|
+
} catch {
|
|
87
|
+
try ILegacyAdapter(adapter)._gearboxAdapterVersion() returns (uint16 v) {
|
|
88
|
+
adapters[i].baseParams.version = uint256(v);
|
|
89
|
+
} catch {}
|
|
90
|
+
}
|
|
34
91
|
|
|
35
|
-
|
|
92
|
+
try IStateSerializer(adapter).serialize() returns (bytes memory serializedParams) {
|
|
93
|
+
adapters[i].baseParams.serializedParams = serializedParams;
|
|
94
|
+
} catch {}
|
|
36
95
|
|
|
37
|
-
|
|
38
|
-
// targetContract: ICreditManagerV3(creditManager).adapterToContract(allowedAdapter),
|
|
39
|
-
// adapter: allowedAdapter,
|
|
40
|
-
// adapterType: uint8(IAdapter(allowedAdapter)._gearboxAdapterType()),
|
|
41
|
-
// version: IAdapter(allowedAdapter)._gearboxAdapterVersion(),
|
|
42
|
-
// stateSerialised: stateSerialised
|
|
43
|
-
// });
|
|
96
|
+
adapters[i].targetContract = ICreditManagerV3(creditManager).adapterToContract(adapter);
|
|
44
97
|
}
|
|
45
98
|
}
|
|
46
99
|
}
|
|
@@ -31,6 +31,8 @@ import {BaseLib} from "../libraries/BaseLib.sol";
|
|
|
31
31
|
import {GaugeSerializer} from "../serializers/pool/GaugeSerializer.sol";
|
|
32
32
|
import {LinearInterestModelSerializer} from "../serializers/pool/LinearInterestModelSerializer.sol";
|
|
33
33
|
|
|
34
|
+
import {AdapterCompressor} from "./AdapterCompressor.sol";
|
|
35
|
+
|
|
34
36
|
/// @title Pool compressor
|
|
35
37
|
/// @notice Collects data from pool related contracts
|
|
36
38
|
/// Do not use for data from data compressor for state-changing functions
|
|
@@ -42,9 +44,12 @@ contract PoolCompressorV3 {
|
|
|
42
44
|
address public immutable gaugeSerializer;
|
|
43
45
|
address public immutable linearInterestModelSerializer;
|
|
44
46
|
|
|
47
|
+
AdapterCompressor adapterCompressor;
|
|
48
|
+
|
|
45
49
|
constructor() {
|
|
46
50
|
gaugeSerializer = address(new GaugeSerializer());
|
|
47
51
|
linearInterestModelSerializer = address(new LinearInterestModelSerializer());
|
|
52
|
+
adapterCompressor = new AdapterCompressor();
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
function getPoolState(address pool) public view returns (PoolState memory result) {
|
|
@@ -172,8 +177,6 @@ contract PoolCompressorV3 {
|
|
|
172
177
|
function getRateKeeperState(address rateKeeper) external view returns (RateKeeperState memory result) {
|
|
173
178
|
IRateKeeper _rateKeeper = IRateKeeper(rateKeeper);
|
|
174
179
|
|
|
175
|
-
bytes32 contractType;
|
|
176
|
-
|
|
177
180
|
result.baseParams = BaseLib.getBaseParams(rateKeeper, "GAUGE", gaugeSerializer);
|
|
178
181
|
|
|
179
182
|
IPoolQuotaKeeperV3 _pqk = IPoolQuotaKeeperV3(PoolV3(_rateKeeper.pool()).poolQuotaKeeper());
|
|
@@ -292,5 +295,7 @@ contract PoolCompressorV3 {
|
|
|
292
295
|
result.totalDebt = _pool.creditManagerBorrowed(creditManager);
|
|
293
296
|
result.totalDebtLimit = _pool.creditManagerDebtLimit(creditManager);
|
|
294
297
|
result.availableToBorrow = _pool.creditManagerBorrowable(creditManager);
|
|
298
|
+
|
|
299
|
+
result.adapters = adapterCompressor.getContractAdapters(creditManager);
|
|
295
300
|
}
|
|
296
301
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Holdings, 2024
|
|
4
|
+
pragma solidity ^0.8.10;
|
|
5
|
+
|
|
6
|
+
import {ContractAdapter} from "../types/MarketData.sol";
|
|
7
|
+
import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol";
|
|
8
|
+
|
|
9
|
+
/// @title Adapter compressor 3.1
|
|
10
|
+
interface IAdapterCompressor is IVersion {
|
|
11
|
+
function getContractAdapters(address creditManager) external view returns (ContractAdapter[] memory result);
|
|
12
|
+
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
// SPDX-License-Identifier: BUSL-1.1
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Holdings, 2024
|
|
4
|
+
pragma solidity ^0.8.10;
|
|
5
|
+
|
|
1
6
|
import {MarketData} from "../types/MarketData.sol";
|
|
2
7
|
import {PoolState} from "../types/PoolState.sol";
|
|
3
8
|
import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol";
|
package/package.json
CHANGED