@1stdex/first-sdk 1.0.28 → 1.0.30
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 +3 -1
- package/dist/cjs/entities/book/apis/index.js.map +1 -1
- package/dist/cjs/entities/book/apis/position.js +48 -0
- package/dist/cjs/entities/book/apis/position.js.map +1 -0
- package/dist/cjs/views/book.js +9 -0
- package/dist/cjs/views/book.js.map +1 -0
- package/dist/cjs/views/index.js +3 -1
- package/dist/cjs/views/index.js.map +1 -1
- package/dist/esm/calls/batch/prepare-order-with-setup.js +4 -4
- package/dist/esm/calls/batch/prepare-order-with-setup.js.map +1 -1
- package/dist/esm/entities/book/apis/index.js +1 -0
- package/dist/esm/entities/book/apis/index.js.map +1 -1
- package/dist/esm/entities/book/apis/position.js +58 -0
- package/dist/esm/entities/book/apis/position.js.map +1 -0
- package/dist/esm/views/book.js +28 -0
- package/dist/esm/views/book.js.map +1 -0
- package/dist/esm/views/index.js +1 -0
- package/dist/esm/views/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/calls/batch/prepare-order-with-setup.d.ts +23 -4
- package/dist/types/calls/batch/prepare-order-with-setup.d.ts.map +1 -1
- package/dist/types/entities/book/apis/index.d.ts +1 -0
- package/dist/types/entities/book/apis/index.d.ts.map +1 -1
- package/dist/types/entities/book/apis/position.d.ts +11 -0
- package/dist/types/entities/book/apis/position.d.ts.map +1 -0
- package/dist/types/views/book.d.ts +34 -0
- package/dist/types/views/book.d.ts.map +1 -0
- package/dist/types/views/index.d.ts +1 -0
- package/dist/types/views/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CHAIN_IDS } from '../../constants/chain-configs/chain';
|
|
2
|
-
import { DefaultWriteContractOptions } from '../../types';
|
|
2
|
+
import { DefaultWriteContractOptions, CurrencyFlow } from '../../types';
|
|
3
3
|
export type BatchCall = {
|
|
4
4
|
to: `0x${string}`;
|
|
5
5
|
data: `0x${string}`;
|
|
@@ -17,12 +17,12 @@ export type BatchCall = {
|
|
|
17
17
|
* @param amount The amount to trade (decimal-adjusted string).
|
|
18
18
|
* @param price The limit price.
|
|
19
19
|
* @param options Optional parameters.
|
|
20
|
-
* @returns Promise resolving to
|
|
20
|
+
* @returns Promise resolving to object containing batch calls and order result.
|
|
21
21
|
* @example
|
|
22
22
|
* import { prepareOrderWithSetup } from '@clober/v2-sdk'
|
|
23
23
|
* import { useSmartWallets } from '@privy-io/react-auth/smart-wallets'
|
|
24
24
|
*
|
|
25
|
-
* const calls = await prepareOrderWithSetup({
|
|
25
|
+
* const { calls, result } = await prepareOrderWithSetup({
|
|
26
26
|
* chainId: 421614,
|
|
27
27
|
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69',
|
|
28
28
|
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
@@ -49,5 +49,24 @@ export declare const prepareOrderWithSetup: ({ chainId, userAddress, inputToken,
|
|
|
49
49
|
takeProvider?: `0x${string}`;
|
|
50
50
|
takeReferrer?: `0x${string}`;
|
|
51
51
|
} & DefaultWriteContractOptions;
|
|
52
|
-
}) => Promise<
|
|
52
|
+
}) => Promise<{
|
|
53
|
+
calls: BatchCall[];
|
|
54
|
+
result: {
|
|
55
|
+
make: CurrencyFlow & {
|
|
56
|
+
price: string;
|
|
57
|
+
};
|
|
58
|
+
taken: CurrencyFlow & {
|
|
59
|
+
events: {
|
|
60
|
+
price: string;
|
|
61
|
+
amount: string;
|
|
62
|
+
}[];
|
|
63
|
+
};
|
|
64
|
+
spent: CurrencyFlow & {
|
|
65
|
+
events: {
|
|
66
|
+
price: string;
|
|
67
|
+
amount: string;
|
|
68
|
+
}[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
53
72
|
//# sourceMappingURL=prepare-order-with-setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare-order-with-setup.d.ts","sourceRoot":"","sources":["../../../../src/calls/batch/prepare-order-with-setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAOhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"prepare-order-with-setup.d.ts","sourceRoot":"","sources":["../../../../src/calls/batch/prepare-order-with-setup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,qCAAqC,CAAC;AAOhE,OAAO,EAAE,2BAA2B,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAExE,MAAM,MAAM,SAAS,GAAG;IACtB,EAAE,EAAE,KAAK,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,qBAAqB,+EAQ/B;IACD,OAAO,EAAE,SAAS,CAAC;IACnB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QACR,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;QAC7B,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;QAC7B,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;QAC7B,YAAY,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;KAC9B,GAAG,2BAA2B,CAAC;CACjC,KAAG,QAAQ;IACV,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,MAAM,EAAE;QACN,IAAI,EAAE,YAAY,GAAG;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,CAAC;QACvC,KAAK,EAAE,YAAY,GAAG;YAAE,MAAM,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,MAAM,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,CAAC;QACtE,KAAK,EAAE,YAAY,GAAG;YAAE,MAAM,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAC;gBAAC,MAAM,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,CAAC;KACvE,CAAC;CACH,CA4HA,CAAC"}
|
|
@@ -2,5 +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 } from './position';
|
|
5
6
|
export declare const fetchBook: (publicClient: PublicClient, chainId: CHAIN_IDS, quoteCurrency: Currency, baseCurrency: Currency, useSubgraph: boolean) => Promise<BookModel>;
|
|
6
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,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;
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CHAIN_IDS } from '../../../constants/chain-configs/chain';
|
|
2
|
+
export declare const fetchBookPositionValue: ({ chainId, bookId, tick, units, }: {
|
|
3
|
+
chainId: CHAIN_IDS;
|
|
4
|
+
bookId: string;
|
|
5
|
+
tick: bigint;
|
|
6
|
+
units: bigint;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
bookType: 'bids' | 'asks';
|
|
9
|
+
usdValue: string;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=position.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { CHAIN_IDS } from '../constants/chain-configs/chain';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the USD value for a book position at a specific tick with given units.
|
|
4
|
+
*
|
|
5
|
+
* @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
|
|
6
|
+
* @param {string} bookId - The book ID as a string
|
|
7
|
+
* @param {bigint} tick - The tick for the order
|
|
8
|
+
* @param {bigint} units - The number of units
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<{ bookType: 'bids' | 'asks'; usdValue: string }>} An object containing:
|
|
11
|
+
* - bookType: 'bids' for bid books, 'asks' for ask books
|
|
12
|
+
* - usdValue: The USD value of the position as a string
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* import { getBookPositionValue } from '@clober/v2-sdk'
|
|
16
|
+
*
|
|
17
|
+
* const result = await getBookPositionValue({
|
|
18
|
+
* chainId: 421614,
|
|
19
|
+
* bookId: '123456789',
|
|
20
|
+
* tick: 1000n,
|
|
21
|
+
* units: 5n,
|
|
22
|
+
* })
|
|
23
|
+
* // returns { bookType: 'bids', usdValue: '1234.56' }
|
|
24
|
+
*/
|
|
25
|
+
export declare const getBookPositionValue: ({ chainId, bookId, tick, units, }: {
|
|
26
|
+
chainId: CHAIN_IDS;
|
|
27
|
+
bookId: string;
|
|
28
|
+
tick: bigint;
|
|
29
|
+
units: bigint;
|
|
30
|
+
}) => Promise<{
|
|
31
|
+
bookType: 'bids' | 'asks';
|
|
32
|
+
usdValue: string;
|
|
33
|
+
}>;
|
|
34
|
+
//# sourceMappingURL=book.d.ts.map
|
|
@@ -0,0 +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,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"}
|
|
@@ -8,4 +8,5 @@ export { getProtocolAnalytics, getUserDailyVolumes, getTopUsersByNativeVolume, g
|
|
|
8
8
|
export { getVault } from './vault';
|
|
9
9
|
export { getTradingBalance, getPortfolioBalance } from './balance';
|
|
10
10
|
export { isOrderOperatorApproved, checkTokenAllowances, needsVaultDeposit, getOrderSetupStatus, } from './setup';
|
|
11
|
+
export { getBookPositionValue } from './book';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,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,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,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,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,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,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC"}
|