-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathVaultHints.sol
85 lines (70 loc) · 2.95 KB
/
VaultHints.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.25;
import {Hints} from "./Hints.sol";
import {Vault} from "../vault/Vault.sol";
import {Checkpoints} from "../libraries/Checkpoints.sol";
contract VaultHints is Hints, Vault {
using Checkpoints for Checkpoints.Trace256;
constructor() Vault(address(0), address(0), address(0)) {}
function activeStakeHintInternal(
uint48 timestamp
) external view internalFunction returns (bool exists, uint32 hint) {
(exists,,, hint) = _activeStake.upperLookupRecentCheckpoint(timestamp);
}
function activeStakeHint(address vault, uint48 timestamp) public view returns (bytes memory) {
(bool exists, uint32 hint_) = abi.decode(
_selfStaticDelegateCall(vault, abi.encodeCall(VaultHints.activeStakeHintInternal, (timestamp))),
(bool, uint32)
);
if (exists) {
return abi.encode(hint_);
}
}
function activeSharesHintInternal(
uint48 timestamp
) external view internalFunction returns (bool exists, uint32 hint) {
(exists,,, hint) = _activeShares.upperLookupRecentCheckpoint(timestamp);
}
function activeSharesHint(address vault, uint48 timestamp) public view returns (bytes memory) {
(bool exists, uint32 hint_) = abi.decode(
_selfStaticDelegateCall(vault, abi.encodeCall(VaultHints.activeSharesHintInternal, (timestamp))),
(bool, uint32)
);
if (exists) {
return abi.encode(hint_);
}
}
function activeSharesOfHintInternal(
address account,
uint48 timestamp
) external view internalFunction returns (bool exists, uint32 hint) {
(exists,,, hint) = _activeSharesOf[account].upperLookupRecentCheckpoint(timestamp);
}
function activeSharesOfHint(address vault, address account, uint48 timestamp) public view returns (bytes memory) {
(bool exists, uint32 hint_) = abi.decode(
_selfStaticDelegateCall(vault, abi.encodeCall(VaultHints.activeSharesOfHintInternal, (account, timestamp))),
(bool, uint32)
);
if (exists) {
return abi.encode(hint_);
}
}
function activeBalanceOfHints(
address vault,
address account,
uint48 timestamp
) external view returns (bytes memory) {
bytes memory activeSharesOfHint_ = activeSharesOfHint(vault, account, timestamp);
bytes memory activeStakeHint_ = activeStakeHint(vault, timestamp);
bytes memory activeSharesHint_ = activeSharesHint(vault, timestamp);
if (activeSharesOfHint_.length > 0 || activeStakeHint_.length > 0 || activeSharesHint_.length > 0) {
return abi.encode(
ActiveBalanceOfHints({
activeSharesOfHint: activeSharesOfHint_,
activeStakeHint: activeStakeHint_,
activeSharesHint: activeSharesHint_
})
);
}
}
}