import BN from 'bn.js' ; export class DirectBuy { public get volume ( ) { return this . _volume ; } public get isFilled ( ) { return this . volume . isZero ( ) ; } constructor ( public readonly id , public readonly userId , public readonly price , private _volume , public readonly askId , public readonly createdAt ) { } public clone ( ) { return new DirectBuy ( this . id , this . userId , this . price , this . volume , this . askId , this . createdAt ) ; } public updateWithTradedVolume ( tradedVolume ) { if ( tradedVolume . gt ( this . volume ) ) { throw new Error ( 'Order overmatched' ) ; } this . _volume = this . _volume . sub ( tradedVolume ) ; return this ; } }