add test for weth protocol fees
This commit is contained in:
parent
bf18b86f9f
commit
5f699b0c47
@ -20,12 +20,14 @@ contract TestFramework {
|
|||||||
|
|
||||||
function emptyRevert()
|
function emptyRevert()
|
||||||
external
|
external
|
||||||
|
pure
|
||||||
{
|
{
|
||||||
revert();
|
revert();
|
||||||
}
|
}
|
||||||
|
|
||||||
function stringRevert(string calldata message)
|
function stringRevert(string calldata message)
|
||||||
external
|
external
|
||||||
|
pure
|
||||||
{
|
{
|
||||||
revert(message);
|
revert(message);
|
||||||
}
|
}
|
||||||
|
@ -327,4 +327,46 @@ blockchainTests.resets('fillOrder integration tests', env => {
|
|||||||
const poolStats = await deployment.staking.stakingWrapper.getStakingPoolStatsThisEpoch.callAsync(poolId);
|
const poolStats = await deployment.staking.stakingWrapper.getStakingPoolStatsThisEpoch.callAsync(poolId);
|
||||||
expect(poolStats.feesCollected).to.bignumber.equal(DeploymentManager.protocolFee);
|
expect(poolStats.feesCollected).to.bignumber.equal(DeploymentManager.protocolFee);
|
||||||
});
|
});
|
||||||
|
it('should collect WETH fees and pay out rewards', async () => {
|
||||||
|
// Operator and delegator each stake some ZRX; wait an epoch so that the stake is active.
|
||||||
|
await operator.stakeAsync(toBaseUnitAmount(100), poolId);
|
||||||
|
await delegator.stakeAsync(toBaseUnitAmount(50), poolId);
|
||||||
|
await delegator.endEpochAsync();
|
||||||
|
|
||||||
|
// Fetch the current balances
|
||||||
|
await balanceStore.updateBalancesAsync();
|
||||||
|
|
||||||
|
// Create and fill the order. One order's worth of protocol fees are now available as rewards.
|
||||||
|
const order = await maker.signOrderAsync();
|
||||||
|
const receipt = await taker.fillOrderAsync(order, order.takerAssetAmount, { value: constants.ZERO_AMOUNT });
|
||||||
|
const rewardsAvailable = DeploymentManager.protocolFee;
|
||||||
|
const expectedBalances = simulateFill(order, receipt, constants.ZERO_AMOUNT);
|
||||||
|
|
||||||
|
// End the epoch. This should wrap the staking proxy's ETH balance.
|
||||||
|
const endEpochReceipt = await delegator.endEpochAsync();
|
||||||
|
|
||||||
|
// Check balances
|
||||||
|
expectedBalances.burnGas(delegator.address, DeploymentManager.gasPrice.times(endEpochReceipt.gasUsed));
|
||||||
|
await balanceStore.updateBalancesAsync();
|
||||||
|
balanceStore.assertEquals(expectedBalances);
|
||||||
|
|
||||||
|
// The rewards are split between the operator and delegator based on the pool's operatorShare
|
||||||
|
const operatorReward = rewardsAvailable
|
||||||
|
.times(operator.operatorShares[poolId])
|
||||||
|
.dividedToIntegerBy(constants.PPM_DENOMINATOR);
|
||||||
|
|
||||||
|
// Finalize the pool. This should automatically pay the operator in WETH.
|
||||||
|
const [finalizePoolReceipt] = await delegator.finalizePoolsAsync([poolId]);
|
||||||
|
|
||||||
|
// Check balances
|
||||||
|
expectedBalances.transferAsset(
|
||||||
|
deployment.staking.stakingProxy.address,
|
||||||
|
operator.address,
|
||||||
|
operatorReward,
|
||||||
|
assetDataUtils.encodeERC20AssetData(deployment.tokens.weth.address),
|
||||||
|
);
|
||||||
|
expectedBalances.burnGas(delegator.address, DeploymentManager.gasPrice.times(finalizePoolReceipt.gasUsed));
|
||||||
|
await balanceStore.updateBalancesAsync();
|
||||||
|
balanceStore.assertEquals(expectedBalances);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -362,11 +362,7 @@ export class DeploymentManager {
|
|||||||
stakingLogic.address,
|
stakingLogic.address,
|
||||||
);
|
);
|
||||||
|
|
||||||
const stakingWrapper = new TestStakingContract(
|
const stakingWrapper = new TestStakingContract(stakingProxy.address, environment.provider, txDefaults);
|
||||||
stakingProxy.address,
|
|
||||||
environment.provider,
|
|
||||||
txDefaults,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Add the zrx vault and the weth contract to the staking proxy.
|
// Add the zrx vault and the weth contract to the staking proxy.
|
||||||
await stakingWrapper.setWethContract.awaitTransactionSuccessAsync(tokens.weth.address, { from: owner });
|
await stakingWrapper.setWethContract.awaitTransactionSuccessAsync(tokens.weth.address, { from: owner });
|
||||||
|
Loading…
x
Reference in New Issue
Block a user