|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | + |
| 3 | +/// @custom:authors: [@unknownunknown1] |
| 4 | +/// @custom:reviewers: [] |
| 5 | +/// @custom:auditors: [] |
| 6 | +/// @custom:bounties: [] |
| 7 | +/// @custom:deployments: [] |
| 8 | + |
| 9 | +pragma solidity 0.8.24; |
| 10 | + |
| 11 | +import {ISortitionModule} from "../arbitration/interfaces/ISortitionModule.sol"; |
| 12 | + |
| 13 | +interface IKlerosCore { |
| 14 | + function sortitionModule() external view returns (ISortitionModule); |
| 15 | +} |
| 16 | + |
| 17 | +/// @title KlerosCoreSnapshotProxy |
| 18 | +/// Proxy contract for V2 that exposes staked PNK with balanceOf() function for Snapshot voting. |
| 19 | +contract KlerosCoreSnapshotProxy { |
| 20 | + IKlerosCore public core; |
| 21 | + address public governor; |
| 22 | + string public name = "Staked Pinakion"; |
| 23 | + string public symbol = "stPNK"; |
| 24 | + uint8 public immutable decimals = 18; |
| 25 | + |
| 26 | + modifier onlyByGovernor() { |
| 27 | + require(governor == msg.sender, "Access not allowed: Governor only."); |
| 28 | + _; |
| 29 | + } |
| 30 | + |
| 31 | + /// @dev Constructor |
| 32 | + /// @param _governor The govenor of the contract. |
| 33 | + /// @param _core KlerosCore to read the balance from. |
| 34 | + constructor(address _governor, IKlerosCore _core) { |
| 35 | + governor = _governor; |
| 36 | + core = _core; |
| 37 | + } |
| 38 | + |
| 39 | + /// @dev Changes the `governor` storage variable. |
| 40 | + /// @param _governor The new value for the `governor` storage variable. |
| 41 | + function changeGovernor(address _governor) external onlyByGovernor { |
| 42 | + governor = _governor; |
| 43 | + } |
| 44 | + |
| 45 | + /// @dev Changes the `core` storage variable. |
| 46 | + /// @param _core The new value for the `core` storage variable. |
| 47 | + function changeCore(IKlerosCore _core) external onlyByGovernor { |
| 48 | + core = _core; |
| 49 | + } |
| 50 | + |
| 51 | + /// @dev Returns the amount of PNK staked in KlerosV2 for a particular address. |
| 52 | + /// Note: Proxy doesn't need to differentiate between courts so we pass 0 as courtID. |
| 53 | + /// @param _account The address to query. |
| 54 | + /// @return totalStaked Total amount staked in V2 by the address. |
| 55 | + function balanceOf(address _account) external view returns (uint256 totalStaked) { |
| 56 | + (totalStaked, , , ) = core.sortitionModule().getJurorBalance(_account, 0); |
| 57 | + } |
| 58 | +} |
0 commit comments