@1stdex/first-sdk 1.0.32 → 1.0.34

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1stdex/first-sdk",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "description": "🛠 An SDK for building applications on top of 1st V2",
5
5
  "files": [
6
6
  "dist"
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrderPositionValue = exports.getOpenOrders = exports.getOpenOrder = void 0;
4
- const apis_1 = require("../entities/order/apis");
5
- const apis_2 = require("../entities/book/apis");
6
- const order_id_1 = require("../entities/order/utils/order-id");
7
- const getOpenOrder = async ({ chainId, id, }) => {
8
- return (0, apis_1.fetchOpenOrderByOrderIdFromSubgraph)(chainId, id);
9
- };
10
- exports.getOpenOrder = getOpenOrder;
11
- const getOpenOrders = async ({ chainId, userAddress, }) => {
12
- return (0, apis_1.fetchOpenOrdersByUserAddressFromSubgraph)(chainId, userAddress);
13
- };
14
- exports.getOpenOrders = getOpenOrders;
15
- const getOrderPositionValue = async ({ chainId, orderId, units, }) => {
16
- const { bookId, tick } = (0, order_id_1.fromOrderId)(BigInt(orderId));
17
- return (0, apis_2.fetchBookPositionValue)({
18
- chainId,
19
- bookId: bookId.toString(),
20
- tick,
21
- units,
22
- });
23
- };
24
- exports.getOrderPositionValue = getOrderPositionValue;
25
- //# sourceMappingURL=order-views.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-views.js","sourceRoot":"","sources":["../../../src/views/order-views.ts"],"names":[],"mappings":";;;AAEA,iDAGgC;AAChC,gDAA+D;AAC/D,+DAA+D;AAiBxD,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,EAAE,GAIH,EAAkB,EAAE;IACnB,OAAO,IAAA,0CAAmC,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB;AAiBK,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,WAAW,GAIZ,EAAoB,EAAE;IACrB,OAAO,IAAA,+CAAwC,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB;AAuBK,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,OAAO,EACP,OAAO,EACP,KAAK,GAKN,EAA4D,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,sBAAW,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,IAAA,6BAAsB,EAAC;QAC5B,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,IAAI;QACJ,KAAK;KACN,CAAC,CAAC;AACL,CAAC,CAAC;AAhBW,QAAA,qBAAqB,yBAgBhC"}
@@ -1,70 +0,0 @@
1
- import { fetchOpenOrderByOrderIdFromSubgraph, fetchOpenOrdersByUserAddressFromSubgraph, } from '../entities/order/apis';
2
- import { fetchBookPositionValue } from '../entities/book/apis';
3
- import { fromOrderId } from '../entities/order/utils/order-id';
4
- /**
5
- * Retrieves the open order with the specified ID on the given chain.
6
- *
7
- * @param {CHAIN_IDS} chainId The chain ID.
8
- * @param {string} id The ID of the open order.
9
- * @param options {@link DefaultReadContractOptions} options.
10
- * @returns {Promise<Order>} Promise resolving to the open order object, or undefined if not found.
11
- * @example
12
- * import { getOpenOrder } from '@clober/v2-sdk'
13
- *
14
- * const openOrder = await getOpenOrder({
15
- * chainId: 421614,
16
- * id: '46223845323662364279893361453861711542636620039907198451770258805035840307200'
17
- * })
18
- */
19
- export const getOpenOrder = async ({ chainId, id, }) => {
20
- return fetchOpenOrderByOrderIdFromSubgraph(chainId, id);
21
- };
22
- /**
23
- * Retrieves open orders for the specified user on the given chain.
24
- *
25
- * @param {CHAIN_IDS} chainId The chain ID.
26
- * @param {`0x${string}`} userAddress The Ethereum address of the user.
27
- * @param options {@link DefaultReadContractOptions} options.
28
- * @returns {Promise<Order[]>} Promise resolving to an array of open orders.
29
- * @example
30
- * import { getOpenOrders } from '@clober/v2-sdk'
31
- *
32
- * const openOrders = await getOpenOrders({
33
- * chainId: 421614,
34
- * userAddress: '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
35
- * })
36
- */
37
- export const getOpenOrders = async ({ chainId, userAddress, }) => {
38
- return fetchOpenOrdersByUserAddressFromSubgraph(chainId, userAddress);
39
- };
40
- /**
41
- * Gets the USD value for an order position with given units.
42
- *
43
- * @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
44
- * @param {string} orderId - The order ID as a string
45
- * @param {bigint} units - The number of units
46
- *
47
- * @returns {Promise<{ bookType: 'bids' | 'asks'; usdValue: string }>} An object containing:
48
- * - bookType: 'bids' for bid books, 'asks' for ask books
49
- * - usdValue: The USD value of the position as a string
50
- *
51
- * @example
52
- * import { getOrderPositionValue } from '@clober/v2-sdk'
53
- *
54
- * const result = await getOrderPositionValue({
55
- * chainId: 421614,
56
- * orderId: '46223845323662364279893361453861711542636620039907198451770258805035840307200',
57
- * units: 5n,
58
- * })
59
- * // returns { bookType: 'bids', usdValue: '1234.56' }
60
- */
61
- export const getOrderPositionValue = async ({ chainId, orderId, units, }) => {
62
- const { bookId, tick } = fromOrderId(BigInt(orderId));
63
- return fetchBookPositionValue({
64
- chainId,
65
- bookId: bookId.toString(),
66
- tick,
67
- units,
68
- });
69
- };
70
- //# sourceMappingURL=order-views.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-views.js","sourceRoot":"","sources":["../../../src/views/order-views.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mCAAmC,EACnC,wCAAwC,GACzC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,EAAE,GAIH,EAAkB,EAAE;IACnB,OAAO,mCAAmC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,WAAW,GAIZ,EAAoB,EAAE;IACrB,OAAO,wCAAwC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AACxE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,OAAO,EACP,OAAO,EACP,KAAK,GAKN,EAA4D,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,sBAAsB,CAAC;QAC5B,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,IAAI;QACJ,KAAK;KACN,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -1,70 +0,0 @@
1
- import { CHAIN_IDS } from '../constants/chain-configs/chain';
2
- import { Order } from '../entities/order/types';
3
- /**
4
- * Retrieves the open order with the specified ID on the given chain.
5
- *
6
- * @param {CHAIN_IDS} chainId The chain ID.
7
- * @param {string} id The ID of the open order.
8
- * @param options {@link DefaultReadContractOptions} options.
9
- * @returns {Promise<Order>} Promise resolving to the open order object, or undefined if not found.
10
- * @example
11
- * import { getOpenOrder } from '@clober/v2-sdk'
12
- *
13
- * const openOrder = await getOpenOrder({
14
- * chainId: 421614,
15
- * id: '46223845323662364279893361453861711542636620039907198451770258805035840307200'
16
- * })
17
- */
18
- export declare const getOpenOrder: ({ chainId, id, }: {
19
- chainId: CHAIN_IDS;
20
- id: string;
21
- }) => Promise<Order>;
22
- /**
23
- * Retrieves open orders for the specified user on the given chain.
24
- *
25
- * @param {CHAIN_IDS} chainId The chain ID.
26
- * @param {`0x${string}`} userAddress The Ethereum address of the user.
27
- * @param options {@link DefaultReadContractOptions} options.
28
- * @returns {Promise<Order[]>} Promise resolving to an array of open orders.
29
- * @example
30
- * import { getOpenOrders } from '@clober/v2-sdk'
31
- *
32
- * const openOrders = await getOpenOrders({
33
- * chainId: 421614,
34
- * userAddress: '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
35
- * })
36
- */
37
- export declare const getOpenOrders: ({ chainId, userAddress, }: {
38
- chainId: CHAIN_IDS;
39
- userAddress: `0x${string}`;
40
- }) => Promise<Order[]>;
41
- /**
42
- * Gets the USD value for an order position with given units.
43
- *
44
- * @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
45
- * @param {string} orderId - The order ID as a string
46
- * @param {bigint} units - The number of units
47
- *
48
- * @returns {Promise<{ bookType: 'bids' | 'asks'; usdValue: string }>} An object containing:
49
- * - bookType: 'bids' for bid books, 'asks' for ask books
50
- * - usdValue: The USD value of the position as a string
51
- *
52
- * @example
53
- * import { getOrderPositionValue } from '@clober/v2-sdk'
54
- *
55
- * const result = await getOrderPositionValue({
56
- * chainId: 421614,
57
- * orderId: '46223845323662364279893361453861711542636620039907198451770258805035840307200',
58
- * units: 5n,
59
- * })
60
- * // returns { bookType: 'bids', usdValue: '1234.56' }
61
- */
62
- export declare const getOrderPositionValue: ({ chainId, orderId, units, }: {
63
- chainId: CHAIN_IDS;
64
- orderId: string;
65
- units: bigint;
66
- }) => Promise<{
67
- bookType: 'bids' | 'asks';
68
- usdValue: string;
69
- }>;
70
- //# sourceMappingURL=order-views.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"order-views.d.ts","sourceRoot":"","sources":["../../../src/views/order-views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAQhD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,YAAY,qBAGtB;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;CACZ,KAAG,QAAQ,KAAK,CAEhB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,8BAGvB;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;CAC5B,KAAG,QAAQ,KAAK,EAAE,CAElB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,qBAAqB,iCAI/B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,QAAQ;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAQ1D,CAAC"}