@clober/v2-sdk 0.0.4 → 0.0.5-0.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 +313 -206
- 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 +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 +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/bignumber.js +9 -0
- package/dist/cjs/utils/bignumber.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 +25 -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 +102 -33
- 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 +430 -309
- 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 +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 +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/bignumber.js +6 -0
- package/dist/esm/utils/bignumber.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 +24 -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 +215 -61
- 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 +151 -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 +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 +4 -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 +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/bignumber.d.ts +3 -0
- package/dist/types/utils/bignumber.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 +8 -1
- 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 +184 -41
- 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/call.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CHAIN_IDS } from './constants/chain';
|
|
2
|
-
import { DefaultOptions,
|
|
2
|
+
import type { CurrencyFlow, DefaultOptions, ERC20PermitParam, Transaction } from './type';
|
|
3
3
|
/**
|
|
4
4
|
* Build a transaction to open a market.
|
|
5
5
|
*
|
|
6
6
|
* @param chainId The chain ID of the blockchain.
|
|
7
|
+
* @param userAddress The address of the user.
|
|
7
8
|
* @param inputToken The address of the input token.
|
|
8
9
|
* @param outputToken The address of the output token.
|
|
9
10
|
* @param options
|
|
@@ -12,14 +13,16 @@ import { DefaultOptions, PermitSignature, Transaction } from './type';
|
|
|
12
13
|
* @example
|
|
13
14
|
* import { openMarket } from '@clober/v2-sdk'
|
|
14
15
|
*
|
|
15
|
-
* const transaction = await openMarket(
|
|
16
|
-
* 421614,
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* const transaction = await openMarket({
|
|
17
|
+
* chainId: 421614,
|
|
18
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69',
|
|
19
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
20
|
+
* outputToken: '0x0000000000000000000000000000000000000000'
|
|
21
|
+
* })
|
|
20
22
|
*/
|
|
21
23
|
export declare const openMarket: (args: {
|
|
22
24
|
chainId: CHAIN_IDS;
|
|
25
|
+
userAddress: `0x${string}`;
|
|
23
26
|
inputToken: `0x${string}`;
|
|
24
27
|
outputToken: `0x${string}`;
|
|
25
28
|
options?: DefaultOptions;
|
|
@@ -34,42 +37,45 @@ export declare const openMarket: (args: {
|
|
|
34
37
|
* @param {string} amount The amount of input tokens for the order.
|
|
35
38
|
* @param {string} price The price at which the order should be executed.
|
|
36
39
|
* @param {Object} [options] Optional parameters for the limit order.
|
|
37
|
-
* @param {
|
|
40
|
+
* @param {erc20PermitParam} [options.erc20PermitParam] The permit signature for token approval.
|
|
38
41
|
* @param {boolean} [options.postOnly] A boolean indicating whether the order is only to be made not taken.
|
|
39
42
|
* @param {string} [options.rpcUrl] The RPC URL of the blockchain.
|
|
40
|
-
* @
|
|
43
|
+
* @param {number} [options.gasLimit] The gas limit to use for the transaction.
|
|
44
|
+
* @param {boolean} [options.useSubgraph] A boolean indicating whether to use the subgraph for fetching orders.
|
|
45
|
+
* @returns {Promise<{ transaction: Transaction, result: { make: CurrencyFlow, take: CurrencyFlow, spent: CurrencyFlow }>}
|
|
46
|
+
* Promise resolving to the transaction object representing the limit order with the result of the order.
|
|
41
47
|
* @example
|
|
42
48
|
* import { signERC20Permit, limitOrder } from '@clober/v2-sdk'
|
|
43
49
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
44
50
|
*
|
|
45
|
-
* const
|
|
46
|
-
* 421614,
|
|
47
|
-
*
|
|
48
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
49
|
-
* '100.123'
|
|
50
|
-
* )
|
|
51
|
+
* const erc20PermitParam = await signERC20Permit({
|
|
52
|
+
* chainId: 421614,
|
|
53
|
+
* walletClient,
|
|
54
|
+
* token: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
55
|
+
* amount: '100.123'
|
|
56
|
+
* })
|
|
51
57
|
*
|
|
52
|
-
* const transaction = await limitOrder(
|
|
53
|
-
* 421614,
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* )
|
|
58
|
+
* const { transaction } = await limitOrder({
|
|
59
|
+
* chainId: 421614,
|
|
60
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69
|
|
61
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
62
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
63
|
+
* amount: '100.123', // 100.123 USDC
|
|
64
|
+
* price: '4000.01', // price at 4000.01 (ETH/USDC)
|
|
65
|
+
* options: { erc20PermitParam }
|
|
66
|
+
* })
|
|
61
67
|
*
|
|
62
68
|
* @example
|
|
63
69
|
* import { limitOrder } from '@clober/v2-sdk'
|
|
64
70
|
*
|
|
65
|
-
* const transaction = await limitOrder(
|
|
66
|
-
* 421614,
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* )
|
|
71
|
+
* const { transaction } = await limitOrder({
|
|
72
|
+
* chainId: 421614,
|
|
73
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69
|
|
74
|
+
* inputToken: '0x0000000000000000000000000000000000000000',
|
|
75
|
+
* outputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
76
|
+
* amount: '0.13', // 0.13 ETH
|
|
77
|
+
* price: '4000.01', // price at 4000.01 (ETH/USDC)
|
|
78
|
+
* })
|
|
73
79
|
*/
|
|
74
80
|
export declare const limitOrder: (args: {
|
|
75
81
|
chainId: CHAIN_IDS;
|
|
@@ -79,66 +85,78 @@ export declare const limitOrder: (args: {
|
|
|
79
85
|
amount: string;
|
|
80
86
|
price: string;
|
|
81
87
|
options?: {
|
|
82
|
-
|
|
88
|
+
erc20PermitParam?: ERC20PermitParam;
|
|
83
89
|
postOnly?: boolean;
|
|
90
|
+
makeTick?: bigint;
|
|
91
|
+
takeLimitTick?: bigint;
|
|
84
92
|
} & DefaultOptions;
|
|
85
|
-
}) => Promise<
|
|
93
|
+
}) => Promise<{
|
|
94
|
+
transaction: Transaction;
|
|
95
|
+
result: {
|
|
96
|
+
make: CurrencyFlow;
|
|
97
|
+
taken: CurrencyFlow;
|
|
98
|
+
spent: CurrencyFlow;
|
|
99
|
+
};
|
|
100
|
+
}>;
|
|
86
101
|
/**
|
|
87
102
|
* Executes a market order on the specified chain for trading tokens.
|
|
103
|
+
* If only `amountIn` is provided, spend the specified amount of input tokens.
|
|
104
|
+
* If only `amountOut` is provided, take the specified amount of output tokens.
|
|
88
105
|
*
|
|
89
106
|
* @param {CHAIN_IDS} chainId The chain ID.
|
|
90
107
|
* @param {`0x${string}`} userAddress The Ethereum address of the user placing the order.
|
|
91
108
|
* @param {`0x${string}`} inputToken The address of the token to be used as input.
|
|
92
109
|
* @param {`0x${string}`} outputToken The address of the token to be received as output.
|
|
93
|
-
* @param {string}
|
|
94
|
-
* @param {
|
|
95
|
-
* @param {
|
|
110
|
+
* @param {string} amountIn The amount of input tokens for the order to spend.
|
|
111
|
+
* @param {string} amountOut The amount of output tokens for the order to take.
|
|
112
|
+
* @param {Object} [options] Optional parameters for the market order.
|
|
113
|
+
* @param {erc20PermitParam} [options.erc20PermitParam] The permit signature for token approval.
|
|
96
114
|
* @param {string} [options.rpcUrl] The RPC URL of the blockchain.
|
|
97
|
-
* @param {
|
|
98
|
-
*
|
|
99
|
-
* @
|
|
115
|
+
* @param {number} [options.gasLimit] The gas limit to use for the transaction.
|
|
116
|
+
* @param {boolean} [options.useSubgraph] A boolean indicating whether to use the subgraph for fetching orders.
|
|
117
|
+
* @param {number} [options.slippage] The maximum slippage percentage allowed for the order.
|
|
118
|
+
* if the slippage is not provided, unlimited slippage is allowed.
|
|
119
|
+
* @returns {Promise<{ transaction: Transaction, result: { spent: CurrencyFlow, taken: CurrencyFlow } }>}
|
|
120
|
+
* Promise resolving to the transaction object representing the market order with the result of the order.
|
|
100
121
|
* @example
|
|
101
122
|
* import { signERC20Permit, marketOrder } from '@clober/v2-sdk'
|
|
102
123
|
* import { privateKeyToAccount } from 'viem/accounts'
|
|
103
124
|
*
|
|
104
|
-
* const
|
|
105
|
-
* 421614,
|
|
106
|
-
*
|
|
107
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
108
|
-
* '100.123'
|
|
109
|
-
* )
|
|
125
|
+
* const erc20PermitParam = await signERC20Permit({
|
|
126
|
+
* chainId: 421614,
|
|
127
|
+
* walletClient,
|
|
128
|
+
* token: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
129
|
+
* amount: '100.123'
|
|
130
|
+
* })
|
|
110
131
|
*
|
|
111
|
-
* const transaction = await marketOrder(
|
|
112
|
-
* 421614,
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* )
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* import { marketOrder } from '@clober/v2-sdk'
|
|
132
|
+
* const transaction = await marketOrder({
|
|
133
|
+
* chainId: 421614,
|
|
134
|
+
* userAddress: '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69
|
|
135
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
136
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
137
|
+
* amount: '100.123', // 100.123 USDC
|
|
138
|
+
* options: { erc20PermitParam }
|
|
139
|
+
* })
|
|
122
140
|
*
|
|
123
|
-
* const transaction = await limitOrder(
|
|
124
|
-
* 421614,
|
|
125
|
-
* '0xF8c1869Ecd4df136693C45EcE1b67f85B6bDaE69
|
|
126
|
-
* '0x0000000000000000000000000000000000000000',
|
|
127
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
128
|
-
* '0.13', // 0.13 ETH
|
|
129
|
-
* )
|
|
130
141
|
*/
|
|
131
142
|
export declare const marketOrder: (args: {
|
|
132
143
|
chainId: CHAIN_IDS;
|
|
133
144
|
userAddress: `0x${string}`;
|
|
134
145
|
inputToken: `0x${string}`;
|
|
135
146
|
outputToken: `0x${string}`;
|
|
136
|
-
|
|
147
|
+
amountIn?: string;
|
|
148
|
+
amountOut?: string;
|
|
137
149
|
options?: {
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
erc20PermitParam?: ERC20PermitParam;
|
|
151
|
+
slippage?: number;
|
|
140
152
|
} & DefaultOptions;
|
|
141
|
-
}) => Promise<
|
|
153
|
+
}) => Promise<{
|
|
154
|
+
transaction: Transaction;
|
|
155
|
+
result: {
|
|
156
|
+
taken: CurrencyFlow;
|
|
157
|
+
spent: CurrencyFlow;
|
|
158
|
+
};
|
|
159
|
+
}>;
|
|
142
160
|
/**
|
|
143
161
|
* Claims specified open order for settlement.
|
|
144
162
|
* [IMPORTANT] Set ApprovalForAll before calling this function.
|
|
@@ -148,27 +166,33 @@ export declare const marketOrder: (args: {
|
|
|
148
166
|
* @param {string} id An ID representing the open order to be claimed.
|
|
149
167
|
* @param {Object} [options] Optional parameters for claiming orders.
|
|
150
168
|
* @param {string} [options.rpcUrl] The RPC URL to use for executing the transaction.
|
|
151
|
-
* @
|
|
169
|
+
* @param {number} [options.gasLimit] The gas limit to use for the transaction.
|
|
170
|
+
* @param {boolean} [options.useSubgraph] A boolean indicating whether to use the subgraph for fetching orders.
|
|
171
|
+
* @returns {Promise<{ transaction: Transaction, result: CurrencyFlow }>}
|
|
172
|
+
* Promise resolving to the transaction object representing the claim action with the result of the order.
|
|
152
173
|
* @throws {Error} Throws an error if no open orders are found for the specified user.
|
|
153
174
|
* @example
|
|
154
175
|
* import { getOpenOrders, claimOrders } from '@clober/v2-sdk'
|
|
155
176
|
*
|
|
156
|
-
* const openOrders = await getOpenOrders(
|
|
157
|
-
* 421614,
|
|
158
|
-
*
|
|
159
|
-
* )
|
|
160
|
-
* const transaction = await claimOrders(
|
|
161
|
-
* 421614,
|
|
162
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
163
|
-
* openOrders.map((order) => order.id)
|
|
164
|
-
* )
|
|
177
|
+
* const openOrders = await getOpenOrders({
|
|
178
|
+
* chainId: 421614,
|
|
179
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0'
|
|
180
|
+
* })
|
|
181
|
+
* const transaction = await claimOrders({
|
|
182
|
+
* chainId: 421614,
|
|
183
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
184
|
+
* id: openOrders.map((order) => order.id)
|
|
185
|
+
* })
|
|
165
186
|
*/
|
|
166
187
|
export declare const claimOrder: (args: {
|
|
167
188
|
chainId: CHAIN_IDS;
|
|
168
189
|
userAddress: `0x${string}`;
|
|
169
190
|
id: string;
|
|
170
191
|
options?: DefaultOptions;
|
|
171
|
-
}) => Promise<
|
|
192
|
+
}) => Promise<{
|
|
193
|
+
transaction: Transaction;
|
|
194
|
+
result: CurrencyFlow;
|
|
195
|
+
}>;
|
|
172
196
|
/**
|
|
173
197
|
* Claims specified open orders for settlement.
|
|
174
198
|
* [IMPORTANT] Set ApprovalForAll before calling this function.
|
|
@@ -178,19 +202,22 @@ export declare const claimOrder: (args: {
|
|
|
178
202
|
* @param {string[]} ids An array of IDs representing the open orders to be claimed.
|
|
179
203
|
* @param {Object} [options] Optional parameters for claiming orders.
|
|
180
204
|
* @param {string} [options.rpcUrl] The RPC URL to use for executing the transaction.
|
|
181
|
-
* @
|
|
205
|
+
* @param {number} [options.gasLimit] The gas limit to use for the transaction.
|
|
206
|
+
* @param {boolean} [options.useSubgraph] A boolean indicating whether to use the subgraph for fetching orders.
|
|
207
|
+
* @returns {Promise<{ transaction: Transaction, result: CurrencyFlow[] }>}
|
|
208
|
+
* Promise resolving to the transaction object representing the claim action with the result of the orders.
|
|
182
209
|
* @throws {Error} Throws an error if no open orders are found for the specified user.
|
|
183
210
|
* @example
|
|
184
211
|
* import { getOpenOrders, claimOrders } from '@clober/v2-sdk'
|
|
185
212
|
*
|
|
186
|
-
* const openOrders = await getOpenOrders(
|
|
187
|
-
* 421614,
|
|
188
|
-
*
|
|
189
|
-
* )
|
|
213
|
+
* const openOrders = await getOpenOrders({
|
|
214
|
+
* chainId: 421614,
|
|
215
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0'
|
|
216
|
+
* })
|
|
190
217
|
* const transaction = await claimOrders(
|
|
191
|
-
* 421614,
|
|
192
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
193
|
-
* openOrders.map((order) => order.id)
|
|
218
|
+
* chainId: 421614,
|
|
219
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
220
|
+
* ids: openOrders.map((order) => order.id)
|
|
194
221
|
* )
|
|
195
222
|
*/
|
|
196
223
|
export declare const claimOrders: (args: {
|
|
@@ -198,7 +225,10 @@ export declare const claimOrders: (args: {
|
|
|
198
225
|
userAddress: `0x${string}`;
|
|
199
226
|
ids: string[];
|
|
200
227
|
options?: DefaultOptions;
|
|
201
|
-
}) => Promise<
|
|
228
|
+
}) => Promise<{
|
|
229
|
+
transaction: Transaction;
|
|
230
|
+
result: CurrencyFlow[];
|
|
231
|
+
}>;
|
|
202
232
|
/**
|
|
203
233
|
* Cancels specified open order if the order is not fully filled.
|
|
204
234
|
* [IMPORTANT] Set ApprovalForAll before calling this function.
|
|
@@ -208,27 +238,33 @@ export declare const claimOrders: (args: {
|
|
|
208
238
|
* @param {string} id An ID representing the open order to be canceled
|
|
209
239
|
* @param {Object} [options] Optional parameters for canceling orders.
|
|
210
240
|
* @param {string} [options.rpcUrl] The RPC URL to use for executing the transaction.
|
|
211
|
-
* @
|
|
241
|
+
* @param {number} [options.gasLimit] The gas limit to use for the transaction.
|
|
242
|
+
* @param {boolean} [options.useSubgraph] A boolean indicating whether to use the subgraph for fetching orders.
|
|
243
|
+
* @returns {Promise<{ transaction: Transaction, result: CurrencyFlow }>}
|
|
244
|
+
* Promise resolving to the transaction object representing the cancel action with the result of the order.
|
|
212
245
|
* @throws {Error} Throws an error if no open orders are found for the specified user.
|
|
213
246
|
* @example
|
|
214
247
|
* import { getOpenOrders, cancelOrders } from '@clober/v2-sdk'
|
|
215
248
|
*
|
|
216
|
-
* const openOrders = await getOpenOrders(
|
|
217
|
-
* 421614,
|
|
218
|
-
*
|
|
219
|
-
* )
|
|
220
|
-
* const transaction = await cancelOrders(
|
|
221
|
-
* 421614,
|
|
222
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
223
|
-
* openOrders.map((order) => order.id)
|
|
224
|
-
* )
|
|
249
|
+
* const openOrders = await getOpenOrders({
|
|
250
|
+
* chainId: 421614,
|
|
251
|
+
* userAddress:'0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0'
|
|
252
|
+
* })
|
|
253
|
+
* const transaction = await cancelOrders({
|
|
254
|
+
* chainId: 421614,
|
|
255
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
256
|
+
* id: openOrders.map((order) => order.id)
|
|
257
|
+
* })
|
|
225
258
|
*/
|
|
226
259
|
export declare const cancelOrder: (args: {
|
|
227
260
|
chainId: CHAIN_IDS;
|
|
228
261
|
userAddress: `0x${string}`;
|
|
229
262
|
id: string;
|
|
230
263
|
options?: DefaultOptions;
|
|
231
|
-
}) => Promise<
|
|
264
|
+
}) => Promise<{
|
|
265
|
+
transaction: Transaction;
|
|
266
|
+
result: CurrencyFlow;
|
|
267
|
+
}>;
|
|
232
268
|
/**
|
|
233
269
|
* Cancels specified open orders if orders are not fully filled.
|
|
234
270
|
* [IMPORTANT] Set ApprovalForAll before calling this function.
|
|
@@ -238,25 +274,31 @@ export declare const cancelOrder: (args: {
|
|
|
238
274
|
* @param {string[]} ids An array of IDs representing the open orders to be canceled.
|
|
239
275
|
* @param {Object} [options] Optional parameters for canceling orders.
|
|
240
276
|
* @param {string} [options.rpcUrl] The RPC URL to use for executing the transaction.
|
|
241
|
-
* @
|
|
277
|
+
* @param {number} [options.gasLimit] The gas limit to use for the transaction.
|
|
278
|
+
* @param {boolean} [options.useSubgraph] A boolean indicating whether to use the subgraph for fetching orders.
|
|
279
|
+
* @returns {Promise<{ transaction: Transaction, result: CurrencyFlow[] }>
|
|
280
|
+
* Promise resolving to the transaction object representing the cancel action with the result of the orders.
|
|
242
281
|
* @throws {Error} Throws an error if no open orders are found for the specified user.
|
|
243
282
|
* @example
|
|
244
283
|
* import { getOpenOrders, cancelOrders } from '@clober/v2-sdk'
|
|
245
284
|
*
|
|
246
|
-
* const openOrders = await getOpenOrders(
|
|
247
|
-
* 421614,
|
|
248
|
-
*
|
|
249
|
-
* )
|
|
250
|
-
* const transaction = await cancelOrders(
|
|
251
|
-
* 421614,
|
|
252
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
253
|
-
* openOrders.map((order) => order.id)
|
|
254
|
-
* )
|
|
285
|
+
* const openOrders = await getOpenOrders({
|
|
286
|
+
* chainId: 421614,
|
|
287
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0'
|
|
288
|
+
* })
|
|
289
|
+
* const transaction = await cancelOrders({
|
|
290
|
+
* chainId: 421614,
|
|
291
|
+
* userAddress: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
292
|
+
* ids: openOrders.map((order) => order.id)
|
|
293
|
+
* })
|
|
255
294
|
*/
|
|
256
295
|
export declare const cancelOrders: (args: {
|
|
257
296
|
chainId: CHAIN_IDS;
|
|
258
297
|
userAddress: `0x${string}`;
|
|
259
298
|
ids: string[];
|
|
260
299
|
options?: DefaultOptions;
|
|
261
|
-
}) => Promise<
|
|
300
|
+
}) => Promise<{
|
|
301
|
+
transaction: Transaction;
|
|
302
|
+
result: CurrencyFlow[];
|
|
303
|
+
}>;
|
|
262
304
|
//# sourceMappingURL=call.d.ts.map
|
package/dist/types/call.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/call.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAA;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"call.d.ts","sourceRoot":"","sources":["../../src/call.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAa,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,WAAW,EACZ,MAAM,QAAQ,CAAA;AAiBf;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,UAAU;aAQV,SAAS;iBACL,KAAK,MAAM,EAAE;gBACd,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;cAChB,cAAc;sCA0C3B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,eAAO,MAAM,UAAU;aAUV,SAAS;iBACL,KAAK,MAAM,EAAE;gBACd,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;YAClB,MAAM;WACP,MAAM;cACH;QACR,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;QACnC,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,aAAa,CAAC,EAAE,MAAM,CAAA;KACvB,GAAG,cAAc;;iBAEL,WAAW;YAChB;QACN,IAAI,EAAE,YAAY,CAAA;QAClB,KAAK,EAAE,YAAY,CAAA;QACnB,KAAK,EAAE,YAAY,CAAA;KACpB;EAwJJ,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,WAAW;aAUX,SAAS;iBACL,KAAK,MAAM,EAAE;gBACd,KAAK,MAAM,EAAE;iBACZ,KAAK,MAAM,EAAE;eACf,MAAM;gBACL,MAAM;cACR;QACR,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;QACnC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,GAAG,cAAc;;iBAEL,WAAW;YAChB;QACN,KAAK,EAAE,YAAY,CAAA;QACnB,KAAK,EAAE,YAAY,CAAA;KACpB;EA0JJ,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU;aAOV,SAAS;iBACL,KAAK,MAAM,EAAE;QACtB,MAAM;cACA,cAAc;;iBACC,WAAW;YAAU,YAAY;EAY7D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,WAAW;aAOX,SAAS;iBACL,KAAK,MAAM,EAAE;SACrB,MAAM,EAAE;cACH,cAAc;;iBACC,WAAW;YAAU,YAAY,EAAE;EAuE/D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,WAAW;aAOX,SAAS;iBACL,KAAK,MAAM,EAAE;QACtB,MAAM;cACA,cAAc;;iBACC,WAAW;YAAU,YAAY;EAY7D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,YAAY;aAOZ,SAAS;iBACL,KAAK,MAAM,EAAE;SACrB,MAAM,EAAE;cACH,cAAc;;iBACC,WAAW;YAAU,YAAY,EAAE;EAwE/D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../../src/constants/addresses.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,eAAO,MAAM,kBAAkB,EAAE;KAC9B,KAAK,IAAI,SAAS,GAAG;QACpB,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;QACzB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAA;QAC1B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;KAC1B;
|
|
1
|
+
{"version":3,"file":"addresses.d.ts","sourceRoot":"","sources":["../../../src/constants/addresses.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,eAAO,MAAM,kBAAkB,EAAE;KAC9B,KAAK,IAAI,SAAS,GAAG;QACpB,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;QACzB,WAAW,EAAE,KAAK,MAAM,EAAE,CAAA;QAC1B,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;KAC1B;CAgCF,CAAA"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type Chain } from 'viem/chains';
|
|
2
2
|
export declare enum CHAIN_IDS {
|
|
3
|
-
|
|
4
|
-
ARBITRUM_SEPOLIA
|
|
3
|
+
CLOBER_TESTNET,
|
|
4
|
+
ARBITRUM_SEPOLIA,
|
|
5
|
+
BASE,
|
|
6
|
+
BERACHAIN_TESTNET,
|
|
7
|
+
ZKSYNC,
|
|
8
|
+
ZKSYNC_SEPOLIA
|
|
5
9
|
}
|
|
6
10
|
export declare const CHAIN_MAP: {
|
|
7
11
|
[chain in CHAIN_IDS]: Chain;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/constants/chain.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"chain.d.ts","sourceRoot":"","sources":["../../../src/constants/chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,KAAK,EAGX,MAAM,aAAa,CAAA;AAIpB,oBAAY,SAAS;IACnB,cAAmC;IACnC,gBAAqC;IACrC,IAAc;IACd,iBAAuC;IACvC,MAAkB;IAClB,cAAwC;CACzC;AAED,eAAO,MAAM,SAAS,EAAE;KACrB,KAAK,IAAI,SAAS,GAAG,KAAK;CAgB5B,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicClient } from 'viem';
|
|
1
|
+
import { type PublicClient } from 'viem';
|
|
2
2
|
import { CHAIN_IDS } from './chain';
|
|
3
3
|
export declare const cachedPublicClients: Record<CHAIN_IDS, PublicClient>;
|
|
4
4
|
export declare const buildPublicClient: (chainId: CHAIN_IDS, rpcUrl?: string) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/constants/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/constants/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,MAAM,CAAA;AAGlE,OAAO,EAAE,SAAS,EAAa,MAAM,SAAS,CAAA;AAE9C,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAe,CAAA;AAC/E,eAAO,MAAM,iBAAiB,YAAa,SAAS,WAAW,MAAM,SAWpE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/constants/currency.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,eAAO,MAAM,cAAc,EAAE;KAC1B,KAAK,IAAI,SAAS,GAAG,KAAK,MAAM,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/constants/currency.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,eAAO,MAAM,cAAc,EAAE;KAC1B,KAAK,IAAI,SAAS,GAAG,KAAK,MAAM,EAAE,EAAE;CAYtC,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE;KACjC,KAAK,IAAI,SAAS,GAAG,KAAK,MAAM,EAAE,EAAE;CAoBtC,CAAA"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { FeePolicy } from '../model/fee-policy';
|
|
2
|
-
|
|
3
|
-
export declare const
|
|
2
|
+
import { CHAIN_IDS } from './chain';
|
|
3
|
+
export declare const MAKER_DEFAULT_POLICY: {
|
|
4
|
+
[chain in CHAIN_IDS]: FeePolicy;
|
|
5
|
+
};
|
|
6
|
+
export declare const TAKER_DEFAULT_POLICY: {
|
|
7
|
+
[chain in CHAIN_IDS]: FeePolicy;
|
|
8
|
+
};
|
|
4
9
|
//# sourceMappingURL=fee.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fee.d.ts","sourceRoot":"","sources":["../../../src/constants/fee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,eAAO,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"fee.d.ts","sourceRoot":"","sources":["../../../src/constants/fee.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,eAAO,MAAM,oBAAoB,EAAE;KAChC,KAAK,IAAI,SAAS,GAAG,SAAS;CAQhC,CAAA;AAED,eAAO,MAAM,oBAAoB,EAAE;KAChC,KAAK,IAAI,SAAS,GAAG,SAAS;CAQhC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CHAIN_IDS } from './chain';
|
|
2
|
+
declare class Subgraph {
|
|
3
|
+
private subgraphURL;
|
|
4
|
+
constructor(chainId: CHAIN_IDS);
|
|
5
|
+
get<T>(operationName: string, query: string, variables: {}): Promise<T>;
|
|
6
|
+
}
|
|
7
|
+
export declare const cachedSubgraph: Record<CHAIN_IDS, Subgraph | undefined>;
|
|
8
|
+
export declare const buildSubgraph: (chainId: CHAIN_IDS, useSubgraph?: boolean) => void;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=subgraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraph.d.ts","sourceRoot":"","sources":["../../../src/constants/subgraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAmBnC,cAAM,QAAQ;IACZ,OAAO,CAAC,WAAW,CAAQ;gBAEf,OAAO,EAAE,SAAS;IAOjB,GAAG,CAAC,CAAC,EAChB,aAAa,EAAE,MAAM,EACrB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,EAAE,GACZ,OAAO,CAAC,CAAC,CAAC;CAqBd;AAED,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,QAAQ,GAAG,SAAS,CACtD,CAAA;AACb,eAAO,MAAM,aAAa,YACf,SAAS,gBACL,OAAO,SAOrB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-chain.d.ts","sourceRoot":"","sources":["../../../src/constants/test-chain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAA;AAE5B,eAAO,MAAM,eAAe,EAAE,KAsB7B,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,QAAQ,CAAA;AACtB,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
|
@@ -1,52 +1,36 @@
|
|
|
1
|
+
import { CHAIN_IDS } from '../constants/chain';
|
|
1
2
|
import type { Currency } from './currency';
|
|
2
|
-
import type {
|
|
3
|
-
export type BookDto = {
|
|
4
|
-
id: string;
|
|
5
|
-
base: {
|
|
6
|
-
id: string;
|
|
7
|
-
name: string;
|
|
8
|
-
symbol: string;
|
|
9
|
-
decimals: string;
|
|
10
|
-
};
|
|
11
|
-
quote: {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
symbol: string;
|
|
15
|
-
decimals: string;
|
|
16
|
-
};
|
|
17
|
-
unit: string;
|
|
18
|
-
depths: {
|
|
19
|
-
tick: string;
|
|
20
|
-
price: string;
|
|
21
|
-
rawAmount: string;
|
|
22
|
-
}[];
|
|
23
|
-
};
|
|
3
|
+
import type { DepthDto } from './depth';
|
|
24
4
|
export declare class Book {
|
|
5
|
+
chainId: CHAIN_IDS;
|
|
25
6
|
id: bigint;
|
|
26
7
|
base: Currency;
|
|
27
|
-
|
|
8
|
+
unitSize: bigint;
|
|
28
9
|
quote: Currency;
|
|
29
|
-
depths:
|
|
30
|
-
|
|
10
|
+
depths: DepthDto[];
|
|
11
|
+
isOpened: boolean;
|
|
12
|
+
constructor({ chainId, id, base, quote, unitSize, depths, isOpened, }: {
|
|
13
|
+
chainId: CHAIN_IDS;
|
|
31
14
|
id: bigint;
|
|
32
15
|
base: Currency;
|
|
33
16
|
quote: Currency;
|
|
34
|
-
|
|
35
|
-
depths:
|
|
17
|
+
unitSize: bigint;
|
|
18
|
+
depths: DepthDto[];
|
|
19
|
+
isOpened: boolean;
|
|
36
20
|
});
|
|
37
21
|
take: ({ limitPrice, amountOut, }: {
|
|
38
22
|
limitPrice: bigint;
|
|
39
23
|
amountOut: bigint;
|
|
40
24
|
}) => {
|
|
41
25
|
takenQuoteAmount: bigint;
|
|
42
|
-
|
|
26
|
+
spentBaseAmount: bigint;
|
|
43
27
|
};
|
|
44
28
|
spend: ({ limitPrice, amountIn, }: {
|
|
45
29
|
limitPrice: bigint;
|
|
46
30
|
amountIn: bigint;
|
|
47
31
|
}) => {
|
|
48
32
|
takenQuoteAmount: bigint;
|
|
49
|
-
|
|
33
|
+
spentBaseAmount: bigint;
|
|
50
34
|
};
|
|
51
35
|
}
|
|
52
36
|
//# sourceMappingURL=book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/model/book.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"book.d.ts","sourceRoot":"","sources":["../../../src/model/book.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAEvC,qBAAa,IAAI;IACf,OAAO,EAAE,SAAS,CAAA;IAClB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,QAAQ,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,QAAQ,CAAA;IACf,MAAM,EAAE,QAAQ,EAAE,CAAA;IAClB,QAAQ,EAAE,OAAO,CAAA;gBAEL,EACV,OAAO,EACP,EAAE,EACF,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,MAAM,EACN,QAAQ,GACT,EAAE;QACD,OAAO,EAAE,SAAS,CAAA;QAClB,EAAE,EAAE,MAAM,CAAA;QACV,IAAI,EAAE,QAAQ,CAAA;QACd,KAAK,EAAE,QAAQ,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,QAAQ,EAAE,CAAA;QAClB,QAAQ,EAAE,OAAO,CAAA;KAClB;IAUD,IAAI,+BAGD;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;KAClB;;;MA6DA;IAED,KAAK,8BAGF;QACD,UAAU,EAAE,MAAM,CAAA;QAClB,QAAQ,EAAE,MAAM,CAAA;KACjB;;;MA0DA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chart-log.d.ts","sourceRoot":"","sources":["../../../src/model/chart-log.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;IACxB,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export type
|
|
2
|
-
bookId: string;
|
|
3
|
-
unit: bigint;
|
|
1
|
+
export type DepthDto = {
|
|
4
2
|
tick: bigint;
|
|
5
|
-
|
|
3
|
+
unitAmount: bigint;
|
|
6
4
|
};
|
|
7
5
|
export type Depth = {
|
|
8
|
-
price:
|
|
6
|
+
price: string;
|
|
7
|
+
tick: bigint;
|
|
9
8
|
baseAmount: bigint;
|
|
10
9
|
};
|
|
11
10
|
//# sourceMappingURL=depth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"depth.d.ts","sourceRoot":"","sources":["../../../src/model/depth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,
|
|
1
|
+
{"version":3,"file":"depth.d.ts","sourceRoot":"","sources":["../../../src/model/depth.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA"}
|