Make wethAssetProxy and zrxVault deployment constants
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { blockchainTests, constants, expect, filterLogsToArguments, randomAddress } from '@0x/contracts-test-utils';
|
||||
import { blockchainTests, constants, expect, filterLogsToArguments } from '@0x/contracts-test-utils';
|
||||
import { StakingRevertErrors } from '@0x/order-utils';
|
||||
import { AuthorizableRevertErrors, BigNumber, StringRevertError } from '@0x/utils';
|
||||
|
||||
@@ -8,7 +8,6 @@ import {
|
||||
StakingProxyContract,
|
||||
TestAssertStorageParamsContract,
|
||||
TestInitTargetContract,
|
||||
TestInitTargetInitAddressesEventArgs,
|
||||
TestStakingProxyContract,
|
||||
TestStakingProxyStakingContractAttachedToProxyEventArgs,
|
||||
} from '../src/';
|
||||
@@ -100,9 +99,6 @@ blockchainTests('Migration tests', env => {
|
||||
});
|
||||
|
||||
it('should set the correct initial params', async () => {
|
||||
const wethProxyAddress = randomAddress();
|
||||
const zrxVaultAddress = randomAddress();
|
||||
|
||||
const stakingProxyContractAddress = (await StakingProxyContract.deployFrom0xArtifactAsync(
|
||||
artifacts.StakingProxy,
|
||||
env.provider,
|
||||
@@ -110,8 +106,6 @@ blockchainTests('Migration tests', env => {
|
||||
artifacts,
|
||||
stakingContract.address,
|
||||
stakingContract.address,
|
||||
wethProxyAddress,
|
||||
zrxVaultAddress,
|
||||
)).address;
|
||||
|
||||
const stakingProxyContract = new StakingContract(
|
||||
@@ -126,8 +120,6 @@ blockchainTests('Migration tests', env => {
|
||||
expect(params[3]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.maximumMakersInPool);
|
||||
expect(params[4]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaNumerator);
|
||||
expect(params[5]).to.bignumber.eq(stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaDenominator);
|
||||
expect(params[6]).to.eq(wethProxyAddress);
|
||||
expect(params[7]).to.eq(zrxVaultAddress);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -141,8 +133,6 @@ blockchainTests('Migration tests', env => {
|
||||
it('throws if not called by an authorized address', async () => {
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
{
|
||||
from: notAuthorizedAddress,
|
||||
},
|
||||
@@ -152,19 +142,13 @@ blockchainTests('Migration tests', env => {
|
||||
});
|
||||
|
||||
it('calls init() and attaches the contract', async () => {
|
||||
await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
|
||||
await assertInitStateAsync(proxyContract);
|
||||
});
|
||||
|
||||
it('emits a `StakingContractAttachedToProxy` event', async () => {
|
||||
const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
const logsArgs = filterLogsToArguments<TestStakingProxyStakingContractAttachedToProxyEventArgs>(
|
||||
receipt.logs,
|
||||
@@ -179,56 +163,12 @@ blockchainTests('Migration tests', env => {
|
||||
|
||||
it('reverts if init() reverts', async () => {
|
||||
await enableInitRevertsAsync();
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
|
||||
return expect(tx).to.revertWith(INIT_REVERT_ERROR);
|
||||
});
|
||||
|
||||
it('calls init with initialized addresses if passed in args are null', async () => {
|
||||
const wethProxyAddress = randomAddress();
|
||||
const zrxVaultAddress = randomAddress();
|
||||
await proxyContract.setAddressParams.awaitTransactionSuccessAsync(wethProxyAddress, zrxVaultAddress);
|
||||
const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
const logsArgs = filterLogsToArguments<TestInitTargetInitAddressesEventArgs>(
|
||||
receipt.logs,
|
||||
'InitAddresses',
|
||||
);
|
||||
for (const args of logsArgs) {
|
||||
expect(args.wethProxyAddress).to.eq(wethProxyAddress);
|
||||
expect(args.zrxVaultAddress).to.eq(zrxVaultAddress);
|
||||
}
|
||||
});
|
||||
it('calls init with passed in addresses if they are not null', async () => {
|
||||
const wethProxyAddress = randomAddress();
|
||||
const zrxVaultAddress = randomAddress();
|
||||
const receipt = await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
wethProxyAddress,
|
||||
zrxVaultAddress,
|
||||
);
|
||||
const logsArgs = filterLogsToArguments<TestInitTargetInitAddressesEventArgs>(
|
||||
receipt.logs,
|
||||
'InitAddresses',
|
||||
);
|
||||
for (const args of logsArgs) {
|
||||
expect(args.wethProxyAddress).to.eq(wethProxyAddress);
|
||||
expect(args.zrxVaultAddress).to.eq(zrxVaultAddress);
|
||||
}
|
||||
});
|
||||
|
||||
it('reverts if assertValidStorageParams() fails', async () => {
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
revertAddress,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
const tx = proxyContract.attachStakingContract.awaitTransactionSuccessAsync(revertAddress);
|
||||
return expect(tx).to.revertWith(STORAGE_PARAMS_REVERT_ERROR);
|
||||
});
|
||||
});
|
||||
@@ -236,11 +176,7 @@ blockchainTests('Migration tests', env => {
|
||||
blockchainTests.resets('upgrades', async () => {
|
||||
it('modifies prior state', async () => {
|
||||
const proxyContract = await deployStakingProxyAsync(initTargetContract.address);
|
||||
await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
initTargetContract.address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
await proxyContract.attachStakingContract.awaitTransactionSuccessAsync(initTargetContract.address);
|
||||
const initCounter = await initTargetContract.getInitCounter.callAsync({ to: proxyContract.address });
|
||||
expect(initCounter).to.bignumber.eq(2);
|
||||
});
|
||||
@@ -249,7 +185,7 @@ blockchainTests('Migration tests', env => {
|
||||
|
||||
blockchainTests.resets('Staking.init()', async () => {
|
||||
it('throws if not called by an authorized address', async () => {
|
||||
const tx = stakingContract.init.awaitTransactionSuccessAsync(randomAddress(), randomAddress(), {
|
||||
const tx = stakingContract.init.awaitTransactionSuccessAsync({
|
||||
from: notAuthorizedAddress,
|
||||
});
|
||||
const expectedError = new AuthorizableRevertErrors.SenderNotAuthorizedError(notAuthorizedAddress);
|
||||
@@ -257,8 +193,8 @@ blockchainTests('Migration tests', env => {
|
||||
});
|
||||
|
||||
it('throws if already intitialized', async () => {
|
||||
await stakingContract.init.awaitTransactionSuccessAsync(randomAddress(), randomAddress());
|
||||
const tx = stakingContract.init.awaitTransactionSuccessAsync(randomAddress(), randomAddress());
|
||||
await stakingContract.init.awaitTransactionSuccessAsync();
|
||||
const tx = stakingContract.init.awaitTransactionSuccessAsync();
|
||||
const expectedError = new StakingRevertErrors.InitializationError();
|
||||
return expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
@@ -380,26 +316,6 @@ blockchainTests('Migration tests', env => {
|
||||
);
|
||||
expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
it('reverts if wethAssetProxy is 0', async () => {
|
||||
const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({
|
||||
...stakingConstants.DEFAULT_PARAMS,
|
||||
wethProxyAddress: constants.NULL_ADDRESS,
|
||||
});
|
||||
const expectedError = new StakingRevertErrors.InvalidParamValueError(
|
||||
StakingRevertErrors.InvalidParamValueErrorCode.InvalidWethProxyAddress,
|
||||
);
|
||||
expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
it('reverts if zrxVault is 0', async () => {
|
||||
const tx = proxyContract.setAndAssertParams.awaitTransactionSuccessAsync({
|
||||
...stakingConstants.DEFAULT_PARAMS,
|
||||
zrxVaultAddress: constants.NULL_ADDRESS,
|
||||
});
|
||||
const expectedError = new StakingRevertErrors.InvalidParamValueError(
|
||||
StakingRevertErrors.InvalidParamValueErrorCode.InvalidZrxVaultAddress,
|
||||
);
|
||||
expect(tx).to.revertWith(expectedError);
|
||||
});
|
||||
});
|
||||
});
|
||||
// tslint:enable:no-unnecessary-type-assertion
|
||||
|
||||
@@ -39,8 +39,6 @@ blockchainTests('Configurable Parameters unit tests', env => {
|
||||
new BigNumber(_params.maximumMakersInPool),
|
||||
new BigNumber(_params.cobbDouglasAlphaNumerator),
|
||||
new BigNumber(_params.cobbDouglasAlphaDenominator),
|
||||
_params.wethProxyAddress,
|
||||
_params.zrxVaultAddress,
|
||||
{ from },
|
||||
);
|
||||
// Assert event.
|
||||
@@ -53,8 +51,6 @@ blockchainTests('Configurable Parameters unit tests', env => {
|
||||
expect(event.maximumMakersInPool).to.bignumber.eq(_params.maximumMakersInPool);
|
||||
expect(event.cobbDouglasAlphaNumerator).to.bignumber.eq(_params.cobbDouglasAlphaNumerator);
|
||||
expect(event.cobbDouglasAlphaDenominator).to.bignumber.eq(_params.cobbDouglasAlphaDenominator);
|
||||
expect(event.wethProxyAddress).to.eq(_params.wethProxyAddress);
|
||||
expect(event.zrxVaultAddress).to.eq(_params.zrxVaultAddress);
|
||||
// Assert `getParams()`.
|
||||
const actual = await testContract.getParams.callAsync();
|
||||
expect(actual[0]).to.bignumber.eq(_params.epochDurationInSeconds);
|
||||
@@ -63,8 +59,6 @@ blockchainTests('Configurable Parameters unit tests', env => {
|
||||
expect(actual[3]).to.bignumber.eq(_params.maximumMakersInPool);
|
||||
expect(actual[4]).to.bignumber.eq(_params.cobbDouglasAlphaNumerator);
|
||||
expect(actual[5]).to.bignumber.eq(_params.cobbDouglasAlphaDenominator);
|
||||
expect(actual[6]).to.eq(_params.wethProxyAddress);
|
||||
expect(actual[7]).to.eq(_params.zrxVaultAddress);
|
||||
return receipt;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ blockchainTests.resets('Testing Rewards', env => {
|
||||
minimumPoolStake: new BigNumber(2),
|
||||
cobbDouglasAlphaNumerator: new BigNumber(1),
|
||||
cobbDouglasAlphaDenominator: new BigNumber(6),
|
||||
zrxVaultAddress: stakingApiWrapper.zrxVaultContract.address,
|
||||
});
|
||||
// setup stakers
|
||||
stakers = actors.slice(0, 2).map(a => new StakerActor(a, stakingApiWrapper));
|
||||
|
||||
@@ -117,8 +117,6 @@ export class StakingApiWrapper {
|
||||
new BigNumber(_params.maximumMakersInPool),
|
||||
new BigNumber(_params.cobbDouglasAlphaNumerator),
|
||||
new BigNumber(_params.cobbDouglasAlphaDenominator),
|
||||
_params.wethProxyAddress,
|
||||
_params.zrxVaultAddress,
|
||||
);
|
||||
},
|
||||
|
||||
@@ -228,22 +226,6 @@ export async function deployAndConfigureContractsAsync(
|
||||
artifacts,
|
||||
);
|
||||
|
||||
// deploy staking contract
|
||||
const stakingContract = await TestStakingContract.deployFrom0xArtifactAsync(
|
||||
customStakingArtifact !== undefined ? customStakingArtifact : artifacts.TestStaking,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
wethContract.address,
|
||||
);
|
||||
|
||||
// deploy read-only proxy
|
||||
const readOnlyProxyContract = await ReadOnlyProxyContract.deployFrom0xArtifactAsync(
|
||||
artifacts.ReadOnlyProxy,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
// deploy zrx vault
|
||||
const zrxVaultContract = await ZrxVaultContract.deployFrom0xArtifactAsync(
|
||||
artifacts.ZrxVault,
|
||||
@@ -253,6 +235,26 @@ export async function deployAndConfigureContractsAsync(
|
||||
erc20ProxyContract.address,
|
||||
zrxTokenContract.address,
|
||||
);
|
||||
|
||||
// deploy staking contract
|
||||
const stakingContract = await TestStakingContract.deployFrom0xArtifactAsync(
|
||||
customStakingArtifact !== undefined ? customStakingArtifact : artifacts.TestStaking,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
wethContract.address,
|
||||
erc20ProxyContract.address,
|
||||
zrxVaultContract.address,
|
||||
);
|
||||
|
||||
// deploy read-only proxy
|
||||
const readOnlyProxyContract = await ReadOnlyProxyContract.deployFrom0xArtifactAsync(
|
||||
artifacts.ReadOnlyProxy,
|
||||
env.provider,
|
||||
env.txDefaults,
|
||||
artifacts,
|
||||
);
|
||||
|
||||
// deploy staking proxy
|
||||
const stakingProxyContract = await StakingProxyContract.deployFrom0xArtifactAsync(
|
||||
artifacts.StakingProxy,
|
||||
@@ -261,8 +263,6 @@ export async function deployAndConfigureContractsAsync(
|
||||
artifacts,
|
||||
stakingContract.address,
|
||||
readOnlyProxyContract.address,
|
||||
erc20ProxyContract.address,
|
||||
zrxVaultContract.address,
|
||||
);
|
||||
// deploy cobb douglas contract
|
||||
const cobbDouglasContract = await TestCobbDouglasContract.deployFrom0xArtifactAsync(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { constants as testConstants, randomAddress } from '@0x/contracts-test-utils';
|
||||
import { constants as testConstants } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
const TEN_DAYS = 10 * 24 * 60 * 60;
|
||||
@@ -17,8 +17,6 @@ export const constants = {
|
||||
maximumMakersInPool: new BigNumber(10),
|
||||
cobbDouglasAlphaNumerator: new BigNumber(1),
|
||||
cobbDouglasAlphaDenominator: new BigNumber(2),
|
||||
wethProxyAddress: randomAddress(),
|
||||
zrxVaultAddress: randomAddress(),
|
||||
},
|
||||
PPM,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BlockchainTestsEnvironment, constants, expect, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { BlockchainTestsEnvironment, expect, txDefaults } from '@0x/contracts-test-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
import { DecodedLogEntry, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
@@ -86,6 +86,7 @@ export class CumulativeRewardTrackingSimulation {
|
||||
txDefaults,
|
||||
artifacts,
|
||||
this._stakingApiWrapper.wethContract.address,
|
||||
this._stakingApiWrapper.zrxVaultContract.address,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -104,8 +105,6 @@ export class CumulativeRewardTrackingSimulation {
|
||||
await this._executeActionsAsync(initActions);
|
||||
await this._stakingApiWrapper.stakingProxyContract.attachStakingContract.awaitTransactionSuccessAsync(
|
||||
this.getTestCumulativeRewardTrackingContract().address,
|
||||
constants.NULL_ADDRESS,
|
||||
constants.NULL_ADDRESS,
|
||||
);
|
||||
const testLogs = await this._executeActionsAsync(testActions);
|
||||
CumulativeRewardTrackingSimulation._assertTestLogs(expectedTestLogs, testLogs);
|
||||
|
||||
@@ -11,8 +11,6 @@ export interface StakingParams {
|
||||
maximumMakersInPool: Numberish;
|
||||
cobbDouglasAlphaNumerator: Numberish;
|
||||
cobbDouglasAlphaDenominator: Numberish;
|
||||
wethProxyAddress: string;
|
||||
zrxVaultAddress: string;
|
||||
}
|
||||
|
||||
export interface StakerBalances {
|
||||
|
||||
Reference in New Issue
Block a user