Got staking contract building again
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
pragma solidity ^0.5.9;
|
||||
|
||||
import "./interfaces/IStaking.sol";
|
||||
import "./core/MixinExchange.sol";
|
||||
import "./core/MixinZrxVault.sol";
|
||||
import "./core/MixinRewardVault.sol";
|
||||
@@ -30,7 +31,7 @@ import "./core/MixinRewards.sol";
|
||||
|
||||
|
||||
contract Staking is
|
||||
IStakingEvents,
|
||||
IStaking,
|
||||
MixinDeploymentConstants,
|
||||
MixinConstants,
|
||||
MixinStorage,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
pragma solidity ^0.5.5;
|
||||
|
||||
import "../interfaces/IStakingEvents.sol";
|
||||
|
||||
import "../immutable/MixinConstants.sol";
|
||||
import "../immutable/MixinStorage.sol";
|
||||
|
||||
@@ -30,6 +29,9 @@ contract MixinExchange is
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
/// @dev This mixin contains logic for managing exchanges
|
||||
///
|
||||
|
||||
modifier onlyExchange() {
|
||||
require(
|
||||
isValidExchangeAddress(msg.sender),
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
pragma solidity ^0.5.5;
|
||||
|
||||
import "../core_interfaces/IMixinScheduler.sol";
|
||||
import "../libs/LibSafeMath.sol";
|
||||
import "../libs/LibSafeMath64.sol";
|
||||
import "../immutable/MixinConstants.sol";
|
||||
@@ -27,7 +28,8 @@ import "../interfaces/IStructs.sol";
|
||||
|
||||
contract MixinScheduler is
|
||||
MixinConstants,
|
||||
MixinStorage
|
||||
MixinStorage,
|
||||
IMixinScheduler
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
@@ -132,7 +134,7 @@ contract MixinScheduler is
|
||||
|
||||
// validate that we can increment the current epoch
|
||||
require(
|
||||
getCurrentEpochEndTimeInSeconds() <= currentBlockTimestamp,
|
||||
getCurrentEpochEarliestEndTimeInSeconds() <= currentBlockTimestamp,
|
||||
"BLOCK_TIMESTAMP_TOO_LOW"
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
|
||||
Copyright 2018 ZeroEx Intl.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
*/
|
||||
|
||||
pragma solidity ^0.5.5;
|
||||
|
||||
|
||||
contract IMixinScheduler {
|
||||
|
||||
/// @dev This mixin contains logic for time-based scheduling.
|
||||
/// All processes in the system are segmented into time intervals, called epochs.
|
||||
/// Epochs have a fixed minimum time period that is configured when this contract is deployed.
|
||||
/// The current epoch only changes by calling this contract, which can be invoked by anyone.
|
||||
/// Epochs serve as the basis for all other time intervals, which provides a more stable
|
||||
/// and consistent scheduling metric than time. Timelocks, for example, are measured in epochs.
|
||||
|
||||
/// @dev Returns the current epoch.
|
||||
function getCurrentEpoch()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the current epoch period, measured in seconds.
|
||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||
function getEpochPeriodInSeconds()
|
||||
public
|
||||
pure
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the start time in seconds of the current epoch.
|
||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||
function getCurrentEpochStartTimeInSeconds()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the earliest end time in seconds of this epoch.
|
||||
/// The next epoch can begin once this time is reached.
|
||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||
function getCurrentEpochEarliestEndTimeInSeconds()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the current timelock period
|
||||
function getCurrentTimelockPeriod()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the length of a timelock period, measured in epochs.
|
||||
/// Timelock period = [startEpoch..endEpoch)
|
||||
function getTimelockPeriodInEpochs()
|
||||
public
|
||||
pure
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the epoch that the current timelock period started at.
|
||||
/// Timelock period = [startEpoch..endEpoch)
|
||||
function getCurrentTimelockPeriodStartEpoch()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the epoch that the current timelock period will end.
|
||||
/// Timelock period = [startEpoch..endEpoch)
|
||||
function getCurrentTimelockPeriodEndEpoch()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
}
|
||||
@@ -19,9 +19,62 @@
|
||||
pragma solidity ^0.5.5;
|
||||
|
||||
|
||||
interface IStaking
|
||||
{
|
||||
function stake(uint256 amount) external returns (uint256);
|
||||
function unstake(uint256 amount) external returns (uint256);
|
||||
function getStakeBalance(address owner) external view returns (uint256);
|
||||
/// THIS CONTRACT IS AUTO-GENERATED FROM INTERFACES IN `./core_interfaces` ///
|
||||
contract IStaking {
|
||||
|
||||
/// @dev Returns the current epoch.
|
||||
function getCurrentEpoch()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the current epoch period, measured in seconds.
|
||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||
function getEpochPeriodInSeconds()
|
||||
public
|
||||
pure
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the start time in seconds of the current epoch.
|
||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||
function getCurrentEpochStartTimeInSeconds()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the earliest end time in seconds of this epoch.
|
||||
/// The next epoch can begin once this time is reached.
|
||||
/// Epoch period = [startTimeInSeconds..endTimeInSeconds)
|
||||
function getCurrentEpochEarliestEndTimeInSeconds()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the current timelock period
|
||||
function getCurrentTimelockPeriod()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the length of a timelock period, measured in epochs.
|
||||
/// Timelock period = [startEpoch..endEpoch)
|
||||
function getTimelockPeriodInEpochs()
|
||||
public
|
||||
pure
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the epoch that the current timelock period started at.
|
||||
/// Timelock period = [startEpoch..endEpoch)
|
||||
function getCurrentTimelockPeriodStartEpoch()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
/// @dev Returns the epoch that the current timelock period will end.
|
||||
/// Timelock period = [startEpoch..endEpoch)
|
||||
function getCurrentTimelockPeriodEndEpoch()
|
||||
public
|
||||
view
|
||||
returns (uint64);
|
||||
|
||||
}
|
||||
|
||||
@@ -73,11 +73,10 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^5.1.0",
|
||||
"@0x/contracts-test-utils": "^3.1.6",
|
||||
"@0x/contracts-utils": "3.1.1",
|
||||
"@0x/contracts-utils": "3.1.6",
|
||||
"@0x/contracts-asset-proxy": "^2.1.1",
|
||||
"@0x/contracts-erc20": "^2.2.0",
|
||||
"@0x/order-utils": "^7.2.0",
|
||||
"@0x/order-utils": "^8.1.0",
|
||||
"@0x/types": "^2.2.2",
|
||||
"@0x/typescript-typings": "^4.2.2",
|
||||
"@0x/utils": "^4.3.1",
|
||||
|
||||
@@ -458,10 +458,10 @@ export class StakingWrapper {
|
||||
const value = this.getStakingContract().getCurrentTimelockPeriodStartEpoch.getABIDecodedReturnData(returnData);
|
||||
return value;
|
||||
}
|
||||
public async getCurrentEpochEndTimeInSecondsAsync(): Promise<BigNumber> {
|
||||
const calldata = this.getStakingContract().getCurrentEpochEndTimeInSeconds.getABIEncodedTransactionData();
|
||||
public async getCurrentEpochEarliestEndTimeInSecondsAsync(): Promise<BigNumber> {
|
||||
const calldata = this.getStakingContract().getCurrentEpochEarliestEndTimeInSeconds.getABIEncodedTransactionData();
|
||||
const returnData = await this._callAsync(calldata);
|
||||
const value = this.getStakingContract().getCurrentEpochEndTimeInSeconds.getABIDecodedReturnData(returnData);
|
||||
const value = this.getStakingContract().getCurrentEpochEarliestEndTimeInSeconds.getABIDecodedReturnData(returnData);
|
||||
return value;
|
||||
}
|
||||
public async getCurrentTimelockPeriodEndEpochAsync(): Promise<BigNumber> {
|
||||
|
||||
Reference in New Issue
Block a user