Skip to content

Commit 4b569b2

Browse files
authored
Merge pull request #153 from threshold-network/remove-legacy-step-1
First step to remove legacy
2 parents 38debeb + 1bc2a56 commit 4b569b2

35 files changed

+3111
-12051
lines changed

.github/workflows/contracts.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,34 +75,6 @@ jobs:
7575
if: github.ref != 'refs/heads/dapp-development'
7676
run: yarn test
7777

78-
contracts-system-tests:
79-
needs: contracts-detect-changes
80-
if: |
81-
needs.contracts-detect-changes.outputs.system-tests == 'true'
82-
&& github.ref != 'refs/heads/dapp-development'
83-
runs-on: ubuntu-latest
84-
steps:
85-
- uses: actions/checkout@v3
86-
87-
- uses: actions/setup-node@v3
88-
with:
89-
# Using fixed version, because 18.16 was sometimes causing issues with
90-
# artifacts generation during `hardhat compile` - see
91-
# https://github.com/NomicFoundation/hardhat/issues/3877
92-
node-version: "18.15.0"
93-
cache: "yarn"
94-
95-
- name: Install dependencies
96-
run: yarn install
97-
98-
- name: Build contracts
99-
run: yarn build
100-
101-
- name: Run system tests
102-
env:
103-
FORKING_URL: ${{ secrets.MAINNET_ETH_HOSTNAME_HTTP }}
104-
run: yarn test:system
105-
10678
contracts-deployment-dry-run:
10779
runs-on: ubuntu-latest
10880
steps:

contracts/governance/BaseTokenholderGovernor.sol

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,16 @@ contract BaseTokenholderGovernor is
122122
return super.supportsInterface(interfaceId);
123123
}
124124

125+
function proposalDeadline(uint256 proposalId)
126+
public
127+
view
128+
virtual
129+
override(IGovernor, Governor, GovernorPreventLateQuorum)
130+
returns (uint256)
131+
{
132+
return super.proposalDeadline(proposalId);
133+
}
134+
125135
function _execute(
126136
uint256 proposalId,
127137
address[] memory targets,
@@ -141,25 +151,6 @@ contract BaseTokenholderGovernor is
141151
return super._cancel(targets, values, calldatas, descriptionHash);
142152
}
143153

144-
function _executor()
145-
internal
146-
view
147-
override(Governor, GovernorTimelockControl)
148-
returns (address)
149-
{
150-
return super._executor();
151-
}
152-
153-
function proposalDeadline(uint256 proposalId)
154-
public
155-
view
156-
virtual
157-
override(IGovernor, Governor, GovernorPreventLateQuorum)
158-
returns (uint256)
159-
{
160-
return super.proposalDeadline(proposalId);
161-
}
162-
163154
function _castVote(
164155
uint256 proposalId,
165156
address account,
@@ -173,4 +164,13 @@ contract BaseTokenholderGovernor is
173164
{
174165
return super._castVote(proposalId, account, support, reason);
175166
}
167+
168+
function _executor()
169+
internal
170+
view
171+
override(Governor, GovernorTimelockControl)
172+
returns (address)
173+
{
174+
return super._executor();
175+
}
176176
}

contracts/staking/ILegacyTokenStaking.sol

Lines changed: 0 additions & 105 deletions
This file was deleted.

contracts/staking/IStaking.sol

Lines changed: 18 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,6 @@ interface IStaking {
5151
uint96 amount
5252
) external;
5353

54-
/// @notice Copies delegation from the legacy KEEP staking contract to T
55-
/// staking contract. No tokens are transferred. Caches the active
56-
/// stake amount from KEEP staking contract. Can be called by
57-
/// anyone.
58-
/// @dev The staking provider in T staking contract is the legacy KEEP
59-
/// staking contract operator.
60-
function stakeKeep(address stakingProvider) external;
61-
62-
/// @notice Copies delegation from the legacy NU staking contract to T
63-
/// staking contract, additionally appointing staking provider,
64-
/// beneficiary and authorizer roles. Caches the amount staked in NU
65-
/// staking contract. Can be called only by the original delegation
66-
/// owner.
67-
function stakeNu(
68-
address stakingProvider,
69-
address payable beneficiary,
70-
address authorizer
71-
) external;
72-
7354
/// @notice Allows the Governance to set the minimum required stake amount.
7455
/// This amount is required to protect against griefing the staking
7556
/// contract and individual applications are allowed to require
@@ -181,16 +162,6 @@ interface IStaking {
181162
/// transfer to the staking contract.
182163
function topUp(address stakingProvider, uint96 amount) external;
183164

184-
/// @notice Propagates information about stake top-up from the legacy KEEP
185-
/// staking contract to T staking contract. Can be called only by
186-
/// the owner or the staking provider.
187-
function topUpKeep(address stakingProvider) external;
188-
189-
/// @notice Propagates information about stake top-up from the legacy NU
190-
/// staking contract to T staking contract. Can be called only by
191-
/// the owner or the staking provider.
192-
function topUpNu(address stakingProvider) external;
193-
194165
//
195166
//
196167
// Undelegating a stake (unstaking)
@@ -214,17 +185,17 @@ interface IStaking {
214185
/// called only by the delegation owner or the staking provider.
215186
function unstakeKeep(address stakingProvider) external;
216187

217-
/// @notice Reduces cached legacy NU stake amount by the provided amount.
218-
/// Reverts if there is at least one authorization higher than the
219-
/// sum of remaining legacy NU stake and liquid T stake for that
220-
/// staking provider or if the untaked amount is higher than the
221-
/// cached legacy stake amount. If succeeded, the legacy NU stake
222-
/// can be partially or fully undelegated on the legacy staking
223-
/// contract. This function allows to unstake from NU staking
224-
/// contract and still being able to operate in T network and
225-
/// earning rewards based on the liquid T staked. Can be called only
226-
/// by the delegation owner or the staking provider.
227-
function unstakeNu(address stakingProvider, uint96 amount) external;
188+
/// @notice Sets to 0 the amount of T that is cached from the legacy
189+
/// NU staking contract. Reverts if there is at least one
190+
/// authorization higher than the sum of remaining legacy NU stake
191+
/// and native T stake for that staking provider or if the unstaked
192+
/// amount is higher than the cached legacy stake amount. If succeeded,
193+
/// the legacy NU stake can be partially or fully undelegated on
194+
/// the legacy NU staking contract. This function allows to unstake
195+
/// from NU staking contract while still being able to operate in
196+
/// T network and earning rewards based on the native T staked.
197+
/// Can be called only by the stake owner or the staking provider.
198+
function unstakeNu(address stakingProvider) external;
228199

229200
/// @notice Sets cached legacy stake amount to 0, sets the liquid T stake
230201
/// amount to 0 and withdraws all liquid T from the stake to the
@@ -239,34 +210,6 @@ interface IStaking {
239210
//
240211
//
241212

242-
/// @notice Notifies about the discrepancy between legacy KEEP active stake
243-
/// and the amount cached in T staking contract. Slashes the staking
244-
/// provider in case the amount cached is higher than the actual
245-
/// active stake amount in KEEP staking contract. Needs to update
246-
/// authorizations of all affected applications and execute an
247-
/// involuntary allocation decrease on all affected applications.
248-
/// Can be called by anyone, notifier receives a reward.
249-
function notifyKeepStakeDiscrepancy(address stakingProvider) external;
250-
251-
/// @notice Notifies about the discrepancy between legacy NU active stake
252-
/// and the amount cached in T staking contract. Slashes the
253-
/// staking provider in case the amount cached is higher than the
254-
/// actual active stake amount in NU staking contract. Needs to
255-
/// update authorizations of all affected applications and execute
256-
/// an involuntary allocation decrease on all affected applications.
257-
/// Can be called by anyone, notifier receives a reward.
258-
function notifyNuStakeDiscrepancy(address stakingProvider) external;
259-
260-
/// @notice Sets the penalty amount for stake discrepancy and reward
261-
/// multiplier for reporting it. The penalty is seized from the
262-
/// delegated stake, and 5% of the penalty, scaled by the
263-
/// multiplier, is given to the notifier. The rest of the tokens are
264-
/// burned. Can only be called by the Governance. See `seize` function.
265-
function setStakeDiscrepancyPenalty(
266-
uint96 penalty,
267-
uint256 rewardMultiplier
268-
) external;
269-
270213
/// @notice Sets reward in T tokens for notification of misbehaviour
271214
/// of one staking provider. Can only be called by the governance.
272215
function setNotificationReward(uint96 reward) external;
@@ -360,20 +303,20 @@ interface IStaking {
360303

361304
/// @notice Returns minimum possible stake for T, KEEP or NU in T
362305
/// denomination.
363-
/// @dev For example, suppose the given staking provider has 10 T, 20 T
364-
/// worth of KEEP, and 30 T worth of NU all staked, and the maximum
306+
/// @dev For example, suppose the given staking provider has 10 T, 20 T worth
307+
/// of KEEP, and 30 T worth of NU all staked, and the maximum
365308
/// application authorization is 40 T, then `getMinStaked` for
366309
/// that staking provider returns:
367310
/// * 0 T if KEEP stake type specified i.e.
368-
/// min = 40 T max - (10 T + 30 T worth of NU) = 0 T
311+
/// min = 40 T max - (10 T) = 30 T
369312
/// * 10 T if NU stake type specified i.e.
370-
/// min = 40 T max - (10 T + 20 T worth of KEEP) = 10 T
313+
/// min = 40 T max - (10 T) = 30 T
371314
/// * 0 T if T stake type specified i.e.
372-
/// min = 40 T max - (20 T worth of KEEP + 30 T worth of NU) < 0 T
315+
/// min = 40 T max = 40 T
373316
/// In other words, the minimum stake amount for the specified
374317
/// stake type is the minimum amount of stake of the given type
375-
/// needed to satisfy the maximum application authorization given the
376-
/// staked amounts of the other stake types for that staking provider.
318+
/// needed to satisfy the maximum application authorization given
319+
/// the staked amounts of the T stake types for that staking provider.
377320
function getMinStaked(address stakingProvider, StakeType stakeTypes)
378321
external
379322
view

0 commit comments

Comments
 (0)