aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2018-12-20 08:08:59 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-01-08 07:50:48 +0800
commitc850046ea0b302f61a5fd24f77bab19784a2adc0 (patch)
tree34157fa6fb1006c080d42ba3b9c7b8ceb1fb691c /packages
parent7dda953bc929e218121c331fedb3884b24555855 (diff)
downloaddexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.tar
dexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.tar.gz
dexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.tar.bz2
dexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.tar.lz
dexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.tar.xz
dexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.tar.zst
dexon-0x-contracts-c850046ea0b302f61a5fd24f77bab19784a2adc0.zip
Dutch Auction Contract Wrapper
Diffstat (limited to 'packages')
-rw-r--r--packages/order-utils/src/asset_data_utils.ts20
-rw-r--r--packages/types/src/index.ts9
2 files changed, 29 insertions, 0 deletions
diff --git a/packages/order-utils/src/asset_data_utils.ts b/packages/order-utils/src/asset_data_utils.ts
index f314891e2..0fc166969 100644
--- a/packages/order-utils/src/asset_data_utils.ts
+++ b/packages/order-utils/src/asset_data_utils.ts
@@ -305,4 +305,24 @@ export const assetDataUtils = {
throw new Error(`Unrecognized asset proxy id: ${assetProxyId}`);
}
},
+ /**
+ * Dutch auction details are encoded with the asset data for a 0x order. This function produces a hex
+ * encoded assetData string, containing information both about the asset being traded and the
+ * dutch auction; which is usable in the makerAssetData or takerAssetData fields in a 0x order.
+ * @param assetData Hex encoded assetData string for the asset being auctioned.
+ * @param beginTimeSeconds Begin time of the dutch auction.
+ * @param beginAmount Starting amount being sold in the dutch auction.
+ * @return The hex encoded assetData string.
+ */
+ encodeDutchAuctionAssetData(assetData: string, beginTimeSeconds: BigNumber, beginAmount: BigNumber): string {
+ const assetDataBuffer = ethUtil.toBuffer(assetData);
+ const abiEncodedAuctionData = (ethAbi as any).rawEncode(
+ ['uint256', 'uint256'],
+ [beginTimeSeconds.toString(), beginAmount.toString()],
+ );
+ const abiEncodedAuctionDataBuffer = ethUtil.toBuffer(abiEncodedAuctionData);
+ const dutchAuctionDataBuffer = Buffer.concat([assetDataBuffer, abiEncodedAuctionDataBuffer]);
+ const dutchAuctionData = ethUtil.bufferToHex(dutchAuctionDataBuffer);
+ return dutchAuctionData;
+ },
};
diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts
index 472b56dc2..49f788fb0 100644
--- a/packages/types/src/index.ts
+++ b/packages/types/src/index.ts
@@ -676,3 +676,12 @@ export interface SimpleEvmOutput {
export interface SimpleEvmBytecodeOutput {
object: string;
}
+
+export interface DutchAuctionDetails {
+ beginTimeSeconds: BigNumber;
+ endTimeSeconds: BigNumber;
+ beginAmount: BigNumber;
+ endAmount: BigNumber;
+ currentAmount: BigNumber;
+ currentTimeSeconds: BigNumber;
+}