blob: bb0bdb80f704c4ace701e36b08db1f38bd26d01a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import { SignedOrder } from '@0xproject/types';
import { BigNumber } from '@0xproject/utils';
import { constants } from '../constants';
export const orderUtils = {
isOrderExpired(order: SignedOrder): boolean {
const millisecondsInSecond = 1000;
const currentUnixTimestampSec = new BigNumber(Date.now() / millisecondsInSecond).round();
return order.expirationTimeSeconds.lessThan(currentUnixTimestampSec);
},
calculateRemainingMakerAssetAmount(order: SignedOrder, remainingTakerAssetAmount: BigNumber): BigNumber {
const result = remainingTakerAssetAmount.eq(0)
? constants.ZERO_AMOUNT
: remainingTakerAssetAmount.times(order.makerAssetAmount).dividedToIntegerBy(order.takerAssetAmount);
return result;
},
isOpenOrder(order: SignedOrder): boolean {
return order.takerAddress === constants.NULL_ADDRESS;
},
};
|