@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.
Files changed (232) hide show
  1. package/README.md +12 -4
  2. package/dist/cjs/abis/core/book-manager-abi.js +112 -0
  3. package/dist/cjs/abis/core/book-manager-abi.js.map +1 -0
  4. package/dist/cjs/abis/core/book-viewer-abi.js +321 -0
  5. package/dist/cjs/abis/core/book-viewer-abi.js.map +1 -0
  6. package/dist/cjs/abis/core/controller-abi.js +29 -24
  7. package/dist/cjs/abis/core/controller-abi.js.map +1 -1
  8. package/dist/cjs/apis/chart-logs.js +154 -0
  9. package/dist/cjs/apis/chart-logs.js.map +1 -0
  10. package/dist/cjs/apis/market.js +61 -32
  11. package/dist/cjs/apis/market.js.map +1 -1
  12. package/dist/cjs/apis/open-order.js +56 -21
  13. package/dist/cjs/apis/open-order.js.map +1 -1
  14. package/dist/cjs/approval.js +77 -30
  15. package/dist/cjs/approval.js.map +1 -1
  16. package/dist/cjs/call.js +358 -207
  17. package/dist/cjs/call.js.map +1 -1
  18. package/dist/cjs/constants/addresses.js +26 -1
  19. package/dist/cjs/constants/addresses.js.map +1 -1
  20. package/dist/cjs/constants/chain.js +19 -1
  21. package/dist/cjs/constants/chain.js.map +1 -1
  22. package/dist/cjs/constants/client.js +4 -0
  23. package/dist/cjs/constants/client.js.map +1 -1
  24. package/dist/cjs/constants/currency.js +28 -2
  25. package/dist/cjs/constants/currency.js.map +1 -1
  26. package/dist/cjs/constants/fee.js +17 -2
  27. package/dist/cjs/constants/fee.js.map +1 -1
  28. package/dist/cjs/constants/subgraph.js +57 -0
  29. package/dist/cjs/constants/subgraph.js.map +1 -0
  30. package/dist/cjs/constants/test-chain.js +27 -0
  31. package/dist/cjs/constants/test-chain.js.map +1 -0
  32. package/dist/cjs/index.js +20 -6
  33. package/dist/cjs/index.js.map +1 -1
  34. package/dist/cjs/model/book.js +63 -29
  35. package/dist/cjs/model/book.js.map +1 -1
  36. package/dist/cjs/model/chart-log.js +3 -0
  37. package/dist/cjs/model/chart-log.js.map +1 -0
  38. package/dist/cjs/model/market.js +45 -182
  39. package/dist/cjs/model/market.js.map +1 -1
  40. package/dist/cjs/signature.js +20 -16
  41. package/dist/cjs/signature.js.map +1 -1
  42. package/dist/cjs/type.js +16 -1
  43. package/dist/cjs/type.js.map +1 -1
  44. package/dist/cjs/utils/allowance.js +40 -0
  45. package/dist/cjs/utils/allowance.js.map +1 -0
  46. package/dist/cjs/utils/bigint.js +9 -0
  47. package/dist/cjs/utils/bigint.js.map +1 -0
  48. package/dist/cjs/utils/book-id.js +7 -7
  49. package/dist/cjs/utils/book-id.js.map +1 -1
  50. package/dist/cjs/utils/build-transaction.js +8 -7
  51. package/dist/cjs/utils/build-transaction.js.map +1 -1
  52. package/dist/cjs/utils/currency.js +166 -0
  53. package/dist/cjs/utils/currency.js.map +1 -0
  54. package/dist/cjs/utils/decorator.js +3 -1
  55. package/dist/cjs/utils/decorator.js.map +1 -1
  56. package/dist/cjs/utils/open.js +36 -0
  57. package/dist/cjs/utils/open.js.map +1 -0
  58. package/dist/cjs/utils/order.js +102 -0
  59. package/dist/cjs/utils/order.js.map +1 -0
  60. package/dist/cjs/utils/prices.js +28 -3
  61. package/dist/cjs/utils/prices.js.map +1 -1
  62. package/dist/cjs/utils/unit-size.js +49 -0
  63. package/dist/cjs/utils/unit-size.js.map +1 -0
  64. package/dist/cjs/utils.js +15 -0
  65. package/dist/cjs/utils.js.map +1 -0
  66. package/dist/cjs/view.js +141 -40
  67. package/dist/cjs/view.js.map +1 -1
  68. package/dist/esm/abis/core/book-manager-abi.js +109 -0
  69. package/dist/esm/abis/core/book-manager-abi.js.map +1 -0
  70. package/dist/esm/abis/core/book-viewer-abi.js +318 -0
  71. package/dist/esm/abis/core/book-viewer-abi.js.map +1 -0
  72. package/dist/esm/abis/core/controller-abi.js +29 -24
  73. package/dist/esm/abis/core/controller-abi.js.map +1 -1
  74. package/dist/esm/apis/chart-logs.js +150 -0
  75. package/dist/esm/apis/chart-logs.js.map +1 -0
  76. package/dist/esm/apis/market.js +61 -32
  77. package/dist/esm/apis/market.js.map +1 -1
  78. package/dist/esm/apis/open-order.js +57 -21
  79. package/dist/esm/apis/open-order.js.map +1 -1
  80. package/dist/esm/approval.js +116 -44
  81. package/dist/esm/approval.js.map +1 -1
  82. package/dist/esm/call.js +478 -311
  83. package/dist/esm/call.js.map +1 -1
  84. package/dist/esm/constants/addresses.js +26 -1
  85. package/dist/esm/constants/addresses.js.map +1 -1
  86. package/dist/esm/constants/chain.js +20 -2
  87. package/dist/esm/constants/chain.js.map +1 -1
  88. package/dist/esm/constants/client.js +5 -1
  89. package/dist/esm/constants/client.js.map +1 -1
  90. package/dist/esm/constants/currency.js +28 -2
  91. package/dist/esm/constants/currency.js.map +1 -1
  92. package/dist/esm/constants/fee.js +17 -2
  93. package/dist/esm/constants/fee.js.map +1 -1
  94. package/dist/esm/constants/subgraph.js +53 -0
  95. package/dist/esm/constants/subgraph.js.map +1 -0
  96. package/dist/esm/constants/test-chain.js +24 -0
  97. package/dist/esm/constants/test-chain.js.map +1 -0
  98. package/dist/esm/index.js +1 -0
  99. package/dist/esm/index.js.map +1 -1
  100. package/dist/esm/model/book.js +63 -29
  101. package/dist/esm/model/book.js.map +1 -1
  102. package/dist/esm/model/chart-log.js +2 -0
  103. package/dist/esm/model/chart-log.js.map +1 -0
  104. package/dist/esm/model/market.js +46 -187
  105. package/dist/esm/model/market.js.map +1 -1
  106. package/dist/esm/signature.js +35 -37
  107. package/dist/esm/signature.js.map +1 -1
  108. package/dist/esm/type.js +15 -0
  109. package/dist/esm/type.js.map +1 -1
  110. package/dist/esm/utils/allowance.js +36 -0
  111. package/dist/esm/utils/allowance.js.map +1 -0
  112. package/dist/esm/utils/bigint.js +5 -0
  113. package/dist/esm/utils/bigint.js.map +1 -0
  114. package/dist/esm/utils/book-id.js +7 -7
  115. package/dist/esm/utils/book-id.js.map +1 -1
  116. package/dist/esm/utils/build-transaction.js +8 -7
  117. package/dist/esm/utils/build-transaction.js.map +1 -1
  118. package/dist/esm/utils/currency.js +161 -0
  119. package/dist/esm/utils/currency.js.map +1 -0
  120. package/dist/esm/utils/decorator.js +3 -1
  121. package/dist/esm/utils/decorator.js.map +1 -1
  122. package/dist/esm/utils/open.js +32 -0
  123. package/dist/esm/utils/open.js.map +1 -0
  124. package/dist/esm/utils/order.js +98 -0
  125. package/dist/esm/utils/order.js.map +1 -0
  126. package/dist/esm/utils/prices.js +27 -2
  127. package/dist/esm/utils/prices.js.map +1 -1
  128. package/dist/esm/utils/unit-size.js +45 -0
  129. package/dist/esm/utils/unit-size.js.map +1 -0
  130. package/dist/esm/utils.js +4 -0
  131. package/dist/esm/utils.js.map +1 -0
  132. package/dist/esm/view.js +254 -68
  133. package/dist/esm/view.js.map +1 -1
  134. package/dist/tsconfig.build.tsbuildinfo +1 -1
  135. package/dist/types/abis/core/book-manager-abi.d.ts +82 -0
  136. package/dist/types/abis/core/book-manager-abi.d.ts.map +1 -0
  137. package/dist/types/abis/core/book-viewer-abi.d.ts +243 -0
  138. package/dist/types/abis/core/book-viewer-abi.d.ts.map +1 -0
  139. package/dist/types/abis/core/controller-abi.d.ts +23 -19
  140. package/dist/types/abis/core/controller-abi.d.ts.map +1 -1
  141. package/dist/types/apis/chart-logs.d.ts +5 -0
  142. package/dist/types/apis/chart-logs.d.ts.map +1 -0
  143. package/dist/types/apis/market.d.ts +1 -1
  144. package/dist/types/apis/market.d.ts.map +1 -1
  145. package/dist/types/apis/open-order.d.ts +3 -2
  146. package/dist/types/apis/open-order.d.ts.map +1 -1
  147. package/dist/types/approval.d.ts +48 -16
  148. package/dist/types/approval.d.ts.map +1 -1
  149. package/dist/types/call.d.ts +181 -109
  150. package/dist/types/call.d.ts.map +1 -1
  151. package/dist/types/constants/addresses.d.ts.map +1 -1
  152. package/dist/types/constants/chain.d.ts +6 -2
  153. package/dist/types/constants/chain.d.ts.map +1 -1
  154. package/dist/types/constants/client.d.ts +1 -1
  155. package/dist/types/constants/client.d.ts.map +1 -1
  156. package/dist/types/constants/currency.d.ts.map +1 -1
  157. package/dist/types/constants/fee.d.ts +7 -2
  158. package/dist/types/constants/fee.d.ts.map +1 -1
  159. package/dist/types/constants/subgraph.d.ts +10 -0
  160. package/dist/types/constants/subgraph.d.ts.map +1 -0
  161. package/dist/types/constants/test-chain.d.ts +3 -0
  162. package/dist/types/constants/test-chain.d.ts.map +1 -0
  163. package/dist/types/index.d.ts +1 -0
  164. package/dist/types/index.d.ts.map +1 -1
  165. package/dist/types/model/book.d.ts +23 -29
  166. package/dist/types/model/book.d.ts.map +1 -1
  167. package/dist/types/model/chart-log.d.ts +9 -0
  168. package/dist/types/model/chart-log.d.ts.map +1 -0
  169. package/dist/types/model/depth.d.ts +4 -5
  170. package/dist/types/model/depth.d.ts.map +1 -1
  171. package/dist/types/model/market.d.ts +25 -19
  172. package/dist/types/model/market.d.ts.map +1 -1
  173. package/dist/types/model/open-order.d.ts +16 -8
  174. package/dist/types/model/open-order.d.ts.map +1 -1
  175. package/dist/types/signature.d.ts +18 -24
  176. package/dist/types/signature.d.ts.map +1 -1
  177. package/dist/types/type.d.ts +52 -8
  178. package/dist/types/type.d.ts.map +1 -1
  179. package/dist/types/utils/allowance.d.ts +3 -0
  180. package/dist/types/utils/allowance.d.ts.map +1 -0
  181. package/dist/types/utils/bigint.d.ts +2 -0
  182. package/dist/types/utils/bigint.d.ts.map +1 -0
  183. package/dist/types/utils/book-id.d.ts +2 -1
  184. package/dist/types/utils/book-id.d.ts.map +1 -1
  185. package/dist/types/utils/build-transaction.d.ts +3 -3
  186. package/dist/types/utils/build-transaction.d.ts.map +1 -1
  187. package/dist/types/{apis → utils}/currency.d.ts +3 -0
  188. package/dist/types/utils/currency.d.ts.map +1 -0
  189. package/dist/types/utils/decorator.d.ts +1 -1
  190. package/dist/types/utils/decorator.d.ts.map +1 -1
  191. package/dist/types/utils/open.d.ts +3 -0
  192. package/dist/types/utils/open.d.ts.map +1 -0
  193. package/dist/types/utils/order.d.ts +8 -0
  194. package/dist/types/utils/order.d.ts.map +1 -0
  195. package/dist/types/utils/prices.d.ts +12 -2
  196. package/dist/types/utils/prices.d.ts.map +1 -1
  197. package/dist/types/utils/unit-size.d.ts +4 -0
  198. package/dist/types/utils/unit-size.d.ts.map +1 -0
  199. package/dist/types/utils.d.ts +4 -0
  200. package/dist/types/utils.d.ts.map +1 -0
  201. package/dist/types/view.d.ts +196 -39
  202. package/dist/types/view.d.ts.map +1 -1
  203. package/package.json +1 -1
  204. package/dist/cjs/abis/core/params-abi.js +0 -62
  205. package/dist/cjs/abis/core/params-abi.js.map +0 -1
  206. package/dist/cjs/apis/currency.js +0 -83
  207. package/dist/cjs/apis/currency.js.map +0 -1
  208. package/dist/cjs/apis/subgraph.js +0 -26
  209. package/dist/cjs/apis/subgraph.js.map +0 -1
  210. package/dist/cjs/constants/subgraph-url.js +0 -8
  211. package/dist/cjs/constants/subgraph-url.js.map +0 -1
  212. package/dist/cjs/utils/unit.js +0 -34
  213. package/dist/cjs/utils/unit.js.map +0 -1
  214. package/dist/esm/abis/core/params-abi.js +0 -59
  215. package/dist/esm/abis/core/params-abi.js.map +0 -1
  216. package/dist/esm/apis/currency.js +0 -79
  217. package/dist/esm/apis/currency.js.map +0 -1
  218. package/dist/esm/apis/subgraph.js +0 -22
  219. package/dist/esm/apis/subgraph.js.map +0 -1
  220. package/dist/esm/constants/subgraph-url.js +0 -5
  221. package/dist/esm/constants/subgraph-url.js.map +0 -1
  222. package/dist/esm/utils/unit.js +0 -30
  223. package/dist/esm/utils/unit.js.map +0 -1
  224. package/dist/types/abis/core/params-abi.d.ts +0 -21
  225. package/dist/types/abis/core/params-abi.d.ts.map +0 -1
  226. package/dist/types/apis/currency.d.ts.map +0 -1
  227. package/dist/types/apis/subgraph.d.ts +0 -3
  228. package/dist/types/apis/subgraph.d.ts.map +0 -1
  229. package/dist/types/constants/subgraph-url.d.ts +0 -5
  230. package/dist/types/constants/subgraph-url.d.ts.map +0 -1
  231. package/dist/types/utils/unit.d.ts +0 -4
  232. package/dist/types/utils/unit.d.ts.map +0 -1
@@ -1,30 +1,102 @@
1
1
  import { CHAIN_IDS } from './constants/chain';
2
- import { DefaultOptions, Market } from './type';
3
- import { OpenOrder } from './model/open-order';
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
- * '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
19
- * '0x0000000000000000000000000000000000000000',
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?: DefaultOptions;
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, spendAmount } = await getExpectedOutput(
43
- * 421614,
44
- * '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
45
- * '0x0000000000000000000000000000000000000000',
46
- * '1000.123', // spend 1000.123 USDC
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
- spendAmount: string;
60
- result: {
61
- bookId: bigint;
62
- takenAmount: bigint;
63
- spendAmount: bigint;
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
- * @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
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, spendAmount } = await getExpectedInput(
81
- * 421614,
82
- * '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
83
- * '0x0000000000000000000000000000000000000000',
84
- * '0.1', // take 0.1 ETH
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
- spendAmount: string;
98
- result: {
99
- bookId: bigint;
100
- takenAmount: bigint;
101
- spendAmount: bigint;
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
- * '46223845323662364279893361453861711542636620039907198451770258805035840307200'
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
- * '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
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
@@ -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;AAI/C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAG9C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS;aAMT,SAAS;YACV,KAAK,MAAM,EAAE;YACb,KAAK,MAAM,EAAE;cACX,cAAc;qBAkB3B,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;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;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE;EA6CzE,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;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;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE;EA6CzE,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY;aAKZ,SAAS;QACd,MAAM;cACA,cAAc;wBAI3B,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,aAAa;aAKb,SAAS;iBACL,KAAK,MAAM,EAAE;cAChB,cAAc;0BAI3B,CAAA"}
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clober/v2-sdk",
3
- "version": "0.0.4",
3
+ "version": "0.0.50.a.dev",
4
4
  "description": "🛠 An SDK for building applications on top of Clober V2",
5
5
  "files": [
6
6
  "dist"
@@ -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"}
@@ -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"}