@1stdex/first-sdk 1.0.92-beta.2 → 1.0.92-beta.4

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 (31) hide show
  1. package/dist/cjs/entities/book/apis/index.js +79 -80
  2. package/dist/cjs/entities/book/apis/index.js.map +1 -1
  3. package/dist/cjs/entities/book/apis/position.js +3 -47
  4. package/dist/cjs/entities/book/apis/position.js.map +1 -1
  5. package/dist/cjs/entities/market/apis/index.js +2 -2
  6. package/dist/cjs/entities/market/apis/index.js.map +1 -1
  7. package/dist/cjs/views/book.js +32 -13
  8. package/dist/cjs/views/book.js.map +1 -1
  9. package/dist/cjs/views/index.js +2 -4
  10. package/dist/cjs/views/index.js.map +1 -1
  11. package/dist/esm/entities/book/apis/index.js +79 -78
  12. package/dist/esm/entities/book/apis/index.js.map +1 -1
  13. package/dist/esm/entities/book/apis/position.js +1 -60
  14. package/dist/esm/entities/book/apis/position.js.map +1 -1
  15. package/dist/esm/entities/market/apis/index.js +2 -2
  16. package/dist/esm/entities/market/apis/index.js.map +1 -1
  17. package/dist/esm/views/book.js +45 -61
  18. package/dist/esm/views/book.js.map +1 -1
  19. package/dist/esm/views/index.js +1 -1
  20. package/dist/esm/views/index.js.map +1 -1
  21. package/dist/tsconfig.build.tsbuildinfo +1 -1
  22. package/dist/types/entities/book/apis/index.d.ts +2 -9
  23. package/dist/types/entities/book/apis/index.d.ts.map +1 -1
  24. package/dist/types/entities/book/apis/position.d.ts +0 -9
  25. package/dist/types/entities/book/apis/position.d.ts.map +1 -1
  26. package/dist/types/entities/market/apis/index.d.ts.map +1 -1
  27. package/dist/types/views/book.d.ts +18 -72
  28. package/dist/types/views/book.d.ts.map +1 -1
  29. package/dist/types/views/index.d.ts +1 -1
  30. package/dist/types/views/index.d.ts.map +1 -1
  31. package/package.json +1 -1
@@ -2,13 +2,6 @@ import { PublicClient } from 'viem';
2
2
  import { CHAIN_IDS } from '../../../constants/chain-configs/chain';
3
3
  import { Currency } from '../../currency/types';
4
4
  import { BookModel } from '../model';
5
- export { fetchBookPositionValue, fetchBookUnitsFromUsdValue } from './position';
6
- export declare const fetchBookTokens: ({ chainId, bookId, }: {
7
- chainId: CHAIN_IDS;
8
- bookId: string;
9
- }) => Promise<{
10
- quote: Currency;
11
- base: Currency;
12
- }>;
13
- export declare const fetchBook: (publicClient: PublicClient, chainId: CHAIN_IDS, quoteCurrency: Currency, baseCurrency: Currency, useSubgraph: boolean) => Promise<BookModel>;
5
+ export { fetchBookPositionValue } from './position';
6
+ export declare const fetchBook: (publicClient: PublicClient, chainId: CHAIN_IDS, quoteCurrency: Currency, baseCurrency: Currency, useSubgraph: boolean, includeDepths?: boolean) => Promise<BookModel>;
14
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/entities/book/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,MAAM,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMhD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAIhF,eAAO,MAAM,eAAe,yBAGzB;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,QAAQ;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAiD9C,CAAC;AAEF,eAAO,MAAM,SAAS,iBACN,YAAY,WACjB,SAAS,iBACH,QAAQ,gBACT,QAAQ,eACT,OAAO,KACnB,QAAQ,SAAS,CAuGnB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/entities/book/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAMhD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAIpD,eAAO,MAAM,SAAS,iBACN,YAAY,WACjB,SAAS,iBACH,QAAQ,gBACT,QAAQ,eACT,OAAO,kBACL,OAAO,KACrB,QAAQ,SAAS,CA+InB,CAAC"}
@@ -8,13 +8,4 @@ export declare const fetchBookPositionValue: ({ chainId, bookId, tick, units, }:
8
8
  bookType: 'bids' | 'asks';
9
9
  usdValue: string;
10
10
  }>;
11
- export declare const fetchBookUnitsFromUsdValue: ({ chainId, bookId, tick, usdValue, }: {
12
- chainId: CHAIN_IDS;
13
- bookId: string;
14
- tick: bigint;
15
- usdValue: string;
16
- }) => Promise<{
17
- bookType: 'bids' | 'asks';
18
- units: bigint;
19
- }>;
20
11
  //# sourceMappingURL=position.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../../../src/entities/book/apis/position.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AASnE,eAAO,MAAM,sBAAsB,sCAKhC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,QAAQ;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA2F1D,CAAC;AAEF,eAAO,MAAM,0BAA0B,yCAKpC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,KAAG,QAAQ;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAmGvD,CAAC"}
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../../../src/entities/book/apis/position.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAKnE,eAAO,MAAM,sBAAsB,sCAKhC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,QAAQ;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CA2F1D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/entities/market/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,wBAAsB,WAAW,CAC/B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,SAAS,EAClB,cAAc,EAAE,KAAK,MAAM,EAAE,EAAE,EAC/B,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,WAAW,CAAC,CA8BtB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/entities/market/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAKvC,wBAAsB,WAAW,CAC/B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,SAAS,EAClB,cAAc,EAAE,KAAK,MAAM,EAAE,EAAE,EAC/B,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,WAAW,CAAC,CA4CtB"}
@@ -1,93 +1,39 @@
1
1
  import { CHAIN_IDS } from '../constants/chain-configs/chain';
2
2
  import { Currency } from '../entities/currency/types';
3
3
  /**
4
- * Gets the USD value for a book position at a specific tick with given units.
4
+ * Gets trade information for a specific book, tick and quote units.
5
5
  *
6
6
  * @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
7
7
  * @param {string} bookId - The book ID as a string
8
- * @param {bigint} tick - The tick for the order
9
- * @param {bigint} units - The number of units
8
+ * @param {bigint} tick - The tick for the trade
9
+ * @param {bigint} quoteUnits - The number of quote units
10
10
  *
11
- * @returns {Promise<{ bookType: 'bids' | 'asks'; usdValue: string }>} An object containing:
12
- * - bookType: 'bids' for bid books, 'asks' for ask books
13
- * - usdValue: The USD value of the position as a string
11
+ * @returns {Promise<{ quoteCurrency: Currency; quoteAmount: bigint; baseCurrency: Currency; baseAmount: bigint }>} An object containing:
12
+ * - quoteCurrency: The quote currency information
13
+ * - quoteAmount: The raw quote token amount
14
+ * - baseCurrency: The base currency information
15
+ * - baseAmount: The raw base token amount
14
16
  *
15
17
  * @example
16
- * import { getBookPositionValue } from '@1stdex/first-sdk'
18
+ * import { getTradeInfo } from '@1stdex/first-sdk'
17
19
  *
18
- * const result = await getBookPositionValue({
20
+ * const result = await getTradeInfo({
19
21
  * chainId: 421614,
20
22
  * bookId: '123456789',
21
23
  * tick: 1000n,
22
- * units: 5n,
24
+ * quoteUnits: 5n,
23
25
  * })
24
- * // returns { bookType: 'bids', usdValue: '1234.56' }
26
+ * // returns { quoteCurrency, quoteAmount, baseCurrency, baseAmount }
25
27
  */
26
- export declare const getBookPositionValue: ({ chainId, bookId, tick, units, }: {
28
+ export declare const getTradeInfo: ({ chainId, bookId, tick, quoteUnits, }: {
27
29
  chainId: CHAIN_IDS;
28
30
  bookId: string;
29
31
  tick: bigint;
30
- units: bigint;
32
+ quoteUnits: bigint;
31
33
  }) => Promise<{
32
- bookType: 'bids' | 'asks';
33
- usdValue: string;
34
- }>;
35
- /**
36
- * Gets the token units needed for a book position at a specific tick to achieve a target USD value.
37
- *
38
- * @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
39
- * @param {string} bookId - The book ID as a string
40
- * @param {bigint} tick - The tick for the order
41
- * @param {string} usdValue - The target USD value as a string
42
- *
43
- * @returns {Promise<{ bookType: 'bids' | 'asks'; units: bigint }>} An object containing:
44
- * - bookType: 'bids' for bid books, 'asks' for ask books
45
- * - units: The number of units needed to achieve the target USD value
46
- *
47
- * @example
48
- * import { getBookUnitsFromUsdValue } from '@1stdex/first-sdk'
49
- *
50
- * const result = await getBookUnitsFromUsdValue({
51
- * chainId: 421614,
52
- * bookId: '123456789',
53
- * tick: 1000n,
54
- * usdValue: '1234.56',
55
- * })
56
- * // returns { bookType: 'bids', units: 5n }
57
- */
58
- export declare const getBookUnitsFromUsdValue: ({ chainId, bookId, tick, usdValue, }: {
59
- chainId: CHAIN_IDS;
60
- bookId: string;
61
- tick: bigint;
62
- usdValue: string;
63
- }) => Promise<{
64
- bookType: 'bids' | 'asks';
65
- units: bigint;
66
- }>;
67
- /**
68
- * Gets the quote and base tokens for a book.
69
- *
70
- * @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
71
- * @param {string} bookId - The book ID as a string
72
- *
73
- * @returns {Promise<{ quote: Currency; base: Currency }>} An object containing:
74
- * - quote: The quote token currency details
75
- * - base: The base token currency details
76
- *
77
- * @example
78
- * import { getBookTokens } from '@1stdex/first-sdk'
79
- *
80
- * const result = await getBookTokens({
81
- * chainId: 421614,
82
- * bookId: '123456789',
83
- * })
84
- * // returns { quote: { address: '0x...', name: 'USDC', symbol: 'USDC', decimals: 6 }, base: { address: '0x...', name: 'Wrapped Ether', symbol: 'WETH', decimals: 18 } }
85
- */
86
- export declare const getBookTokens: ({ chainId, bookId, }: {
87
- chainId: CHAIN_IDS;
88
- bookId: string;
89
- }) => Promise<{
90
- quote: Currency;
91
- base: Currency;
34
+ quoteCurrency: Currency;
35
+ quoteAmount: bigint;
36
+ baseCurrency: Currency;
37
+ baseAmount: bigint;
92
38
  }>;
93
39
  //# sourceMappingURL=book.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAM7D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,sCAK9B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,QAAQ;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAE1D,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,yCAKlC;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB,KAAG,QAAQ;IAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAEvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,aAAa,yBAGvB;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,QAAQ;IAAE,KAAK,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,QAAQ,CAAA;CAAE,CAE9C,CAAC"}
1
+ {"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAGtD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,YAAY,2CAKtB;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,KAAG,QAAQ;IACV,aAAa,EAAE,QAAQ,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,QAAQ,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB,CA+DA,CAAC"}
@@ -8,7 +8,7 @@ export { getProtocolAnalytics, getUserDailyVolumes, getTopUsersByNativeVolume, g
8
8
  export { getVault } from './vault';
9
9
  export { getTradingBalance, getPortfolioBalance, getAllBalances, getRealTokenBalance, } from './balance';
10
10
  export { checkTokenAllowances, needsVaultDeposit, getOrderSetupStatus, } from './setup';
11
- export { getBookPositionValue, getBookUnitsFromUsdValue, getBookTokens, } from './book';
11
+ export { getTradeInfo } from './book';
12
12
  export { getOrder, getOrderPositionValue } from './order';
13
13
  export { getTradeHistory } from './trade-history';
14
14
  export { getUserVolumeUSD } from './user-volume';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,4BAA4B,EAC5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1stdex/first-sdk",
3
- "version": "1.0.92-beta.2",
3
+ "version": "1.0.92-beta.4",
4
4
  "description": "🛠 An SDK for building applications on top of 1st V2",
5
5
  "files": [
6
6
  "dist"