diff options
Diffstat (limited to 'packages/forwarder-helper/src')
-rw-r--r-- | packages/forwarder-helper/src/forwarder_helper_impl.ts | 50 | ||||
-rw-r--r-- | packages/forwarder-helper/src/types.ts | 2 |
2 files changed, 51 insertions, 1 deletions
diff --git a/packages/forwarder-helper/src/forwarder_helper_impl.ts b/packages/forwarder-helper/src/forwarder_helper_impl.ts index e69de29bb..1069bca73 100644 --- a/packages/forwarder-helper/src/forwarder_helper_impl.ts +++ b/packages/forwarder-helper/src/forwarder_helper_impl.ts @@ -0,0 +1,50 @@ +import { SignedOrder } from '@0xproject/types'; +import { BigNumber } from '@0xproject/utils'; + +import { + ForwarderHelper, + MarketBuyOrdersInfo, + MarketBuyOrdersInfoRequest, + MarketSellOrdersInfo, + MarketSellOrdersInfoRequest, +} from './types'; + +export class ForwarderHelperImpl implements ForwarderHelper { + private _orders: SignedOrder[]; + private _feeOrders: SignedOrder[]; + private _remainingFillableMakerAssetAmountsIfExists?: BigNumber[]; + private _remainingFillableFeeAmountsIfExists?: BigNumber[]; + constructor( + orders: SignedOrder[], + feeOrders: SignedOrder[] = [] as SignedOrder[], + remainingFillableMakerAssetAmounts?: BigNumber[], + remainingFillableFeeAmounts?: BigNumber[], + ) { + this._orders = orders; + this._feeOrders = feeOrders; + this._remainingFillableMakerAssetAmountsIfExists = remainingFillableMakerAssetAmounts; + this._remainingFillableFeeAmountsIfExists = remainingFillableFeeAmounts; + } + public getMarketBuyOrdersInfo(request: MarketBuyOrdersInfoRequest): MarketBuyOrdersInfo { + const { makerAssetFillAmount, feePercentage, acceptableEthAmountRange } = request; + return { + makerAssetFillAmount, + orders: this._orders, + feeOrders: this._feeOrders, + minEthAmount: new BigNumber(0), + maxEthAmount: new BigNumber(0), + feePercentage, + }; + } + public getMarketSellOrdersInfo(request: MarketSellOrdersInfoRequest): MarketSellOrdersInfo { + const { ethAmount, feePercentage, acceptableFillAmountRange } = request; + return { + ethAmount, + orders: this._orders, + feeOrders: this._feeOrders, + minFillAmount: new BigNumber(0), + maxFillAmount: new BigNumber(0), + feePercentage, + }; + } +} diff --git a/packages/forwarder-helper/src/types.ts b/packages/forwarder-helper/src/types.ts index 23eaa1281..c6d4083a9 100644 --- a/packages/forwarder-helper/src/types.ts +++ b/packages/forwarder-helper/src/types.ts @@ -46,9 +46,9 @@ export interface MarketBuyOrdersInfo { makerAssetFillAmount: BigNumber; orders: SignedOrder[]; feeOrders: SignedOrder[]; - feePercentage?: BigNumber; minEthAmount: BigNumber; maxEthAmount: BigNumber; + feePercentage?: BigNumber; } /** |