@gearbox-protocol/periphery-v3 1.0.3 → 1.0.5

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.
@@ -1,9 +1,11 @@
1
1
  // SPDX-License-Identifier: BUSL-1.1
2
2
  // Gearbox Protocol. Generalized leverage for DeFi protocols
3
- // (c) Gearbox Holdings, 2022
3
+ // (c) Gearbox Holdings, 2023
4
4
  pragma solidity ^0.8.10;
5
5
  pragma experimental ABIEncoderV2;
6
6
 
7
+ import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
8
+
7
9
  import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
8
10
  import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
9
11
 
@@ -177,11 +179,12 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait, Li
177
179
  {
178
180
  result.pool = creditManagerV2.pool();
179
181
  PoolService pool = PoolService(result.pool);
180
- // result.canBorrow =;
181
182
  result.baseBorrowRate = pool.borrowAPY_RAY();
182
- // TODO: add limit calculation
183
- result.availableToBorrow = pool.creditManagersCanBorrow(_creditManager) ? pool.availableLiquidity() : 0;
184
183
 
184
+ (uint128 currentTotalDebt, uint128 totalDebtLimit) = creditFacade.totalDebt();
185
+ result.availableToBorrow = pool.creditManagersCanBorrow(_creditManager)
186
+ ? Math.min(pool.availableLiquidity(), totalDebtLimit - currentTotalDebt)
187
+ : 0;
185
188
  result.lirm = getLIRMData(address(pool.interestRateModel()));
186
189
  }
187
190
 
@@ -244,8 +247,7 @@ contract DataCompressorV2_10 is IDataCompressorV2_10, ContractsRegisterTrait, Li
244
247
 
245
248
  /// @dev Returns PoolData for a particular pool
246
249
  /// @param _pool Pool address
247
- // TODO: add isPaused()
248
- // TODO: add interestRateModel address / data
250
+
249
251
  function getPoolData(address _pool) public view registeredPoolOnly(_pool) returns (PoolData memory result) {
250
252
  PoolService pool = PoolService(_pool);
251
253
 
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: BUSL-1.1
2
2
  // Gearbox Protocol. Generalized leverage for DeFi protocols
3
- // (c) Gearbox Holdings, 2022
3
+ // (c) Gearbox Holdings, 2023
4
4
  pragma solidity ^0.8.10;
5
5
  pragma experimental ABIEncoderV2;
6
6
 
@@ -1,3 +1,8 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ // Gearbox Protocol. Generalized leverage for DeFi protocols
3
+ // (c) Gearbox Holdings, 2023
4
+ pragma solidity ^0.8.17;
5
+
1
6
  import {LinearInterestRateModelV3} from "@gearbox-protocol/core-v3/contracts/pool/LinearInterestRateModelV3.sol";
2
7
  import {LinearModel} from "./Types.sol";
3
8
 
@@ -100,6 +100,7 @@ struct CreditManagerData {
100
100
  // V3 Fileds
101
101
  QuotaInfo[] quotas;
102
102
  LinearModel lirm;
103
+ bool isPaused;
103
104
  }
104
105
  // LIR
105
106
 
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Gearbox Protocol. Generalized leverage for DeFi protocols
3
- // (c) Gearbox Holdings, 2022
3
+ // (c) Gearbox Holdings, 2023
4
4
  pragma solidity ^0.8.10;
5
5
 
6
6
  import {CreditAccountData, CreditManagerData, PoolData} from "../data/Types.sol";
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Gearbox Protocol. Generalized leverage for DeFi protocols
3
- // (c) Gearbox Holdings, 2022
3
+ // (c) Gearbox Holdings, 2023
4
4
  pragma solidity ^0.8.10;
5
5
 
6
6
  import {CreditAccountData, CreditManagerData, PoolData} from "../data/Types.sol";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/periphery-v3",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
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>",