diff --git a/test/helpers/BytesHelper.js b/test/helpers/BytesHelper.js index cb55f333..b33cbb28 100644 --- a/test/helpers/BytesHelper.js +++ b/test/helpers/BytesHelper.js @@ -44,15 +44,15 @@ function zeroExV1OrderToBytes(order) { function zeroExV2OrderToBytes(order) { const v = [] - .concat(toBytes32(order.maker)) - .concat(toBytes32(order.taker)) - .concat(toBytes32(order.feeRecipient)) - .concat(toBytes32(order.sender)) - .concat(toBytes32(order.makerTokenAmount)) - .concat(toBytes32(order.takerTokenAmount)) + .concat(toBytes32(order.makerAddress)) + .concat(toBytes32(order.takerAddress)) + .concat(toBytes32(order.feeRecipientAddress)) + .concat(toBytes32(order.senderAddress)) + .concat(toBytes32(order.makerAssetAmount)) + .concat(toBytes32(order.takerAssetAmount)) .concat(toBytes32(order.makerFee)) .concat(toBytes32(order.takerFee)) - .concat(toBytes32(order.expirationUnixTimestampSec)) + .concat(toBytes32(order.expirationTimeSeconds)) .concat(toBytes32(order.salt)) .concat(toBytes32(order.signature)); return web3Instance.utils.bytesToHex(v); diff --git a/test/helpers/ZeroExV2Helper.js b/test/helpers/ZeroExV2Helper.js index 39617c06..2c1175d1 100644 --- a/test/helpers/ZeroExV2Helper.js +++ b/test/helpers/ZeroExV2Helper.js @@ -1,4 +1,3 @@ - const Web3 = require('web3'); const BigNumber = require('bignumber.js'); @@ -18,30 +17,30 @@ async function createSignedV2SellOrder( accounts, { salt = DEFAULT_SALT, - feeRecipient, + feeRecipientAddress, } = {} ) { let order = { type: ORDER_TYPE.ZERO_EX_V2, - exchangeContractAddress: ZeroExExchangeV2.address, + exchangeAddress: ZeroExExchangeV2.address, - maker: accounts[5], - taker: ADDRESSES.ZERO, - feeRecipient: feeRecipient || accounts[6], - sender: ADDRESSES.ZERO, + makerAddress: accounts[5], + takerAddress: ADDRESSES.ZERO, + feeRecipientAddress: feeRecipientAddress || accounts[6], + senderAddress: ADDRESSES.ZERO, makerFee: BASE_AMOUNT.times(0.010928345).floor(), takerFee: BASE_AMOUNT.times(0.109128341).floor(), - expirationUnixTimestampSec: new BigNumber(100000000000000), + expirationTimeSeconds: new BigNumber(100000000000000), salt: new BigNumber(salt), // owedToken makerTokenAddress: OwedToken.address, - makerTokenAmount: BASE_AMOUNT.times(6.382472).floor(), + makerAssetAmount: BASE_AMOUNT.times(6.382472).floor(), // heldToken takerTokenAddress: HeldToken.address, - takerTokenAmount: BASE_AMOUNT.times(19.123475).floor() + takerAssetAmount: BASE_AMOUNT.times(19.123475).floor() }; order.signature = await signV2Order(order); @@ -53,30 +52,30 @@ async function createSignedV2BuyOrder( accounts, { salt = DEFAULT_SALT, - feeRecipient, + feeRecipientAddress, } = {} ) { let order = { type: ORDER_TYPE.ZERO_EX_V2, - exchangeContractAddress: ZeroExExchangeV2.address, + exchangeAddress: ZeroExExchangeV2.address, - maker: accounts[2], - taker: ADDRESSES.ZERO, - feeRecipient: feeRecipient || accounts[4], - sender: ADDRESSES.ZERO, + makerAddress: accounts[2], + takerAddress: ADDRESSES.ZERO, + feeRecipientAddress: feeRecipientAddress || accounts[4], + senderAddress: ADDRESSES.ZERO, makerFee: BASE_AMOUNT.times(.02012398).floor(), takerFee: BASE_AMOUNT.times(.1019238).floor(), - expirationUnixTimestampSec: new BigNumber(100000000000000), + expirationTimeSeconds: new BigNumber(100000000000000), salt: new BigNumber(salt), // heldToken makerTokenAddress: HeldToken.address, - makerTokenAmount: BASE_AMOUNT.times(30.091234687).floor(), + makerAssetAmount: BASE_AMOUNT.times(30.091234687).floor(), // owedToken takerTokenAddress: OwedToken.address, - takerTokenAmount: BASE_AMOUNT.times(10.092138781).floor(), + takerAssetAmount: BASE_AMOUNT.times(10.092138781).floor(), }; order.signature = await signV2Order(order); @@ -88,32 +87,32 @@ async function createSignedV2Order( accounts, { salt = DEFAULT_SALT, - feeRecipient, - maker, + feeRecipientAddress, + makerAddress, makerToken, - makerTokenAmount, + makerAssetAmount, takerToken, - takerTokenAmount, + takerAssetAmount, } ) { const order = { type: ORDER_TYPE.ZERO_EX_V2, - exchangeContractAddress: ZeroExExchangeV2.address, + exchangeAddress: ZeroExExchangeV2.address, - maker: maker || accounts[5], - taker: ADDRESSES.ZERO, - feeRecipient: feeRecipient || accounts[6], - sender: ADDRESSES.ZERO, + makerAddress: makerAddress || accounts[5], + takerAddress: ADDRESSES.ZERO, + feeRecipientAddress: feeRecipientAddress || accounts[6], + senderAddress: ADDRESSES.ZERO, makerFee: BASE_AMOUNT.times(0.010928345).floor(), takerFee: BASE_AMOUNT.times(0.109128341).floor(), - expirationUnixTimestampSec: new BigNumber(100000000000000), + expirationTimeSeconds: new BigNumber(100000000000000), salt: new BigNumber(salt), makerTokenAddress: makerToken, - makerTokenAmount: makerTokenAmount || BASE_AMOUNT.times(6.382472).floor(), + makerAssetAmount: makerAssetAmount || BASE_AMOUNT.times(6.382472).floor(), takerTokenAddress: takerToken, - takerTokenAmount: takerTokenAmount || BASE_AMOUNT.times(19.123475).floor() + takerAssetAmount: takerAssetAmount || BASE_AMOUNT.times(19.123475).floor() }; order.signature = await signV2Order(order); @@ -123,7 +122,7 @@ async function createSignedV2Order( async function signV2Order(order) { const signature = await promisify(web3Instance.eth.sign)( - getV2OrderHash(order), order.maker + getV2OrderHash(order), order.makerAddress ); const { v, r, s } = ethUtil.fromRpcSig(signature); @@ -157,15 +156,15 @@ function getV2OrderHash(order) { const basicHash = web3Instance.utils.soliditySha3( { t: 'bytes32', v: eip712Hash }, - { t: 'bytes32', v: addressToBytes32(order.maker) }, - { t: 'bytes32', v: addressToBytes32(order.taker) }, - { t: 'bytes32', v: addressToBytes32(order.feeRecipient) }, - { t: 'bytes32', v: addressToBytes32(order.sender) }, - { t: 'uint256', v: order.makerTokenAmount }, - { t: 'uint256', v: order.takerTokenAmount }, + { t: 'bytes32', v: addressToBytes32(order.makerAddress) }, + { t: 'bytes32', v: addressToBytes32(order.takerAddress) }, + { t: 'bytes32', v: addressToBytes32(order.feeRecipientAddress) }, + { t: 'bytes32', v: addressToBytes32(order.senderAddress) }, + { t: 'uint256', v: order.makerAssetAmount }, + { t: 'uint256', v: order.takerAssetAmount }, { t: 'uint256', v: order.makerFee }, { t: 'uint256', v: order.takerFee }, - { t: 'uint256', v: order.expirationUnixTimestampSec }, + { t: 'uint256', v: order.expirationTimeSeconds }, { t: 'uint256', v: order.salt }, { t: 'bytes32', v: web3Instance.utils.soliditySha3({ t: 'bytes', v: makerAssetData })}, { t: 'bytes32', v: web3Instance.utils.soliditySha3({ t: 'bytes', v: takerAssetData })} @@ -177,7 +176,7 @@ function getV2OrderHash(order) { { t: 'bytes32', v: eip712DomSepHash }, { t: 'bytes32', v: web3Instance.utils.soliditySha3({ t: 'string', v: '0x Protocol' })}, { t: 'bytes32', v: web3Instance.utils.soliditySha3({ t: 'string', v: '2' })}, - { t: 'bytes32', v: addressToBytes32(order.exchangeContractAddress) } + { t: 'bytes32', v: addressToBytes32(order.exchangeAddress) } ); const retVal = web3Instance.utils.soliditySha3( diff --git a/test/tests/margin/external/exchangewrappers/TestZeroExV2ExchangeWrapper.js b/test/tests/margin/external/exchangewrappers/TestZeroExV2ExchangeWrapper.js index dc75a6a1..4937c9bc 100644 --- a/test/tests/margin/external/exchangewrappers/TestZeroExV2ExchangeWrapper.js +++ b/test/tests/margin/external/exchangewrappers/TestZeroExV2ExchangeWrapper.js @@ -68,7 +68,7 @@ describe('ZeroExV2ExchangeWrapper', () => { const order = await createSignedV2SellOrder(accounts); const amount = new BigNumber(baseAmount.times(2)); - const requiredTakerTokenAmount = await exchangeWrapper.getExchangeCost.call( + const requiredtakerAssetAmount = await exchangeWrapper.getExchangeCost.call( order.makerTokenAddress, order.takerTokenAddress, amount, @@ -76,13 +76,13 @@ describe('ZeroExV2ExchangeWrapper', () => { ); const expected = getPartialAmount( - order.takerTokenAmount, - order.makerTokenAmount, + order.takerAssetAmount, + order.makerAssetAmount, amount, true ); - expect(requiredTakerTokenAmount).to.be.bignumber.eq(expected); + expect(requiredtakerAssetAmount).to.be.bignumber.eq(expected); }); }); }); @@ -98,7 +98,7 @@ describe('ZeroExV2ExchangeWrapper', () => { } = await setup(accounts); const order = await createSignedV2SellOrder(accounts); - order.feeRecipient = ADDRESSES.ZERO; + order.feeRecipientAddress = ADDRESSES.ZERO; order.signature = await signV2Order(order); // test for un-taken order @@ -107,10 +107,10 @@ describe('ZeroExV2ExchangeWrapper', () => { order.takerTokenAddress, zeroExV2OrderToBytes(order) ); - expect(responseFull).to.be.bignumber.eq(order.makerTokenAmount); + expect(responseFull).to.be.bignumber.eq(order.makerAssetAmount); // fill half of order - const amount = order.takerTokenAmount.div(2).floor(); + const amount = order.takerAssetAmount.div(2).floor(); await grantTokens(order, exchangeWrapper, tradeOriginator, amount); await exchangeWrapper.exchange( tradeOriginator, @@ -126,7 +126,7 @@ describe('ZeroExV2ExchangeWrapper', () => { expect(filled).to.be.bignumber.eq(amount); // test for partially-taken order - const expectedAmount = order.makerTokenAmount.div(2).floor() + const expectedAmount = order.makerAssetAmount.div(2).floor() const responsePart = await exchangeWrapper.getMaxMakerAmount.call( order.makerTokenAddress, order.takerTokenAddress, @@ -143,7 +143,7 @@ describe('ZeroExV2ExchangeWrapper', () => { } = await setup(accounts); const order = await createSignedV2SellOrder(accounts); - order.expirationUnixTimestampSec = new BigNumber(1); + order.expirationTimeSeconds = new BigNumber(1); order.signature = await signV2Order(order); // test for partially-taken order @@ -363,7 +363,7 @@ describe('ZeroExV2ExchangeWrapper', () => { } = await setup(accounts); const order = await createSignedV2SellOrder(accounts); - order.makerTokenAmount = new BigNumber(0); + order.makerAssetAmount = new BigNumber(0); order.signature = await signV2Order(order); const amount = new BigNumber(baseAmount.times(2)); @@ -383,7 +383,7 @@ describe('ZeroExV2ExchangeWrapper', () => { }); contract('ZeroExV1ExchangeWrapper', accounts => { - it('succeeds if no-fee is provided by anyone', async () => { + it('succeeds if zero taker fee for any msg.sender', async () => { const { exchangeWrapper, tradeOriginator, @@ -436,7 +436,7 @@ describe('ZeroExV2ExchangeWrapper', () => { const order = await createSignedV2SellOrder(accounts); - const amount = new BigNumber(order.takerTokenAmount.plus(1)); + const amount = new BigNumber(order.takerAssetAmount.plus(1)); await grantTokens(order, exchangeWrapper, tradeOriginator, amount); @@ -463,7 +463,7 @@ describe('ZeroExV2ExchangeWrapper', () => { const order = await createSignedV2SellOrder(accounts); - const amount = new BigNumber(order.takerTokenAmount.times(2).div(3).floor()); + const amount = new BigNumber(order.takerAssetAmount.times(2).div(3).floor()); await grantTokens(order, exchangeWrapper, tradeOriginator, amount); @@ -527,8 +527,8 @@ async function grantTokens(order, exchangeWrapper, tradeOriginator, amount) { // Maker Token issueAndSetAllowance( makerToken, - order.maker, - order.makerTokenAmount, + order.makerAddress, + order.makerAssetAmount, ZeroExProxyV2.address ), @@ -538,7 +538,7 @@ async function grantTokens(order, exchangeWrapper, tradeOriginator, amount) { // Maker Fee Token issueAndSetAllowance( feeToken, - order.maker, + order.makerAddress, order.makerFee, ZeroExProxyV2.address ), @@ -575,15 +575,15 @@ async function getBalances(order, exchangeWrapper, tradeOriginator, dydxProxy) { exchangeWrapperProxyAllowance ] = await Promise.all([ - makerToken.balanceOf.call(order.maker), - takerToken.balanceOf.call(order.maker), - feeToken.balanceOf.call(order.maker), + makerToken.balanceOf.call(order.makerAddress), + takerToken.balanceOf.call(order.makerAddress), + feeToken.balanceOf.call(order.makerAddress), makerToken.balanceOf.call(exchangeWrapper.address), takerToken.balanceOf.call(exchangeWrapper.address), feeToken.balanceOf.call(exchangeWrapper.address), - feeToken.balanceOf.call(order.feeRecipient), + feeToken.balanceOf.call(order.feeRecipientAddress), feeToken.balanceOf.call(tradeOriginator), @@ -633,17 +633,17 @@ async function validateBalances( const tradedMakerToken = getPartialAmount( amount, - order.takerTokenAmount, - order.makerTokenAmount + order.takerAssetAmount, + order.makerAssetAmount ); - const makerFee = order.feeRecipient === ADDRESSES.ZERO ? BIGNUMBERS.ZERO : getPartialAmount( + const makerFee = getPartialAmount( amount, - order.takerTokenAmount, + order.takerAssetAmount, order.makerFee ); - const takerFee = order.feeRecipient === ADDRESSES.ZERO ? BIGNUMBERS.ZERO : getPartialAmount( + const takerFee = getPartialAmount( amount, - order.takerTokenAmount, + order.takerAssetAmount, order.takerFee );