Merge pull request #2169 from 0xProject/fix/3.0/fix-breaking-tests
Fix breaking tests, remove MixinZrxVault
This commit is contained in:
@@ -39,7 +39,7 @@ contract MixinStake is
|
||||
address payable owner = msg.sender;
|
||||
|
||||
// deposit equivalent amount of ZRX into vault
|
||||
_depositFromOwnerIntoZrxVault(owner, amount);
|
||||
zrxVault.depositFrom(owner, amount);
|
||||
|
||||
// mint stake
|
||||
_incrementCurrentAndNextBalance(_activeStakeByOwner[owner], amount);
|
||||
@@ -77,7 +77,7 @@ contract MixinStake is
|
||||
_withdrawableStakeByOwner[owner] = currentWithdrawableStake.safeSub(amount);
|
||||
|
||||
// withdraw equivalent amount of ZRX from vault
|
||||
_withdrawToOwnerFromZrxVault(owner, amount);
|
||||
zrxVault.withdrawFrom(owner, amount);
|
||||
|
||||
// emit stake event
|
||||
emit Unstake(
|
||||
|
@@ -21,14 +21,12 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import "@0x/contracts-utils/contracts/src/LibSafeMath.sol";
|
||||
import "../interfaces/IStructs.sol";
|
||||
import "./MixinZrxVault.sol";
|
||||
import "./MixinStakeStorage.sol";
|
||||
|
||||
|
||||
/// @dev This mixin contains logic for querying stake balances.
|
||||
/// **** Read MixinStake before continuing ****
|
||||
contract MixinStakeBalances is
|
||||
MixinZrxVault,
|
||||
MixinStakeStorage
|
||||
{
|
||||
using LibSafeMath for uint256;
|
||||
@@ -41,7 +39,7 @@ contract MixinStakeBalances is
|
||||
view
|
||||
returns (uint256)
|
||||
{
|
||||
return _balanceOfOwnerInZrxVault(owner);
|
||||
return zrxVault.balanceOf(owner);
|
||||
}
|
||||
|
||||
/// @dev Returns the active stake for a given owner.
|
||||
|
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
|
||||
Copyright 2019 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.9;
|
||||
|
||||
import "../interfaces/IZrxVault.sol";
|
||||
import "../immutable/MixinStorage.sol";
|
||||
|
||||
|
||||
/// @dev This mixin contains logic for managing and interfacing with the Zrx Vault.
|
||||
/// (see vaults/ZrxVault.sol).
|
||||
contract MixinZrxVault is
|
||||
MixinStorage
|
||||
{
|
||||
/// @dev Deposits Zrx Tokens from the `owner` into the vault.
|
||||
/// @param owner of Zrx Tokens
|
||||
/// @param amount of tokens to deposit.
|
||||
function _depositFromOwnerIntoZrxVault(address owner, uint256 amount)
|
||||
internal
|
||||
{
|
||||
zrxVault.depositFrom(owner, amount);
|
||||
}
|
||||
|
||||
/// @dev Withdraws Zrx Tokens from to `owner` from the vault.
|
||||
/// @param owner of deposited Zrx Tokens
|
||||
/// @param amount of tokens to withdraw.
|
||||
function _withdrawToOwnerFromZrxVault(address owner, uint256 amount)
|
||||
internal
|
||||
{
|
||||
zrxVault.withdrawFrom(owner, amount);
|
||||
}
|
||||
|
||||
/// @dev Returns balance of `owner` in the ZRX ault.
|
||||
/// @param owner of deposited Zrx Tokens.
|
||||
function _balanceOfOwnerInZrxVault(address owner)
|
||||
internal
|
||||
view
|
||||
returns (uint256)
|
||||
{
|
||||
return zrxVault.balanceOf(owner);
|
||||
}
|
||||
}
|
@@ -37,7 +37,7 @@
|
||||
},
|
||||
"config": {
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.",
|
||||
"abis": "./generated-artifacts/@(EthVault|IEthVault|IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStorage|IStorageInit|IStructs|IVaultCore|IZrxVault|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|MixinZrxVault|ReadOnlyProxy|Staking|StakingPoolRewardVault|StakingProxy|TestCobbDouglas|TestCumulativeRewardTracking|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestProtocolFees|TestProtocolFeesERC20Proxy|TestStaking|TestStakingProxy|TestStorageLayout|ZrxVault).json"
|
||||
"abis": "./generated-artifacts/@(EthVault|IEthVault|IStaking|IStakingEvents|IStakingPoolRewardVault|IStakingProxy|IStorage|IStorageInit|IStructs|IVaultCore|IZrxVault|LibFixedMath|LibFixedMathRichErrors|LibProxy|LibSafeDowncast|LibStakingRichErrors|MixinConstants|MixinCumulativeRewards|MixinDeploymentConstants|MixinExchangeFees|MixinExchangeManager|MixinParams|MixinScheduler|MixinStake|MixinStakeBalances|MixinStakeStorage|MixinStakingPool|MixinStakingPoolRewardVault|MixinStakingPoolRewards|MixinStorage|MixinVaultCore|ReadOnlyProxy|Staking|StakingPoolRewardVault|StakingProxy|TestCobbDouglas|TestCumulativeRewardTracking|TestInitTarget|TestLibFixedMath|TestLibProxy|TestLibProxyReceiver|TestLibSafeDowncast|TestProtocolFees|TestProtocolFeesERC20Proxy|TestStaking|TestStakingProxy|TestStorageLayout|ZrxVault).json"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@@ -36,7 +36,6 @@ import * as MixinStakingPoolRewards from '../generated-artifacts/MixinStakingPoo
|
||||
import * as MixinStakingPoolRewardVault from '../generated-artifacts/MixinStakingPoolRewardVault.json';
|
||||
import * as MixinStorage from '../generated-artifacts/MixinStorage.json';
|
||||
import * as MixinVaultCore from '../generated-artifacts/MixinVaultCore.json';
|
||||
import * as MixinZrxVault from '../generated-artifacts/MixinZrxVault.json';
|
||||
import * as ReadOnlyProxy from '../generated-artifacts/ReadOnlyProxy.json';
|
||||
import * as Staking from '../generated-artifacts/Staking.json';
|
||||
import * as StakingPoolRewardVault from '../generated-artifacts/StakingPoolRewardVault.json';
|
||||
@@ -81,7 +80,6 @@ export const artifacts = {
|
||||
MixinStake: MixinStake as ContractArtifact,
|
||||
MixinStakeBalances: MixinStakeBalances as ContractArtifact,
|
||||
MixinStakeStorage: MixinStakeStorage as ContractArtifact,
|
||||
MixinZrxVault: MixinZrxVault as ContractArtifact,
|
||||
MixinCumulativeRewards: MixinCumulativeRewards as ContractArtifact,
|
||||
MixinStakingPool: MixinStakingPool as ContractArtifact,
|
||||
MixinStakingPoolRewardVault: MixinStakingPoolRewardVault as ContractArtifact,
|
||||
|
@@ -34,7 +34,6 @@ export * from '../generated-wrappers/mixin_staking_pool_reward_vault';
|
||||
export * from '../generated-wrappers/mixin_staking_pool_rewards';
|
||||
export * from '../generated-wrappers/mixin_storage';
|
||||
export * from '../generated-wrappers/mixin_vault_core';
|
||||
export * from '../generated-wrappers/mixin_zrx_vault';
|
||||
export * from '../generated-wrappers/read_only_proxy';
|
||||
export * from '../generated-wrappers/staking';
|
||||
export * from '../generated-wrappers/staking_pool_reward_vault';
|
||||
|
@@ -165,7 +165,7 @@ export class FinalizerActor extends BaseActor {
|
||||
const operatorShareByPoolId: OperatorShareByPoolId = {};
|
||||
for (const poolId of poolIds) {
|
||||
const pool = await this._stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
|
||||
const operatorShare = new BigNumber(pool[1]);
|
||||
const operatorShare = new BigNumber(pool[0]);
|
||||
operatorShareByPoolId[poolId] = operatorShare;
|
||||
}
|
||||
return operatorShareByPoolId;
|
||||
@@ -181,8 +181,8 @@ export class FinalizerActor extends BaseActor {
|
||||
|
||||
private async _getRewardVaultBalanceAsync(poolId: string): Promise<RewardVaultBalance> {
|
||||
const pool = await this._stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
|
||||
const operatorBalance = pool[2];
|
||||
const membersBalance = pool[3];
|
||||
const operatorBalance = pool[1];
|
||||
const membersBalance = pool[2];
|
||||
return {
|
||||
poolBalance: operatorBalance.plus(membersBalance),
|
||||
operatorBalance,
|
||||
|
@@ -104,7 +104,7 @@ export class PoolOperatorActor extends BaseActor {
|
||||
await txReceiptPromise;
|
||||
// Check operator share
|
||||
const pool = await this._stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
|
||||
const decreasedOperatorShare = new BigNumber(pool[1]);
|
||||
const decreasedOperatorShare = new BigNumber(pool[0]);
|
||||
expect(decreasedOperatorShare, 'updated operator share').to.be.bignumber.equal(newOperatorShare);
|
||||
}
|
||||
}
|
||||
|
@@ -123,8 +123,8 @@ blockchainTests.resets('Testing Rewards', env => {
|
||||
: ZERO,
|
||||
};
|
||||
const pool = await stakingApiWrapper.rewardVaultContract.poolById.callAsync(poolId);
|
||||
const operatorBalance = pool[2];
|
||||
const membersBalance = pool[3];
|
||||
const operatorBalance = pool[1];
|
||||
const membersBalance = pool[2];
|
||||
const poolBalances = { poolBalance: operatorBalance.plus(membersBalance), operatorBalance, membersBalance };
|
||||
const finalEndBalancesAsArray = await Promise.all([
|
||||
// staker 1
|
||||
|
@@ -46,7 +46,7 @@ blockchainTests.resets('Stake Statuses', env => {
|
||||
await stakingApiWrapper.utils.createStakingPoolAsync(poolOperator, 4, false),
|
||||
await stakingApiWrapper.utils.createStakingPoolAsync(poolOperator, 5, false),
|
||||
]);
|
||||
unusedPoolId = await stakingApiWrapper.stakingContract.getNextStakingPoolId.callAsync();
|
||||
unusedPoolId = await stakingApiWrapper.stakingContract.nextPoolId.callAsync();
|
||||
});
|
||||
describe('Stake', () => {
|
||||
it('should successfully stake zero ZRX', async () => {
|
||||
|
@@ -34,7 +34,6 @@
|
||||
"generated-artifacts/MixinStakingPoolRewards.json",
|
||||
"generated-artifacts/MixinStorage.json",
|
||||
"generated-artifacts/MixinVaultCore.json",
|
||||
"generated-artifacts/MixinZrxVault.json",
|
||||
"generated-artifacts/ReadOnlyProxy.json",
|
||||
"generated-artifacts/Staking.json",
|
||||
"generated-artifacts/StakingPoolRewardVault.json",
|
||||
|
Reference in New Issue
Block a user