@gearbox-protocol/periphery-v3 1.0.7 → 1.0.9
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.
|
@@ -26,15 +26,14 @@ import {IVersion} from "@gearbox-protocol/core-v2/contracts/interfaces/IVersion.
|
|
|
26
26
|
import {IAddressProvider} from "@gearbox-protocol/core-v2/contracts/interfaces/IAddressProvider.sol";
|
|
27
27
|
import {IDataCompressorV2_10} from "../interfaces/IDataCompressorV2_10.sol";
|
|
28
28
|
|
|
29
|
-
import {
|
|
29
|
+
import {
|
|
30
|
+
COUNT, QUERY, CreditAccountData, CreditManagerData, PoolData, TokenBalance, ContractAdapter
|
|
31
|
+
} from "./Types.sol";
|
|
30
32
|
|
|
31
33
|
// EXCEPTIONS
|
|
32
34
|
import {ZeroAddressException} from "@gearbox-protocol/core-v2/contracts/interfaces/IErrors.sol";
|
|
33
35
|
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
34
36
|
|
|
35
|
-
uint256 constant COUNT = 0;
|
|
36
|
-
uint256 constant QUERY = 1;
|
|
37
|
-
|
|
38
37
|
/// @title Data compressor 2.1.
|
|
39
38
|
/// @notice Collects data from various contracts for use in the dApp
|
|
40
39
|
/// Do not use for data from data compressor for state-changing functions
|
|
@@ -46,33 +45,27 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait, Li
|
|
|
46
45
|
|
|
47
46
|
/// @dev Returns CreditAccountData for all opened accounts for particular borrower
|
|
48
47
|
/// @param borrower Borrower address
|
|
49
|
-
function
|
|
48
|
+
function getCreditAccountsByBorrower(address borrower) external view returns (CreditAccountData[] memory result) {
|
|
50
49
|
// Counts how many opened accounts a borrower has
|
|
51
|
-
|
|
52
|
-
uint256 creditManagersLength =
|
|
50
|
+
address[] memory cms = _listCreditManagersV2();
|
|
51
|
+
uint256 creditManagersLength = cms.length;
|
|
52
|
+
|
|
53
|
+
uint256 index;
|
|
53
54
|
unchecked {
|
|
54
|
-
for (uint256
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
for (uint256 op = COUNT; op <= QUERY; ++op) {
|
|
56
|
+
if (op == QUERY && index == 0) {
|
|
57
|
+
break;
|
|
58
|
+
} else {
|
|
59
|
+
result = new CreditAccountData[](index);
|
|
60
|
+
index = 0;
|
|
58
61
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
count = 0;
|
|
66
|
-
for (uint256 i = 0; i < creditManagersLength;) {
|
|
67
|
-
address creditManager = IContractsRegister(contractsRegister).creditManagers(i);
|
|
68
|
-
unchecked {
|
|
69
|
-
if (hasOpenedCreditAccount(creditManager, borrower)) {
|
|
70
|
-
result[count] = getCreditAccountData(creditManager, borrower);
|
|
71
|
-
|
|
72
|
-
count++;
|
|
62
|
+
for (uint256 i = 0; i < creditManagersLength; ++i) {
|
|
63
|
+
address creditManager = cms[i];
|
|
64
|
+
if (hasOpenedCreditAccount(creditManager, borrower)) {
|
|
65
|
+
if (op == QUERY) result[index] = getCreditAccountData(creditManager, borrower);
|
|
66
|
+
++index;
|
|
67
|
+
}
|
|
73
68
|
}
|
|
74
|
-
|
|
75
|
-
++i;
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
}
|
|
@@ -153,12 +146,12 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait, Li
|
|
|
153
146
|
/// @dev Returns CreditManagerData for all Credit Managers
|
|
154
147
|
function getCreditManagersV2List() external view returns (CreditManagerData[] memory result) {
|
|
155
148
|
address[] memory cms = _listCreditManagersV2();
|
|
156
|
-
uint256
|
|
149
|
+
uint256 creditManagersLength = cms.length;
|
|
157
150
|
|
|
158
|
-
result = new CreditManagerData[](
|
|
151
|
+
result = new CreditManagerData[](creditManagersLength);
|
|
159
152
|
|
|
160
153
|
unchecked {
|
|
161
|
-
for (uint256 i = 0; i <
|
|
154
|
+
for (uint256 i = 0; i < creditManagersLength; ++i) {
|
|
162
155
|
result[i] = getCreditManagerData(cms[i]);
|
|
163
156
|
}
|
|
164
157
|
}
|
|
@@ -40,6 +40,8 @@ import {AddressProvider} from "@gearbox-protocol/core-v2/contracts/core/AddressP
|
|
|
40
40
|
import {IDataCompressorV3_00, PriceOnDemand} from "../interfaces/IDataCompressorV3_00.sol";
|
|
41
41
|
|
|
42
42
|
import {
|
|
43
|
+
COUNT,
|
|
44
|
+
QUERY,
|
|
43
45
|
CreditAccountData,
|
|
44
46
|
CreditManagerData,
|
|
45
47
|
PoolData,
|
|
@@ -56,9 +58,6 @@ import {
|
|
|
56
58
|
import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
57
59
|
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
58
60
|
|
|
59
|
-
uint256 constant COUNT = 0;
|
|
60
|
-
uint256 constant QUERY = 1;
|
|
61
|
-
|
|
62
61
|
/// @title Data compressor 3.0.
|
|
63
62
|
/// @notice Collects data from various contracts for use in the dApp
|
|
64
63
|
/// Do not use for data from data compressor for state-changing functions
|
|
@@ -541,8 +540,14 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
541
540
|
unchecked {
|
|
542
541
|
for (uint256 i; i < len; ++i) {
|
|
543
542
|
quotas[i].token = quotaTokens[i];
|
|
544
|
-
(
|
|
545
|
-
|
|
543
|
+
(
|
|
544
|
+
quotas[i].rate,
|
|
545
|
+
,
|
|
546
|
+
quotas[i].quotaIncreaseFee,
|
|
547
|
+
quotas[i].totalQuoted,
|
|
548
|
+
quotas[i].limit,
|
|
549
|
+
quotas[i].isActive
|
|
550
|
+
) = pqk.getTokenQuotaParams(quotaTokens[i]);
|
|
546
551
|
}
|
|
547
552
|
}
|
|
548
553
|
}
|
|
@@ -568,8 +573,14 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
568
573
|
address token = quotaTokens[j];
|
|
569
574
|
quotaParams.token = token;
|
|
570
575
|
|
|
571
|
-
(
|
|
572
|
-
|
|
576
|
+
(
|
|
577
|
+
quotaParams.rate,
|
|
578
|
+
,
|
|
579
|
+
quotaParams.quotaIncreaseFee,
|
|
580
|
+
quotaParams.totalQuoted,
|
|
581
|
+
quotaParams.limit,
|
|
582
|
+
quotaParams.isActive
|
|
583
|
+
) = pqk.getTokenQuotaParams(token);
|
|
573
584
|
|
|
574
585
|
(
|
|
575
586
|
quotaParams.minRate,
|
package/contracts/data/Types.sol
CHANGED
|
@@ -5,6 +5,9 @@ pragma solidity ^0.8.17;
|
|
|
5
5
|
|
|
6
6
|
import {ScheduledWithdrawal} from "@gearbox-protocol/core-v3/contracts/interfaces/IWithdrawalManagerV3.sol";
|
|
7
7
|
|
|
8
|
+
uint256 constant COUNT = 0;
|
|
9
|
+
uint256 constant QUERY = 1;
|
|
10
|
+
|
|
8
11
|
struct TokenBalance {
|
|
9
12
|
address token;
|
|
10
13
|
uint256 balance;
|
|
@@ -21,6 +24,7 @@ struct QuotaInfo {
|
|
|
21
24
|
uint16 quotaIncreaseFee;
|
|
22
25
|
uint96 totalQuoted;
|
|
23
26
|
uint96 limit;
|
|
27
|
+
bool isActive;
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
struct ContractAdapter {
|
|
@@ -148,6 +152,7 @@ struct GaugeQuotaParams {
|
|
|
148
152
|
uint16 quotaIncreaseFee;
|
|
149
153
|
uint96 totalQuoted;
|
|
150
154
|
uint96 limit;
|
|
155
|
+
bool isActive;
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
struct GaugeInfo {
|
|
@@ -9,7 +9,7 @@ import {IVersion} from "@gearbox-protocol/core-v2/contracts/interfaces/IVersion.
|
|
|
9
9
|
interface IDataCompressorV2_10 is IVersion {
|
|
10
10
|
/// @dev Returns CreditAccountData for all opened accounts for particular borrower
|
|
11
11
|
/// @param borrower Borrower address
|
|
12
|
-
function
|
|
12
|
+
function getCreditAccountsByBorrower(address borrower) external view returns (CreditAccountData[] memory);
|
|
13
13
|
|
|
14
14
|
/// @dev Returns whether the borrower has an open credit account with the credit manager
|
|
15
15
|
/// @param creditManager Credit manager to check
|
|
@@ -94,7 +94,7 @@ contract DCTest {
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
function
|
|
97
|
+
function test_dc_01_pools() public view {
|
|
98
98
|
PoolData[] memory pools = dc2.getPoolsV1List();
|
|
99
99
|
console.log("V1 pools");
|
|
100
100
|
_printPools(pools);
|
|
@@ -104,7 +104,7 @@ contract DCTest {
|
|
|
104
104
|
_printPools(pools);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function
|
|
107
|
+
function test_dc_02_credit_managers() public view {
|
|
108
108
|
CreditManagerData[] memory cms = dc2.getCreditManagersV2List();
|
|
109
109
|
console.log("V2 credit managers");
|
|
110
110
|
_printCreditManagers(cms);
|
|
@@ -113,4 +113,9 @@ contract DCTest {
|
|
|
113
113
|
console.log("\n\nV3 credit managers");
|
|
114
114
|
_printCreditManagers(cms);
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
function test_dc_03_credit_accounts() public view {
|
|
118
|
+
CreditAccountData[] memory cas = dc2.getCreditAccountsByBorrower(address(this));
|
|
119
|
+
console.log("V2 credit accounts", cas.length);
|
|
120
|
+
}
|
|
116
121
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/periphery-v3",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
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>",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@commitlint/cli": "^17.6.3",
|
|
19
19
|
"@commitlint/config-conventional": "17.6.0",
|
|
20
20
|
"@gearbox-protocol/core-v2": "1.19.0-base.14",
|
|
21
|
-
"@gearbox-protocol/core-v3": "^1.
|
|
21
|
+
"@gearbox-protocol/core-v3": "^1.39.0",
|
|
22
22
|
"@gearbox-protocol/oracles-v3": "^1.7.2",
|
|
23
23
|
"@gearbox-protocol/sdk-gov": "^1.5.10",
|
|
24
24
|
"@openzeppelin/contracts": "4.8.3",
|