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