@gearbox-protocol/periphery-v3 1.2.2 → 1.2.4
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.
|
@@ -62,6 +62,8 @@ import "@gearbox-protocol/core-v3/contracts/interfaces/IExceptions.sol";
|
|
|
62
62
|
import {LinearInterestModelHelper} from "./LinearInterestModelHelper.sol";
|
|
63
63
|
import {IZapperRegister} from "../interfaces/IZapperRegister.sol";
|
|
64
64
|
|
|
65
|
+
import "forge-std/console.sol";
|
|
66
|
+
|
|
65
67
|
/// @title Data compressor 3.0.
|
|
66
68
|
/// @notice Collects data from various contracts for use in the dApp
|
|
67
69
|
/// Do not use for data from data compressor for state-changing functions
|
|
@@ -137,10 +139,10 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
137
139
|
uint256 caLen = creditAccounts.length;
|
|
138
140
|
for (uint256 j; j < caLen; ++j) {
|
|
139
141
|
if (
|
|
140
|
-
(borrower == address(0) || _getBorrowerOrRevert(_cm, creditAccounts[
|
|
142
|
+
(borrower == address(0) || _getBorrowerOrRevert(_cm, creditAccounts[j]) == borrower)
|
|
141
143
|
&& (
|
|
142
144
|
!liquidatableOnly
|
|
143
|
-
|| ICreditManagerV3(_cm).isLiquidatable(creditAccounts[
|
|
145
|
+
|| ICreditManagerV3(_cm).isLiquidatable(creditAccounts[j], PERCENTAGE_FACTOR)
|
|
144
146
|
)
|
|
145
147
|
) {
|
|
146
148
|
if (op == QUERY) {
|
|
@@ -232,7 +234,8 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
|
|
235
|
-
result.aggregatedBorrowRate =
|
|
237
|
+
result.aggregatedBorrowRate =
|
|
238
|
+
result.baseBorrowRate + (result.debt == 0 ? 0 : RAY * quotaRevenue / PERCENTAGE_FACTOR / result.debt);
|
|
236
239
|
|
|
237
240
|
// uint256 debt;
|
|
238
241
|
// uint256 cumulativeIndexNow;
|
|
@@ -412,7 +415,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
412
415
|
result.availableLiquidity = pool.availableLiquidity();
|
|
413
416
|
|
|
414
417
|
result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
415
|
-
result.linearCumulativeIndex = pool.
|
|
418
|
+
result.linearCumulativeIndex = pool.baseInterestIndex();
|
|
416
419
|
result.baseInterestRate = _getBaseInterestRate(address(pool));
|
|
417
420
|
result.underlying = pool.underlyingToken();
|
|
418
421
|
result.dieselToken = address(pool);
|
|
@@ -432,6 +435,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
432
435
|
|
|
433
436
|
unchecked {
|
|
434
437
|
for (uint256 i; i < len; ++i) {
|
|
438
|
+
console.log("i: ", i);
|
|
435
439
|
address creditManager = creditManagers[i];
|
|
436
440
|
result.creditManagerDebtParams[i] = CreditManagerDebtParams({
|
|
437
441
|
creditManager: creditManager,
|
|
@@ -22,6 +22,8 @@ contract LinearInterestModelHelper {
|
|
|
22
22
|
} else {
|
|
23
23
|
(irm.U_1, irm.U_2, irm.R_base, irm.R_slope1, irm.R_slope2, irm.R_slope3) =
|
|
24
24
|
LinearInterestRateModelV3(_model).getModelParameters();
|
|
25
|
+
|
|
26
|
+
irm.isBorrowingMoreU2Forbidden = LinearInterestRateModelV3(_model).isBorrowingMoreU2Forbidden();
|
|
25
27
|
}
|
|
26
28
|
}
|
|
27
29
|
}
|
package/contracts/data/Types.sol
CHANGED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// SPDX-License-Identifier: UNLICENSED
|
|
2
|
+
// Gearbox Protocol. Generalized leverage for DeFi protocols
|
|
3
|
+
// (c) Gearbox Foundation, 2023.
|
|
4
|
+
pragma solidity ^0.8.17;
|
|
5
|
+
|
|
6
|
+
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
|
|
7
|
+
|
|
8
|
+
import {DataCompressorV2_10} from "../data/DataCompressor_2_1.sol";
|
|
9
|
+
import {DataCompressorV3_00} from "../data/DataCompressor_3_0.sol";
|
|
10
|
+
import {IDataCompressorV3_00, PriceOnDemand} from "../interfaces/IDataCompressorV3_00.sol";
|
|
11
|
+
import {CreditAccountData, CreditManagerData, PoolData, TokenBalance, ContractAdapter} from "../data/Types.sol";
|
|
12
|
+
|
|
13
|
+
import {NetworkDetector} from "@gearbox-protocol/sdk-gov/contracts/NetworkDetector.sol";
|
|
14
|
+
|
|
15
|
+
import "forge-std/console.sol";
|
|
16
|
+
|
|
17
|
+
address constant ap = 0xfb78A83730aBd595A362645368D10fE5a20525a6;
|
|
18
|
+
|
|
19
|
+
contract DCTest {
|
|
20
|
+
DataCompressorV2_10 public dc2;
|
|
21
|
+
DataCompressorV3_00 public dc3;
|
|
22
|
+
|
|
23
|
+
uint256 chainId;
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
NetworkDetector nd = new NetworkDetector();
|
|
27
|
+
chainId = nd.chainId();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
modifier liveTestOnly() {
|
|
31
|
+
if (chainId == 1) {
|
|
32
|
+
_;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function setUp() public liveTestOnly {
|
|
37
|
+
dc2 = new DataCompressorV2_10(ap);
|
|
38
|
+
dc3 = new DataCompressorV3_00(ap);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function _printPools(PoolData[] memory pools) internal view {
|
|
42
|
+
uint256 len = pools.length;
|
|
43
|
+
unchecked {
|
|
44
|
+
for (uint256 i; i < len; ++i) {
|
|
45
|
+
PoolData memory pool = pools[i];
|
|
46
|
+
console.log("\n\n");
|
|
47
|
+
console.log(IERC20Metadata(pool.underlying).symbol(), pool.addr);
|
|
48
|
+
console.log("-------------------------------");
|
|
49
|
+
|
|
50
|
+
console.log("dieselToken: ", pool.dieselToken);
|
|
51
|
+
///
|
|
52
|
+
console.log("linearCumulativeIndex: ", pool.linearCumulativeIndex);
|
|
53
|
+
console.log("availableLiquidity: ", pool.availableLiquidity);
|
|
54
|
+
console.log("expectedLiquidity: ", pool.expectedLiquidity);
|
|
55
|
+
//
|
|
56
|
+
console.log("totalBorrowed: ", pool.totalBorrowed);
|
|
57
|
+
console.log("totalDebtLimit: ", pool.totalDebtLimit);
|
|
58
|
+
// CreditManagerDebtParams[] creditManagerDebtParams;
|
|
59
|
+
console.log("totalAssets: ", pool.totalAssets);
|
|
60
|
+
console.log("totalSupply: ", pool.totalSupply);
|
|
61
|
+
console.log("supplyRate", pool.supplyRate);
|
|
62
|
+
console.log("baseInterestRate: ", pool.baseInterestRate);
|
|
63
|
+
console.log("dieselRate_RAY: ", pool.dieselRate_RAY);
|
|
64
|
+
console.log("withdrawFee", pool.withdrawFee);
|
|
65
|
+
console.log("cumulativeIndex_RAY:", pool.cumulativeIndex_RAY);
|
|
66
|
+
console.log("baseInterestIndexLU:", pool.baseInterestIndexLU);
|
|
67
|
+
console.log("version: ", pool.version);
|
|
68
|
+
// QuotaInfo[] quotas;
|
|
69
|
+
// LinearModel lirm;
|
|
70
|
+
console.log("isPaused", pool.isPaused);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function _printCreditManagers(CreditManagerData[] memory cms) internal view {
|
|
76
|
+
uint256 len = cms.length;
|
|
77
|
+
unchecked {
|
|
78
|
+
for (uint256 i; i < len; ++i) {
|
|
79
|
+
CreditManagerData memory cm = cms[i];
|
|
80
|
+
console.log("\n\n");
|
|
81
|
+
console.log(IERC20Metadata(cm.underlying).symbol(), cm.addr);
|
|
82
|
+
console.log("-------------------------------");
|
|
83
|
+
console.log("cfVersion: ", cm.cfVersion);
|
|
84
|
+
console.log("creditFacace: ", cm.creditFacade); // V2 only: address of creditFacade
|
|
85
|
+
console.log("creditConfigurator: ", cm.creditConfigurator); // V2 only: address of creditConfigurator
|
|
86
|
+
console.log("pool: ", cm.pool);
|
|
87
|
+
console.log("totalDebt: ", cm.totalDebt);
|
|
88
|
+
console.log("totalDebtLimit: ", cm.totalDebtLimit);
|
|
89
|
+
console.log("baseBorrowRate: ", cm.baseBorrowRate);
|
|
90
|
+
console.log("minDebt: ", cm.minDebt);
|
|
91
|
+
console.log("maxDebt: ", cm.maxDebt);
|
|
92
|
+
console.log("availableToBorrow: ", cm.availableToBorrow);
|
|
93
|
+
// address[] collateralTokens);
|
|
94
|
+
// ContractAdapter[] adapters);
|
|
95
|
+
// uint256[] liquidationThresholds);
|
|
96
|
+
console.log("isDegenMode: ", cm.isDegenMode); // V2 only: true if contract is in Degen mode
|
|
97
|
+
console.log("degenNFT: ", cm.degenNFT); // V2 only: degenNFT, address(0) if not in degen mode
|
|
98
|
+
console.log("forbiddenTokenMask: ", cm.forbiddenTokenMask); // V2 only: mask which forbids some particular tokens
|
|
99
|
+
console.log("maxEnabledTokensLength: ", cm.maxEnabledTokensLength); // V2 only: in V1 as many tokens as the CM can support (256)
|
|
100
|
+
console.log("feeInterest: ", cm.feeInterest); // Interest fee protocol charges: fee = interest accrues * feeInterest
|
|
101
|
+
console.log("feeLiquidation: ", cm.feeLiquidation); // Liquidation fee protocol charges: fee = totalValue * feeLiquidation
|
|
102
|
+
console.log("liquidationDiscount: ", cm.liquidationDiscount); // Miltiplier to get amount which liquidator should pay: amount = totalValue * liquidationDiscount
|
|
103
|
+
console.log("feeLiquidationExpired: ", cm.feeLiquidationExpired); // Liquidation fee protocol charges on expired accounts
|
|
104
|
+
console.log("liquidationDiscountExpired: ", cm.liquidationDiscountExpired); // Multiplier for the amount the liquidator has to pay when closing an expired account
|
|
105
|
+
// V3 Fileds
|
|
106
|
+
// QuotaInfo[] quotas);
|
|
107
|
+
// LinearModel lirm);
|
|
108
|
+
console.log("sPaused: ", cm.isPaused);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function test_dc_01_pools() public view liveTestOnly {
|
|
114
|
+
PoolData[] memory pools = dc2.getPoolsV1List();
|
|
115
|
+
console.log("V1 pools");
|
|
116
|
+
_printPools(pools);
|
|
117
|
+
|
|
118
|
+
pools = dc3.getPoolsV3List();
|
|
119
|
+
console.log("\nV3 pools");
|
|
120
|
+
_printPools(pools);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function test_dc_02_credit_managers() public view liveTestOnly {
|
|
124
|
+
CreditManagerData[] memory cms = dc2.getCreditManagersV2List();
|
|
125
|
+
console.log("V2 credit managers");
|
|
126
|
+
_printCreditManagers(cms);
|
|
127
|
+
|
|
128
|
+
cms = dc3.getCreditManagersV3List();
|
|
129
|
+
console.log("\n\nV3 credit managers");
|
|
130
|
+
_printCreditManagers(cms);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function test_dc_03_credit_accounts() public liveTestOnly {
|
|
134
|
+
CreditAccountData[] memory cas = dc2.getCreditAccountsByBorrower(address(this));
|
|
135
|
+
console.log("V2 credit accounts", cas.length);
|
|
136
|
+
|
|
137
|
+
cas = dc3.getCreditAccountsByBorrower(address(this), new PriceOnDemand[](0));
|
|
138
|
+
console.log("V3 credit accounts", cas.length);
|
|
139
|
+
}
|
|
140
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/periphery-v3",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
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,10 +18,10 @@
|
|
|
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.39.
|
|
21
|
+
"@gearbox-protocol/core-v3": "^1.39.2",
|
|
22
|
+
"@gearbox-protocol/integrations-v3": "^1.16.0",
|
|
22
23
|
"@gearbox-protocol/oracles-v3": "^1.7.2",
|
|
23
24
|
"@gearbox-protocol/sdk-gov": "^1.5.10",
|
|
24
|
-
"@gearbox-protocol/integrations-v3": "^1.16.0",
|
|
25
25
|
"@openzeppelin/contracts": "4.8.3"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|