Fixed issues after rebase
This commit is contained in:
@@ -96,7 +96,6 @@ blockchainTests('LibFillResults', env => {
|
||||
);
|
||||
}
|
||||
|
||||
// TODO(jalextowle): We might want to add combinatorial testing for protocol fees
|
||||
async function testCalculateFillResultsAsync(
|
||||
orderTakerAssetAmount: BigNumber,
|
||||
takerAssetFilledAmount: BigNumber,
|
||||
@@ -252,49 +251,6 @@ blockchainTests('LibFillResults', env => {
|
||||
expectedError,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if there is a rounding error computing `takerFeePaid`', async () => {
|
||||
const order = makeOrder({
|
||||
makerAssetAmount: ONE_ETHER,
|
||||
takerAssetAmount: ONE_ETHER,
|
||||
takerFee: new BigNumber(100),
|
||||
});
|
||||
const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3);
|
||||
const makerAssetFilledAmount = ReferenceFunctions.getPartialAmountFloor(
|
||||
takerAssetFilledAmount,
|
||||
order.takerAssetAmount,
|
||||
order.makerAssetAmount,
|
||||
);
|
||||
const expectedError = new LibMathRevertErrors.RoundingError(
|
||||
makerAssetFilledAmount,
|
||||
order.makerAssetAmount,
|
||||
order.takerFee,
|
||||
);
|
||||
return expect(libsContract.calculateFillResults.callAsync(order, takerAssetFilledAmount)).to.revertWith(
|
||||
expectedError,
|
||||
);
|
||||
});
|
||||
|
||||
it('reverts if there is an overflow when computing `protocolFeePaid`', async () => {
|
||||
// All values need to be large to ensure we don't trigger a RoundingError.
|
||||
const order = makeOrder({
|
||||
makerAssetAmount: ONE_ETHER,
|
||||
takerAssetAmount: ONE_ETHER.times(2),
|
||||
makerFee: ONE_ETHER.times(0.0023),
|
||||
takerFee: ONE_ETHER.times(0.0025),
|
||||
});
|
||||
const takerAssetFilledAmount = order.takerAssetAmount.dividedToIntegerBy(3);
|
||||
const protocolFeeMultiplier = MAX_UINT256;
|
||||
const gasPrice = new BigNumber(2);
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256MultiplicationOverflow,
|
||||
gasPrice,
|
||||
protocolFeeMultiplier,
|
||||
);
|
||||
return expect(libsContract.calculateFillResults.callAsync(order, takerAssetFilledAmount)).to.revertWith(
|
||||
expectedError,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -371,8 +327,8 @@ blockchainTests('LibFillResults', env => {
|
||||
it('reverts if computing `protocolFeePaid` overflows', async () => {
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.protocolFeePaid = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
|
||||
SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
|
||||
a.protocolFeePaid,
|
||||
b.protocolFeePaid,
|
||||
);
|
||||
|
||||
@@ -81,8 +81,8 @@ describe('Reference Functions', () => {
|
||||
it('reverts if computing `protocolFeePaid` overflows', () => {
|
||||
const [a, b] = _.cloneDeep(DEFAULT_FILL_RESULTS);
|
||||
b.protocolFeePaid = MAX_UINT256;
|
||||
const expectedError = new SafeMathRevertErrors.SafeMathError(
|
||||
SafeMathRevertErrors.SafeMathErrorCodes.Uint256AdditionOverflow,
|
||||
const expectedError = new SafeMathRevertErrors.Uint256BinOpError(
|
||||
SafeMathRevertErrors.BinOpErrorCodes.AdditionOverflow,
|
||||
a.protocolFeePaid,
|
||||
b.protocolFeePaid,
|
||||
);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"evmVersion": "constantinople",
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 15000,
|
||||
"runs": 5000,
|
||||
"details": { "yul": true, "deduplicate": true, "cse": true, "constantOptimizer": true }
|
||||
},
|
||||
"outputSelection": {
|
||||
|
||||
@@ -164,7 +164,7 @@ contract MixinWrapperFunctions is
|
||||
)
|
||||
public
|
||||
payable
|
||||
// disableRefundUntilEnd
|
||||
disableRefundUntilEnd
|
||||
returns (LibFillResults.FillResults[] memory fillResults)
|
||||
{
|
||||
uint256 ordersLength = orders.length;
|
||||
@@ -290,6 +290,8 @@ contract MixinWrapperFunctions is
|
||||
bytes[] memory signatures
|
||||
)
|
||||
public
|
||||
payable
|
||||
disableRefundUntilEnd
|
||||
returns (LibFillResults.FillResults memory fillResults)
|
||||
{
|
||||
fillResults = marketSellOrdersNoThrow(orders, takerAssetFillAmount, signatures);
|
||||
@@ -313,6 +315,8 @@ contract MixinWrapperFunctions is
|
||||
bytes[] memory signatures
|
||||
)
|
||||
public
|
||||
payable
|
||||
disableRefundUntilEnd
|
||||
returns (LibFillResults.FillResults memory fillResults)
|
||||
{
|
||||
fillResults = marketBuyOrdersNoThrow(orders, makerAssetFillAmount, signatures);
|
||||
|
||||
@@ -121,6 +121,7 @@ contract IWrapperFunctions {
|
||||
bytes[] memory signatures
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (LibFillResults.FillResults memory fillResults);
|
||||
|
||||
/// @dev Calls marketSellOrdersNoThrow then reverts if < takerAssetFillAmount has been sold.
|
||||
@@ -134,6 +135,7 @@ contract IWrapperFunctions {
|
||||
bytes[] memory signatures
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (LibFillResults.FillResults memory fillResults);
|
||||
|
||||
/// @dev Calls marketBuyOrdersNoThrow then reverts if < makerAssetFillAmount has been bought.
|
||||
|
||||
@@ -71,6 +71,7 @@ contract ReentrancyTester is
|
||||
bytes memory signature
|
||||
)
|
||||
public
|
||||
payable
|
||||
returns (LibFillResults.FillResults memory fillResults)
|
||||
{
|
||||
// ABI encode calldata for `fillOrder`
|
||||
@@ -154,13 +155,15 @@ contract ReentrancyTester is
|
||||
makerAssetFilledAmount: leftOrders[i].makerAssetAmount,
|
||||
takerAssetFilledAmount: leftOrders[i].takerAssetAmount,
|
||||
makerFeePaid: leftOrders[i].makerFee,
|
||||
takerFeePaid: leftOrders[i].takerFee
|
||||
takerFeePaid: leftOrders[i].takerFee,
|
||||
protocolFeePaid: 0
|
||||
});
|
||||
batchMatchedFillResults.right[i] = LibFillResults.FillResults({
|
||||
makerAssetFilledAmount: rightOrders[i].makerAssetAmount,
|
||||
takerAssetFilledAmount: rightOrders[i].takerAssetAmount,
|
||||
makerFeePaid: rightOrders[i].makerFee,
|
||||
takerFeePaid: rightOrders[i].takerFee
|
||||
takerFeePaid: rightOrders[i].takerFee,
|
||||
protocolFeePaid: 0
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -180,13 +183,15 @@ contract ReentrancyTester is
|
||||
makerAssetFilledAmount: leftOrder.makerAssetAmount,
|
||||
takerAssetFilledAmount: leftOrder.takerAssetAmount,
|
||||
makerFeePaid: leftOrder.makerFee,
|
||||
takerFeePaid: leftOrder.takerFee
|
||||
takerFeePaid: leftOrder.takerFee,
|
||||
protocolFeePaid: 0
|
||||
});
|
||||
matchedFillResults.right = LibFillResults.FillResults({
|
||||
makerAssetFilledAmount: rightOrder.makerAssetAmount,
|
||||
takerAssetFilledAmount: rightOrder.takerAssetAmount,
|
||||
makerFeePaid: rightOrder.makerFee,
|
||||
takerFeePaid: rightOrder.takerFee
|
||||
takerFeePaid: rightOrder.takerFee,
|
||||
protocolFeePaid: 0
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"compile:truffle": "truffle compile"
|
||||
},
|
||||
"config": {
|
||||
"abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxy|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|ISignatureValidator|IStakingManager|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinSignatureValidator|MixinStakingManager|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestSignatureValidator|TestTransactions|TestValidatorWallet|TestWrapperFunctions|Whitelist).json",
|
||||
"abis": "./generated-artifacts/@(Exchange|ExchangeWrapper|IAssetProxy|IAssetProxyDispatcher|IEIP1271Wallet|IExchange|IExchangeCore|IMatchOrders|IProtocolFees|ISignatureValidator|IStakingManager|ITransactions|ITransferSimulator|IWallet|IWrapperFunctions|IsolatedExchange|LibExchangeRichErrorDecoder|MixinAssetProxyDispatcher|MixinExchangeCore|MixinMatchOrders|MixinProtocolFees|MixinSignatureValidator|MixinTransactions|MixinTransferSimulator|MixinWrapperFunctions|ReentrancyTester|TestAssetProxyDispatcher|TestExchangeInternals|TestLibExchangeRichErrorDecoder|TestProtocolFees|TestProtocolFeesReceiver|TestSignatureValidator|TestTransactions|TestValidatorWallet|TestWrapperFunctions|Whitelist).json",
|
||||
"abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually."
|
||||
},
|
||||
"repository": {
|
||||
|
||||
@@ -15,12 +15,12 @@ import * as IExchangeCore from '../generated-artifacts/IExchangeCore.json';
|
||||
import * as IMatchOrders from '../generated-artifacts/IMatchOrders.json';
|
||||
import * as IProtocolFees from '../generated-artifacts/IProtocolFees.json';
|
||||
import * as ISignatureValidator from '../generated-artifacts/ISignatureValidator.json';
|
||||
import * as IsolatedExchange from '../generated-artifacts/IsolatedExchange.json';
|
||||
import * as IStakingManager from '../generated-artifacts/IStakingManager.json';
|
||||
import * as ITransactions from '../generated-artifacts/ITransactions.json';
|
||||
import * as ITransferSimulator from '../generated-artifacts/ITransferSimulator.json';
|
||||
import * as IWallet from '../generated-artifacts/IWallet.json';
|
||||
import * as IWrapperFunctions from '../generated-artifacts/IWrapperFunctions.json';
|
||||
import * as IsolatedExchange from '../generated-artifacts/IsolatedExchange.json';
|
||||
import * as LibExchangeRichErrorDecoder from '../generated-artifacts/LibExchangeRichErrorDecoder.json';
|
||||
import * as MixinAssetProxyDispatcher from '../generated-artifacts/MixinAssetProxyDispatcher.json';
|
||||
import * as MixinExchangeCore from '../generated-artifacts/MixinExchangeCore.json';
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from '@0x/contracts-test-utils';
|
||||
import { ReferenceFunctions as UtilReferenceFunctions } from '@0x/contracts-utils';
|
||||
import { ExchangeRevertErrors, orderHashUtils } from '@0x/order-utils';
|
||||
import { FillResults, OrderInfo, OrderStatus, OrderWithoutDomain as Order } from '@0x/types';
|
||||
import { FillResults, OrderWithoutDomain as Order } from '@0x/types';
|
||||
import { AnyRevertError, BigNumber, SafeMathRevertErrors, StringRevertError } from '@0x/utils';
|
||||
import { LogEntry, LogWithDecodedArgs } from 'ethereum-types';
|
||||
import * as ethjs from 'ethereumjs-util';
|
||||
|
||||
Reference in New Issue
Block a user