@1stdex/first-sdk 1.0.92-beta.3 → 1.0.92-beta.5
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/dist/cjs/entities/book/apis/index.js +79 -80
- package/dist/cjs/entities/book/apis/index.js.map +1 -1
- package/dist/cjs/entities/book/apis/position.js +3 -30
- package/dist/cjs/entities/book/apis/position.js.map +1 -1
- package/dist/cjs/entities/market/apis/index.js +2 -2
- package/dist/cjs/entities/market/apis/index.js.map +1 -1
- package/dist/cjs/views/book.js +33 -13
- package/dist/cjs/views/book.js.map +1 -1
- package/dist/cjs/views/index.js +2 -4
- package/dist/cjs/views/index.js.map +1 -1
- package/dist/esm/entities/book/apis/index.js +79 -78
- package/dist/esm/entities/book/apis/index.js.map +1 -1
- package/dist/esm/entities/book/apis/position.js +0 -30
- package/dist/esm/entities/book/apis/position.js.map +1 -1
- package/dist/esm/entities/market/apis/index.js +2 -2
- package/dist/esm/entities/market/apis/index.js.map +1 -1
- package/dist/esm/views/book.js +46 -61
- package/dist/esm/views/book.js.map +1 -1
- package/dist/esm/views/index.js +1 -1
- package/dist/esm/views/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/entities/book/apis/index.d.ts +2 -9
- package/dist/types/entities/book/apis/index.d.ts.map +1 -1
- package/dist/types/entities/book/apis/position.d.ts +0 -9
- package/dist/types/entities/book/apis/position.d.ts.map +1 -1
- package/dist/types/entities/market/apis/index.d.ts.map +1 -1
- package/dist/types/views/book.d.ts +16 -73
- package/dist/types/views/book.d.ts.map +1 -1
- package/dist/types/views/index.d.ts +1 -1
- package/dist/types/views/index.d.ts.map +1 -1
- 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
|
|
6
|
-
export declare const
|
|
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,
|
|
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 fetchBaseFromQuoteAmount: ({ chainId, bookId, tick, quoteAmount, }: {
|
|
12
|
-
chainId: CHAIN_IDS;
|
|
13
|
-
bookId: string;
|
|
14
|
-
tick: bigint;
|
|
15
|
-
quoteAmount: string;
|
|
16
|
-
}) => Promise<{
|
|
17
|
-
bookType: 'bids' | 'asks';
|
|
18
|
-
baseAmount: 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":"
|
|
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,
|
|
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,36 @@
|
|
|
1
1
|
import { CHAIN_IDS } from '../constants/chain-configs/chain';
|
|
2
|
-
import {
|
|
2
|
+
import { CurrencyAmount } from '../entities/currency/types';
|
|
3
3
|
/**
|
|
4
|
-
* Gets
|
|
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
|
|
9
|
-
* @param {bigint}
|
|
8
|
+
* @param {bigint} tick - The tick for the trade
|
|
9
|
+
* @param {bigint} quoteUnits - The number of quote units
|
|
10
10
|
*
|
|
11
|
-
* @returns {Promise<{
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
11
|
+
* @returns {Promise<{ quote: CurrencyAmount; base: CurrencyAmount }>} An object containing:
|
|
12
|
+
* - quote: The quote currency and formatted amount
|
|
13
|
+
* - base: The base currency and formatted amount
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
|
-
* import {
|
|
16
|
+
* import { getTradeInfo } from '@1stdex/first-sdk'
|
|
17
17
|
*
|
|
18
|
-
* const result = await
|
|
18
|
+
* const result = await getTradeInfo({
|
|
19
19
|
* chainId: 421614,
|
|
20
20
|
* bookId: '123456789',
|
|
21
21
|
* tick: 1000n,
|
|
22
|
-
*
|
|
22
|
+
* quoteUnits: 5n,
|
|
23
23
|
* })
|
|
24
|
-
*
|
|
24
|
+
* console.log(`Quote: ${result.quote.value} ${result.quote.currency.symbol}`)
|
|
25
|
+
* console.log(`Base: ${result.base.value} ${result.base.currency.symbol}`)
|
|
25
26
|
*/
|
|
26
|
-
export declare const
|
|
27
|
+
export declare const getTradeInfo: ({ chainId, bookId, tick, quoteUnits, }: {
|
|
27
28
|
chainId: CHAIN_IDS;
|
|
28
29
|
bookId: string;
|
|
29
30
|
tick: bigint;
|
|
30
|
-
|
|
31
|
+
quoteUnits: bigint;
|
|
31
32
|
}) => Promise<{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}>;
|
|
35
|
-
/**
|
|
36
|
-
* Converts base token amount to quote token amount at a specific tick price.
|
|
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 conversion
|
|
41
|
-
* @param {string} baseAmount - The base token amount (raw) as a string
|
|
42
|
-
*
|
|
43
|
-
* @returns {Promise<{ bookType: 'bids' | 'asks'; quoteAmount: bigint }>} An object containing:
|
|
44
|
-
* - bookType: 'bids' for bid books, 'asks' for ask books
|
|
45
|
-
* - quoteAmount: The quote token amount at the given tick price
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* import { getQuoteFromBaseAmount } from '@1stdex/first-sdk'
|
|
49
|
-
*
|
|
50
|
-
* const result = await getQuoteFromBaseAmount({
|
|
51
|
-
* chainId: 421614,
|
|
52
|
-
* bookId: '123456789',
|
|
53
|
-
* tick: -283255n,
|
|
54
|
-
* baseAmount: '970871980108393703474280',
|
|
55
|
-
* })
|
|
56
|
-
* // returns { bookType: 'bids', quoteAmount: 485477000000n }
|
|
57
|
-
*/
|
|
58
|
-
export declare const getBaseFromQuoteAmount: ({ chainId, bookId, tick, quoteAmount, }: {
|
|
59
|
-
chainId: CHAIN_IDS;
|
|
60
|
-
bookId: string;
|
|
61
|
-
tick: bigint;
|
|
62
|
-
quoteAmount: string;
|
|
63
|
-
}) => Promise<{
|
|
64
|
-
bookType: 'bids' | 'asks';
|
|
65
|
-
baseAmount: 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;
|
|
33
|
+
quote: CurrencyAmount;
|
|
34
|
+
base: CurrencyAmount;
|
|
92
35
|
}>;
|
|
93
36
|
//# sourceMappingURL=book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAY,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAGtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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,KAAK,EAAE,cAAc,CAAC;IACtB,IAAI,EAAE,cAAc,CAAC;CACtB,CAiEA,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 {
|
|
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,
|
|
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"}
|