diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-02-09 09:09:34 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-04-21 04:56:16 +0800 |
commit | 7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7 (patch) | |
tree | f0cd69fbe346bc6e7fcd8cb1a4f010e8d4513804 /packages/contracts/util/formatters.ts | |
parent | 9e2f8bead9a51a4c30b77781ae3b39bed31c36ee (diff) | |
download | dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.tar dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.tar.gz dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.tar.bz2 dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.tar.lz dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.tar.xz dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.tar.zst dexon-sol-tools-7201a74aeaa6b646e97d7c9c2c4cc979ace5f4f7.zip |
Move utils dir into src
Diffstat (limited to 'packages/contracts/util/formatters.ts')
-rw-r--r-- | packages/contracts/util/formatters.ts | 107 |
1 files changed, 0 insertions, 107 deletions
diff --git a/packages/contracts/util/formatters.ts b/packages/contracts/util/formatters.ts deleted file mode 100644 index 88e12a6b4..000000000 --- a/packages/contracts/util/formatters.ts +++ /dev/null @@ -1,107 +0,0 @@ -import { SignedOrder } from '0x.js'; -import { BigNumber } from '@0xproject/utils'; -import * as _ from 'lodash'; - -import { BatchCancelOrders, BatchFillOrders, MarketFillOrders } from './types'; - -export const formatters = { - createBatchFill( - signedOrders: SignedOrder[], - takerTokenFillAmounts: BigNumber[] = [], - ) { - const batchFill: BatchFillOrders = { - orderAddresses: [], - orderValues: [], - takerTokenFillAmounts, - v: [], - r: [], - s: [], - }; - _.forEach(signedOrders, signedOrder => { - batchFill.orderAddresses.push([ - signedOrder.maker, - signedOrder.taker, - signedOrder.makerTokenAddress, - signedOrder.takerTokenAddress, - signedOrder.feeRecipient, - ]); - batchFill.orderValues.push([ - signedOrder.makerTokenAmount, - signedOrder.takerTokenAmount, - signedOrder.makerFee, - signedOrder.takerFee, - signedOrder.expirationUnixTimestampSec, - signedOrder.salt, - ]); - batchFill.v.push(signedOrder.ecSignature.v); - batchFill.r.push(signedOrder.ecSignature.r); - batchFill.s.push(signedOrder.ecSignature.s); - if (takerTokenFillAmounts.length < signedOrders.length) { - batchFill.takerTokenFillAmounts.push(signedOrder.takerTokenAmount); - } - }); - return batchFill; - }, - createMarketFillOrders( - signedOrders: SignedOrder[], - takerTokenFillAmount: BigNumber, - ) { - const marketFillOrders: MarketFillOrders = { - orderAddresses: [], - orderValues: [], - takerTokenFillAmount, - v: [], - r: [], - s: [], - }; - signedOrders.forEach(signedOrder => { - marketFillOrders.orderAddresses.push([ - signedOrder.maker, - signedOrder.taker, - signedOrder.makerTokenAddress, - signedOrder.takerTokenAddress, - signedOrder.feeRecipient, - ]); - marketFillOrders.orderValues.push([ - signedOrder.makerTokenAmount, - signedOrder.takerTokenAmount, - signedOrder.makerFee, - signedOrder.takerFee, - signedOrder.expirationUnixTimestampSec, - signedOrder.salt, - ]); - marketFillOrders.v.push(signedOrder.ecSignature.v); - marketFillOrders.r.push(signedOrder.ecSignature.r); - marketFillOrders.s.push(signedOrder.ecSignature.s); - }); - return marketFillOrders; - }, - createBatchCancel(signedOrders: SignedOrder[], takerTokenCancelAmounts: BigNumber[] = []) { - const batchCancel: BatchCancelOrders = { - orderAddresses: [], - orderValues: [], - takerTokenCancelAmounts, - }; - signedOrders.forEach(signedOrder => { - batchCancel.orderAddresses.push([ - signedOrder.maker, - signedOrder.taker, - signedOrder.makerTokenAddress, - signedOrder.takerTokenAddress, - signedOrder.feeRecipient, - ]); - batchCancel.orderValues.push([ - signedOrder.makerTokenAmount, - signedOrder.takerTokenAmount, - signedOrder.makerFee, - signedOrder.takerFee, - signedOrder.expirationUnixTimestampSec, - signedOrder.salt, - ]); - if (takerTokenCancelAmounts.length < signedOrders.length) { - batchCancel.takerTokenCancelAmounts.push(signedOrder.takerTokenAmount); - } - }); - return batchCancel; - }, -}; |