Skip to content

Commit 09487d8

Browse files
authored
Merge pull request #159 from threshold-network/remove-legacy-step-2
Second step to remove legacy
2 parents 0c74099 + 9d5daff commit 09487d8

16 files changed

+124
-58293
lines changed

.github/workflows/contracts.yml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ jobs:
115115
- name: Install dependencies
116116
run: yarn install --frozen-lockfile
117117

118-
- name: Resolve latest contracts
119-
run: yarn upgrade @keep-network/keep-core@${{ github.event.inputs.environment }}
120-
121118
- name: Configure tenderly
122119
env:
123120
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
@@ -186,13 +183,6 @@ jobs:
186183
- name: Install needed dependencies
187184
run: yarn install --frozen-lockfile
188185

189-
# If we don't remove the `keep-core` contracts from `node-modules`, the
190-
# `etherscan-verify` plugins tries to verify them, which is not desired.
191-
- name: Prepare for verification on Etherscan
192-
run: |
193-
rm -rf ./node_modules/@keep-network/keep-core
194-
rm -rf ./external/npm
195-
196186
- name: Verify contracts on Etherscan
197187
env:
198188
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
@@ -226,9 +216,6 @@ jobs:
226216
- name: Install dependencies
227217
run: yarn install --frozen-lockfile
228218

229-
- name: Resolve latest contracts
230-
run: yarn upgrade @keep-network/keep-core@${{ github.event.inputs.environment }}
231-
232219
- name: Deploy contracts
233220
env:
234221
CHAIN_API_URL: ${{ secrets.SEPOLIA_ETH_HOSTNAME_HTTP }}

.github/workflows/npm.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ jobs:
2727
registry-url: "https://registry.npmjs.org"
2828
cache: "yarn"
2929

30-
- name: Resolve latest contracts
31-
run: |
32-
yarn upgrade --exact \
33-
@keep-network/keep-core
30+
- name: Install needed dependencies
31+
run: yarn install --frozen-lockfile
3432

3533
# Deploy contracts to a local network to generate deployment artifacts that
3634
# are required by dashboard compilation.

contracts/governance/StakerGovernorVotes.sol

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ import "./GovernorParameters.sol";
1919
import "./IVotesHistory.sol";
2020

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

@@ -29,8 +28,7 @@ abstract contract StakerGovernorVotes is GovernorParameters {
2928
}
3029

3130
/// @notice Read the voting weight from the snapshot mechanism in the T
32-
/// staking contracts. Note that this also tracks legacy stakes
33-
/// (NU/KEEP).
31+
/// staking contracts.
3432
/// @param account Delegate account with T staking voting power
3533
/// @param blockNumber The block number to get the vote balance at
3634
/// @dev See {IGovernor-getVotes}

contracts/governance/TokenholderGovernorVotes.sol

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import "./IVotesHistory.sol";
2020

2121
/// @title TokenholderGovernorVotes
2222
/// @notice Tokenholder DAO voting power extraction from both liquid and staked
23-
/// T token positions, including legacy stakes (NU/KEEP).
23+
/// T token positions.
2424
abstract contract TokenholderGovernorVotes is GovernorParameters {
2525
IVotesHistory public immutable token;
2626
IVotesHistory public immutable staking;
@@ -35,10 +35,6 @@ abstract contract TokenholderGovernorVotes is GovernorParameters {
3535
/// two voting power sources:
3636
/// - Liquid T, tracked by the T token contract
3737
/// - Stakes in the T network, tracked by the T staking contract.
38-
/// Note that this also tracks legacy stakes (NU/KEEP); legacy
39-
/// stakes count for tokenholders' voting power, but not for the
40-
/// total voting power of the Tokenholder DAO
41-
/// (see {_getPastTotalSupply}).
4238
/// @param account Tokenholder account in the T network
4339
/// @param blockNumber The block number to get the vote balance at
4440
/// @dev See {IGovernor-getVotes}
@@ -57,10 +53,7 @@ abstract contract TokenholderGovernorVotes is GovernorParameters {
5753
/// @notice Compute the total voting power for Tokenholder DAO. Note how it
5854
/// only uses the token total supply as source, as native T tokens
5955
/// that are staked continue existing, but as deposits in the
60-
/// staking contract. However, legacy stakes can't contribute to the
61-
/// total voting power as they're already implicitly counted as part
62-
/// of Vending Machines' liquid balance; hence, we only need to read
63-
/// total voting power from the token.
56+
/// staking contract.
6457
/// @param blockNumber The block number to get the vote power at
6558
function _getPastTotalSupply(uint256 blockNumber)
6659
internal

contracts/staking/IStaking.sol

Lines changed: 9 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ pragma solidity ^0.8.9;
2727
/// delegation optimizes the network throughput without compromising the
2828
/// security of the owners’ stake.
2929
interface IStaking {
30-
enum StakeType {
31-
NU,
32-
KEEP,
33-
T
34-
}
35-
3630
//
3731
//
3832
// Delegating a stake
@@ -174,41 +168,13 @@ interface IStaking {
174168
//
175169
//
176170

177-
/// @notice Reduces the liquid T stake amount by the provided amount and
171+
/// @notice Reduces the T stake amount by the provided amount and
178172
/// withdraws T to the owner. Reverts if there is at least one
179-
/// authorization higher than the sum of the legacy stake and
180-
/// remaining liquid T stake or if the unstake amount is higher than
181-
/// the liquid T stake amount. Can be called only by the delegation
182-
/// owner or the staking provider.
183-
function unstakeT(address stakingProvider, uint96 amount) external;
184-
185-
/// @notice Sets the legacy KEEP staking contract active stake amount cached
186-
/// in T staking contract to 0. Reverts if the amount of liquid T
187-
/// staked in T staking contract is lower than the highest
188-
/// application authorization. This function allows to unstake from
189-
/// KEEP staking contract and still being able to operate in T
190-
/// network and earning rewards based on the liquid T staked. Can be
191-
/// called only by the delegation owner or the staking provider.
192-
function unstakeKeep(address stakingProvider) external;
193-
194-
/// @notice Sets to 0 the amount of T that is cached from the legacy
195-
/// NU staking contract. Reverts if there is at least one
196-
/// authorization higher than the sum of remaining legacy NU stake
197-
/// and native T stake for that staking provider or if the unstaked
198-
/// amount is higher than the cached legacy stake amount. If succeeded,
199-
/// the legacy NU stake can be partially or fully undelegated on
200-
/// the legacy NU staking contract. This function allows to unstake
201-
/// from NU staking contract while still being able to operate in
202-
/// T network and earning rewards based on the native T staked.
203-
/// Can be called only by the stake owner or the staking provider.
204-
function unstakeNu(address stakingProvider) external;
205-
206-
/// @notice Sets cached legacy stake amount to 0, sets the liquid T stake
207-
/// amount to 0 and withdraws all liquid T from the stake to the
208-
/// owner. Reverts if there is at least one non-zero authorization.
173+
/// authorization higher than the remaining T stake or
174+
/// if the unstake amount is higher than the T stake amount.
209175
/// Can be called only by the delegation owner or the staking
210176
/// provider.
211-
function unstakeAll(address stakingProvider) external;
177+
function unstakeT(address stakingProvider, uint96 amount) external;
212178

213179
//
214180
//
@@ -265,17 +231,11 @@ interface IStaking {
265231
view
266232
returns (uint96);
267233

268-
/// @notice Returns staked amount of T, Keep and Nu for the specified
269-
/// staking provider.
270-
/// @dev All values are in T denomination
271-
function stakes(address stakingProvider)
234+
/// @notice Returns staked amount of T for the specified staking provider.
235+
function stakeAmount(address stakingProvider)
272236
external
273237
view
274-
returns (
275-
uint96 tStake,
276-
uint96 keepInTStake,
277-
uint96 nuInTStake
278-
);
238+
returns (uint96);
279239

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

293-
/// @notice Returns staked amount of NU for the specified staking provider.
294-
function stakedNu(address stakingProvider) external view returns (uint256);
295-
296253
/// @notice Gets the stake owner, the beneficiary and the authorizer
297254
/// for the specified staking provider address.
298255
/// @return owner Stake owner address.
@@ -313,23 +270,8 @@ interface IStaking {
313270
/// @notice Returns length of slashing queue
314271
function getSlashingQueueLength() external view returns (uint256);
315272

316-
/// @notice Returns minimum possible stake for T, KEEP or NU in T
317-
/// denomination.
318-
/// @dev For example, suppose the given staking provider has 10 T, 20 T worth
319-
/// of KEEP, and 30 T worth of NU all staked, and the maximum
320-
/// application authorization is 40 T, then `getMinStaked` for
321-
/// that staking provider returns:
322-
/// * 0 T if KEEP stake type specified i.e.
323-
/// min = 40 T max - (10 T) = 30 T
324-
/// * 10 T if NU stake type specified i.e.
325-
/// min = 40 T max - (10 T) = 30 T
326-
/// * 0 T if T stake type specified i.e.
327-
/// min = 40 T max = 40 T
328-
/// In other words, the minimum stake amount for the specified
329-
/// stake type is the minimum amount of stake of the given type
330-
/// needed to satisfy the maximum application authorization given
331-
/// the staked amounts of the T stake types for that staking provider.
332-
function getMinStaked(address stakingProvider, StakeType stakeTypes)
273+
/// @notice Returns the maximum application authorization
274+
function getMaxAuthorization(address stakingProvider)
333275
external
334276
view
335277
returns (uint96);

0 commit comments

Comments
 (0)