Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Second step to remove legacy #159

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Resolve latest contracts
run: yarn upgrade @keep-network/keep-core@${{ github.event.inputs.environment }}

- name: Configure tenderly
env:
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
Expand Down Expand Up @@ -186,13 +183,6 @@ jobs:
- name: Install needed dependencies
run: yarn install --frozen-lockfile

# If we don't remove the `keep-core` contracts from `node-modules`, the
# `etherscan-verify` plugins tries to verify them, which is not desired.
- name: Prepare for verification on Etherscan
run: |
rm -rf ./node_modules/@keep-network/keep-core
rm -rf ./external/npm

- name: Verify contracts on Etherscan
env:
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
Expand Down Expand Up @@ -226,9 +216,6 @@ jobs:
- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Resolve latest contracts
run: yarn upgrade @keep-network/keep-core@${{ github.event.inputs.environment }}

- name: Deploy contracts
env:
CHAIN_API_URL: ${{ secrets.SEPOLIA_ETH_HOSTNAME_HTTP }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ jobs:
registry-url: "https://registry.npmjs.org"
cache: "yarn"

- name: Resolve latest contracts
run: |
yarn upgrade --exact \
@keep-network/keep-core
- name: Install needed dependencies
run: yarn install --frozen-lockfile

# Deploy contracts to a local network to generate deployment artifacts that
# are required by dashboard compilation.
Expand Down
6 changes: 2 additions & 4 deletions contracts/governance/StakerGovernorVotes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import "./GovernorParameters.sol";
import "./IVotesHistory.sol";

/// @title StakerGovernorVotes
/// @notice Staker DAO voting power extraction from staked T positions,
// including legacy stakes (NU/KEEP).
/// @notice Staker DAO voting power extraction from staked T positions.
abstract contract StakerGovernorVotes is GovernorParameters {
IVotesHistory public immutable staking;

Expand All @@ -29,8 +28,7 @@ abstract contract StakerGovernorVotes is GovernorParameters {
}

/// @notice Read the voting weight from the snapshot mechanism in the T
/// staking contracts. Note that this also tracks legacy stakes
/// (NU/KEEP).
/// staking contracts.
/// @param account Delegate account with T staking voting power
/// @param blockNumber The block number to get the vote balance at
/// @dev See {IGovernor-getVotes}
Expand Down
11 changes: 2 additions & 9 deletions contracts/governance/TokenholderGovernorVotes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import "./IVotesHistory.sol";

/// @title TokenholderGovernorVotes
/// @notice Tokenholder DAO voting power extraction from both liquid and staked
/// T token positions, including legacy stakes (NU/KEEP).
/// T token positions.
abstract contract TokenholderGovernorVotes is GovernorParameters {
IVotesHistory public immutable token;
IVotesHistory public immutable staking;
Expand All @@ -35,10 +35,6 @@ abstract contract TokenholderGovernorVotes is GovernorParameters {
/// two voting power sources:
/// - Liquid T, tracked by the T token contract
/// - Stakes in the T network, tracked by the T staking contract.
/// Note that this also tracks legacy stakes (NU/KEEP); legacy
/// stakes count for tokenholders' voting power, but not for the
/// total voting power of the Tokenholder DAO
/// (see {_getPastTotalSupply}).
/// @param account Tokenholder account in the T network
/// @param blockNumber The block number to get the vote balance at
/// @dev See {IGovernor-getVotes}
Expand All @@ -57,10 +53,7 @@ abstract contract TokenholderGovernorVotes is GovernorParameters {
/// @notice Compute the total voting power for Tokenholder DAO. Note how it
/// only uses the token total supply as source, as native T tokens
/// that are staked continue existing, but as deposits in the
/// staking contract. However, legacy stakes can't contribute to the
/// total voting power as they're already implicitly counted as part
/// of Vending Machines' liquid balance; hence, we only need to read
/// total voting power from the token.
/// staking contract.
/// @param blockNumber The block number to get the vote power at
function _getPastTotalSupply(uint256 blockNumber)
internal
Expand Down
76 changes: 9 additions & 67 deletions contracts/staking/IStaking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ pragma solidity ^0.8.9;
/// delegation optimizes the network throughput without compromising the
/// security of the owners’ stake.
interface IStaking {
enum StakeType {
NU,
KEEP,
T
}

//
//
// Delegating a stake
Expand Down Expand Up @@ -174,41 +168,13 @@ interface IStaking {
//
//

/// @notice Reduces the liquid T stake amount by the provided amount and
/// @notice Reduces the T stake amount by the provided amount and
/// withdraws T to the owner. Reverts if there is at least one
/// authorization higher than the sum of the legacy stake and
/// remaining liquid T stake or if the unstake amount is higher than
/// the liquid T stake amount. Can be called only by the delegation
/// owner or the staking provider.
function unstakeT(address stakingProvider, uint96 amount) external;

/// @notice Sets the legacy KEEP staking contract active stake amount cached
/// in T staking contract to 0. Reverts if the amount of liquid T
/// staked in T staking contract is lower than the highest
/// application authorization. This function allows to unstake from
/// KEEP staking contract and still being able to operate in T
/// network and earning rewards based on the liquid T staked. Can be
/// called only by the delegation owner or the staking provider.
function unstakeKeep(address stakingProvider) external;

/// @notice Sets to 0 the amount of T that is cached from the legacy
/// NU staking contract. Reverts if there is at least one
/// authorization higher than the sum of remaining legacy NU stake
/// and native T stake for that staking provider or if the unstaked
/// amount is higher than the cached legacy stake amount. If succeeded,
/// the legacy NU stake can be partially or fully undelegated on
/// the legacy NU staking contract. This function allows to unstake
/// from NU staking contract while still being able to operate in
/// T network and earning rewards based on the native T staked.
/// Can be called only by the stake owner or the staking provider.
function unstakeNu(address stakingProvider) external;

/// @notice Sets cached legacy stake amount to 0, sets the liquid T stake
/// amount to 0 and withdraws all liquid T from the stake to the
/// owner. Reverts if there is at least one non-zero authorization.
/// authorization higher than the remaining T stake or
/// if the unstake amount is higher than the T stake amount.
/// Can be called only by the delegation owner or the staking
/// provider.
function unstakeAll(address stakingProvider) external;
function unstakeT(address stakingProvider, uint96 amount) external;

//
//
Expand Down Expand Up @@ -265,17 +231,11 @@ interface IStaking {
view
returns (uint96);

/// @notice Returns staked amount of T, Keep and Nu for the specified
/// staking provider.
/// @dev All values are in T denomination
function stakes(address stakingProvider)
/// @notice Returns staked amount of T for the specified staking provider.
function stakeAmount(address stakingProvider)
external
view
returns (
uint96 tStake,
uint96 keepInTStake,
uint96 nuInTStake
);
returns (uint96);

/// @notice Returns start staking timestamp.
/// @dev This value is set at most once.
Expand All @@ -290,9 +250,6 @@ interface IStaking {
view
returns (bool);

/// @notice Returns staked amount of NU for the specified staking provider.
function stakedNu(address stakingProvider) external view returns (uint256);

/// @notice Gets the stake owner, the beneficiary and the authorizer
/// for the specified staking provider address.
/// @return owner Stake owner address.
Expand All @@ -313,23 +270,8 @@ interface IStaking {
/// @notice Returns length of slashing queue
function getSlashingQueueLength() external view returns (uint256);

/// @notice Returns minimum possible stake for T, KEEP or NU in T
/// denomination.
/// @dev For example, suppose the given staking provider has 10 T, 20 T worth
/// of KEEP, and 30 T worth of NU all staked, and the maximum
/// application authorization is 40 T, then `getMinStaked` for
/// that staking provider returns:
/// * 0 T if KEEP stake type specified i.e.
/// min = 40 T max - (10 T) = 30 T
/// * 10 T if NU stake type specified i.e.
/// min = 40 T max - (10 T) = 30 T
/// * 0 T if T stake type specified i.e.
/// min = 40 T max = 40 T
/// In other words, the minimum stake amount for the specified
/// stake type is the minimum amount of stake of the given type
/// needed to satisfy the maximum application authorization given
/// the staked amounts of the T stake types for that staking provider.
function getMinStaked(address stakingProvider, StakeType stakeTypes)
/// @notice Returns the maximum application authorization
function getMaxAuthorization(address stakingProvider)
external
view
returns (uint96);
Expand Down
Loading
Loading