Skip to content

Commit

Permalink
SKALE-4466 add interfaces and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
payvint committed Jan 6, 2022
1 parent d67bd64 commit e46b3d1
Show file tree
Hide file tree
Showing 13 changed files with 631 additions and 24 deletions.
4 changes: 0 additions & 4 deletions contracts/IBountyV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@
pragma solidity >=0.6.10 <0.9.0;

interface IBountyV2 {
struct BountyHistory {
uint month;
uint bountyPaid;
}

/**
* @dev Emitted when bounty reduction is turned on or turned off.
Expand Down
4 changes: 0 additions & 4 deletions contracts/IKeyStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ pragma solidity >=0.6.10 <0.9.0;
import "./ISkaleDKG.sol";

interface IKeyStorage {
struct BroadcastedData {
KeyShare[] secretKeyContribution;
ISkaleDKG.G2Point[] verificationVector;
}

struct KeyShare {
bytes32[2] publicKey;
Expand Down
9 changes: 1 addition & 8 deletions contracts/ISchains.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,7 @@
pragma solidity >=0.6.10 <0.9.0;

interface ISchains {
struct SchainParameters {
uint lifetime;
uint8 typeOfSchain;
uint16 nonce;
string name;
address originator;
}


/**
* @dev Emitted when an schain is created.
*/
Expand Down
8 changes: 0 additions & 8 deletions contracts/ISkaleDKG.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pragma solidity >=0.6.10 <0.9.0;

interface ISkaleDKG {

enum DkgFunction {Broadcast, Alright, ComplaintBadData, PreResponse, Complaint, Response}

struct Fp2Point {
uint a;
uint b;
Expand Down Expand Up @@ -62,12 +60,6 @@ interface ISkaleDKG {
bytes32[2] publicKey;
bytes32 share;
}

struct Context {
bool isDebt;
uint delta;
DkgFunction dkgFunction;
}

/**
* @dev Emitted when a channel is opened.
Expand Down
120 changes: 120 additions & 0 deletions contracts/delegation/IDelegationController.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
IDelegationController.sol - SKALE Manager
Copyright (C) 2018-Present SKALE Labs
@author Artem Payvin
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IDelegationController {
enum State {
PROPOSED,
ACCEPTED,
CANCELED,
REJECTED,
DELEGATED,
UNDELEGATION_REQUESTED,
COMPLETED
}

struct Delegation {
address holder; // address of token owner
uint validatorId;
uint amount;
uint delegationPeriod;
uint created; // time of delegation creation
uint started; // month when a delegation becomes active
uint finished; // first month after a delegation ends
string info;
}

/**
* @dev Emitted when validator was confiscated.
*/
event Confiscated(
uint indexed validatorId,
uint amount
);

/**
* @dev Emitted when validator was confiscated.
*/
event SlashesProcessed(
address indexed holder,
uint limit
);

/**
* @dev Emitted when a delegation is proposed to a validator.
*/
event DelegationProposed(
uint delegationId
);

/**
* @dev Emitted when a delegation is accepted by a validator.
*/
event DelegationAccepted(
uint delegationId
);

/**
* @dev Emitted when a delegation is cancelled by the delegator.
*/
event DelegationRequestCanceledByUser(
uint delegationId
);

/**
* @dev Emitted when a delegation is requested to undelegate.
*/
event UndelegationRequested(
uint delegationId
);

function getAndUpdateDelegatedToValidatorNow(uint validatorId) external returns (uint);
function getAndUpdateDelegatedAmount(address holder) external returns (uint);
function getAndUpdateEffectiveDelegatedByHolderToValidator(address holder, uint validatorId, uint month)
external
returns (uint effectiveDelegated);
function delegate(
uint validatorId,
uint amount,
uint delegationPeriod,
string calldata info
)
external;
function cancelPendingDelegation(uint delegationId) external;
function acceptPendingDelegation(uint delegationId) external;
function requestUndelegation(uint delegationId) external;
function confiscate(uint validatorId, uint amount) external;
function getAndUpdateEffectiveDelegatedToValidator(uint validatorId, uint month) external returns (uint);
function getAndUpdateDelegatedByHolderToValidatorNow(address holder, uint validatorId) external returns (uint);
function processSlashes(address holder, uint limit) external;
function processAllSlashes(address holder) external;
function getEffectiveDelegatedValuesByValidator(uint validatorId) external view returns (uint[] memory);
function getEffectiveDelegatedToValidator(uint validatorId, uint month) external view returns (uint);
function getDelegatedToValidator(uint validatorId, uint month) external view returns (uint);
function getDelegation(uint delegationId) external view returns (Delegation memory);
function getFirstDelegationMonth(address holder, uint validatorId) external view returns(uint);
function getDelegationsByValidatorLength(uint validatorId) external view returns (uint);
function getDelegationsByHolderLength(address holder) external view returns (uint);
function getState(uint delegationId) external view returns (State state);
function getLockedInPendingDelegations(address holder) external view returns (uint);
function hasUnprocessedSlashes(address holder) external view returns (bool);
}
35 changes: 35 additions & 0 deletions contracts/delegation/IDelegationPeriodManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
IDelegationPeriodManager.sol - SKALE Manager
Copyright (C) 2018-Present SKALE Labs
@author Artem Payvin
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IDelegationPeriodManager {
/**
* @dev Emitted when a new delegation period is specified.
*/
event DelegationPeriodWasSet(
uint length,
uint stakeMultiplier
);

function setDelegationPeriod(uint monthsCount, uint stakeMultiplier) external;
function isDelegationPeriodAllowed(uint monthsCount) external view returns (bool);
}
60 changes: 60 additions & 0 deletions contracts/delegation/IDistributor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
IDistributor.sol - SKALE Manager
Copyright (C) 2018-Present SKALE Labs
@author Artem Payvin
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IDistributor {
/**
* @dev Emitted when bounty is withdrawn.
*/
event WithdrawBounty(
address holder,
uint validatorId,
address destination,
uint amount
);

/**
* @dev Emitted when a validator fee is withdrawn.
*/
event WithdrawFee(
uint validatorId,
address destination,
uint amount
);

/**
* @dev Emitted when bounty is distributed.
*/
event BountyWasPaid(
uint validatorId,
uint amount
);

function getAndUpdateEarnedBountyAmount(uint validatorId) external returns (uint earned, uint endMonth);
function withdrawBounty(uint validatorId, address to) external;
function withdrawFee(address to) external;
function getAndUpdateEarnedBountyAmountOf(address wallet, uint validatorId)
external
returns (uint earned, uint endMonth);
function getEarnedFeeAmount() external view returns (uint earned, uint endMonth);
function getEarnedFeeAmountOf(uint validatorId) external view returns (uint earned, uint endMonth);
}
44 changes: 44 additions & 0 deletions contracts/delegation/IPunisher.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
IPunisher.sol - SKALE Manager
Copyright (C) 2018-Present SKALE Labs
@author Artem Payvin
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface IPunisher {
/**
* @dev Emitted upon slashing condition.
*/
event Slash(
uint validatorId,
uint amount
);

/**
* @dev Emitted upon forgive condition.
*/
event Forgive(
address wallet,
uint amount
);

function slash(uint validatorId, uint amount) external;
function forgive(address holder, uint amount) external;
function handleSlash(address holder, uint amount) external;
}
33 changes: 33 additions & 0 deletions contracts/delegation/ITimeHelpers.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
ITimeHelpers.sol - SKALE Manager
Copyright (C) 2018-Present SKALE Labs
@author Artem Payvin
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface ITimeHelpers {
function calculateProofOfUseLockEndTime(uint month, uint lockUpPeriodDays) external view returns (uint timestamp);
function getCurrentMonth() external view returns (uint);
function timestampToYear(uint timestamp) external view returns (uint);
function timestampToMonth(uint timestamp) external view returns (uint);
function monthToTimestamp(uint month) external view returns (uint timestamp);
function addDays(uint fromTimestamp, uint n) external pure returns (uint);
function addMonths(uint fromTimestamp, uint n) external pure returns (uint);
function addYears(uint fromTimestamp, uint n) external pure returns (uint);
}
41 changes: 41 additions & 0 deletions contracts/delegation/ITokenState.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: AGPL-3.0-only

/*
ITokenState.sol - SKALE Manager
Copyright (C) 2018-Present SKALE Labs
@author Artem Payvin
SKALE Manager is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
SKALE Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with SKALE Manager. If not, see <https://www.gnu.org/licenses/>.
*/

pragma solidity >=0.6.10 <0.9.0;

interface ITokenState {
/**
* @dev Emitted when a contract is added to the locker.
*/
event LockerWasAdded(
string locker
);

/**
* @dev Emitted when a contract is removed from the locker.
*/
event LockerWasRemoved(
string locker
);

function removeLocker(string calldata locker) external;
function addLocker(string memory locker) external;
}
Loading

0 comments on commit e46b3d1

Please sign in to comment.