From 832d2ff5ca1e82c4580e47c0b101069ee7cc0fca Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Fri, 2 Jun 2017 13:08:59 +0200 Subject: Add fill scenario with fees --- test/utils/fill_scenarios.ts | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'test/utils/fill_scenarios.ts') diff --git a/test/utils/fill_scenarios.ts b/test/utils/fill_scenarios.ts index 568b11ef8..31f93618f 100644 --- a/test/utils/fill_scenarios.ts +++ b/test/utils/fill_scenarios.ts @@ -2,6 +2,7 @@ import * as BigNumber from 'bignumber.js'; import {ZeroEx} from '../../src/0x.js'; import {Token, SignedOrder} from '../../src/types'; import {orderFactory} from '../utils/order_factory'; +import {constants} from './constants'; export class FillScenarios { private zeroEx: ZeroEx; @@ -24,10 +25,36 @@ export class FillScenarios { fillableAmount, fillableAmount, expirationUnixTimestampSec, ); } + public async createFillableSignedOrderWithFeesAsync( + makerTokenAddress: string, takerTokenAddress: string, + makerFee: BigNumber.BigNumber, takerFee: BigNumber.BigNumber, + makerAddress: string, takerAddress: string, + fillableAmount: BigNumber.BigNumber, + feeRecepient: string, expirationUnixTimestampSec?: BigNumber.BigNumber, + ): Promise { + return this.createAsymetricFillableSignedOrderWithFeesAsync( + makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress, + fillableAmount, fillableAmount, feeRecepient, expirationUnixTimestampSec, + ); + } public async createAsymetricFillableSignedOrderAsync( makerTokenAddress: string, takerTokenAddress: string, makerAddress: string, takerAddress: string, makerFillableAmount: BigNumber.BigNumber, takerFillableAmount: BigNumber.BigNumber, expirationUnixTimestampSec?: BigNumber.BigNumber): Promise { + const makerFee = new BigNumber(0); + const takerFee = new BigNumber(0); + const feeRecepient = constants.NULL_ADDRESS; + return this.createAsymetricFillableSignedOrderWithFeesAsync( + makerTokenAddress, takerTokenAddress, makerFee, takerFee, makerAddress, takerAddress, + makerFillableAmount, takerFillableAmount, feeRecepient, expirationUnixTimestampSec, + ); + } + private async createAsymetricFillableSignedOrderWithFeesAsync( + makerTokenAddress: string, takerTokenAddress: string, + makerFee: BigNumber.BigNumber, takerFee: BigNumber.BigNumber, + makerAddress: string, takerAddress: string, + makerFillableAmount: BigNumber.BigNumber, takerFillableAmount: BigNumber.BigNumber, + feeRecepient: string, expirationUnixTimestampSec?: BigNumber.BigNumber): Promise { await this.zeroEx.token.transferAsync(makerTokenAddress, this.coinBase, makerAddress, makerFillableAmount); await this.zeroEx.token.setProxyAllowanceAsync(makerTokenAddress, makerAddress, makerFillableAmount); await this.zeroEx.token.transferAsync(takerTokenAddress, this.coinBase, takerAddress, takerFillableAmount); @@ -35,9 +62,10 @@ export class FillScenarios { const transactionSenderAccount = await this.zeroEx.getTransactionSenderAccountIfExistsAsync(); this.zeroEx.setTransactionSenderAccount(makerAddress); - const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, makerAddress, - takerAddress, makerFillableAmount, makerTokenAddress, takerFillableAmount, takerTokenAddress, - expirationUnixTimestampSec); + const signedOrder = await orderFactory.createSignedOrderAsync(this.zeroEx, + makerAddress, takerAddress, makerFee, takerFee, + makerFillableAmount, makerTokenAddress, takerFillableAmount, takerTokenAddress, + feeRecepient, expirationUnixTimestampSec); this.zeroEx.setTransactionSenderAccount(transactionSenderAccount as string); return signedOrder; } -- cgit v1.2.3