@gearbox-protocol/periphery-v3 1.7.0-next.15 → 1.7.0-next.17
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 +13 -5
- package/contracts/compressors/MarketCompressorV3.sol +68 -0
- package/contracts/compressors/PoolCompressor.sol +76 -2
- package/contracts/compressors/PriceFeedCompressor.sol +15 -2
- package/contracts/compressors/Types.sol +5 -5
- package/contracts/interfaces/IVersion.sol +13 -0
- package/contracts/types/CreditManagerState.sol +5 -6
- package/contracts/types/PoolState.sol +1 -1
- package/contracts/types/PriceOracleState.sol +2 -2
- package/package.json +2 -2
- package/contracts/market/MarketCompressor.sol +0 -451
|
@@ -367,12 +367,12 @@ contract CreditAccountCompressor is IVersion, SanityCheckTrait {
|
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
// allocate the array with maximum potentially needed size (total number of credit managers can be assumed
|
|
370
|
-
// to be relatively small and the function is only called once, so
|
|
370
|
+
// to be relatively small and the function is only called once, so memory expansion cost is not an issue)
|
|
371
371
|
creditManagers = new address[](max);
|
|
372
372
|
uint256 num;
|
|
373
373
|
for (uint256 i; i < configurators.length; ++i) {
|
|
374
|
-
if (filter.
|
|
375
|
-
if (IMarketConfiguratorV3(configurators[i]).owner()
|
|
374
|
+
if (filter.curators.length != 0) {
|
|
375
|
+
if (!_contains(filter.curators, IMarketConfiguratorV3(configurators[i]).owner())) continue;
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
address cr = IMarketConfiguratorV3(configurators[i]).contractsRegister();
|
|
@@ -382,8 +382,8 @@ contract CreditAccountCompressor is IVersion, SanityCheckTrait {
|
|
|
382
382
|
uint256 ver = IVersion(managers[j]).version();
|
|
383
383
|
if (ver < 3_00 || ver > 3_99) continue;
|
|
384
384
|
|
|
385
|
-
if (filter.
|
|
386
|
-
if (ICreditManagerV3(managers[j]).pool()
|
|
385
|
+
if (filter.pools.length != 0) {
|
|
386
|
+
if (!_contains(filter.pools, ICreditManagerV3(managers[j]).pool())) continue;
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
if (filter.underlying != address(0)) {
|
|
@@ -399,4 +399,12 @@ contract CreditAccountCompressor is IVersion, SanityCheckTrait {
|
|
|
399
399
|
mstore(creditManagers, num)
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
+
|
|
403
|
+
/// @dev Checks whether `arr` contains `value`
|
|
404
|
+
function _contains(address[] memory arr, address value) internal pure returns (bool) {
|
|
405
|
+
for (uint256 i; i < arr.length; ++i) {
|
|
406
|
+
if (value == arr[i]) return true;
|
|
407
|
+
}
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
402
410
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Holdings, 2024
|
|
4
|
+
pragma solidity ^0.8.17;
|
|
5
|
+
|
|
6
|
+
import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
|
|
7
|
+
import {IPoolQuotaKeeperV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolQuotaKeeperV3.sol";
|
|
8
|
+
|
|
9
|
+
import {PoolCompressorV3} from "./PoolCompressor.sol";
|
|
10
|
+
import {PriceFeedCompressor} from "./PriceFeedCompressor.sol";
|
|
11
|
+
|
|
12
|
+
// // EXCEPTIONS
|
|
13
|
+
// import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
14
|
+
|
|
15
|
+
import {MarketData} from "../types/MarketData.sol";
|
|
16
|
+
import {PoolState} from "../types/PoolState.sol";
|
|
17
|
+
|
|
18
|
+
import "forge-std/console.sol";
|
|
19
|
+
|
|
20
|
+
// struct PriceOnDemand {
|
|
21
|
+
// address priceFeed;
|
|
22
|
+
// bytes callData;
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
/// @title Data compressor 3.0.
|
|
26
|
+
/// @notice Collects data from various contracts for use in the dApp
|
|
27
|
+
/// Do not use for data from data compressor for state-changing functions
|
|
28
|
+
contract MarketCompressorV3 {
|
|
29
|
+
// Contract version
|
|
30
|
+
uint256 public constant version = 3_10;
|
|
31
|
+
|
|
32
|
+
PriceFeedCompressor priceOracleCompressor;
|
|
33
|
+
PoolCompressorV3 poolCompressor;
|
|
34
|
+
|
|
35
|
+
error CreditManagerIsNotV3Exception();
|
|
36
|
+
|
|
37
|
+
constructor(address priceOracleCompressorAddress) {
|
|
38
|
+
poolCompressor = new PoolCompressorV3();
|
|
39
|
+
priceOracleCompressor = PriceFeedCompressor(priceOracleCompressorAddress);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function getMarketData(address pool) public view returns (MarketData memory result) {
|
|
43
|
+
result.pool = poolCompressor.getPoolState(pool);
|
|
44
|
+
result.poolQuotaKeeper = poolCompressor.getPoolQuotaKeeperState(result.pool.poolQuotaKeeper);
|
|
45
|
+
result.rateKeeper = poolCompressor.getRateKeeperState(result.poolQuotaKeeper.rateKeeper);
|
|
46
|
+
result.interestRateModel = poolCompressor.getInterestRateModelState(result.pool.interestRateModel);
|
|
47
|
+
|
|
48
|
+
address priceOracle = _getPriceOracle(result.pool);
|
|
49
|
+
address[] memory tokens = IPoolQuotaKeeperV3(result.pool.poolQuotaKeeper).quotedTokens();
|
|
50
|
+
|
|
51
|
+
result.tokens = new address[](tokens.length + 1);
|
|
52
|
+
result.tokens[0] = result.pool.underlying;
|
|
53
|
+
|
|
54
|
+
for (uint256 i = 0; i < tokens.length; i++) {
|
|
55
|
+
result.tokens[i + 1] = tokens[i];
|
|
56
|
+
}
|
|
57
|
+
// How to query if no credit mangers are deployed?
|
|
58
|
+
result.priceOracleData = priceOracleCompressor.getPriceOracleState(priceOracle, result.tokens);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _getPriceOracle(PoolState memory ps) internal view returns (address) {
|
|
62
|
+
if (ps.creditManagerDebtParams.length == 0) {
|
|
63
|
+
return address(0);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return ICreditManagerV3(ps.creditManagerDebtParams[0].creditManager).priceOracle();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -7,16 +7,25 @@ pragma experimental ABIEncoderV2;
|
|
|
7
7
|
import {PoolV3} from "@gearbox-protocol/core-v3/contracts/pool/PoolV3.sol";
|
|
8
8
|
import {IPoolQuotaKeeperV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolQuotaKeeperV3.sol";
|
|
9
9
|
import {IGaugeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IGaugeV3.sol";
|
|
10
|
+
import {IVersion} from "../interfaces/IVersion.sol";
|
|
11
|
+
import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
|
|
12
|
+
import {ICreditConfiguratorV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditConfiguratorV3.sol";
|
|
13
|
+
import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol";
|
|
10
14
|
|
|
11
15
|
import {PoolState, CreditManagerDebtParams} from "../types/PoolState.sol";
|
|
12
16
|
import {PoolQuotaKeeperState, QuotaTokenParams} from "../types/PoolQuotaKeeperState.sol";
|
|
13
17
|
import {RateKeeperState, Rate} from "../types/RateKeeperState.sol";
|
|
18
|
+
import {InterestRateModelState} from "../types/InterestRateModelState.sol";
|
|
19
|
+
import {CreditManagerState} from "../types/CreditManagerState.sol";
|
|
20
|
+
|
|
14
21
|
import {PERCENTAGE_FACTOR, RAY} from "@gearbox-protocol/core-v3/contracts/libraries/Constants.sol";
|
|
15
22
|
import {IRateKeeper} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IRateKeeper.sol";
|
|
16
23
|
|
|
17
24
|
import {RateKeeperType} from "../types/Enums.sol";
|
|
25
|
+
|
|
18
26
|
// Serializers
|
|
19
27
|
import {GaugeSerializer} from "../serializers/pool/GaugeSerializer.sol";
|
|
28
|
+
import {LinearInterestModelSerializer} from "../serializers/pool/LinearInterestModelSerializer.sol";
|
|
20
29
|
|
|
21
30
|
/// @title Pool compressor
|
|
22
31
|
/// @notice Collects data from pool related contracts
|
|
@@ -26,9 +35,11 @@ contract PoolCompressorV3 {
|
|
|
26
35
|
uint256 public constant version = 3_10;
|
|
27
36
|
|
|
28
37
|
address public immutable gaugeSerializer;
|
|
38
|
+
address public immutable linearInterestModelSerializer;
|
|
29
39
|
|
|
30
40
|
constructor() {
|
|
31
41
|
gaugeSerializer = address(new GaugeSerializer());
|
|
42
|
+
linearInterestModelSerializer = address(new LinearInterestModelSerializer());
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
function getPoolState(address pool) public view returns (PoolState memory result) {
|
|
@@ -73,8 +84,8 @@ contract PoolCompressorV3 {
|
|
|
73
84
|
result.baseInterestIndex = _pool.baseInterestIndex();
|
|
74
85
|
// uint256 baseInterestRate;
|
|
75
86
|
result.baseInterestRate = _pool.baseInterestRate();
|
|
76
|
-
// uint256
|
|
77
|
-
result.
|
|
87
|
+
// uint256 dieselRate;
|
|
88
|
+
result.dieselRate = _pool.convertToAssets(RAY);
|
|
78
89
|
// uint256 totalBorrowed;
|
|
79
90
|
result.totalBorrowed = _pool.totalBorrowed();
|
|
80
91
|
// uint256 totalDebtLimit;
|
|
@@ -173,4 +184,67 @@ contract PoolCompressorV3 {
|
|
|
173
184
|
result.rates[i].rate = rawRates[i];
|
|
174
185
|
}
|
|
175
186
|
}
|
|
187
|
+
|
|
188
|
+
function getInterestRateModelState(address irm) external view returns (InterestRateModelState memory result) {
|
|
189
|
+
InterestRateModelState memory irmState;
|
|
190
|
+
irmState.addr = irm;
|
|
191
|
+
irmState.version = IVersion(irm).version();
|
|
192
|
+
|
|
193
|
+
try IVersion(irm).contractType() returns (bytes32 contractType) {
|
|
194
|
+
irmState.contractType = contractType;
|
|
195
|
+
} catch {
|
|
196
|
+
irmState.contractType = "IRM_LINEAR";
|
|
197
|
+
}
|
|
198
|
+
// add serialiser
|
|
199
|
+
irmState.serializedParams = LinearInterestModelSerializer(linearInterestModelSerializer).serialize(irm);
|
|
200
|
+
return irmState;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/// @dev Returns CreditManagerData for a particular _cm
|
|
204
|
+
/// @param _cm CreditManager address
|
|
205
|
+
function getCreditManagerData(address _cm) public view returns (CreditManagerState memory result) {
|
|
206
|
+
ICreditManagerV3 creditManager = ICreditManagerV3(_cm);
|
|
207
|
+
ICreditConfiguratorV3 creditConfigurator = ICreditConfiguratorV3(creditManager.creditConfigurator());
|
|
208
|
+
ICreditFacadeV3 creditFacade = ICreditFacadeV3(creditManager.creditFacade());
|
|
209
|
+
|
|
210
|
+
result.addr = _cm;
|
|
211
|
+
result.name = ICreditManagerV3(_cm).name();
|
|
212
|
+
result.cfVersion = IVersion(address(creditFacade)).version();
|
|
213
|
+
|
|
214
|
+
result.creditFacade = address(creditFacade);
|
|
215
|
+
result.creditConfigurator = address(creditConfigurator);
|
|
216
|
+
|
|
217
|
+
result.underlying = creditManager.underlying();
|
|
218
|
+
|
|
219
|
+
(result.minDebt, result.maxDebt) = creditFacade.debtLimits();
|
|
220
|
+
|
|
221
|
+
{
|
|
222
|
+
uint256 collateralTokenCount = creditManager.collateralTokensCount();
|
|
223
|
+
|
|
224
|
+
result.collateralTokens = new address[](collateralTokenCount);
|
|
225
|
+
result.liquidationThresholds = new uint256[](collateralTokenCount);
|
|
226
|
+
|
|
227
|
+
unchecked {
|
|
228
|
+
for (uint256 i = 0; i < collateralTokenCount; ++i) {
|
|
229
|
+
(result.collateralTokens[i], result.liquidationThresholds[i]) =
|
|
230
|
+
creditManager.collateralTokenByMask(1 << i);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
result.degenNFT = creditFacade.degenNFT();
|
|
236
|
+
|
|
237
|
+
// (, result.isIncreaseDebtForbidden,,) = creditFacade.params(); // V2 only: true if increasing debt is forbidden
|
|
238
|
+
result.forbiddenTokenMask = creditFacade.forbiddenTokenMask(); // V2 only: mask which forbids some particular tokens
|
|
239
|
+
result.maxEnabledTokensLength = creditManager.maxEnabledTokens(); // V2 only: a limit on enabled tokens imposed for security
|
|
240
|
+
{
|
|
241
|
+
(
|
|
242
|
+
result.feeInterest,
|
|
243
|
+
result.feeLiquidation,
|
|
244
|
+
result.liquidationDiscount,
|
|
245
|
+
result.feeLiquidationExpired,
|
|
246
|
+
result.liquidationDiscountExpired
|
|
247
|
+
) = creditManager.fees();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
176
250
|
}
|
|
@@ -8,6 +8,7 @@ import {IPriceOracleV3, PriceFeedParams} from "@gearbox-protocol/core-v3/contrac
|
|
|
8
8
|
import {IPriceFeed, IUpdatablePriceFeed} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IPriceFeed.sol";
|
|
9
9
|
import {IPriceFeedCompressor} from "../interfaces/IPriceFeedCompressor.sol";
|
|
10
10
|
import {PriceFeedType} from "@gearbox-protocol/sdk-gov/contracts/PriceFeedType.sol";
|
|
11
|
+
import {IVersion} from "../interfaces/IVersion.sol";
|
|
11
12
|
|
|
12
13
|
import {IStateSerializerLegacy} from "../interfaces/IStateSerializerLegacy.sol";
|
|
13
14
|
import {IStateSerializer} from "../interfaces/IStateSerializer.sol";
|
|
@@ -17,7 +18,7 @@ import {BPTWeightedPriceFeedSerializer} from "../serializers/oracles/BPTWeighted
|
|
|
17
18
|
import {LPPriceFeedSerializer} from "../serializers/oracles/LPPriceFeedSerializer.sol";
|
|
18
19
|
import {PythPriceFeedSerializer} from "../serializers/oracles/PythPriceFeedSerializer.sol";
|
|
19
20
|
import {RedstonePriceFeedSerializer} from "../serializers/oracles/RedstonePriceFeedSerializer.sol";
|
|
20
|
-
import {PriceFeedAnswer, PriceFeedMapEntry, PriceFeedTreeNode} from "../types/PriceOracleState.sol";
|
|
21
|
+
import {PriceFeedAnswer, PriceFeedMapEntry, PriceFeedTreeNode, PriceOracleState} from "../types/PriceOracleState.sol";
|
|
21
22
|
|
|
22
23
|
interface ImplementsPriceFeedType {
|
|
23
24
|
/// @dev Annotates `priceFeedType` as `uint8` instead of `PriceFeedType` enum to support future types
|
|
@@ -78,7 +79,7 @@ contract PriceFeedCompressor is IPriceFeedCompressor {
|
|
|
78
79
|
/// from `priceFeedMap` and their underlying feeds, in case former are nested, which can help to determine
|
|
79
80
|
/// what underlying feeds should be updated to query the nested one.
|
|
80
81
|
function getPriceFeeds(address priceOracle)
|
|
81
|
-
|
|
82
|
+
public
|
|
82
83
|
view
|
|
83
84
|
override
|
|
84
85
|
returns (PriceFeedMapEntry[] memory priceFeedMap, PriceFeedTreeNode[] memory priceFeedTree)
|
|
@@ -87,6 +88,18 @@ contract PriceFeedCompressor is IPriceFeedCompressor {
|
|
|
87
88
|
return getPriceFeeds(priceOracle, tokens);
|
|
88
89
|
}
|
|
89
90
|
|
|
91
|
+
function getPriceOracleState(address priceOracle, address[] memory tokens)
|
|
92
|
+
external
|
|
93
|
+
view
|
|
94
|
+
returns (PriceOracleState memory result)
|
|
95
|
+
{
|
|
96
|
+
result.addr = priceOracle;
|
|
97
|
+
result.version = IPriceOracleV3(priceOracle).version();
|
|
98
|
+
result.contractType = IVersion(priceOracle).contractType();
|
|
99
|
+
|
|
100
|
+
(result.priceFeedMapping, result.priceFeedStructure) = getPriceFeeds(priceOracle, tokens);
|
|
101
|
+
}
|
|
102
|
+
|
|
90
103
|
/// @dev Same as the above but takes the list of tokens as argument as legacy oracle doesn't implement `getTokens`
|
|
91
104
|
function getPriceFeeds(address priceOracle, address[] memory tokens)
|
|
92
105
|
public
|
|
@@ -55,13 +55,13 @@ struct CreditAccountFilter {
|
|
|
55
55
|
bool reverting;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
/// @param
|
|
60
|
-
/// @param
|
|
58
|
+
/// @notice Credit manager filters
|
|
59
|
+
/// @param curators If set, match credit managers managed by given curators
|
|
60
|
+
/// @param pools If set, match credit managers connected to given pools
|
|
61
61
|
/// @param underlying If set, match credit managers with given underlying
|
|
62
62
|
struct CreditManagerFilter {
|
|
63
|
-
address
|
|
64
|
-
address
|
|
63
|
+
address[] curators;
|
|
64
|
+
address[] pools;
|
|
65
65
|
address underlying;
|
|
66
66
|
}
|
|
67
67
|
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
/// @title Version interface
|
|
7
|
+
/// @notice Defines contract version
|
|
8
|
+
interface IVersion {
|
|
9
|
+
/// @notice Contract version
|
|
10
|
+
function version() external view returns (uint256);
|
|
11
|
+
|
|
12
|
+
function contractType() external view returns (bytes32);
|
|
13
|
+
}
|
|
@@ -8,20 +8,21 @@ struct CreditManagerState {
|
|
|
8
8
|
uint256 version;
|
|
9
9
|
bytes32 contractType;
|
|
10
10
|
string name;
|
|
11
|
-
address creditFacade;
|
|
12
|
-
|
|
11
|
+
address creditFacade;
|
|
12
|
+
uint256 cfVersion;
|
|
13
|
+
bytes32 cfContractType;
|
|
14
|
+
address creditConfigurator;
|
|
13
15
|
address underlying;
|
|
14
16
|
address pool;
|
|
15
17
|
uint256 totalDebt;
|
|
16
18
|
uint256 totalDebtLimit;
|
|
17
19
|
uint256 minDebt;
|
|
18
20
|
uint256 maxDebt;
|
|
21
|
+
address degenNFT;
|
|
19
22
|
uint256 availableToBorrow;
|
|
20
23
|
address[] collateralTokens;
|
|
21
24
|
ContractAdapter[] adapters;
|
|
22
25
|
uint256[] liquidationThresholds;
|
|
23
|
-
bool isDegenMode; // V2 only: true if contract is in Degen mode
|
|
24
|
-
address degenNFT; // V2 only: degenNFT, address(0) if not in degen mode
|
|
25
26
|
uint256 forbiddenTokenMask; // V2 only: mask which forbids some particular tokens
|
|
26
27
|
uint8 maxEnabledTokensLength; // V2 only: in V1 as many tokens as the CM can support (256)
|
|
27
28
|
uint16 feeInterest; // Interest fee protocol charges: fee = interest accrues * feeInterest
|
|
@@ -29,8 +30,6 @@ struct CreditManagerState {
|
|
|
29
30
|
uint16 liquidationDiscount; // Miltiplier to get amount which liquidator should pay: amount = totalValue * liquidationDiscount
|
|
30
31
|
uint16 feeLiquidationExpired; // Liquidation fee protocol charges on expired accounts
|
|
31
32
|
uint16 liquidationDiscountExpired; // Multiplier for the amount the liquidator has to pay when closing an expired account
|
|
32
|
-
// V3 Fileds
|
|
33
|
-
bool isPaused;
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
struct ContractAdapter {
|
|
@@ -7,8 +7,8 @@ struct PriceOracleState {
|
|
|
7
7
|
address addr;
|
|
8
8
|
uint256 version;
|
|
9
9
|
bytes32 contractType;
|
|
10
|
-
PriceFeedMapEntry priceFeedMapping;
|
|
11
|
-
PriceFeedTreeNode priceFeedStructure;
|
|
10
|
+
PriceFeedMapEntry[] priceFeedMapping;
|
|
11
|
+
PriceFeedTreeNode[] priceFeedStructure;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/// @notice Price feed answer packed in a struct
|
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.17",
|
|
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>",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"@gearbox-protocol/governance": "^1.4.0-next.5",
|
|
23
23
|
"@gearbox-protocol/integrations-v3": "^1.23.1",
|
|
24
24
|
"@gearbox-protocol/oracles-v3": "^1.11.0-next.3",
|
|
25
|
-
"@gearbox-protocol/sdk-gov": "^2.
|
|
25
|
+
"@gearbox-protocol/sdk-gov": "^2.17.0",
|
|
26
26
|
"@openzeppelin/contracts": "^4.9.3",
|
|
27
27
|
"@redstone-finance/evm-connector": "0.2.5",
|
|
28
28
|
"ds-test": "dapphub/ds-test",
|
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
-
// (c) Gearbox Holdings, 2024
|
|
4
|
-
pragma solidity ^0.8.17;
|
|
5
|
-
|
|
6
|
-
// import {IAddressProviderV3} from "@gearbox-protocol/governance/contracts/interfaces/IAddressProviderV3.sol";
|
|
7
|
-
// import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
8
|
-
// import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
9
|
-
// import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
|
|
10
|
-
// import {PERCENTAGE_FACTOR, RAY} from "@gearbox-protocol/core-v3/contracts/libraries/Constants.sol";
|
|
11
|
-
|
|
12
|
-
// import {ContractsRegisterTrait} from "@gearbox-protocol/core-v3/contracts/traits/ContractsRegisterTrait.sol";
|
|
13
|
-
// import {IContractsRegister} from "@gearbox-protocol/core-v3/contracts/interfaces/IContractsRegister.sol";
|
|
14
|
-
// import {CreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/credit/CreditFacadeV3.sol";
|
|
15
|
-
|
|
16
|
-
// import {
|
|
17
|
-
// ICreditManagerV3,
|
|
18
|
-
// CollateralDebtData,
|
|
19
|
-
// CollateralCalcTask
|
|
20
|
-
// } from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
|
|
21
|
-
// import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol";
|
|
22
|
-
// import {ICreditConfiguratorV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditConfiguratorV3.sol";
|
|
23
|
-
// import {IPriceOracleV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPriceOracleV3.sol";
|
|
24
|
-
// import {ICreditAccountV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditAccountV3.sol";
|
|
25
|
-
// import {IPoolQuotaKeeperV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolQuotaKeeperV3.sol";
|
|
26
|
-
// import {IPoolV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IPoolV3.sol";
|
|
27
|
-
// import {PoolV3} from "@gearbox-protocol/core-v3/contracts/pool/PoolV3.sol";
|
|
28
|
-
|
|
29
|
-
// import {CreditManagerV3} from "@gearbox-protocol/core-v3/contracts/credit/CreditManagerV3.sol";
|
|
30
|
-
|
|
31
|
-
// import {CreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/credit/CreditFacadeV3.sol";
|
|
32
|
-
// import {IBotListV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IBotListV3.sol";
|
|
33
|
-
// import {IGaugeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/IGaugeV3.sol";
|
|
34
|
-
|
|
35
|
-
// import {IPriceFeed, IUpdatablePriceFeed} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IPriceFeed.sol";
|
|
36
|
-
|
|
37
|
-
// import {IVersion} from "@gearbox-protocol/core-v3/contracts/interfaces/base/IVersion.sol";
|
|
38
|
-
|
|
39
|
-
// import {IZapper} from "@gearbox-protocol/integrations-v3/contracts/interfaces/zappers/IZapper.sol";
|
|
40
|
-
|
|
41
|
-
// import {
|
|
42
|
-
// CreditManagerData,
|
|
43
|
-
// PoolData,
|
|
44
|
-
// TokenBalance,
|
|
45
|
-
// ContractAdapter,
|
|
46
|
-
// QuotaInfo,
|
|
47
|
-
// GaugeInfo,
|
|
48
|
-
// GaugeQuotaParams,
|
|
49
|
-
// CreditManagerDebtParams,
|
|
50
|
-
// ZapperInfo,
|
|
51
|
-
// LinearModel
|
|
52
|
-
// } from "./Types.sol";
|
|
53
|
-
|
|
54
|
-
// // EXCEPTIONS
|
|
55
|
-
// import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
56
|
-
|
|
57
|
-
// import {MarketData} from "./Types.sol";
|
|
58
|
-
|
|
59
|
-
// import "forge-std/console.sol";
|
|
60
|
-
|
|
61
|
-
// struct PriceOnDemand {
|
|
62
|
-
// address priceFeed;
|
|
63
|
-
// bytes callData;
|
|
64
|
-
// }
|
|
65
|
-
|
|
66
|
-
// /// @title Data compressor 3.0.
|
|
67
|
-
// /// @notice Collects data from various contracts for use in the dApp
|
|
68
|
-
// /// Do not use for data from data compressor for state-changing functions
|
|
69
|
-
// contract MarketCompressorV3 is ContractsRegisterTrait {
|
|
70
|
-
// // Contract version
|
|
71
|
-
// uint256 public constant version = 3_10;
|
|
72
|
-
|
|
73
|
-
// error CreditManagerIsNotV3Exception();
|
|
74
|
-
|
|
75
|
-
// constructor(address _addressProvider) ContractsRegisterTrait(_addressProvider) {
|
|
76
|
-
// // zapperRegister =
|
|
77
|
-
// // IZapperRegister(IAddressProviderV3(_addressProvider).getAddressOrRevert("ZAPPER_REGISTER", 3_00));
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
// function getMarketDataByPool(address pool) external returns (MarketData memory marketData) {}
|
|
81
|
-
|
|
82
|
-
// function getMarketDataByRiskCurtator(address riskCurator) external returns (MarketData[] memory marketData) {}
|
|
83
|
-
|
|
84
|
-
// function getMarketDataAll() external returns (MarketData[] memory marketData) {}
|
|
85
|
-
|
|
86
|
-
// /// @dev Returns CreditManagerData for a particular _cm
|
|
87
|
-
// /// @param _cm CreditManager address
|
|
88
|
-
// function getCreditManagerData(address _cm) public view returns (CreditManagerData memory result) {
|
|
89
|
-
// ICreditManagerV3 creditManager = ICreditManagerV3(_cm);
|
|
90
|
-
// ICreditConfiguratorV3 creditConfigurator = ICreditConfiguratorV3(creditManager.creditConfigurator());
|
|
91
|
-
// ICreditFacadeV3 creditFacade = _getCreditFacade(address(creditManager));
|
|
92
|
-
|
|
93
|
-
// result.addr = _cm;
|
|
94
|
-
// result.name = _getName(_cm);
|
|
95
|
-
// result.cfVersion = _getVersion(address(creditFacade));
|
|
96
|
-
|
|
97
|
-
// result.creditFacade = address(creditFacade);
|
|
98
|
-
// result.creditConfigurator = address(creditConfigurator);
|
|
99
|
-
|
|
100
|
-
// result.underlying = _getUnderlying(creditManager);
|
|
101
|
-
|
|
102
|
-
// {
|
|
103
|
-
// result.pool = _getPool(_cm);
|
|
104
|
-
// IPoolV3 pool = IPoolV3(result.pool);
|
|
105
|
-
// result.totalDebt = pool.creditManagerBorrowed(_cm);
|
|
106
|
-
// result.totalDebtLimit = pool.creditManagerDebtLimit(_cm);
|
|
107
|
-
|
|
108
|
-
// result.baseBorrowRate = _getBaseInterestRate(address(pool));
|
|
109
|
-
// result.availableToBorrow = pool.creditManagerBorrowable(_cm);
|
|
110
|
-
// result.lirm = _getInterestRateModel(address(pool));
|
|
111
|
-
// }
|
|
112
|
-
|
|
113
|
-
// (result.minDebt, result.maxDebt) = creditFacade.debtLimits();
|
|
114
|
-
|
|
115
|
-
// {
|
|
116
|
-
// uint256 collateralTokenCount = _getCollateralTokensCount(address(creditManager));
|
|
117
|
-
|
|
118
|
-
// result.collateralTokens = new address[](collateralTokenCount);
|
|
119
|
-
// result.liquidationThresholds = new uint256[](collateralTokenCount);
|
|
120
|
-
|
|
121
|
-
// unchecked {
|
|
122
|
-
// for (uint256 i = 0; i < collateralTokenCount; ++i) {
|
|
123
|
-
// (result.collateralTokens[i], result.liquidationThresholds[i]) =
|
|
124
|
-
// creditManager.collateralTokenByMask(1 << i);
|
|
125
|
-
// }
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
|
-
|
|
129
|
-
// address[] memory allowedAdapters = creditConfigurator.allowedAdapters();
|
|
130
|
-
// uint256 len = allowedAdapters.length;
|
|
131
|
-
// result.adapters = new ContractAdapter[](len);
|
|
132
|
-
|
|
133
|
-
// // unchecked {
|
|
134
|
-
// // for (uint256 i = 0; i < len; ++i) {
|
|
135
|
-
// // address allowedAdapter = allowedAdapters[i];
|
|
136
|
-
|
|
137
|
-
// // result.adapters[i] = ContractAdapter({
|
|
138
|
-
// // targetContract: creditManager.adapterToContract(allowedAdapter),
|
|
139
|
-
// // adapter: allowedAdapter
|
|
140
|
-
// // });
|
|
141
|
-
// // }
|
|
142
|
-
// // }
|
|
143
|
-
|
|
144
|
-
// result.degenNFT = creditFacade.degenNFT();
|
|
145
|
-
// result.isDegenMode = result.degenNFT != address(0);
|
|
146
|
-
// // (, result.isIncreaseDebtForbidden,,) = creditFacade.params(); // V2 only: true if increasing debt is forbidden
|
|
147
|
-
// result.forbiddenTokenMask = creditFacade.forbiddenTokenMask(); // V2 only: mask which forbids some particular tokens
|
|
148
|
-
// result.maxEnabledTokensLength = creditManager.maxEnabledTokens(); // V2 only: a limit on enabled tokens imposed for security
|
|
149
|
-
// {
|
|
150
|
-
// (
|
|
151
|
-
// result.feeInterest,
|
|
152
|
-
// result.feeLiquidation,
|
|
153
|
-
// result.liquidationDiscount,
|
|
154
|
-
// result.feeLiquidationExpired,
|
|
155
|
-
// result.liquidationDiscountExpired
|
|
156
|
-
// ) = creditManager.fees();
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
|
-
// result.quotas = _getQuotas(result.pool);
|
|
160
|
-
|
|
161
|
-
// result.isPaused = _getPaused(address(creditFacade));
|
|
162
|
-
// }
|
|
163
|
-
|
|
164
|
-
// /// @dev Returns PoolData for a particular pool
|
|
165
|
-
// /// @param _pool Pool address
|
|
166
|
-
// function getPoolData(address _pool) public view registeredPoolOnly(_pool) returns (PoolData memory result) {
|
|
167
|
-
// PoolV3 pool = PoolV3(_pool);
|
|
168
|
-
|
|
169
|
-
// result.addr = _pool;
|
|
170
|
-
// result.expectedLiquidity = pool.expectedLiquidity();
|
|
171
|
-
// result.availableLiquidity = pool.availableLiquidity();
|
|
172
|
-
|
|
173
|
-
// result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
174
|
-
// result.baseInterestIndex = pool.baseInterestIndex();
|
|
175
|
-
// result.baseInterestRate = _getBaseInterestRate(address(pool));
|
|
176
|
-
// result.underlying = pool.underlyingToken();
|
|
177
|
-
// result.dieselToken = address(pool);
|
|
178
|
-
// (result.symbol, result.name) = _getSymbolAndName(_pool);
|
|
179
|
-
|
|
180
|
-
// result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
181
|
-
// result.withdrawFee = pool.withdrawFee();
|
|
182
|
-
// result.baseInterestIndexLU = pool.baseInterestIndexLU();
|
|
183
|
-
// result.lastBaseInterestUpdate = pool.lastBaseInterestUpdate();
|
|
184
|
-
// // result.cumulativeIndex_RAY = pool.calcLinearCumulative_RAY();
|
|
185
|
-
|
|
186
|
-
// // Borrowing limits
|
|
187
|
-
// result.totalBorrowed = pool.totalBorrowed();
|
|
188
|
-
// result.totalDebtLimit = pool.totalDebtLimit();
|
|
189
|
-
|
|
190
|
-
// address[] memory creditManagers = pool.creditManagers();
|
|
191
|
-
// uint256 len = creditManagers.length;
|
|
192
|
-
// result.creditManagerDebtParams = new CreditManagerDebtParams[](len);
|
|
193
|
-
|
|
194
|
-
// unchecked {
|
|
195
|
-
// for (uint256 i; i < len; ++i) {
|
|
196
|
-
// address creditManager = creditManagers[i];
|
|
197
|
-
// result.creditManagerDebtParams[i] = CreditManagerDebtParams({
|
|
198
|
-
// creditManager: creditManager,
|
|
199
|
-
// borrowed: pool.creditManagerBorrowed(creditManager),
|
|
200
|
-
// limit: pool.creditManagerDebtLimit(creditManager),
|
|
201
|
-
// availableToBorrow: pool.creditManagerBorrowable(creditManager)
|
|
202
|
-
// });
|
|
203
|
-
// }
|
|
204
|
-
// }
|
|
205
|
-
|
|
206
|
-
// result.totalSupply = pool.totalSupply();
|
|
207
|
-
// result.totalAssets = pool.totalAssets();
|
|
208
|
-
// result.supplyRate = pool.supplyRate();
|
|
209
|
-
|
|
210
|
-
// result.version = _getVersion(address(pool));
|
|
211
|
-
|
|
212
|
-
// result.quotas = _getQuotas(_pool);
|
|
213
|
-
// result.lirm = _getInterestRateModel(_pool);
|
|
214
|
-
// result.isPaused = _getPaused(_pool);
|
|
215
|
-
|
|
216
|
-
// // Adding zappers
|
|
217
|
-
// // address[] memory zappers = zapperRegister.zappers(address(pool));
|
|
218
|
-
// // len = zappers.length;
|
|
219
|
-
// // result.zappers = new ZapperInfo[](len);
|
|
220
|
-
|
|
221
|
-
// // unchecked {
|
|
222
|
-
// // for (uint256 i; i < len; ++i) {
|
|
223
|
-
// // address tokenIn = IZapper(zappers[i]).tokenIn();
|
|
224
|
-
// // address tokenOut = IZapper(zappers[i]).tokenOut();
|
|
225
|
-
// // result.zappers[i] = ZapperInfo({tokenIn: tokenIn, tokenOut: tokenOut, zapper: zappers[i]});
|
|
226
|
-
// // }
|
|
227
|
-
// // }
|
|
228
|
-
|
|
229
|
-
// result.poolQuotaKeeper = address(_getPoolQuotaKeeper(_pool));
|
|
230
|
-
// result.gauge = _getGauge(IPoolQuotaKeeperV3(result.poolQuotaKeeper));
|
|
231
|
-
|
|
232
|
-
// return result;
|
|
233
|
-
// }
|
|
234
|
-
|
|
235
|
-
// /// @dev Returns PoolData for all registered pools
|
|
236
|
-
// function getPoolsV3List() external view returns (PoolData[] memory result) {
|
|
237
|
-
// address[] memory poolsV3 = _listPoolsV3();
|
|
238
|
-
// uint256 len = poolsV3.length;
|
|
239
|
-
// result = new PoolData[](len);
|
|
240
|
-
|
|
241
|
-
// unchecked {
|
|
242
|
-
// for (uint256 i = 0; i < len; ++i) {
|
|
243
|
-
// result[i] = getPoolData(poolsV3[i]);
|
|
244
|
-
// }
|
|
245
|
-
// }
|
|
246
|
-
// }
|
|
247
|
-
|
|
248
|
-
// function _listPoolsV3() internal view returns (address[] memory result) {
|
|
249
|
-
// uint256 len = IContractsRegister(contractsRegister).getPools().length;
|
|
250
|
-
|
|
251
|
-
// // uint256 index;
|
|
252
|
-
// // unchecked {
|
|
253
|
-
// // for (uint256 op = COUNT; op <= QUERY; ++op) {
|
|
254
|
-
// // if (op == QUERY && index == 0) {
|
|
255
|
-
// // break;
|
|
256
|
-
// // } else {
|
|
257
|
-
// // result = new address[](index);
|
|
258
|
-
// // index = 0;
|
|
259
|
-
// // }
|
|
260
|
-
|
|
261
|
-
// // for (uint256 i = 0; i < len; ++i) {
|
|
262
|
-
// // address _pool = IContractsRegister(contractsRegister).pools(i);
|
|
263
|
-
|
|
264
|
-
// // if (_isContractV3(_pool)) {
|
|
265
|
-
// // if (op == QUERY) result[index] = _pool;
|
|
266
|
-
// // ++index;
|
|
267
|
-
// // }
|
|
268
|
-
// // }
|
|
269
|
-
// // }
|
|
270
|
-
// // }
|
|
271
|
-
// }
|
|
272
|
-
|
|
273
|
-
// function _updatePrices(address creditManager, PriceOnDemand[] memory priceUpdates) internal {
|
|
274
|
-
// uint256 len = priceUpdates.length;
|
|
275
|
-
// unchecked {
|
|
276
|
-
// for (uint256 i; i < len; ++i) {
|
|
277
|
-
// address priceFeed = _getPriceOracle(creditManager).priceFeeds(priceUpdates[i].priceFeed);
|
|
278
|
-
// if (priceFeed == address(0)) revert PriceFeedDoesNotExistException();
|
|
279
|
-
|
|
280
|
-
// IUpdatablePriceFeed(priceFeed).updatePrice(priceUpdates[i].callData);
|
|
281
|
-
// }
|
|
282
|
-
// }
|
|
283
|
-
// }
|
|
284
|
-
|
|
285
|
-
// function _getPriceFeedFailedList(address _cm, TokenBalance[] memory balances)
|
|
286
|
-
// internal
|
|
287
|
-
// view
|
|
288
|
-
// returns (address[] memory priceFeedFailed)
|
|
289
|
-
// {
|
|
290
|
-
// uint256 len = balances.length;
|
|
291
|
-
|
|
292
|
-
// IPriceOracleV3 priceOracle = _getPriceOracle(_cm);
|
|
293
|
-
|
|
294
|
-
// uint256 index;
|
|
295
|
-
|
|
296
|
-
// /// It counts on the first iteration how many price feeds failed and then fill the array on the second iteration
|
|
297
|
-
// // for (uint256 op = COUNT; op <= QUERY; ++op) {
|
|
298
|
-
// // if (op == QUERY && index == 0) {
|
|
299
|
-
// // break;
|
|
300
|
-
// // } else {
|
|
301
|
-
// // priceFeedFailed = new address[](index);
|
|
302
|
-
// // index = 0;
|
|
303
|
-
// // }
|
|
304
|
-
// // unchecked {
|
|
305
|
-
// // for (uint256 i = 0; i < len; ++i) {
|
|
306
|
-
// // TokenBalance memory balance = balances[i];
|
|
307
|
-
|
|
308
|
-
// // if (balance.balance > 1 && balance.isEnabled) {
|
|
309
|
-
// // try priceOracle.getPrice(balance.token) returns (uint256) {}
|
|
310
|
-
// // catch {
|
|
311
|
-
// // if (op == QUERY) priceFeedFailed[index] = balance.token;
|
|
312
|
-
// // ++index;
|
|
313
|
-
// // }
|
|
314
|
-
// // }
|
|
315
|
-
// // }
|
|
316
|
-
// // }
|
|
317
|
-
// // }
|
|
318
|
-
// }
|
|
319
|
-
|
|
320
|
-
// function _getPoolQuotaKeeper(address pool) internal view returns (IPoolQuotaKeeperV3) {
|
|
321
|
-
// return IPoolQuotaKeeperV3(IPoolV3(pool).poolQuotaKeeper());
|
|
322
|
-
// }
|
|
323
|
-
|
|
324
|
-
// function _getPriceOracle(address _cm) internal view returns (IPriceOracleV3) {
|
|
325
|
-
// return IPriceOracleV3(ICreditManagerV3(_cm).priceOracle());
|
|
326
|
-
// }
|
|
327
|
-
|
|
328
|
-
// function _getBaseInterestRate(address pool) internal view returns (uint256) {
|
|
329
|
-
// return IPoolV3(pool).baseInterestRate();
|
|
330
|
-
// }
|
|
331
|
-
|
|
332
|
-
// function _getBorrowerOrRevert(address cm, address creditAccount) internal view returns (address) {
|
|
333
|
-
// return ICreditManagerV3(cm).getBorrowerOrRevert(creditAccount);
|
|
334
|
-
// }
|
|
335
|
-
|
|
336
|
-
// function _getVersion(address versionedContract) internal view returns (uint256) {
|
|
337
|
-
// return IVersion(versionedContract).version();
|
|
338
|
-
// }
|
|
339
|
-
|
|
340
|
-
// function _getCreditFacade(address cm) internal view returns (ICreditFacadeV3) {
|
|
341
|
-
// return ICreditFacadeV3(ICreditManagerV3(cm).creditFacade());
|
|
342
|
-
// }
|
|
343
|
-
|
|
344
|
-
// function _getSymbolAndName(address token) internal view returns (string memory symbol, string memory name) {
|
|
345
|
-
// symbol = IERC20Metadata(token).symbol();
|
|
346
|
-
// name = _getName(token);
|
|
347
|
-
// }
|
|
348
|
-
|
|
349
|
-
// function _getInterestRateModel(address pool) internal view returns (LinearModel memory) {
|
|
350
|
-
// // return getLIRMData(IPoolV3(pool).interestRateModel());
|
|
351
|
-
// }
|
|
352
|
-
|
|
353
|
-
// function _getQuotedTokens(IPoolQuotaKeeperV3 pqk) internal view returns (address[] memory result) {
|
|
354
|
-
// result = pqk.quotedTokens();
|
|
355
|
-
// }
|
|
356
|
-
|
|
357
|
-
// function _getPool(address cnt) internal view returns (address) {
|
|
358
|
-
// return ICreditManagerV3(cnt).pool();
|
|
359
|
-
// }
|
|
360
|
-
|
|
361
|
-
// function _getName(address _cm) internal view returns (string memory) {
|
|
362
|
-
// return IERC20Metadata(_cm).name();
|
|
363
|
-
// }
|
|
364
|
-
|
|
365
|
-
// function _getCollateralTokensCount(address _cm) internal view returns (uint256) {
|
|
366
|
-
// return ICreditManagerV3(_cm).collateralTokensCount();
|
|
367
|
-
// }
|
|
368
|
-
|
|
369
|
-
// function _getGauge(IPoolQuotaKeeperV3 pqk) internal view returns (address) {
|
|
370
|
-
// return pqk.gauge();
|
|
371
|
-
// }
|
|
372
|
-
|
|
373
|
-
// function _getPaused(address pausableContract) internal view returns (bool) {
|
|
374
|
-
// return Pausable(pausableContract).paused();
|
|
375
|
-
// }
|
|
376
|
-
|
|
377
|
-
// function _getUnderlying(ICreditManagerV3 cm) internal view returns (address) {
|
|
378
|
-
// return cm.underlying();
|
|
379
|
-
// }
|
|
380
|
-
|
|
381
|
-
// function _getQuotas(address _pool) internal view returns (QuotaInfo[] memory quotas) {
|
|
382
|
-
// IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(_pool);
|
|
383
|
-
|
|
384
|
-
// address[] memory quotaTokens = _getQuotedTokens(pqk);
|
|
385
|
-
// uint256 len = quotaTokens.length;
|
|
386
|
-
// quotas = new QuotaInfo[](len);
|
|
387
|
-
// unchecked {
|
|
388
|
-
// for (uint256 i; i < len; ++i) {
|
|
389
|
-
// quotas[i].token = quotaTokens[i];
|
|
390
|
-
// (
|
|
391
|
-
// quotas[i].rate,
|
|
392
|
-
// ,
|
|
393
|
-
// quotas[i].quotaIncreaseFee,
|
|
394
|
-
// quotas[i].totalQuoted,
|
|
395
|
-
// quotas[i].limit,
|
|
396
|
-
// quotas[i].isActive
|
|
397
|
-
// ) = pqk.getTokenQuotaParams(quotaTokens[i]);
|
|
398
|
-
// }
|
|
399
|
-
// }
|
|
400
|
-
// }
|
|
401
|
-
|
|
402
|
-
// function getGaugesV3Data(address staker) external view returns (GaugeInfo[] memory result) {
|
|
403
|
-
// address[] memory poolsV3 = _listPoolsV3();
|
|
404
|
-
// uint256 len = poolsV3.length;
|
|
405
|
-
// result = new GaugeInfo[](len);
|
|
406
|
-
|
|
407
|
-
// unchecked {
|
|
408
|
-
// for (uint256 i; i < len; ++i) {
|
|
409
|
-
// GaugeInfo memory gaugeInfo = result[i];
|
|
410
|
-
// IPoolQuotaKeeperV3 pqk = _getPoolQuotaKeeper(poolsV3[i]);
|
|
411
|
-
// address gauge = _getGauge(pqk);
|
|
412
|
-
// gaugeInfo.addr = gauge;
|
|
413
|
-
// gaugeInfo.pool = _getPool(gauge);
|
|
414
|
-
// (gaugeInfo.symbol, gaugeInfo.name) = _getSymbolAndName(gaugeInfo.pool);
|
|
415
|
-
// gaugeInfo.underlying = IPoolV3(gaugeInfo.pool).asset();
|
|
416
|
-
|
|
417
|
-
// address[] memory quotaTokens = _getQuotedTokens(pqk);
|
|
418
|
-
// uint256 quotaTokensLen = quotaTokens.length;
|
|
419
|
-
// gaugeInfo.quotaParams = new GaugeQuotaParams[](quotaTokensLen);
|
|
420
|
-
|
|
421
|
-
// gaugeInfo.currentEpoch = IGaugeV3(gauge).epochLastUpdate();
|
|
422
|
-
// gaugeInfo.epochFrozen = IGaugeV3(gauge).epochFrozen();
|
|
423
|
-
|
|
424
|
-
// for (uint256 j; j < quotaTokensLen; ++j) {
|
|
425
|
-
// GaugeQuotaParams memory quotaParams = gaugeInfo.quotaParams[j];
|
|
426
|
-
// address token = quotaTokens[j];
|
|
427
|
-
// quotaParams.token = token;
|
|
428
|
-
|
|
429
|
-
// (
|
|
430
|
-
// quotaParams.rate,
|
|
431
|
-
// ,
|
|
432
|
-
// quotaParams.quotaIncreaseFee,
|
|
433
|
-
// quotaParams.totalQuoted,
|
|
434
|
-
// quotaParams.limit,
|
|
435
|
-
// quotaParams.isActive
|
|
436
|
-
// ) = pqk.getTokenQuotaParams(token);
|
|
437
|
-
|
|
438
|
-
// (
|
|
439
|
-
// quotaParams.minRate,
|
|
440
|
-
// quotaParams.maxRate,
|
|
441
|
-
// quotaParams.totalVotesLpSide,
|
|
442
|
-
// quotaParams.totalVotesCaSide
|
|
443
|
-
// ) = IGaugeV3(gauge).quotaRateParams(token);
|
|
444
|
-
|
|
445
|
-
// (quotaParams.stakerVotesLpSide, quotaParams.stakerVotesCaSide) =
|
|
446
|
-
// IGaugeV3(gauge).userTokenVotes(staker, token);
|
|
447
|
-
// }
|
|
448
|
-
// }
|
|
449
|
-
// }
|
|
450
|
-
// }
|
|
451
|
-
// }
|