@haneullabs/deepbook 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +974 -0
  2. package/README.md +11 -0
  3. package/dist/cjs/client.d.ts +198 -0
  4. package/dist/cjs/client.js +630 -0
  5. package/dist/cjs/client.js.map +7 -0
  6. package/dist/cjs/index.d.ts +1 -0
  7. package/dist/cjs/index.js +19 -0
  8. package/dist/cjs/index.js.map +7 -0
  9. package/dist/cjs/package.json +4 -0
  10. package/dist/cjs/types/bcs.d.ts +11 -0
  11. package/dist/cjs/types/bcs.js +36 -0
  12. package/dist/cjs/types/bcs.js.map +7 -0
  13. package/dist/cjs/types/index.d.ts +51 -0
  14. package/dist/cjs/types/index.js +38 -0
  15. package/dist/cjs/types/index.js.map +7 -0
  16. package/dist/cjs/utils/constants.d.ts +7 -0
  17. package/dist/cjs/utils/constants.js +38 -0
  18. package/dist/cjs/utils/constants.js.map +7 -0
  19. package/dist/cjs/utils/index.d.ts +1 -0
  20. package/dist/cjs/utils/index.js +19 -0
  21. package/dist/cjs/utils/index.js.map +7 -0
  22. package/dist/esm/client.d.ts +198 -0
  23. package/dist/esm/client.js +623 -0
  24. package/dist/esm/client.js.map +7 -0
  25. package/dist/esm/index.d.ts +1 -0
  26. package/dist/esm/index.js +2 -0
  27. package/dist/esm/index.js.map +7 -0
  28. package/dist/esm/package.json +4 -0
  29. package/dist/esm/types/bcs.d.ts +11 -0
  30. package/dist/esm/types/bcs.js +16 -0
  31. package/dist/esm/types/bcs.js.map +7 -0
  32. package/dist/esm/types/index.d.ts +51 -0
  33. package/dist/esm/types/index.js +17 -0
  34. package/dist/esm/types/index.js.map +7 -0
  35. package/dist/esm/utils/constants.d.ts +7 -0
  36. package/dist/esm/utils/constants.js +18 -0
  37. package/dist/esm/utils/constants.js.map +7 -0
  38. package/dist/esm/utils/index.d.ts +1 -0
  39. package/dist/esm/utils/index.js +2 -0
  40. package/dist/esm/utils/index.js.map +7 -0
  41. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  42. package/dist/tsconfig.tsbuildinfo +1 -0
  43. package/package.json +56 -0
  44. package/src/client.ts +786 -0
  45. package/src/index.ts +4 -0
  46. package/src/types/bcs.ts +16 -0
  47. package/src/types/index.ts +71 -0
  48. package/src/utils/constants.ts +18 -0
  49. package/src/utils/index.ts +4 -0
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './client.js';
@@ -0,0 +1,16 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { bcs } from '@haneullabs/haneul/bcs';
5
+
6
+ export const BcsOrder = bcs.struct('Order', {
7
+ orderId: bcs.u64(),
8
+ clientOrderId: bcs.u64(),
9
+ price: bcs.u64(),
10
+ originalQuantity: bcs.u64(),
11
+ quantity: bcs.u64(),
12
+ isBid: bcs.bool(),
13
+ owner: bcs.Address,
14
+ expireTimestamp: bcs.u64(),
15
+ selfMatchingPrevention: bcs.u8(),
16
+ });
@@ -0,0 +1,71 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { EventId } from '@haneullabs/haneul/client';
5
+
6
+ export * from './bcs.js';
7
+
8
+ export interface PoolSummary {
9
+ poolId: string;
10
+ baseAsset: string;
11
+ quoteAsset: string;
12
+ }
13
+
14
+ /**
15
+ * `next_cursor` points to the last item in the page; Reading with `next_cursor` will start from the
16
+ * next item after `next_cursor` if `next_cursor` is `Some`, otherwise it will start from the first
17
+ * item.
18
+ */
19
+ export interface PaginatedPoolSummary {
20
+ data: PoolSummary[];
21
+ hasNextPage: boolean;
22
+ nextCursor?: EventId | null;
23
+ }
24
+
25
+ export interface UserPosition {
26
+ availableBaseAmount: bigint;
27
+ lockedBaseAmount: bigint;
28
+ availableQuoteAmount: bigint;
29
+ lockedQuoteAmount: bigint;
30
+ }
31
+
32
+ export enum LimitOrderType {
33
+ // Fill as much quantity as possible in the current transaction as taker, and inject the remaining as a maker order.
34
+ NO_RESTRICTION = 0,
35
+ // Fill as much quantity as possible in the current transaction as taker, and cancel the rest of the order.
36
+ IMMEDIATE_OR_CANCEL = 1,
37
+ // Only fill if the entire order size can be filled as taker in the current transaction. Otherwise, abort the entire transaction.
38
+ FILL_OR_KILL = 2,
39
+ // Only proceed if the entire order size can be posted to the order book as maker in the current transaction. Otherwise, abort the entire transaction.
40
+ POST_OR_ABORT = 3,
41
+ }
42
+
43
+ // The self-matching prevention mechanism ensures that the matching engine takes measures to avoid unnecessary trades
44
+ // when matching a user's buy/sell order with their own sell/buy order.
45
+ // NOTE: we have only implemented one variant for now
46
+ export enum SelfMatchingPreventionStyle {
47
+ // Cancel older (resting) order in full. Continue to execute the newer taking order.
48
+ CANCEL_OLDEST = 0,
49
+ }
50
+
51
+ export interface Order {
52
+ orderId: string;
53
+ clientOrderId: string;
54
+ price: string;
55
+ originalQuantity: string;
56
+ quantity: string;
57
+ isBid: boolean;
58
+ owner: string;
59
+ expireTimestamp: string;
60
+ selfMatchingPrevention: SelfMatchingPreventionStyle;
61
+ }
62
+
63
+ export interface MarketPrice {
64
+ bestBidPrice: bigint | undefined;
65
+ bestAskPrice: bigint | undefined;
66
+ }
67
+
68
+ export interface Level2BookStatusPoint {
69
+ price: bigint;
70
+ depth: bigint;
71
+ }
@@ -0,0 +1,18 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { normalizeStructTag, HANEUL_TYPE_ARG } from '@haneullabs/haneul/utils';
5
+
6
+ export const PACKAGE_ID = '0xdee9';
7
+
8
+ export const MODULE_CLOB = 'clob_v2';
9
+
10
+ export const MODULE_CUSTODIAN = 'custodian_v2';
11
+
12
+ export const CREATION_FEE = 100 * 1e9;
13
+
14
+ export const NORMALIZED_HANEUL_COIN_TYPE = normalizeStructTag(HANEUL_TYPE_ARG);
15
+
16
+ export const ORDER_DEFAULT_EXPIRATION_IN_MS = 1000 * 60 * 60 * 24; // 24 hours
17
+
18
+ export const FLOAT_SCALING_FACTOR = 1_000_000_000n;
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Mysten Labs, Inc.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './constants.js';