@clober/v2-sdk 0.0.3 → 0.0.4-6.dev
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/README.md +12 -4
- package/dist/cjs/abis/core/book-manager-abi.js +112 -0
- package/dist/cjs/abis/core/book-manager-abi.js.map +1 -0
- package/dist/cjs/abis/core/book-viewer-abi.js +321 -0
- package/dist/cjs/abis/core/book-viewer-abi.js.map +1 -0
- package/dist/cjs/abis/core/controller-abi.js +29 -24
- package/dist/cjs/abis/core/controller-abi.js.map +1 -1
- package/dist/cjs/apis/chart-logs.js +154 -0
- package/dist/cjs/apis/chart-logs.js.map +1 -0
- package/dist/cjs/apis/market.js +63 -34
- package/dist/cjs/apis/market.js.map +1 -1
- package/dist/cjs/apis/open-order.js +60 -25
- package/dist/cjs/apis/open-order.js.map +1 -1
- package/dist/cjs/approval.js +79 -32
- package/dist/cjs/approval.js.map +1 -1
- package/dist/cjs/call.js +346 -245
- package/dist/cjs/call.js.map +1 -1
- package/dist/cjs/constants/addresses.js +26 -1
- package/dist/cjs/constants/addresses.js.map +1 -1
- package/dist/cjs/constants/chain.js +19 -1
- package/dist/cjs/constants/chain.js.map +1 -1
- package/dist/cjs/constants/client.js +18 -0
- package/dist/cjs/constants/client.js.map +1 -0
- package/dist/cjs/constants/currency.js +28 -2
- package/dist/cjs/constants/currency.js.map +1 -1
- package/dist/cjs/constants/fee.js +17 -2
- package/dist/cjs/constants/fee.js.map +1 -1
- package/dist/cjs/constants/subgraph.js +57 -0
- package/dist/cjs/constants/subgraph.js.map +1 -0
- package/dist/cjs/constants/test-chain.js +27 -0
- package/dist/cjs/constants/test-chain.js.map +1 -0
- package/dist/cjs/index.js +20 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/book.js +47 -29
- package/dist/cjs/model/book.js.map +1 -1
- package/dist/cjs/model/chart-log.js +3 -0
- package/dist/cjs/model/chart-log.js.map +1 -0
- package/dist/cjs/model/market.js +43 -182
- package/dist/cjs/model/market.js.map +1 -1
- package/dist/cjs/signature.js +25 -25
- package/dist/cjs/signature.js.map +1 -1
- package/dist/cjs/type.js +16 -1
- package/dist/cjs/type.js.map +1 -1
- package/dist/cjs/utils/allowance.js +40 -0
- package/dist/cjs/utils/allowance.js.map +1 -0
- package/dist/cjs/utils/approval.js +3 -8
- package/dist/cjs/utils/approval.js.map +1 -1
- package/dist/cjs/utils/bigint.js +9 -0
- package/dist/cjs/utils/bigint.js.map +1 -0
- package/dist/cjs/utils/book-id.js +7 -7
- package/dist/cjs/utils/book-id.js.map +1 -1
- package/dist/cjs/utils/build-transaction.js +10 -13
- package/dist/cjs/utils/build-transaction.js.map +1 -1
- package/dist/cjs/utils/currency.js +166 -0
- package/dist/cjs/utils/currency.js.map +1 -0
- package/dist/cjs/utils/decorator.js +15 -0
- package/dist/cjs/utils/decorator.js.map +1 -0
- package/dist/cjs/utils/open.js +36 -0
- package/dist/cjs/utils/open.js.map +1 -0
- package/dist/cjs/utils/order.js +102 -0
- package/dist/cjs/utils/order.js.map +1 -0
- package/dist/cjs/utils/prices.js +1 -1
- package/dist/cjs/utils/unit-size.js +49 -0
- package/dist/cjs/utils/unit-size.js.map +1 -0
- package/dist/cjs/utils.js +14 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/view.js +64 -49
- package/dist/cjs/view.js.map +1 -1
- package/dist/esm/abis/core/book-manager-abi.js +109 -0
- package/dist/esm/abis/core/book-manager-abi.js.map +1 -0
- package/dist/esm/abis/core/book-viewer-abi.js +318 -0
- package/dist/esm/abis/core/book-viewer-abi.js.map +1 -0
- package/dist/esm/abis/core/controller-abi.js +29 -24
- package/dist/esm/abis/core/controller-abi.js.map +1 -1
- package/dist/esm/apis/chart-logs.js +150 -0
- package/dist/esm/apis/chart-logs.js.map +1 -0
- package/dist/esm/apis/market.js +63 -34
- package/dist/esm/apis/market.js.map +1 -1
- package/dist/esm/apis/open-order.js +61 -25
- package/dist/esm/apis/open-order.js.map +1 -1
- package/dist/esm/approval.js +118 -45
- package/dist/esm/approval.js.map +1 -1
- package/dist/esm/call.js +464 -342
- package/dist/esm/call.js.map +1 -1
- package/dist/esm/constants/addresses.js +26 -1
- package/dist/esm/constants/addresses.js.map +1 -1
- package/dist/esm/constants/chain.js +20 -2
- package/dist/esm/constants/chain.js.map +1 -1
- package/dist/esm/constants/client.js +14 -0
- package/dist/esm/constants/client.js.map +1 -0
- package/dist/esm/constants/currency.js +28 -2
- package/dist/esm/constants/currency.js.map +1 -1
- package/dist/esm/constants/fee.js +17 -2
- package/dist/esm/constants/fee.js.map +1 -1
- package/dist/esm/constants/subgraph.js +53 -0
- package/dist/esm/constants/subgraph.js.map +1 -0
- package/dist/esm/constants/test-chain.js +24 -0
- package/dist/esm/constants/test-chain.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/book.js +47 -29
- package/dist/esm/model/book.js.map +1 -1
- package/dist/esm/model/chart-log.js +2 -0
- package/dist/esm/model/chart-log.js.map +1 -0
- package/dist/esm/model/market.js +44 -187
- package/dist/esm/model/market.js.map +1 -1
- package/dist/esm/signature.js +40 -45
- package/dist/esm/signature.js.map +1 -1
- package/dist/esm/type.js +15 -0
- package/dist/esm/type.js.map +1 -1
- package/dist/esm/utils/allowance.js +36 -0
- package/dist/esm/utils/allowance.js.map +1 -0
- package/dist/esm/utils/approval.js +3 -8
- package/dist/esm/utils/approval.js.map +1 -1
- package/dist/esm/utils/bigint.js +5 -0
- package/dist/esm/utils/bigint.js.map +1 -0
- package/dist/esm/utils/book-id.js +7 -7
- package/dist/esm/utils/book-id.js.map +1 -1
- package/dist/esm/utils/build-transaction.js +11 -14
- package/dist/esm/utils/build-transaction.js.map +1 -1
- package/dist/esm/utils/currency.js +161 -0
- package/dist/esm/utils/currency.js.map +1 -0
- package/dist/esm/utils/decorator.js +11 -0
- package/dist/esm/utils/decorator.js.map +1 -0
- package/dist/esm/utils/open.js +32 -0
- package/dist/esm/utils/open.js.map +1 -0
- package/dist/esm/utils/order.js +98 -0
- package/dist/esm/utils/order.js.map +1 -0
- package/dist/esm/utils/prices.js +1 -1
- package/dist/esm/utils/unit-size.js +45 -0
- package/dist/esm/utils/unit-size.js.map +1 -0
- package/dist/esm/utils.js +4 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/view.js +164 -71
- package/dist/esm/view.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/abis/core/book-manager-abi.d.ts +82 -0
- package/dist/types/abis/core/book-manager-abi.d.ts.map +1 -0
- package/dist/types/abis/core/book-viewer-abi.d.ts +243 -0
- package/dist/types/abis/core/book-viewer-abi.d.ts.map +1 -0
- package/dist/types/abis/core/controller-abi.d.ts +23 -19
- package/dist/types/abis/core/controller-abi.d.ts.map +1 -1
- package/dist/types/apis/chart-logs.d.ts +5 -0
- package/dist/types/apis/chart-logs.d.ts.map +1 -0
- package/dist/types/apis/market.d.ts +1 -1
- package/dist/types/apis/market.d.ts.map +1 -1
- package/dist/types/apis/open-order.d.ts +4 -3
- package/dist/types/apis/open-order.d.ts.map +1 -1
- package/dist/types/approval.d.ts +50 -15
- package/dist/types/approval.d.ts.map +1 -1
- package/dist/types/call.d.ts +191 -123
- package/dist/types/call.d.ts.map +1 -1
- package/dist/types/constants/addresses.d.ts.map +1 -1
- package/dist/types/constants/chain.d.ts +6 -2
- package/dist/types/constants/chain.d.ts.map +1 -1
- package/dist/types/constants/client.d.ts +5 -0
- package/dist/types/constants/client.d.ts.map +1 -0
- package/dist/types/constants/currency.d.ts.map +1 -1
- package/dist/types/constants/fee.d.ts +7 -2
- package/dist/types/constants/fee.d.ts.map +1 -1
- package/dist/types/constants/subgraph.d.ts +10 -0
- package/dist/types/constants/subgraph.d.ts.map +1 -0
- package/dist/types/constants/test-chain.d.ts +3 -0
- package/dist/types/constants/test-chain.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model/book.d.ts +13 -29
- package/dist/types/model/book.d.ts.map +1 -1
- package/dist/types/model/chart-log.d.ts +9 -0
- package/dist/types/model/chart-log.d.ts.map +1 -0
- package/dist/types/model/depth.d.ts +3 -5
- package/dist/types/model/depth.d.ts.map +1 -1
- package/dist/types/model/market.d.ts +15 -19
- package/dist/types/model/market.d.ts.map +1 -1
- package/dist/types/model/open-order.d.ts +16 -8
- package/dist/types/model/open-order.d.ts.map +1 -1
- package/dist/types/signature.d.ts +23 -25
- package/dist/types/signature.d.ts.map +1 -1
- package/dist/types/type.d.ts +54 -8
- package/dist/types/type.d.ts.map +1 -1
- package/dist/types/utils/allowance.d.ts +3 -0
- package/dist/types/utils/allowance.d.ts.map +1 -0
- package/dist/types/utils/approval.d.ts +1 -1
- package/dist/types/utils/approval.d.ts.map +1 -1
- package/dist/types/utils/bigint.d.ts +2 -0
- package/dist/types/utils/bigint.d.ts.map +1 -0
- package/dist/types/utils/book-id.d.ts +2 -1
- package/dist/types/utils/book-id.d.ts.map +1 -1
- package/dist/types/utils/build-transaction.d.ts +3 -4
- package/dist/types/utils/build-transaction.d.ts.map +1 -1
- package/dist/types/utils/currency.d.ts +7 -0
- package/dist/types/utils/currency.d.ts.map +1 -0
- package/dist/types/utils/decorator.d.ts +6 -0
- package/dist/types/utils/decorator.d.ts.map +1 -0
- package/dist/types/utils/open.d.ts +3 -0
- package/dist/types/utils/open.d.ts.map +1 -0
- package/dist/types/utils/order.d.ts +8 -0
- package/dist/types/utils/order.d.ts.map +1 -0
- package/dist/types/utils/prices.d.ts +1 -1
- package/dist/types/utils/unit-size.d.ts +4 -0
- package/dist/types/utils/unit-size.d.ts.map +1 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/view.d.ts +164 -52
- package/dist/types/view.d.ts.map +1 -1
- package/package.json +1 -8
- package/dist/cjs/abis/core/params-abi.js +0 -62
- package/dist/cjs/abis/core/params-abi.js.map +0 -1
- package/dist/cjs/apis/currency.js +0 -87
- package/dist/cjs/apis/currency.js.map +0 -1
- package/dist/cjs/apis/subgraph.js +0 -26
- package/dist/cjs/apis/subgraph.js.map +0 -1
- package/dist/cjs/constants/subgraph-url.js +0 -8
- package/dist/cjs/constants/subgraph-url.js.map +0 -1
- package/dist/cjs/utils/unit.js +0 -38
- package/dist/cjs/utils/unit.js.map +0 -1
- package/dist/esm/abis/core/params-abi.js +0 -59
- package/dist/esm/abis/core/params-abi.js.map +0 -1
- package/dist/esm/apis/currency.js +0 -83
- package/dist/esm/apis/currency.js.map +0 -1
- package/dist/esm/apis/subgraph.js +0 -22
- package/dist/esm/apis/subgraph.js.map +0 -1
- package/dist/esm/constants/subgraph-url.js +0 -5
- package/dist/esm/constants/subgraph-url.js.map +0 -1
- package/dist/esm/utils/unit.js +0 -34
- package/dist/esm/utils/unit.js.map +0 -1
- package/dist/types/abis/core/params-abi.d.ts +0 -21
- package/dist/types/abis/core/params-abi.d.ts.map +0 -1
- package/dist/types/apis/currency.d.ts +0 -4
- package/dist/types/apis/currency.d.ts.map +0 -1
- package/dist/types/apis/subgraph.d.ts +0 -3
- package/dist/types/apis/subgraph.d.ts.map +0 -1
- package/dist/types/constants/subgraph-url.d.ts +0 -5
- package/dist/types/constants/subgraph-url.d.ts.map +0 -1
- package/dist/types/utils/unit.d.ts +0 -4
- package/dist/types/utils/unit.d.ts.map +0 -1
package/dist/types/view.d.ts
CHANGED
|
@@ -1,26 +1,53 @@
|
|
|
1
1
|
import { CHAIN_IDS } from './constants/chain';
|
|
2
|
-
import { Market } from './type';
|
|
3
|
-
import {
|
|
2
|
+
import type { ChartLog, DefaultOptions, Market } from './type';
|
|
3
|
+
import { CHART_LOG_INTERVALS } from './type';
|
|
4
|
+
import { type OpenOrder } from './model/open-order';
|
|
5
|
+
/**
|
|
6
|
+
* Get contract addresses by chain id
|
|
7
|
+
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
8
|
+
* @returns Contract addresses
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { getContractAddresses } from '@clober/v2-sdk'
|
|
12
|
+
*
|
|
13
|
+
* const addresses = await getContractAddresses({
|
|
14
|
+
* chainId: 421614,
|
|
15
|
+
* })
|
|
16
|
+
*/
|
|
17
|
+
export declare const getContractAddresses: ({ chainId }: {
|
|
18
|
+
chainId: CHAIN_IDS;
|
|
19
|
+
}) => {
|
|
20
|
+
Controller: `0x${string}`;
|
|
21
|
+
BookManager: `0x${string}`;
|
|
22
|
+
BookViewer: `0x${string}`;
|
|
23
|
+
};
|
|
4
24
|
/**
|
|
5
25
|
* Get market information by chain id and token addresses
|
|
6
26
|
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
7
27
|
* @param token0 - token0 address
|
|
8
28
|
* @param token1 - token1 address
|
|
9
29
|
* @param options
|
|
30
|
+
* @param options.n - number of depth levels to fetch
|
|
10
31
|
* @param options.rpcUrl - RPC URL of the blockchain
|
|
32
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
11
33
|
* @returns A market {@link Market}
|
|
12
34
|
*
|
|
13
35
|
* @example
|
|
14
36
|
* import { getMarket } from '@clober/v2-sdk'
|
|
15
37
|
*
|
|
16
|
-
* const market = await getMarket(
|
|
17
|
-
* 421614,
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* )
|
|
38
|
+
* const market = await getMarket({
|
|
39
|
+
* chainId: 421614,
|
|
40
|
+
* token0: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
41
|
+
* token1: '0x0000000000000000000000000000000000000000',
|
|
42
|
+
* })
|
|
21
43
|
*/
|
|
22
|
-
export declare const getMarket: (
|
|
23
|
-
|
|
44
|
+
export declare const getMarket: (args: {
|
|
45
|
+
chainId: CHAIN_IDS;
|
|
46
|
+
token0: `0x${string}`;
|
|
47
|
+
token1: `0x${string}`;
|
|
48
|
+
options?: {
|
|
49
|
+
n?: number;
|
|
50
|
+
} & DefaultOptions;
|
|
24
51
|
}) => Promise<Market>;
|
|
25
52
|
/**
|
|
26
53
|
* Calculates the expected output for a given input amount, based on the provided market data.
|
|
@@ -32,28 +59,30 @@ export declare const getMarket: (chainId: CHAIN_IDS, token0: `0x${string}`, toke
|
|
|
32
59
|
* @param options
|
|
33
60
|
* @param options.limitPrice The maximum limit price to spend.
|
|
34
61
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
62
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
35
63
|
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
36
64
|
* @example
|
|
37
65
|
* import { getExpectedOutput } from '@clober/v2-sdk'
|
|
38
66
|
*
|
|
39
|
-
* const { takenAmount,
|
|
40
|
-
* 421614,
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* )
|
|
67
|
+
* const { takenAmount, spentAmount } = await getExpectedOutput({
|
|
68
|
+
* chainId: 421614,
|
|
69
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
70
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
71
|
+
* amountIn: '1000.123', // spend 1000.123 USDC
|
|
72
|
+
* })
|
|
45
73
|
*/
|
|
46
|
-
export declare const getExpectedOutput: (
|
|
47
|
-
|
|
48
|
-
|
|
74
|
+
export declare const getExpectedOutput: (args: {
|
|
75
|
+
chainId: CHAIN_IDS;
|
|
76
|
+
inputToken: `0x${string}`;
|
|
77
|
+
outputToken: `0x${string}`;
|
|
78
|
+
amountIn: string;
|
|
79
|
+
options?: {
|
|
80
|
+
limitPrice?: string;
|
|
81
|
+
} & DefaultOptions;
|
|
49
82
|
}) => Promise<{
|
|
50
83
|
takenAmount: string;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
bookId: bigint;
|
|
54
|
-
takenAmount: bigint;
|
|
55
|
-
spendAmount: bigint;
|
|
56
|
-
}[];
|
|
84
|
+
spentAmount: string;
|
|
85
|
+
bookId: bigint;
|
|
57
86
|
}>;
|
|
58
87
|
/**
|
|
59
88
|
* Calculates the expected input for a given output amount, based on the provided market data.
|
|
@@ -65,28 +94,30 @@ export declare const getExpectedOutput: (chainId: CHAIN_IDS, inputToken: `0x${st
|
|
|
65
94
|
* @param options
|
|
66
95
|
* @param options.limitPrice The maximum limit price to take.
|
|
67
96
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
68
|
-
* @
|
|
97
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
98
|
+
* @returns A Promise resolving to an object containing the taken amount, spent amount and result of the calculation.
|
|
69
99
|
* @example
|
|
70
100
|
* import { getExpectedInput } from '@clober/v2-sdk'
|
|
71
101
|
*
|
|
72
|
-
* const { takenAmount,
|
|
73
|
-
* 421614,
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* )
|
|
102
|
+
* const { takenAmount, spentAmount } = await getExpectedInput({
|
|
103
|
+
* chainId: 421614,
|
|
104
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
105
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
106
|
+
* amountOut: '0.1', // take 0.1 ETH
|
|
107
|
+
* })
|
|
78
108
|
*/
|
|
79
|
-
export declare const getExpectedInput: (
|
|
80
|
-
|
|
81
|
-
|
|
109
|
+
export declare const getExpectedInput: (args: {
|
|
110
|
+
chainId: CHAIN_IDS;
|
|
111
|
+
inputToken: `0x${string}`;
|
|
112
|
+
outputToken: `0x${string}`;
|
|
113
|
+
amountOut: string;
|
|
114
|
+
options?: {
|
|
115
|
+
limitPrice?: string;
|
|
116
|
+
} & DefaultOptions;
|
|
82
117
|
}) => Promise<{
|
|
83
118
|
takenAmount: string;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
bookId: bigint;
|
|
87
|
-
takenAmount: bigint;
|
|
88
|
-
spendAmount: bigint;
|
|
89
|
-
}[];
|
|
119
|
+
spentAmount: string;
|
|
120
|
+
bookId: bigint;
|
|
90
121
|
}>;
|
|
91
122
|
/**
|
|
92
123
|
* Retrieves the open order with the specified ID on the given chain.
|
|
@@ -95,17 +126,20 @@ export declare const getExpectedInput: (chainId: CHAIN_IDS, inputToken: `0x${str
|
|
|
95
126
|
* @param {string} id The ID of the open order.
|
|
96
127
|
* @param options
|
|
97
128
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
129
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
98
130
|
* @returns {Promise<OpenOrder>} Promise resolving to the open order object, or undefined if not found.
|
|
99
131
|
* @example
|
|
100
132
|
* import { getOpenOrder } from '@clober/v2-sdk'
|
|
101
133
|
*
|
|
102
|
-
* const openOrder = await getOpenOrder(
|
|
103
|
-
* 421614,
|
|
104
|
-
*
|
|
105
|
-
* )
|
|
134
|
+
* const openOrder = await getOpenOrder({
|
|
135
|
+
* chainId: 421614,
|
|
136
|
+
* id: '46223845323662364279893361453861711542636620039907198451770258805035840307200'
|
|
137
|
+
* })
|
|
106
138
|
*/
|
|
107
|
-
export declare const getOpenOrder: (
|
|
108
|
-
|
|
139
|
+
export declare const getOpenOrder: (args: {
|
|
140
|
+
chainId: CHAIN_IDS;
|
|
141
|
+
id: string;
|
|
142
|
+
options?: DefaultOptions;
|
|
109
143
|
}) => Promise<OpenOrder>;
|
|
110
144
|
/**
|
|
111
145
|
* Retrieves open orders for the specified user on the given chain.
|
|
@@ -114,16 +148,94 @@ export declare const getOpenOrder: (chainId: CHAIN_IDS, id: string, options?: {
|
|
|
114
148
|
* @param {`0x${string}`} userAddress The Ethereum address of the user.
|
|
115
149
|
* @param options
|
|
116
150
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
151
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
117
152
|
* @returns {Promise<OpenOrder[]>} Promise resolving to an array of open orders.
|
|
118
153
|
* @example
|
|
119
154
|
* import { getOpenOrders } from '@clober/v2-sdk'
|
|
120
155
|
*
|
|
121
|
-
* const openOrders = await getOpenOrders(
|
|
122
|
-
* 421614,
|
|
123
|
-
*
|
|
124
|
-
* )
|
|
156
|
+
* const openOrders = await getOpenOrders({
|
|
157
|
+
* chainId: 421614,
|
|
158
|
+
* userAddress: '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
|
|
159
|
+
* })
|
|
125
160
|
*/
|
|
126
|
-
export declare const getOpenOrders: (
|
|
127
|
-
|
|
161
|
+
export declare const getOpenOrders: (args: {
|
|
162
|
+
chainId: CHAIN_IDS;
|
|
163
|
+
userAddress: `0x${string}`;
|
|
164
|
+
options?: DefaultOptions;
|
|
128
165
|
}) => Promise<OpenOrder[]>;
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves the latest chart log for a specific market.
|
|
168
|
+
*
|
|
169
|
+
* @param {CHAIN_IDS} params.chainId - The ID of the blockchain.
|
|
170
|
+
* @param {`0x${string}`} params.quote - The address of the quote token.
|
|
171
|
+
* @param {`0x${string}`} params.base - The address of the base token.
|
|
172
|
+
* @returns {Promise<ChartLog>} A promise that resolves with the latest chart log.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* import { getLatestChartLog } from '@clober/v2-sdk'
|
|
176
|
+
*
|
|
177
|
+
* const logs = await getLatestChartLog({
|
|
178
|
+
* chainId: 421614,
|
|
179
|
+
* quote: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
180
|
+
* base: '0x0000000000000000000000000000000000000000',
|
|
181
|
+
* })
|
|
182
|
+
*/
|
|
183
|
+
export declare const getLatestChartLog: (args: {
|
|
184
|
+
chainId: CHAIN_IDS;
|
|
185
|
+
quote: `0x${string}`;
|
|
186
|
+
base: `0x${string}`;
|
|
187
|
+
}) => Promise<ChartLog>;
|
|
188
|
+
/**
|
|
189
|
+
* Retrieves chart logs for a specific market within a specified time interval.
|
|
190
|
+
*
|
|
191
|
+
* @param {CHAIN_IDS} params.chainId - The ID of the chain.
|
|
192
|
+
* @param {`0x${string}`} params.quote - The address of the quote token.
|
|
193
|
+
* @param {`0x${string}`} params.base - The address of the base token.
|
|
194
|
+
* @param {CHART_LOG_INTERVALS} params.intervalType - The type of time interval for the chart logs.
|
|
195
|
+
* @param {number} params.from - The start of the time interval (Unix timestamp in seconds).
|
|
196
|
+
* @param {number} params.to - The end of the time interval (Unix timestamp in seconds).
|
|
197
|
+
* @returns {Promise<ChartLog[]>} A promise that resolves with an array of chart logs within the specified interval.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* import { getLatestChartLog, CHART_LOG_INTERVALS } from '@clober/v2-sdk'
|
|
201
|
+
*
|
|
202
|
+
* const logs = await getChartLogs({
|
|
203
|
+
* chainId: 421614,
|
|
204
|
+
* quote: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
205
|
+
* base: '0x0000000000000000000000000000000000000000',
|
|
206
|
+
* intervalType: CHART_LOG_INTERVALS.oneDay,
|
|
207
|
+
* from: 1687305600,
|
|
208
|
+
* to: 1713312000,
|
|
209
|
+
* })
|
|
210
|
+
*/
|
|
211
|
+
export declare const getChartLogs: (args: {
|
|
212
|
+
chainId: CHAIN_IDS;
|
|
213
|
+
quote: `0x${string}`;
|
|
214
|
+
base: `0x${string}`;
|
|
215
|
+
intervalType: CHART_LOG_INTERVALS;
|
|
216
|
+
from: number;
|
|
217
|
+
to: number;
|
|
218
|
+
}) => Promise<ChartLog[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Retrieves the quote token address for a given chain and a pair of tokens.
|
|
221
|
+
*
|
|
222
|
+
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
223
|
+
* @param token0 - token0 address
|
|
224
|
+
* @param token1 - token1 address
|
|
225
|
+
* @returns {string} The address of the quote token.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* import { getQuoteToken } from '@clober/v2-sdk'
|
|
229
|
+
*
|
|
230
|
+
* const quote = await getQuoteToken({
|
|
231
|
+
* chainId: 421614,
|
|
232
|
+
* token0: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
233
|
+
* token1: '0x0000000000000000000000000000000000000000',
|
|
234
|
+
* })
|
|
235
|
+
*/
|
|
236
|
+
export declare const getQuoteToken: ({ chainId, token0, token1, }: {
|
|
237
|
+
chainId: CHAIN_IDS;
|
|
238
|
+
token0: `0x${string}`;
|
|
239
|
+
token1: `0x${string}`;
|
|
240
|
+
}) => `0x${string}`;
|
|
129
241
|
//# sourceMappingURL=view.d.ts.map
|
package/dist/types/view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAA;AAI5C,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAMnD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,gBAAiB;IAAE,OAAO,EAAE,SAAS,CAAA;CAAE;;;;CAEvE,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,SAAS;aAOT,SAAS;YACV,KAAK,MAAM,EAAE;YACb,KAAK,MAAM,EAAE;cACX;QACR,CAAC,CAAC,EAAE,MAAM,CAAA;KACX,GAAG,cAAc;qBAoCrB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,iBAAiB;aAQjB,SAAS;gBACN,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;cAChB,MAAM;cACN;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc;;iBAErC,MAAM;iBACN,MAAM;YACX,MAAM;EAgCjB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,gBAAgB;aAQhB,SAAS;gBACN,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;eACf,MAAM;cACP;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc;;iBAErC,MAAM;iBACN,MAAM;YACX,MAAM;EAgCjB,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY;aAKZ,SAAS;QACd,MAAM;cACA,cAAc;wBAI3B,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa;aAKb,SAAS;iBACL,KAAK,MAAM,EAAE;cAChB,cAAc;0BAI3B,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,iBAAiB;aAMjB,SAAS;WACX,KAAK,MAAM,EAAE;UACd,KAAK,MAAM,EAAE;uBAItB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,eAAO,MAAM,YAAY;aASZ,SAAS;WACX,KAAK,MAAM,EAAE;UACd,KAAK,MAAM,EAAE;kBACL,mBAAmB;UAC3B,MAAM;QACR,MAAM;yBAIb,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,aAAa,iCAIvB;IACD,OAAO,EAAE,SAAS,CAAA;IAClB,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;IACrB,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;CACtB,KAAG,KAAK,MAAM,EAEd,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clober/v2-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46.dev",
|
|
4
4
|
"description": "🛠 An SDK for building applications on top of Clober V2",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -9,13 +9,6 @@
|
|
|
9
9
|
"module": "./dist/esm/index.js",
|
|
10
10
|
"types": "./dist/types/index.d.ts",
|
|
11
11
|
"typings": "./dist/types/index.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/types/index.d.ts",
|
|
15
|
-
"import": "./dist/esm/index.js",
|
|
16
|
-
"default": "./dist/cjs/index.js"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
12
|
"repository": {
|
|
20
13
|
"type": "git",
|
|
21
14
|
"url": "git+https://github.com/clober-dex/v2-sdk.git"
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAKE_ORDER_PARAMS_ABI = exports.TAKE_ORDER_PARAMS_ABI = void 0;
|
|
4
|
-
exports.TAKE_ORDER_PARAMS_ABI = [
|
|
5
|
-
{
|
|
6
|
-
components: [
|
|
7
|
-
{
|
|
8
|
-
internalType: 'BookId',
|
|
9
|
-
name: 'id',
|
|
10
|
-
type: 'uint192',
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
internalType: 'uint256',
|
|
14
|
-
name: 'limitPrice',
|
|
15
|
-
type: 'uint256',
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
internalType: 'uint256',
|
|
19
|
-
name: 'quoteAmount',
|
|
20
|
-
type: 'uint256',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
internalType: 'bytes',
|
|
24
|
-
name: 'hookData',
|
|
25
|
-
type: 'bytes',
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
internalType: 'struct IController.TakeOrderParams',
|
|
29
|
-
name: 'params',
|
|
30
|
-
type: 'tuple',
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
exports.MAKE_ORDER_PARAMS_ABI = [
|
|
34
|
-
{
|
|
35
|
-
components: [
|
|
36
|
-
{
|
|
37
|
-
internalType: 'BookId',
|
|
38
|
-
name: 'id',
|
|
39
|
-
type: 'uint192',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
internalType: 'Tick',
|
|
43
|
-
name: 'tick',
|
|
44
|
-
type: 'int24',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
internalType: 'uint256',
|
|
48
|
-
name: 'quoteAmount',
|
|
49
|
-
type: 'uint256',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
internalType: 'bytes',
|
|
53
|
-
name: 'hookData',
|
|
54
|
-
type: 'bytes',
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
internalType: 'struct IController.MakeOrderParams',
|
|
58
|
-
name: 'params',
|
|
59
|
-
type: 'tuple',
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
//# sourceMappingURL=params-abi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params-abi.js","sourceRoot":"","sources":["../../../../src/abis/core/params-abi.ts"],"names":[],"mappings":";;;AAAa,QAAA,qBAAqB,GAAG;IACnC;QACE,UAAU,EAAE;YACV;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;aACd;SACF;QACD,YAAY,EAAE,oCAAoC;QAClD,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;KACd;CACF,CAAA;AAEY,QAAA,qBAAqB,GAAG;IACnC;QACE,UAAU,EAAE;YACV;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,MAAM;gBACpB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;aACd;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;aACd;SACF;QACD,YAAY,EAAE,oCAAoC;QAClD,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;KACd;CACF,CAAA"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchCurrency = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const chain_1 = require("../constants/chain");
|
|
6
|
-
const _abi = [
|
|
7
|
-
{
|
|
8
|
-
inputs: [],
|
|
9
|
-
name: 'name',
|
|
10
|
-
outputs: [
|
|
11
|
-
{
|
|
12
|
-
internalType: 'string',
|
|
13
|
-
name: '',
|
|
14
|
-
type: 'string',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
stateMutability: 'view',
|
|
18
|
-
type: 'function',
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
inputs: [],
|
|
22
|
-
name: 'symbol',
|
|
23
|
-
outputs: [
|
|
24
|
-
{
|
|
25
|
-
internalType: 'string',
|
|
26
|
-
name: '',
|
|
27
|
-
type: 'string',
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
stateMutability: 'view',
|
|
31
|
-
type: 'function',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
inputs: [],
|
|
35
|
-
name: 'decimals',
|
|
36
|
-
outputs: [
|
|
37
|
-
{
|
|
38
|
-
internalType: 'uint8',
|
|
39
|
-
name: '',
|
|
40
|
-
type: 'uint8',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
stateMutability: 'view',
|
|
44
|
-
type: 'function',
|
|
45
|
-
},
|
|
46
|
-
];
|
|
47
|
-
const fetchCurrency = async (chainId, address, rpcUrl) => {
|
|
48
|
-
if ((0, viem_1.isAddressEqual)(address, viem_1.zeroAddress)) {
|
|
49
|
-
return {
|
|
50
|
-
address: viem_1.zeroAddress,
|
|
51
|
-
name: 'Ethereum',
|
|
52
|
-
symbol: 'ETH',
|
|
53
|
-
decimals: 18,
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
57
|
-
chain: chain_1.CHAIN_MAP[chainId],
|
|
58
|
-
transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
|
|
59
|
-
});
|
|
60
|
-
const [{ result: name }, { result: symbol }, { result: decimals }] = await publicClient.multicall({
|
|
61
|
-
contracts: [
|
|
62
|
-
{
|
|
63
|
-
address,
|
|
64
|
-
abi: _abi,
|
|
65
|
-
functionName: 'name',
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
address,
|
|
69
|
-
abi: _abi,
|
|
70
|
-
functionName: 'symbol',
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
address,
|
|
74
|
-
abi: _abi,
|
|
75
|
-
functionName: 'decimals',
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
address,
|
|
81
|
-
name: name ?? 'Unknown',
|
|
82
|
-
symbol: symbol ?? 'Unknown',
|
|
83
|
-
decimals: decimals ?? 18,
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
exports.fetchCurrency = fetchCurrency;
|
|
87
|
-
//# sourceMappingURL=currency.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/apis/currency.ts"],"names":[],"mappings":";;;AAAA,+BAA4E;AAG5E,8CAAyD;AAEzD,MAAM,IAAI,GAAG;IACX;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,QAAQ;aACf;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,QAAQ;aACf;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;IACD;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,OAAO;aACd;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACO,CAAA;AAEH,MAAM,aAAa,GAAG,KAAK,EAChC,OAAkB,EAClB,OAAsB,EACtB,MAAe,EACI,EAAE;IACrB,IAAI,IAAA,qBAAc,EAAC,OAAO,EAAE,kBAAW,CAAC,EAAE,CAAC;QACzC,OAAO;YACL,OAAO,EAAE,kBAAW;YACpB,IAAI,EAAE,UAAU;YAChB,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,EAAE;SACb,CAAA;IACH,CAAC;IAED,MAAM,YAAY,GAAG,IAAA,yBAAkB,EAAC;QACtC,KAAK,EAAE,iBAAS,CAAC,OAAO,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,WAAI,GAAE;KAC1C,CAAC,CAAA;IACF,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAChE,MAAM,YAAY,CAAC,SAAS,CAAC;QAC3B,SAAS,EAAE;YACT;gBACE,OAAO;gBACP,GAAG,EAAE,IAAI;gBACT,YAAY,EAAE,MAAM;aACrB;YACD;gBACE,OAAO;gBACP,GAAG,EAAE,IAAI;gBACT,YAAY,EAAE,QAAQ;aACvB;YACD;gBACE,OAAO;gBACP,GAAG,EAAE,IAAI;gBACT,YAAY,EAAE,UAAU;aACzB;SACF;KACF,CAAC,CAAA;IACJ,OAAO;QACL,OAAO;QACP,IAAI,EAAE,IAAI,IAAI,SAAS;QACvB,MAAM,EAAE,MAAM,IAAI,SAAS;QAC3B,QAAQ,EAAE,QAAQ,IAAI,EAAE;KACzB,CAAA;AACH,CAAC,CAAA;AA5CY,QAAA,aAAa,iBA4CzB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchSubgraph = void 0;
|
|
4
|
-
const subgraph_url_1 = require("../constants/subgraph-url");
|
|
5
|
-
async function fetchSubgraph(chainId, operationName, query, variables) {
|
|
6
|
-
const response = await fetch(subgraph_url_1.SUBGRAPH_URL[chainId], {
|
|
7
|
-
method: 'POST',
|
|
8
|
-
headers: {
|
|
9
|
-
'Content-Type': 'application/json',
|
|
10
|
-
},
|
|
11
|
-
body: JSON.stringify({
|
|
12
|
-
query,
|
|
13
|
-
variables,
|
|
14
|
-
operationName,
|
|
15
|
-
}),
|
|
16
|
-
});
|
|
17
|
-
if (response.ok) {
|
|
18
|
-
return response.json();
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
const errorResponse = await response.json();
|
|
22
|
-
throw new Error(errorResponse.message || 'Unknown Error');
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.fetchSubgraph = fetchSubgraph;
|
|
26
|
-
//# sourceMappingURL=subgraph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/apis/subgraph.ts"],"names":[],"mappings":";;;AAAA,4DAAwD;AAGjD,KAAK,UAAU,aAAa,CACjC,OAAkB,EAClB,aAAqB,EACrB,KAAa,EACb,SAAa;IAEb,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,2BAAY,CAAC,OAAO,CAAE,EAAE;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,KAAK;YACL,SAAS;YACT,aAAa;SACd,CAAC;KACH,CAAC,CAAA;IAEF,IAAI,QAAQ,CAAC,EAAE,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;IACxB,CAAC;SAAM,CAAC;QACN,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAE3C,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,OAAO,IAAI,eAAe,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAzBD,sCAyBC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SUBGRAPH_URL = void 0;
|
|
4
|
-
const chain_1 = require("./chain");
|
|
5
|
-
exports.SUBGRAPH_URL = {
|
|
6
|
-
[chain_1.CHAIN_IDS.ARBITRUM_SEPOLIA]: 'https://subgraph.satsuma-prod.com/f6a8c4889b7b/clober/v2-core-subgraph/api',
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=subgraph-url.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph-url.js","sourceRoot":"","sources":["../../../src/constants/subgraph-url.ts"],"names":[],"mappings":";;;AAAA,mCAAmC;AAEtB,QAAA,YAAY,GAErB;IACF,CAAC,iBAAS,CAAC,gBAAgB,CAAC,EAC1B,4EAA4E;CAC/E,CAAA"}
|
package/dist/cjs/utils/unit.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateUnit = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const chain_1 = require("../constants/chain");
|
|
6
|
-
const _abi = [
|
|
7
|
-
{
|
|
8
|
-
inputs: [],
|
|
9
|
-
name: 'totalSupply',
|
|
10
|
-
outputs: [
|
|
11
|
-
{
|
|
12
|
-
internalType: 'uint256',
|
|
13
|
-
name: '',
|
|
14
|
-
type: 'uint256',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
stateMutability: 'view',
|
|
18
|
-
type: 'function',
|
|
19
|
-
},
|
|
20
|
-
];
|
|
21
|
-
const calculateUnit = async (chainId, quote, rpcUrl) => {
|
|
22
|
-
if ((0, viem_1.isAddressEqual)(quote.address, viem_1.zeroAddress)) {
|
|
23
|
-
return 10n ** 12n;
|
|
24
|
-
}
|
|
25
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
26
|
-
chain: chain_1.CHAIN_MAP[chainId],
|
|
27
|
-
transport: rpcUrl ? (0, viem_1.http)(rpcUrl) : (0, viem_1.http)(),
|
|
28
|
-
});
|
|
29
|
-
const totalSupply = await publicClient.readContract({
|
|
30
|
-
address: quote.address,
|
|
31
|
-
abi: _abi,
|
|
32
|
-
functionName: 'totalSupply',
|
|
33
|
-
});
|
|
34
|
-
return (10n **
|
|
35
|
-
BigInt(totalSupply <= 2n ** 64n ? 0n : Math.max(quote.decimals - 6, 0)));
|
|
36
|
-
};
|
|
37
|
-
exports.calculateUnit = calculateUnit;
|
|
38
|
-
//# sourceMappingURL=unit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unit.js","sourceRoot":"","sources":["../../../src/utils/unit.ts"],"names":[],"mappings":";;;AAAA,+BAA4E;AAG5E,8CAAyD;AAEzD,MAAM,IAAI,GAAG;IACX;QACE,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE;YACP;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,EAAE;gBACR,IAAI,EAAE,SAAS;aAChB;SACF;QACD,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,UAAU;KACjB;CACO,CAAA;AAEH,MAAM,aAAa,GAAG,KAAK,EAChC,OAAkB,EAClB,KAAe,EACf,MAAe,EACf,EAAE;IACF,IAAI,IAAA,qBAAc,EAAC,KAAK,CAAC,OAAO,EAAE,kBAAW,CAAC,EAAE,CAAC;QAC/C,OAAO,GAAG,IAAI,GAAG,CAAA;IACnB,CAAC;IACD,MAAM,YAAY,GAAG,IAAA,yBAAkB,EAAC;QACtC,KAAK,EAAE,iBAAS,CAAC,OAAO,CAAC;QACzB,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,IAAA,WAAI,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,WAAI,GAAE;KAC1C,CAAC,CAAA;IACF,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,YAAY,CAAC;QAClD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,GAAG,EAAE,IAAI;QACT,YAAY,EAAE,aAAa;KAC5B,CAAC,CAAA;IACF,OAAO,CACL,GAAG;QACH,MAAM,CAAC,WAAW,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CACxE,CAAA;AACH,CAAC,CAAA;AArBY,QAAA,aAAa,iBAqBzB"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export const TAKE_ORDER_PARAMS_ABI = [
|
|
2
|
-
{
|
|
3
|
-
components: [
|
|
4
|
-
{
|
|
5
|
-
internalType: 'BookId',
|
|
6
|
-
name: 'id',
|
|
7
|
-
type: 'uint192',
|
|
8
|
-
},
|
|
9
|
-
{
|
|
10
|
-
internalType: 'uint256',
|
|
11
|
-
name: 'limitPrice',
|
|
12
|
-
type: 'uint256',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
internalType: 'uint256',
|
|
16
|
-
name: 'quoteAmount',
|
|
17
|
-
type: 'uint256',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
internalType: 'bytes',
|
|
21
|
-
name: 'hookData',
|
|
22
|
-
type: 'bytes',
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
internalType: 'struct IController.TakeOrderParams',
|
|
26
|
-
name: 'params',
|
|
27
|
-
type: 'tuple',
|
|
28
|
-
},
|
|
29
|
-
];
|
|
30
|
-
export const MAKE_ORDER_PARAMS_ABI = [
|
|
31
|
-
{
|
|
32
|
-
components: [
|
|
33
|
-
{
|
|
34
|
-
internalType: 'BookId',
|
|
35
|
-
name: 'id',
|
|
36
|
-
type: 'uint192',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
internalType: 'Tick',
|
|
40
|
-
name: 'tick',
|
|
41
|
-
type: 'int24',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
internalType: 'uint256',
|
|
45
|
-
name: 'quoteAmount',
|
|
46
|
-
type: 'uint256',
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
internalType: 'bytes',
|
|
50
|
-
name: 'hookData',
|
|
51
|
-
type: 'bytes',
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
internalType: 'struct IController.MakeOrderParams',
|
|
55
|
-
name: 'params',
|
|
56
|
-
type: 'tuple',
|
|
57
|
-
},
|
|
58
|
-
];
|
|
59
|
-
//# sourceMappingURL=params-abi.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"params-abi.js","sourceRoot":"","sources":["../../../../src/abis/core/params-abi.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;QACE,UAAU,EAAE;YACV;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;aACd;SACF;QACD,YAAY,EAAE,oCAAoC;QAClD,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;KACd;CACF,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;QACE,UAAU,EAAE;YACV;gBACE,YAAY,EAAE,QAAQ;gBACtB,IAAI,EAAE,IAAI;gBACV,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,MAAM;gBACpB,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,OAAO;aACd;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO;aACd;SACF;QACD,YAAY,EAAE,oCAAoC;QAClD,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,OAAO;KACd;CACF,CAAA"}
|