aboutsummaryrefslogtreecommitdiffstats
path: root/test/utils/fill_scenarios.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-06-02 19:08:59 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-06-02 19:08:59 +0800
commit832d2ff5ca1e82c4580e47c0b101069ee7cc0fca (patch)
treeb5302140396ad6b8e3e896bdc89cc6fe5a78f674 /test/utils/fill_scenarios.ts
parente1ee6b84945e729d894f6535be02f3541e43dbf0 (diff)
downloaddexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.tar
dexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.tar.gz
dexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.tar.bz2
dexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.tar.lz
dexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.tar.xz
dexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.tar.zst
dexon-sol-tools-832d2ff5ca1e82c4580e47c0b101069ee7cc0fca.zip
Add fill scenario with fees
Diffstat (limited to 'test/utils/fill_scenarios.ts')
-rw-r--r--test/utils/fill_scenarios.ts34
1 files changed, 31 insertions, 3 deletions
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<SignedOrder> {
+ 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<SignedOrder> {
+ 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<SignedOrder> {
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;
}