@clober/v2-sdk 0.0.4 → 0.0.5-0.a.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 +61 -32
- package/dist/cjs/apis/market.js.map +1 -1
- package/dist/cjs/apis/open-order.js +56 -21
- package/dist/cjs/apis/open-order.js.map +1 -1
- package/dist/cjs/approval.js +77 -30
- package/dist/cjs/approval.js.map +1 -1
- package/dist/cjs/call.js +358 -207
- 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 +4 -0
- package/dist/cjs/constants/client.js.map +1 -1
- 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 +63 -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 +45 -182
- package/dist/cjs/model/market.js.map +1 -1
- package/dist/cjs/signature.js +20 -16
- 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/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 +8 -7
- 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 +3 -1
- package/dist/cjs/utils/decorator.js.map +1 -1
- 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 +28 -3
- package/dist/cjs/utils/prices.js.map +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 +15 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/view.js +141 -40
- 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 +61 -32
- package/dist/esm/apis/market.js.map +1 -1
- package/dist/esm/apis/open-order.js +57 -21
- package/dist/esm/apis/open-order.js.map +1 -1
- package/dist/esm/approval.js +116 -44
- package/dist/esm/approval.js.map +1 -1
- package/dist/esm/call.js +478 -311
- 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 +5 -1
- package/dist/esm/constants/client.js.map +1 -1
- 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 +63 -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 +46 -187
- package/dist/esm/model/market.js.map +1 -1
- package/dist/esm/signature.js +35 -37
- 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/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 +8 -7
- 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 +3 -1
- package/dist/esm/utils/decorator.js.map +1 -1
- 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 +27 -2
- package/dist/esm/utils/prices.js.map +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 +254 -68
- 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 +3 -2
- package/dist/types/apis/open-order.d.ts.map +1 -1
- package/dist/types/approval.d.ts +48 -16
- package/dist/types/approval.d.ts.map +1 -1
- package/dist/types/call.d.ts +181 -109
- 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 +1 -1
- package/dist/types/constants/client.d.ts.map +1 -1
- 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 +23 -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 +4 -5
- package/dist/types/model/depth.d.ts.map +1 -1
- package/dist/types/model/market.d.ts +25 -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 +18 -24
- package/dist/types/signature.d.ts.map +1 -1
- package/dist/types/type.d.ts +52 -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/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 -3
- package/dist/types/utils/build-transaction.d.ts.map +1 -1
- package/dist/types/{apis → utils}/currency.d.ts +3 -0
- package/dist/types/utils/currency.d.ts.map +1 -0
- package/dist/types/utils/decorator.d.ts +1 -1
- package/dist/types/utils/decorator.d.ts.map +1 -1
- 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 +12 -2
- package/dist/types/utils/prices.d.ts.map +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 +196 -39
- package/dist/types/view.d.ts.map +1 -1
- package/package.json +1 -1
- 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 -83
- 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 -34
- 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 -79
- 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 -30
- 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.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,30 +1,102 @@
|
|
|
1
1
|
import { CHAIN_IDS } from './constants/chain';
|
|
2
|
-
import { DefaultOptions, Market } from './type';
|
|
3
|
-
import {
|
|
2
|
+
import type { ChartLog, Currency, 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
44
|
export declare const getMarket: (args: {
|
|
23
45
|
chainId: CHAIN_IDS;
|
|
24
46
|
token0: `0x${string}`;
|
|
25
47
|
token1: `0x${string}`;
|
|
26
|
-
options?:
|
|
48
|
+
options?: {
|
|
49
|
+
n?: number;
|
|
50
|
+
} & DefaultOptions;
|
|
27
51
|
}) => Promise<Market>;
|
|
52
|
+
/**
|
|
53
|
+
* Calculates and returns the neighboring price ticks and their corresponding prices for a given input price.
|
|
54
|
+
*
|
|
55
|
+
* @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
|
|
56
|
+
* @param {string} price - The input price to calculate the neighborhood for, as a string.
|
|
57
|
+
* @param {Currency} currency0 - token0 currency {@link Currency}.
|
|
58
|
+
* @param {Currency} currency1 - token1 currency {@link Currency}.
|
|
59
|
+
*
|
|
60
|
+
* @returns {Object} An object containing the normal and inverted price neighborhoods. Each neighborhood includes:
|
|
61
|
+
* - up: The tick and price for one tick above the current price.
|
|
62
|
+
* - now: The tick and price for the current price.
|
|
63
|
+
* - down: The tick and price for one tick below the current price.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getPriceNeighborhood: ({ chainId, price, currency0, currency1, }: {
|
|
66
|
+
chainId: CHAIN_IDS;
|
|
67
|
+
price: string;
|
|
68
|
+
currency0: Currency;
|
|
69
|
+
currency1: Currency;
|
|
70
|
+
}) => {
|
|
71
|
+
normal: {
|
|
72
|
+
up: {
|
|
73
|
+
tick: bigint;
|
|
74
|
+
price: string;
|
|
75
|
+
};
|
|
76
|
+
now: {
|
|
77
|
+
tick: bigint;
|
|
78
|
+
price: string;
|
|
79
|
+
};
|
|
80
|
+
down: {
|
|
81
|
+
tick: bigint;
|
|
82
|
+
price: string;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
inverted: {
|
|
86
|
+
up: {
|
|
87
|
+
tick: bigint;
|
|
88
|
+
price: string;
|
|
89
|
+
};
|
|
90
|
+
now: {
|
|
91
|
+
tick: bigint;
|
|
92
|
+
price: string;
|
|
93
|
+
};
|
|
94
|
+
down: {
|
|
95
|
+
tick: bigint;
|
|
96
|
+
price: string;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
28
100
|
/**
|
|
29
101
|
* Calculates the expected output for a given input amount, based on the provided market data.
|
|
30
102
|
*
|
|
@@ -35,16 +107,17 @@ export declare const getMarket: (args: {
|
|
|
35
107
|
* @param options
|
|
36
108
|
* @param options.limitPrice The maximum limit price to spend.
|
|
37
109
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
110
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
38
111
|
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
39
112
|
* @example
|
|
40
113
|
* import { getExpectedOutput } from '@clober/v2-sdk'
|
|
41
114
|
*
|
|
42
|
-
* const { takenAmount,
|
|
43
|
-
* 421614,
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* )
|
|
115
|
+
* const { takenAmount, spentAmount } = await getExpectedOutput({
|
|
116
|
+
* chainId: 421614,
|
|
117
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
118
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
119
|
+
* amountIn: '1000.123', // spend 1000.123 USDC
|
|
120
|
+
* })
|
|
48
121
|
*/
|
|
49
122
|
export declare const getExpectedOutput: (args: {
|
|
50
123
|
chainId: CHAIN_IDS;
|
|
@@ -53,14 +126,17 @@ export declare const getExpectedOutput: (args: {
|
|
|
53
126
|
amountIn: string;
|
|
54
127
|
options?: {
|
|
55
128
|
limitPrice?: string;
|
|
129
|
+
roundingDownTakenBid?: boolean;
|
|
130
|
+
roundingUpTakenAsk?: boolean;
|
|
56
131
|
} & DefaultOptions;
|
|
57
132
|
}) => Promise<{
|
|
58
133
|
takenAmount: string;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
134
|
+
spentAmount: string;
|
|
135
|
+
bookId: bigint;
|
|
136
|
+
events: {
|
|
137
|
+
price: string;
|
|
138
|
+
takenAmount: string;
|
|
139
|
+
spentAmount: string;
|
|
64
140
|
}[];
|
|
65
141
|
}>;
|
|
66
142
|
/**
|
|
@@ -73,16 +149,17 @@ export declare const getExpectedOutput: (args: {
|
|
|
73
149
|
* @param options
|
|
74
150
|
* @param options.limitPrice The maximum limit price to take.
|
|
75
151
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
76
|
-
* @
|
|
152
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
153
|
+
* @returns A Promise resolving to an object containing the taken amount, spent amount and result of the calculation.
|
|
77
154
|
* @example
|
|
78
155
|
* import { getExpectedInput } from '@clober/v2-sdk'
|
|
79
156
|
*
|
|
80
|
-
* const { takenAmount,
|
|
81
|
-
* 421614,
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* )
|
|
157
|
+
* const { takenAmount, spentAmount } = await getExpectedInput({
|
|
158
|
+
* chainId: 421614,
|
|
159
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
160
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
161
|
+
* amountOut: '0.1', // take 0.1 ETH
|
|
162
|
+
* })
|
|
86
163
|
*/
|
|
87
164
|
export declare const getExpectedInput: (args: {
|
|
88
165
|
chainId: CHAIN_IDS;
|
|
@@ -91,14 +168,17 @@ export declare const getExpectedInput: (args: {
|
|
|
91
168
|
amountOut: string;
|
|
92
169
|
options?: {
|
|
93
170
|
limitPrice?: string;
|
|
171
|
+
roundingDownTakenBid?: boolean;
|
|
172
|
+
roundingUpTakenAsk?: boolean;
|
|
94
173
|
} & DefaultOptions;
|
|
95
174
|
}) => Promise<{
|
|
96
175
|
takenAmount: string;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
176
|
+
spentAmount: string;
|
|
177
|
+
bookId: bigint;
|
|
178
|
+
events: {
|
|
179
|
+
price: string;
|
|
180
|
+
takenAmount: string;
|
|
181
|
+
spentAmount: string;
|
|
102
182
|
}[];
|
|
103
183
|
}>;
|
|
104
184
|
/**
|
|
@@ -108,14 +188,15 @@ export declare const getExpectedInput: (args: {
|
|
|
108
188
|
* @param {string} id The ID of the open order.
|
|
109
189
|
* @param options
|
|
110
190
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
191
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
111
192
|
* @returns {Promise<OpenOrder>} Promise resolving to the open order object, or undefined if not found.
|
|
112
193
|
* @example
|
|
113
194
|
* import { getOpenOrder } from '@clober/v2-sdk'
|
|
114
195
|
*
|
|
115
|
-
* const openOrder = await getOpenOrder(
|
|
116
|
-
* 421614,
|
|
117
|
-
*
|
|
118
|
-
* )
|
|
196
|
+
* const openOrder = await getOpenOrder({
|
|
197
|
+
* chainId: 421614,
|
|
198
|
+
* id: '46223845323662364279893361453861711542636620039907198451770258805035840307200'
|
|
199
|
+
* })
|
|
119
200
|
*/
|
|
120
201
|
export declare const getOpenOrder: (args: {
|
|
121
202
|
chainId: CHAIN_IDS;
|
|
@@ -129,18 +210,94 @@ export declare const getOpenOrder: (args: {
|
|
|
129
210
|
* @param {`0x${string}`} userAddress The Ethereum address of the user.
|
|
130
211
|
* @param options
|
|
131
212
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
213
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
132
214
|
* @returns {Promise<OpenOrder[]>} Promise resolving to an array of open orders.
|
|
133
215
|
* @example
|
|
134
216
|
* import { getOpenOrders } from '@clober/v2-sdk'
|
|
135
217
|
*
|
|
136
|
-
* const openOrders = await getOpenOrders(
|
|
137
|
-
* 421614,
|
|
138
|
-
*
|
|
139
|
-
* )
|
|
218
|
+
* const openOrders = await getOpenOrders({
|
|
219
|
+
* chainId: 421614,
|
|
220
|
+
* userAddress: '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
|
|
221
|
+
* })
|
|
140
222
|
*/
|
|
141
223
|
export declare const getOpenOrders: (args: {
|
|
142
224
|
chainId: CHAIN_IDS;
|
|
143
225
|
userAddress: `0x${string}`;
|
|
144
226
|
options?: DefaultOptions;
|
|
145
227
|
}) => Promise<OpenOrder[]>;
|
|
228
|
+
/**
|
|
229
|
+
* Retrieves the latest chart log for a specific market.
|
|
230
|
+
*
|
|
231
|
+
* @param {CHAIN_IDS} params.chainId - The ID of the blockchain.
|
|
232
|
+
* @param {`0x${string}`} params.quote - The address of the quote token.
|
|
233
|
+
* @param {`0x${string}`} params.base - The address of the base token.
|
|
234
|
+
* @returns {Promise<ChartLog>} A promise that resolves with the latest chart log.
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* import { getLatestChartLog } from '@clober/v2-sdk'
|
|
238
|
+
*
|
|
239
|
+
* const logs = await getLatestChartLog({
|
|
240
|
+
* chainId: 421614,
|
|
241
|
+
* quote: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
242
|
+
* base: '0x0000000000000000000000000000000000000000',
|
|
243
|
+
* })
|
|
244
|
+
*/
|
|
245
|
+
export declare const getLatestChartLog: (args: {
|
|
246
|
+
chainId: CHAIN_IDS;
|
|
247
|
+
quote: `0x${string}`;
|
|
248
|
+
base: `0x${string}`;
|
|
249
|
+
}) => Promise<ChartLog>;
|
|
250
|
+
/**
|
|
251
|
+
* Retrieves chart logs for a specific market within a specified time interval.
|
|
252
|
+
*
|
|
253
|
+
* @param {CHAIN_IDS} params.chainId - The ID of the chain.
|
|
254
|
+
* @param {`0x${string}`} params.quote - The address of the quote token.
|
|
255
|
+
* @param {`0x${string}`} params.base - The address of the base token.
|
|
256
|
+
* @param {CHART_LOG_INTERVALS} params.intervalType - The type of time interval for the chart logs.
|
|
257
|
+
* @param {number} params.from - The start of the time interval (Unix timestamp in seconds).
|
|
258
|
+
* @param {number} params.to - The end of the time interval (Unix timestamp in seconds).
|
|
259
|
+
* @returns {Promise<ChartLog[]>} A promise that resolves with an array of chart logs within the specified interval.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* import { getLatestChartLog, CHART_LOG_INTERVALS } from '@clober/v2-sdk'
|
|
263
|
+
*
|
|
264
|
+
* const logs = await getChartLogs({
|
|
265
|
+
* chainId: 421614,
|
|
266
|
+
* quote: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
267
|
+
* base: '0x0000000000000000000000000000000000000000',
|
|
268
|
+
* intervalType: CHART_LOG_INTERVALS.oneDay,
|
|
269
|
+
* from: 1687305600,
|
|
270
|
+
* to: 1713312000,
|
|
271
|
+
* })
|
|
272
|
+
*/
|
|
273
|
+
export declare const getChartLogs: (args: {
|
|
274
|
+
chainId: CHAIN_IDS;
|
|
275
|
+
quote: `0x${string}`;
|
|
276
|
+
base: `0x${string}`;
|
|
277
|
+
intervalType: CHART_LOG_INTERVALS;
|
|
278
|
+
from: number;
|
|
279
|
+
to: number;
|
|
280
|
+
}) => Promise<ChartLog[]>;
|
|
281
|
+
/**
|
|
282
|
+
* Retrieves the quote token address for a given chain and a pair of tokens.
|
|
283
|
+
*
|
|
284
|
+
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
285
|
+
* @param token0 - token0 address
|
|
286
|
+
* @param token1 - token1 address
|
|
287
|
+
* @returns {string} The address of the quote token.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* import { getQuoteToken } from '@clober/v2-sdk'
|
|
291
|
+
*
|
|
292
|
+
* const quote = await getQuoteToken({
|
|
293
|
+
* chainId: 421614,
|
|
294
|
+
* token0: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
295
|
+
* token1: '0x0000000000000000000000000000000000000000',
|
|
296
|
+
* })
|
|
297
|
+
*/
|
|
298
|
+
export declare const getQuoteToken: ({ chainId, token0, token1, }: {
|
|
299
|
+
chainId: CHAIN_IDS;
|
|
300
|
+
token0: `0x${string}`;
|
|
301
|
+
token1: `0x${string}`;
|
|
302
|
+
}) => `0x${string}`;
|
|
146
303
|
//# 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,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -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,83 +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 client_1 = require("../constants/client");
|
|
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) => {
|
|
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 [{ result: name }, { result: symbol }, { result: decimals }] = await client_1.cachedPublicClients[chainId].multicall({
|
|
57
|
-
contracts: [
|
|
58
|
-
{
|
|
59
|
-
address,
|
|
60
|
-
abi: _abi,
|
|
61
|
-
functionName: 'name',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
address,
|
|
65
|
-
abi: _abi,
|
|
66
|
-
functionName: 'symbol',
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
address,
|
|
70
|
-
abi: _abi,
|
|
71
|
-
functionName: 'decimals',
|
|
72
|
-
},
|
|
73
|
-
],
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
address,
|
|
77
|
-
name: name ?? 'Unknown',
|
|
78
|
-
symbol: symbol ?? 'Unknown',
|
|
79
|
-
decimals: decimals ?? 18,
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
exports.fetchCurrency = fetchCurrency;
|
|
83
|
-
//# sourceMappingURL=currency.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency.js","sourceRoot":"","sources":["../../../src/apis/currency.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAIlD,gDAAyD;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,EACH,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,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,GAChE,MAAM,4BAAmB,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QAC3C,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;AAvCY,QAAA,aAAa,iBAuCzB"}
|
|
@@ -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,34 +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 client_1 = require("../constants/client");
|
|
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) => {
|
|
22
|
-
if ((0, viem_1.isAddressEqual)(quote.address, viem_1.zeroAddress)) {
|
|
23
|
-
return 10n ** 12n;
|
|
24
|
-
}
|
|
25
|
-
const totalSupply = await client_1.cachedPublicClients[chainId].readContract({
|
|
26
|
-
address: quote.address,
|
|
27
|
-
abi: _abi,
|
|
28
|
-
functionName: 'totalSupply',
|
|
29
|
-
});
|
|
30
|
-
return (10n **
|
|
31
|
-
BigInt(totalSupply <= 2n ** 64n ? 0n : Math.max(quote.decimals - 6, 0)));
|
|
32
|
-
};
|
|
33
|
-
exports.calculateUnit = calculateUnit;
|
|
34
|
-
//# sourceMappingURL=unit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unit.js","sourceRoot":"","sources":["../../../src/utils/unit.ts"],"names":[],"mappings":";;;AAAA,+BAAkD;AAIlD,gDAAyD;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,EAAE,OAAkB,EAAE,KAAe,EAAE,EAAE;IACzE,IAAI,IAAA,qBAAc,EAAC,KAAK,CAAC,OAAO,EAAE,kBAAW,CAAC,EAAE,CAAC;QAC/C,OAAO,GAAG,IAAI,GAAG,CAAA;IACnB,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,4BAAmB,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC;QAClE,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;AAbY,QAAA,aAAa,iBAazB"}
|
|
@@ -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"}
|