-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import {Script, console2 as console} from "forge-std/Script.sol"; | ||
|
||
import {StakeInspector} from "src/helpers/StakeInspector.sol"; | ||
|
||
contract DeployStakeInspector is Script { | ||
address escrowMode = 0xff8AB822b8A853b01F9a9E9465321d6Fe77c9D2F; | ||
address escrowBPT = 0x9c2eFe2a1FBfb601125Bb07a3D5bC6EC91F91e01; | ||
|
||
function run() public { | ||
vm.startBroadcast(vm.addr(vm.envUint("DEPLOYMENT_PRIVATE_KEY"))); | ||
StakeInspector stakeInspectorMode = new StakeInspector(escrowMode); | ||
StakeInspector stakeInspectorBPT = new StakeInspector(escrowBPT); | ||
|
||
vm.stopBroadcast(); | ||
console.log("StakeInspector for Mode deployed at: ", address(stakeInspectorMode)); | ||
console.log("StakeInspector for BPT deployed at: ", address(stakeInspectorBPT)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.17; | ||
|
||
import {IVotingEscrowIncreasing} from "@escrow-interfaces/IVotingEscrowIncreasing.sol"; | ||
|
||
interface IVotingEscrowIncreasingExtended is IVotingEscrowIncreasing { | ||
function ownedTokens(address _account) external view returns (uint256[] memory tokenIds); | ||
} | ||
|
||
/// @notice Aggregate staked balances for an address given multiple veNFTs | ||
contract StakeInspector { | ||
/// @notice The staking contract | ||
IVotingEscrowIncreasingExtended public escrow; | ||
|
||
constructor(address _escrow) { | ||
escrow = IVotingEscrowIncreasingExtended(_escrow); | ||
} | ||
|
||
/// @notice Fetch the total underlying tokens staked across all the veNFTs owned by an account | ||
function getTotalStaked(address _account) external view returns (uint256) { | ||
uint256 totalStaked = 0; | ||
|
||
uint256[] memory veNFTs = escrow.ownedTokens(_account); | ||
for (uint256 i = 0; i < veNFTs.length; i++) { | ||
totalStaked += escrow.locked(veNFTs[i]).amount; | ||
} | ||
return totalStaked; | ||
} | ||
} |