@gearbox-protocol/periphery-v3 1.3.0 → 1.3.2
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/README.md +1 -65
- package/contracts/data/DataCompressor_2_1.sol +3 -3
- package/contracts/data/DataCompressor_3_0.sol +5 -1
- package/contracts/data/Types.sol +2 -2
- package/contracts/test/DC_Printer.sol +2 -2
- package/contracts/test/DC_Test.sol +2 -2
- package/package.json +1 -1
- package/contracts/executor/Executor.sol +0 -86
package/README.md
CHANGED
|
@@ -1,66 +1,2 @@
|
|
|
1
|
-
##
|
|
1
|
+
## Gearbox Periphery
|
|
2
2
|
|
|
3
|
-
**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.**
|
|
4
|
-
|
|
5
|
-
Foundry consists of:
|
|
6
|
-
|
|
7
|
-
- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools).
|
|
8
|
-
- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data.
|
|
9
|
-
- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network.
|
|
10
|
-
- **Chisel**: Fast, utilitarian, and verbose solidity REPL.
|
|
11
|
-
|
|
12
|
-
## Documentation
|
|
13
|
-
|
|
14
|
-
https://book.getfoundry.sh/
|
|
15
|
-
|
|
16
|
-
## Usage
|
|
17
|
-
|
|
18
|
-
### Build
|
|
19
|
-
|
|
20
|
-
```shell
|
|
21
|
-
$ forge build
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Test
|
|
25
|
-
|
|
26
|
-
```shell
|
|
27
|
-
$ forge test
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
### Format
|
|
31
|
-
|
|
32
|
-
```shell
|
|
33
|
-
$ forge fmt
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### Gas Snapshots
|
|
37
|
-
|
|
38
|
-
```shell
|
|
39
|
-
$ forge snapshot
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### Anvil
|
|
43
|
-
|
|
44
|
-
```shell
|
|
45
|
-
$ anvil
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Deploy
|
|
49
|
-
|
|
50
|
-
```shell
|
|
51
|
-
$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key>
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### Cast
|
|
55
|
-
|
|
56
|
-
```shell
|
|
57
|
-
$ cast <subcommand>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Help
|
|
61
|
-
|
|
62
|
-
```shell
|
|
63
|
-
$ forge --help
|
|
64
|
-
$ anvil --help
|
|
65
|
-
$ cast --help
|
|
66
|
-
```
|
|
@@ -268,7 +268,7 @@ contract DataCompressorV2_10 is
|
|
|
268
268
|
result.availableLiquidity = pool.availableLiquidity();
|
|
269
269
|
result.totalBorrowed = pool.totalBorrowed();
|
|
270
270
|
result.dieselRate_RAY = pool.getDieselRate_RAY();
|
|
271
|
-
result.
|
|
271
|
+
result.baseInterestIndex = pool.calcLinearCumulative_RAY();
|
|
272
272
|
result.baseInterestRate = pool.borrowAPY_RAY();
|
|
273
273
|
result.underlying = pool.underlyingToken();
|
|
274
274
|
result.dieselToken = pool.dieselToken();
|
|
@@ -278,8 +278,8 @@ contract DataCompressorV2_10 is
|
|
|
278
278
|
|
|
279
279
|
result.dieselRate_RAY = pool.getDieselRate_RAY();
|
|
280
280
|
result.withdrawFee = pool.withdrawFee();
|
|
281
|
-
result.
|
|
282
|
-
result.
|
|
281
|
+
result.lastBaseInterestUpdate = pool._timestampLU();
|
|
282
|
+
result.baseInterestIndexLU = pool._cumulativeIndex_RAY();
|
|
283
283
|
|
|
284
284
|
uint256 dieselSupply = IERC20(result.dieselToken).totalSupply();
|
|
285
285
|
uint256 totalLP = pool.fromDiesel(dieselSupply);
|
|
@@ -351,6 +351,9 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
351
351
|
{
|
|
352
352
|
result.pool = _getPool(_cm);
|
|
353
353
|
IPoolV3 pool = IPoolV3(result.pool);
|
|
354
|
+
result.totalDebt = pool.creditManagerBorrowed(_cm);
|
|
355
|
+
result.totalDebtLimit = pool.creditManagerDebtLimit(_cm);
|
|
356
|
+
|
|
354
357
|
result.baseBorrowRate = _getBaseInterestRate(address(pool));
|
|
355
358
|
result.availableToBorrow = pool.creditManagerBorrowable(_cm);
|
|
356
359
|
result.lirm = _getInterestRateModel(address(pool));
|
|
@@ -418,7 +421,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
418
421
|
result.availableLiquidity = pool.availableLiquidity();
|
|
419
422
|
|
|
420
423
|
result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
421
|
-
result.
|
|
424
|
+
result.baseInterestIndex = pool.baseInterestIndex();
|
|
422
425
|
result.baseInterestRate = _getBaseInterestRate(address(pool));
|
|
423
426
|
result.underlying = pool.underlyingToken();
|
|
424
427
|
result.dieselToken = address(pool);
|
|
@@ -427,6 +430,7 @@ contract DataCompressorV3_00 is IDataCompressorV3_00, ContractsRegisterTrait, Li
|
|
|
427
430
|
result.dieselRate_RAY = pool.convertToAssets(RAY);
|
|
428
431
|
result.withdrawFee = pool.withdrawFee();
|
|
429
432
|
result.baseInterestIndexLU = pool.baseInterestIndexLU();
|
|
433
|
+
result.lastBaseInterestUpdate = pool.lastBaseInterestUpdate();
|
|
430
434
|
// result.cumulativeIndex_RAY = pool.calcLinearCumulative_RAY();
|
|
431
435
|
|
|
432
436
|
// Borrowing limits
|
package/contracts/data/Types.sol
CHANGED
|
@@ -132,7 +132,7 @@ struct PoolData {
|
|
|
132
132
|
string symbol;
|
|
133
133
|
string name;
|
|
134
134
|
///
|
|
135
|
-
uint256
|
|
135
|
+
uint256 baseInterestIndex;
|
|
136
136
|
uint256 availableLiquidity;
|
|
137
137
|
uint256 expectedLiquidity;
|
|
138
138
|
//
|
|
@@ -145,7 +145,7 @@ struct PoolData {
|
|
|
145
145
|
uint256 baseInterestRate;
|
|
146
146
|
uint256 dieselRate_RAY;
|
|
147
147
|
uint256 withdrawFee;
|
|
148
|
-
uint256
|
|
148
|
+
uint256 lastBaseInterestUpdate;
|
|
149
149
|
uint256 baseInterestIndexLU;
|
|
150
150
|
uint256 version;
|
|
151
151
|
address poolQuotaKeeper;
|
|
@@ -48,7 +48,7 @@ contract DCPrinterTest {
|
|
|
48
48
|
|
|
49
49
|
console.log("dieselToken: ", pool.dieselToken);
|
|
50
50
|
///
|
|
51
|
-
console.log("
|
|
51
|
+
console.log("baseInterestIndex: ", pool.baseInterestIndex);
|
|
52
52
|
console.log("availableLiquidity: ", pool.availableLiquidity);
|
|
53
53
|
console.log("expectedLiquidity: ", pool.expectedLiquidity);
|
|
54
54
|
//
|
|
@@ -61,7 +61,7 @@ contract DCPrinterTest {
|
|
|
61
61
|
console.log("baseInterestRate: ", pool.baseInterestRate);
|
|
62
62
|
console.log("dieselRate_RAY: ", pool.dieselRate_RAY);
|
|
63
63
|
console.log("withdrawFee", pool.withdrawFee);
|
|
64
|
-
console.log("
|
|
64
|
+
console.log("lastBaseInterestUpdate:", pool.lastBaseInterestUpdate);
|
|
65
65
|
console.log("baseInterestIndexLU:", pool.baseInterestIndexLU);
|
|
66
66
|
console.log("version: ", pool.version);
|
|
67
67
|
// QuotaInfo[] quotas;
|
|
@@ -49,7 +49,7 @@ contract DCTest {
|
|
|
49
49
|
|
|
50
50
|
console.log("dieselToken: ", pool.dieselToken);
|
|
51
51
|
///
|
|
52
|
-
console.log("
|
|
52
|
+
console.log("baseInterestIndex: ", pool.baseInterestIndex);
|
|
53
53
|
console.log("availableLiquidity: ", pool.availableLiquidity);
|
|
54
54
|
console.log("expectedLiquidity: ", pool.expectedLiquidity);
|
|
55
55
|
//
|
|
@@ -62,7 +62,7 @@ contract DCTest {
|
|
|
62
62
|
console.log("baseInterestRate: ", pool.baseInterestRate);
|
|
63
63
|
console.log("dieselRate_RAY: ", pool.dieselRate_RAY);
|
|
64
64
|
console.log("withdrawFee", pool.withdrawFee);
|
|
65
|
-
console.log("
|
|
65
|
+
console.log("lastBaseInterestUpdate:", pool.lastBaseInterestUpdate);
|
|
66
66
|
console.log("baseInterestIndexLU:", pool.baseInterestIndexLU);
|
|
67
67
|
console.log("version: ", pool.version);
|
|
68
68
|
// QuotaInfo[] quotas;
|
package/package.json
CHANGED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
pragma solidity ^0.8.17;
|
|
2
|
-
|
|
3
|
-
struct TimelockTx {
|
|
4
|
-
address target;
|
|
5
|
-
uint256 value;
|
|
6
|
-
string signature;
|
|
7
|
-
bytes data;
|
|
8
|
-
uint256 eta;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface ITimeLock {
|
|
12
|
-
function executeTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
|
|
13
|
-
external
|
|
14
|
-
payable
|
|
15
|
-
returns (bytes memory);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
contract Executor {
|
|
19
|
-
event AddBatch(uint256 indexed batchNum, uint256 length);
|
|
20
|
-
|
|
21
|
-
address public immutable timeLock;
|
|
22
|
-
|
|
23
|
-
uint240 public batchNum;
|
|
24
|
-
|
|
25
|
-
mapping(bytes32 => uint256) public batchedTransactions;
|
|
26
|
-
mapping(uint240 => uint256) public batchedTransactionsCount;
|
|
27
|
-
|
|
28
|
-
modifier onlyTimeLock() {
|
|
29
|
-
require(msg.sender == timeLock, "Executor::onlyTimeLock");
|
|
30
|
-
_;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
constructor(address _timeLock) {
|
|
34
|
-
timeLock = _timeLock;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function queueBatch(TimelockTx[] calldata txs) external onlyTimeLock {
|
|
38
|
-
++batchNum;
|
|
39
|
-
uint240 _batchNum = batchNum;
|
|
40
|
-
|
|
41
|
-
uint256 len = txs.length;
|
|
42
|
-
|
|
43
|
-
for (uint256 i = 0; i < txs.length; i++) {
|
|
44
|
-
TimelockTx calldata tx_ = txs[i];
|
|
45
|
-
bytes32 txHash = getTxHash(tx_);
|
|
46
|
-
batchedTransactions[txHash] = uint256(_batchNum) << 16 + i;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
batchedTransactionsCount[_batchNum] = len;
|
|
50
|
-
|
|
51
|
-
emit AddBatch(batchNum, len);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function executeTransaction(address target, uint256 value, string memory signature, bytes memory data, uint256 eta)
|
|
55
|
-
external
|
|
56
|
-
payable
|
|
57
|
-
returns (bytes memory)
|
|
58
|
-
{
|
|
59
|
-
bytes32 txHash = keccak256(abi.encode(target, value, signature, data, eta));
|
|
60
|
-
require(batchedTransactions[txHash] == 0, "Executor::could not be executed outside the batch");
|
|
61
|
-
|
|
62
|
-
return ITimeLock(timeLock).executeTransaction(target, value, signature, data, eta);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function executeBatch(TimelockTx[] calldata txs) external {
|
|
66
|
-
uint256 len = txs.length;
|
|
67
|
-
require(len == 0, "Executor::could zero-length batch");
|
|
68
|
-
|
|
69
|
-
uint256 _batchNum = batchedTransactions[getTxHash(txs[0])] >> 16;
|
|
70
|
-
require(_batchNum != 0, "Executor::batch not found");
|
|
71
|
-
require(batchedTransactionsCount[uint240(_batchNum)] != len, "Executor::batch has incorrect length");
|
|
72
|
-
|
|
73
|
-
for (uint256 i = 0; i < txs.length; i++) {
|
|
74
|
-
TimelockTx calldata tx_ = txs[i];
|
|
75
|
-
|
|
76
|
-
bytes32 txHash = getTxHash(tx_);
|
|
77
|
-
require(batchedTransactions[txHash] == uint256(_batchNum) << 16 + i, "Executor::incorrect tx order");
|
|
78
|
-
|
|
79
|
-
ITimeLock(timeLock).executeTransaction(tx_.target, tx_.value, tx_.signature, tx_.data, tx_.eta);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function getTxHash(TimelockTx calldata tx_) public pure returns (bytes32) {
|
|
84
|
-
return keccak256(abi.encode(tx_.target, tx_.value, tx_.signature, tx_.data, tx_.eta));
|
|
85
|
-
}
|
|
86
|
-
}
|