@0x/contracts-staking
: Fix contracts formatting.
`@0x/contracts-staking`: Remove typo test suite in `migration.ts`. `@0x/contracts-staking`: Address minor review comments.
This commit is contained in:
parent
1c2f4906e6
commit
6410366f8b
@ -25,6 +25,7 @@ import "./libs/LibProxy.sol";
|
||||
contract ReadOnlyProxy is
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
using LibProxy for address;
|
||||
|
||||
// solhint-disable payable-fallback
|
||||
|
@ -50,6 +50,7 @@ contract Staking is
|
||||
MixinStakingPool,
|
||||
MixinExchangeFees
|
||||
{
|
||||
|
||||
// this contract can receive ETH
|
||||
// solhint-disable no-empty-blocks
|
||||
function ()
|
||||
|
@ -33,6 +33,7 @@ contract StakingProxy is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
using LibProxy for address;
|
||||
|
||||
/// @dev Constructor.
|
||||
|
@ -58,6 +58,7 @@ contract MixinExchangeFees is
|
||||
MixinStakingPoolRewards,
|
||||
MixinStakingPool
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
/// @dev Pays a protocol fee in ETH or WETH.
|
||||
|
@ -35,6 +35,7 @@ contract MixinExchangeManager is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
/// @dev Asserts that the call is coming from a valid exchange.
|
||||
modifier onlyExchange() {
|
||||
if (!isValidExchangeAddress(msg.sender)) {
|
||||
|
@ -20,6 +20,7 @@ pragma solidity ^0.5.9;
|
||||
|
||||
|
||||
interface IStaking {
|
||||
|
||||
/// @dev Pays a protocol fee in ETH.
|
||||
/// @param makerAddress The address of the order's maker.
|
||||
/// @param payerAddress The address that is responsible for paying the protocol fee.
|
||||
|
@ -20,6 +20,7 @@ pragma solidity ^0.5.9;
|
||||
|
||||
|
||||
interface IStorageInit {
|
||||
|
||||
/// @dev Initialize storage owned by this contract.
|
||||
function init() external;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import "./LibFixedMathRichErrors.sol";
|
||||
// solhint-disable indent
|
||||
/// @dev Signed, fixed-point, 127-bit precision math library.
|
||||
library LibFixedMath {
|
||||
|
||||
// 1
|
||||
int256 private constant FIXED_1 = int256(0x0000000000000000000000000000000080000000000000000000000000000000);
|
||||
// 1^2 (in fixed-point)
|
||||
|
@ -46,6 +46,7 @@ contract MixinStake is
|
||||
MixinStakeBalances,
|
||||
MixinStakingPoolRewards
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
/// @dev Stake ZRX tokens. Tokens are deposited into the ZRX Vault. Unstake to retrieve the ZRX.
|
||||
|
@ -39,6 +39,7 @@ contract MixinStakeBalances is
|
||||
MixinScheduler,
|
||||
MixinStakeStorage
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
/// @dev Returns the total stake for a given owner.
|
||||
|
@ -35,6 +35,7 @@ contract MixinStakeStorage is
|
||||
MixinStorage,
|
||||
MixinScheduler
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
using LibSafeDowncast for uint256;
|
||||
|
||||
|
@ -29,6 +29,7 @@ contract MixinZrxVault is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
/// @dev Set the Zrx Vault.
|
||||
/// @param zrxVaultAddress Address of the Zrx Vault.
|
||||
function setZrxVault(address zrxVaultAddress)
|
||||
|
@ -64,6 +64,7 @@ contract MixinStakingPool is
|
||||
MixinStakeBalances,
|
||||
MixinStakingPoolRewards
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
/// @dev Create a new staking pool. The sender will be the operator of this pool.
|
||||
|
@ -38,6 +38,7 @@ contract MixinStakingPoolRewards is
|
||||
MixinStakeStorage,
|
||||
MixinStakeBalances
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
/// @dev Computes the reward balance in ETH of a specific member of a pool.
|
||||
|
@ -32,6 +32,7 @@ contract MixinParams is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
/// @dev Set all configurable parameters at once.
|
||||
/// @param _epochDurationInSeconds Minimum seconds between epochs.
|
||||
/// @param _rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm.
|
||||
@ -74,7 +75,7 @@ contract MixinParams is
|
||||
);
|
||||
}
|
||||
|
||||
/// @dev Retrives all configurable parameter values.
|
||||
/// @dev Retrieves all configurable parameter values.
|
||||
/// @return _epochDurationInSeconds Minimum seconds between epochs.
|
||||
/// @return _rewardDelegatedStakeWeight How much delegated stake is weighted vs operator stake, in ppm.
|
||||
/// @return _minimumPoolStake Minimum amount of stake required in a pool to collect rewards.
|
||||
|
@ -39,6 +39,7 @@ contract MixinScheduler is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
/// @dev Returns the current epoch.
|
||||
|
@ -30,6 +30,7 @@ contract EthVault is
|
||||
IVaultCore,
|
||||
MixinVaultCore
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
// mapping from Owner to ETH balance
|
||||
|
@ -46,6 +46,7 @@ contract StakingPoolRewardVault is
|
||||
MixinConstants,
|
||||
MixinVaultCore
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
using LibSafeDowncast for uint256;
|
||||
|
||||
|
@ -39,6 +39,7 @@ contract ZrxVault is
|
||||
IZrxVault,
|
||||
MixinVaultCore
|
||||
{
|
||||
|
||||
using LibSafeMath for uint256;
|
||||
|
||||
// mapping from Owner to ZRX balance
|
||||
|
@ -24,6 +24,7 @@ import "../src/fees/MixinExchangeFees.sol";
|
||||
contract TestCobbDouglas is
|
||||
MixinExchangeFees
|
||||
{
|
||||
|
||||
function cobbDouglas(
|
||||
uint256 totalRewards,
|
||||
uint256 ownerFees,
|
||||
|
@ -24,6 +24,7 @@ import "../src/Staking.sol";
|
||||
contract TestExchangeFees is
|
||||
Staking
|
||||
{
|
||||
|
||||
struct TestPool {
|
||||
uint256 stake;
|
||||
mapping(address => bool) isMaker;
|
||||
|
@ -26,6 +26,7 @@ contract TestInitTarget is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
// We can't store state in this contract before it is attached, so
|
||||
// we will grant this predefined address a balance to indicate that
|
||||
// `init()` should revert.
|
||||
|
@ -24,6 +24,7 @@ import "../src/StakingProxy.sol";
|
||||
contract TestStakingProxy is
|
||||
StakingProxy
|
||||
{
|
||||
|
||||
// solhint-disable no-empty-blocks
|
||||
constructor(address _stakingContract)
|
||||
public
|
||||
|
@ -29,6 +29,7 @@ contract TestStorageLayout is
|
||||
Ownable,
|
||||
MixinStorage
|
||||
{
|
||||
|
||||
function assertExpectedStorageLayout()
|
||||
public
|
||||
pure
|
||||
|
@ -49,7 +49,7 @@ blockchainTests('Migration tests', env => {
|
||||
...env.txDefaults,
|
||||
from: ownerAddress,
|
||||
to: revertAddress,
|
||||
data: '0x',
|
||||
data: constants.NULL_BYTES,
|
||||
value: new BigNumber(1),
|
||||
}),
|
||||
);
|
||||
@ -114,34 +114,6 @@ blockchainTests('Migration tests', env => {
|
||||
expect(initCounter).to.bignumber.eq(2);
|
||||
});
|
||||
});
|
||||
|
||||
blockchainTests.resets('upgrade', async () => {
|
||||
let proxyContract: TestStakingProxyContract;
|
||||
|
||||
before(async () => {
|
||||
proxyContract = await deployStakingProxyAsync();
|
||||
});
|
||||
|
||||
it('incm', async () => {
|
||||
const attachedAddress = randomAddress();
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(attachedAddress, {
|
||||
from: notOwnerAddress,
|
||||
});
|
||||
const expectedError = new OwnableRevertErrors.OnlyOwnerError(notOwnerAddress, ownerAddress);
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
|
||||
it('calls init() and attaches the contract', async () => {
|
||||
await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
|
||||
await assertInitStateAsync(proxyContract);
|
||||
});
|
||||
|
||||
it('reverts if init() reverts', async () => {
|
||||
await enableInitRevertsAsync();
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
|
||||
return expect(tx).to.revertWith(REVERT_ERROR);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
blockchainTests.resets('Staking.init()', async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user