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

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.
@@ -2,6 +2,13 @@ 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 } from './position';
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
+ }>;
6
13
  export declare const fetchBook: (publicClient: PublicClient, chainId: CHAIN_IDS, quoteCurrency: Currency, baseCurrency: Currency, useSubgraph: boolean) => Promise<BookModel>;
7
14
  //# 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,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,KACnB,QAAQ,SAAS,CAuGnB,CAAC"}
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"}
@@ -8,4 +8,13 @@ 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
+ }>;
11
20
  //# 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"}
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,4 +1,5 @@
1
1
  import { CHAIN_IDS } from '../constants/chain-configs/chain';
2
+ import { Currency } from '../entities/currency/types';
2
3
  /**
3
4
  * Gets the USD value for a book position at a specific tick with given units.
4
5
  *
@@ -31,4 +32,62 @@ export declare const getBookPositionValue: ({ chainId, bookId, tick, units, }: {
31
32
  bookType: 'bids' | 'asks';
32
33
  usdValue: string;
33
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;
92
+ }>;
34
93
  //# 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;AAG7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,oBAAoB,sCAK9B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,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TopUsersByNativeVolume, 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 } from './book';
11
+ export { getBookPositionValue, getBookUnitsFromUsdValue, getBookTokens, } 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,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1stdex/first-sdk",
3
- "version": "1.0.91",
3
+ "version": "1.0.92-beta.2",
4
4
  "description": "🛠 An SDK for building applications on top of 1st V2",
5
5
  "files": [
6
6
  "dist"