@kasarlabs/ekubo-mcp 0.1.1 → 0.1.3
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/build/index.js +12 -2
- package/build/index.js.map +1 -1
- package/build/lib/constants/index.d.ts +1 -0
- package/build/lib/constants/index.js +2 -0
- package/build/lib/constants/index.js.map +1 -0
- package/build/lib/utils/math.d.ts +4 -0
- package/build/lib/utils/math.js +34 -1
- package/build/lib/utils/math.js.map +1 -1
- package/build/lib/utils/pools.js +4 -6
- package/build/lib/utils/pools.js.map +1 -1
- package/build/lib/utils/position.d.ts +10 -0
- package/build/lib/utils/position.js +95 -0
- package/build/lib/utils/position.js.map +1 -0
- package/build/lib/utils/quote.d.ts +2 -0
- package/build/lib/utils/quote.js +20 -0
- package/build/lib/utils/quote.js.map +1 -1
- package/build/lib/utils/swap.d.ts +1 -1
- package/build/lib/utils/swap.js +2 -2
- package/build/lib/utils/swap.js.map +1 -1
- package/build/lib/utils/token.d.ts +1 -15
- package/build/lib/utils/token.js +0 -14
- package/build/lib/utils/token.js.map +1 -1
- package/build/schemas/index.d.ts +222 -266
- package/build/schemas/index.js +129 -174
- package/build/schemas/index.js.map +1 -1
- package/build/tools/read/getPoolFeesPerLiquidity.d.ts +1 -1
- package/build/tools/read/getPoolFeesPerLiquidity.js +8 -3
- package/build/tools/read/getPoolFeesPerLiquidity.js.map +1 -1
- package/build/tools/read/getPoolInfo.js +6 -3
- package/build/tools/read/getPoolInfo.js.map +1 -1
- package/build/tools/read/getPoolLiquidity.d.ts +1 -1
- package/build/tools/read/getPoolLiquidity.js +8 -3
- package/build/tools/read/getPoolLiquidity.js.map +1 -1
- package/build/tools/read/getPosition.d.ts +25 -0
- package/build/tools/read/getPosition.js +64 -0
- package/build/tools/read/getPosition.js.map +1 -0
- package/build/tools/read/getTokenPrice.d.ts +1 -1
- package/build/tools/read/getTokenPrice.js +12 -6
- package/build/tools/read/getTokenPrice.js.map +1 -1
- package/build/tools/write/addLiquidity.d.ts +1 -1
- package/build/tools/write/addLiquidity.js +53 -22
- package/build/tools/write/addLiquidity.js.map +1 -1
- package/build/tools/write/createPosition.d.ts +3 -1
- package/build/tools/write/createPosition.js +49 -16
- package/build/tools/write/createPosition.js.map +1 -1
- package/build/tools/write/swap.d.ts +1 -1
- package/build/tools/write/swap.js +29 -15
- package/build/tools/write/swap.js.map +1 -1
- package/build/tools/write/transferPosition.d.ts +1 -1
- package/build/tools/write/transferPosition.js +4 -1
- package/build/tools/write/transferPosition.js.map +1 -1
- package/build/tools/write/withdrawLiquidity.d.ts +3 -1
- package/build/tools/write/withdrawLiquidity.js +28 -7
- package/build/tools/write/withdrawLiquidity.js.map +1 -1
- package/package.json +3 -3
- package/build/interfaces/index.d.ts +0 -21
- package/build/interfaces/index.js +0 -2
- package/build/interfaces/index.js.map +0 -1
package/build/schemas/index.js
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
.describe('The type of the asset concerned by the allowance: SYMBOL or ADDRESS'),
|
|
6
|
-
assetValue: z
|
|
2
|
+
export const poolKeySchema = z
|
|
3
|
+
.object({
|
|
4
|
+
token0_symbol: z
|
|
7
5
|
.string()
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
|
|
22
|
-
.object({
|
|
23
|
-
assetType: z
|
|
24
|
-
.enum(['SYMBOL', 'ADDRESS'])
|
|
25
|
-
.describe('The type of the asset concerned by the allowance: SYMBOL or ADDRESS'),
|
|
26
|
-
assetValue: z
|
|
27
|
-
.string()
|
|
28
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
29
|
-
})
|
|
30
|
-
.describe('The asset information (symbol or contract address) of the second token in the pool'),
|
|
6
|
+
.optional()
|
|
7
|
+
.describe('The symbol of the first token (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token0_symbol or token0_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
8
|
+
token0_address: z
|
|
9
|
+
.string()
|
|
10
|
+
.optional()
|
|
11
|
+
.describe('The contract address of the first token. Either token0_symbol or token0_address must be provided.'),
|
|
12
|
+
token1_symbol: z
|
|
13
|
+
.string()
|
|
14
|
+
.optional()
|
|
15
|
+
.describe('The symbol of the second token (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token1_symbol or token1_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
16
|
+
token1_address: z
|
|
17
|
+
.string()
|
|
18
|
+
.optional()
|
|
19
|
+
.describe('The contract address of the second token. Either token1_symbol or token1_address must be provided.'),
|
|
31
20
|
fee: z
|
|
32
21
|
.number()
|
|
33
22
|
.optional()
|
|
@@ -43,28 +32,33 @@ export const poolKeySchema = z.object({
|
|
|
43
32
|
.optional()
|
|
44
33
|
.default('0x0')
|
|
45
34
|
.describe('The extension contract address (default: "0x0")'),
|
|
35
|
+
})
|
|
36
|
+
.refine((data) => data.token0_symbol || data.token0_address, {
|
|
37
|
+
message: 'Either token0_symbol or token0_address must be provided',
|
|
38
|
+
path: ['token0_symbol'],
|
|
39
|
+
})
|
|
40
|
+
.refine((data) => data.token1_symbol || data.token1_address, {
|
|
41
|
+
message: 'Either token1_symbol or token1_address must be provided',
|
|
42
|
+
path: ['token1_symbol'],
|
|
46
43
|
});
|
|
47
|
-
export const getTokenPriceSchema = z
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
66
|
-
})
|
|
67
|
-
.describe('The asset information (symbol or contract address) of the quote currency (e.g., USDC, ETH)'),
|
|
44
|
+
export const getTokenPriceSchema = z
|
|
45
|
+
.object({
|
|
46
|
+
token_symbol: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe('The symbol of the token to get the price for (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token_symbol or token_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
50
|
+
token_address: z
|
|
51
|
+
.string()
|
|
52
|
+
.optional()
|
|
53
|
+
.describe('The contract address of the token to get the price for. Either token_symbol or token_address must be provided.'),
|
|
54
|
+
quote_currency_symbol: z
|
|
55
|
+
.string()
|
|
56
|
+
.optional()
|
|
57
|
+
.describe('The symbol of the quote currency (e.g., "STRK", "USDC", "ETH", "WBTC"). Either quote_currency_symbol or quote_currency_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
58
|
+
quote_currency_address: z
|
|
59
|
+
.string()
|
|
60
|
+
.optional()
|
|
61
|
+
.describe('The contract address of the quote currency. Either quote_currency_symbol or quote_currency_address must be provided.'),
|
|
68
62
|
fee: z
|
|
69
63
|
.number()
|
|
70
64
|
.optional()
|
|
@@ -80,31 +74,36 @@ export const getTokenPriceSchema = z.object({
|
|
|
80
74
|
.optional()
|
|
81
75
|
.default('0x0')
|
|
82
76
|
.describe('The extension contract address (default: "0x0")'),
|
|
77
|
+
})
|
|
78
|
+
.refine((data) => data.token_symbol || data.token_address, {
|
|
79
|
+
message: 'Either token_symbol or token_address must be provided',
|
|
80
|
+
path: ['token_symbol'],
|
|
81
|
+
})
|
|
82
|
+
.refine((data) => data.quote_currency_symbol || data.quote_currency_address, {
|
|
83
|
+
message: 'Either quote_currency_symbol or quote_currency_address must be provided',
|
|
84
|
+
path: ['quote_currency_symbol'],
|
|
83
85
|
});
|
|
84
|
-
export const swapTokensSchema = z
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
103
|
-
})
|
|
104
|
-
.describe('The asset information (symbol or contract address) of the token to buy'),
|
|
86
|
+
export const swapTokensSchema = z
|
|
87
|
+
.object({
|
|
88
|
+
token_in_symbol: z
|
|
89
|
+
.string()
|
|
90
|
+
.optional()
|
|
91
|
+
.describe('The symbol of the token to sell (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token_in_symbol or token_in_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
92
|
+
token_in_address: z
|
|
93
|
+
.string()
|
|
94
|
+
.optional()
|
|
95
|
+
.describe('The contract address of the token to sell. Either token_in_symbol or token_in_address must be provided.'),
|
|
96
|
+
token_out_symbol: z
|
|
97
|
+
.string()
|
|
98
|
+
.optional()
|
|
99
|
+
.describe('The symbol of the token to buy (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token_out_symbol or token_out_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
100
|
+
token_out_address: z
|
|
101
|
+
.string()
|
|
102
|
+
.optional()
|
|
103
|
+
.describe('The contract address of the token to buy. Either token_out_symbol or token_out_address must be provided.'),
|
|
105
104
|
amount: z
|
|
106
105
|
.string()
|
|
107
|
-
.describe('The amount to swap (in
|
|
106
|
+
.describe('The amount to swap (in human decimals, e.g., "1" for 1 USDC)'),
|
|
108
107
|
is_amount_in: z
|
|
109
108
|
.boolean()
|
|
110
109
|
.optional()
|
|
@@ -130,57 +129,30 @@ export const swapTokensSchema = z.object({
|
|
|
130
129
|
.optional()
|
|
131
130
|
.default('0x0')
|
|
132
131
|
.describe('The extension contract address (default: "0x0")'),
|
|
132
|
+
})
|
|
133
|
+
.refine((data) => data.token_in_symbol || data.token_in_address, {
|
|
134
|
+
message: 'Either token_in_symbol or token_in_address must be provided',
|
|
135
|
+
path: ['token_in_symbol'],
|
|
136
|
+
})
|
|
137
|
+
.refine((data) => data.token_out_symbol || data.token_out_address, {
|
|
138
|
+
message: 'Either token_out_symbol or token_out_address must be provided',
|
|
139
|
+
path: ['token_out_symbol'],
|
|
133
140
|
});
|
|
134
141
|
export const addLiquiditySchema = z.object({
|
|
135
142
|
position_id: z
|
|
136
143
|
.number()
|
|
144
|
+
.int()
|
|
145
|
+
.min(1)
|
|
137
146
|
.describe('The NFT position ID (u64) to add liquidity to'),
|
|
138
147
|
amount0: z
|
|
139
148
|
.string()
|
|
140
|
-
.describe('The amount of token0 to add (in
|
|
149
|
+
.describe('The amount of token0 to add (in human decimals, e.g., "1" for 1 USDC)'),
|
|
141
150
|
amount1: z
|
|
142
151
|
.string()
|
|
143
|
-
.describe('The amount of token1 to add (in
|
|
144
|
-
token0: z
|
|
145
|
-
.object({
|
|
146
|
-
assetType: z
|
|
147
|
-
.enum(['SYMBOL', 'ADDRESS'])
|
|
148
|
-
.describe('The type of the asset concerned by the allowance: SYMBOL or ADDRESS'),
|
|
149
|
-
assetValue: z
|
|
150
|
-
.string()
|
|
151
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
152
|
-
})
|
|
153
|
-
.describe('The asset information (symbol or contract address) of the first token'),
|
|
154
|
-
token1: z
|
|
155
|
-
.object({
|
|
156
|
-
assetType: z
|
|
157
|
-
.enum(['SYMBOL', 'ADDRESS'])
|
|
158
|
-
.describe('The type of the asset concerned by the allowance: SYMBOL or ADDRESS'),
|
|
159
|
-
assetValue: z
|
|
160
|
-
.string()
|
|
161
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
162
|
-
})
|
|
163
|
-
.describe('The asset information (symbol or contract address) of the second token'),
|
|
164
|
-
lower_tick: z.number().describe('The lower tick of the position range'),
|
|
165
|
-
upper_tick: z.number().describe('The upper tick of the position range'),
|
|
166
|
-
fee: z
|
|
167
|
-
.number()
|
|
168
|
-
.optional()
|
|
169
|
-
.default(0.05)
|
|
170
|
-
.describe('The fee tier as a percentage (e.g., 0.05 for 0.05%, 0.3 for 0.3%, 1 for 1%, defaults to 0.05)'),
|
|
171
|
-
tick_spacing: z
|
|
172
|
-
.number()
|
|
173
|
-
.optional()
|
|
174
|
-
.default(0.1)
|
|
175
|
-
.describe('The tick spacing as a percentage (e.g., 0.01 for 0.01%, 0.1 for 0.1%, 1 for 1%, defaults to 0.1)'),
|
|
176
|
-
extension: z
|
|
177
|
-
.string()
|
|
178
|
-
.optional()
|
|
179
|
-
.default('0x0')
|
|
180
|
-
.describe('The extension contract address (default: "0x0")'),
|
|
152
|
+
.describe('The amount of token1 to add (in human decimals, e.g., "1" for 1 USDC)'),
|
|
181
153
|
});
|
|
182
154
|
export const withdrawLiquiditySchema = z.object({
|
|
183
|
-
position_id: z.number().describe('The NFT position ID (u64)'),
|
|
155
|
+
position_id: z.number().int().min(1).describe('The NFT position ID (u64)'),
|
|
184
156
|
liquidity_amount: z
|
|
185
157
|
.string()
|
|
186
158
|
.describe('The amount of liquidity to remove (as a string to handle large numbers, set to "0" for fees only)'),
|
|
@@ -194,79 +166,47 @@ export const withdrawLiquiditySchema = z.object({
|
|
|
194
166
|
.optional()
|
|
195
167
|
.default(true)
|
|
196
168
|
.describe('Whether to collect accumulated fees (defaults to true)'),
|
|
197
|
-
token0: z
|
|
198
|
-
.object({
|
|
199
|
-
assetType: z
|
|
200
|
-
.enum(['SYMBOL', 'ADDRESS'])
|
|
201
|
-
.describe('The type of the asset concerned by the allowance: SYMBOL or ADDRESS'),
|
|
202
|
-
assetValue: z
|
|
203
|
-
.string()
|
|
204
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
205
|
-
})
|
|
206
|
-
.describe('The asset information (symbol or contract address) of the first token'),
|
|
207
|
-
token1: z
|
|
208
|
-
.object({
|
|
209
|
-
assetType: z
|
|
210
|
-
.enum(['SYMBOL', 'ADDRESS'])
|
|
211
|
-
.describe('The type of the asset concerned by the allowance: SYMBOL or ADDRESS'),
|
|
212
|
-
assetValue: z
|
|
213
|
-
.string()
|
|
214
|
-
.describe('The symbol (e.g., "ETH", "USDC") or the contract address of the token'),
|
|
215
|
-
})
|
|
216
|
-
.describe('The asset information (symbol or contract address) of the second token'),
|
|
217
|
-
lower_tick: z.number().describe('The lower tick of the position range'),
|
|
218
|
-
upper_tick: z.number().describe('The upper tick of the position range'),
|
|
219
|
-
fee: z
|
|
220
|
-
.number()
|
|
221
|
-
.optional()
|
|
222
|
-
.default(0.05)
|
|
223
|
-
.describe('The fee tier as a percentage (e.g., 0.05 for 0.05%, 0.3 for 0.3%, 1 for 1%, defaults to 0.05)'),
|
|
224
|
-
tick_spacing: z
|
|
225
|
-
.number()
|
|
226
|
-
.optional()
|
|
227
|
-
.default(0.1)
|
|
228
|
-
.describe('The tick spacing as a percentage (e.g., 0.01 for 0.01%, 0.1 for 0.1%, 1 for 1%, defaults to 0.1)'),
|
|
229
|
-
extension: z
|
|
230
|
-
.string()
|
|
231
|
-
.optional()
|
|
232
|
-
.default('0x0')
|
|
233
|
-
.describe('The extension contract address (default: "0x0")'),
|
|
234
169
|
});
|
|
235
170
|
export const transferPositionSchema = z.object({
|
|
236
|
-
position_id: z
|
|
171
|
+
position_id: z
|
|
172
|
+
.number()
|
|
173
|
+
.int()
|
|
174
|
+
.min(1)
|
|
175
|
+
.describe('The NFT position ID to transfer (u64)'),
|
|
237
176
|
to_address: z
|
|
238
177
|
.string()
|
|
239
178
|
.describe('The recipient address to transfer the position to'),
|
|
240
179
|
});
|
|
241
|
-
export const createPositionSchema = z
|
|
180
|
+
export const createPositionSchema = z
|
|
181
|
+
.object({
|
|
242
182
|
amount0: z
|
|
243
183
|
.string()
|
|
244
|
-
.describe('The amount of token0 to add (in
|
|
184
|
+
.describe('The amount of token0 to add (in human decimals, e.g., "1" for 1 USDC)'),
|
|
245
185
|
amount1: z
|
|
246
186
|
.string()
|
|
247
|
-
.describe('The amount of token1 to add (in
|
|
248
|
-
|
|
249
|
-
.
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
.
|
|
258
|
-
|
|
259
|
-
.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
187
|
+
.describe('The amount of token1 to add (in human decimals, e.g., "1" for 1 USDC)'),
|
|
188
|
+
token0_symbol: z
|
|
189
|
+
.string()
|
|
190
|
+
.optional()
|
|
191
|
+
.describe('The symbol of the first token (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token0_symbol or token0_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
192
|
+
token0_address: z
|
|
193
|
+
.string()
|
|
194
|
+
.optional()
|
|
195
|
+
.describe('The contract address of the first token. Either token0_symbol or token0_address must be provided.'),
|
|
196
|
+
token1_symbol: z
|
|
197
|
+
.string()
|
|
198
|
+
.optional()
|
|
199
|
+
.describe('The symbol of the second token (e.g., "STRK", "USDC", "ETH", "WBTC"). Either token1_symbol or token1_address must be provided. Supported symbols include: STRK, USDC, USDT, ETH, DAI, WBTC, and many others.'),
|
|
200
|
+
token1_address: z
|
|
201
|
+
.string()
|
|
202
|
+
.optional()
|
|
203
|
+
.describe('The contract address of the second token. Either token1_symbol or token1_address must be provided.'),
|
|
204
|
+
lower_price: z
|
|
205
|
+
.number()
|
|
206
|
+
.describe('The minimum price (token1/token0) for the position range. This will be converted to lower_tick automatically.'),
|
|
207
|
+
upper_price: z
|
|
208
|
+
.number()
|
|
209
|
+
.describe('The maximum price (token1/token0) for the position range. This will be converted to upper_tick automatically.'),
|
|
270
210
|
fee: z
|
|
271
211
|
.number()
|
|
272
212
|
.optional()
|
|
@@ -282,5 +222,20 @@ export const createPositionSchema = z.object({
|
|
|
282
222
|
.optional()
|
|
283
223
|
.default('0x0')
|
|
284
224
|
.describe('The extension contract address (default: "0x0")'),
|
|
225
|
+
})
|
|
226
|
+
.refine((data) => data.token0_symbol || data.token0_address, {
|
|
227
|
+
message: 'Either token0_symbol or token0_address must be provided',
|
|
228
|
+
path: ['token0_symbol'],
|
|
229
|
+
})
|
|
230
|
+
.refine((data) => data.token1_symbol || data.token1_address, {
|
|
231
|
+
message: 'Either token1_symbol or token1_address must be provided',
|
|
232
|
+
path: ['token1_symbol'],
|
|
233
|
+
});
|
|
234
|
+
export const getPositionSchema = z.object({
|
|
235
|
+
position_id: z
|
|
236
|
+
.number()
|
|
237
|
+
.int()
|
|
238
|
+
.min(1)
|
|
239
|
+
.describe('The NFT position ID (u64) to get liquidity information for'),
|
|
285
240
|
});
|
|
286
241
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,MAAM,CAAC;IACN,aAAa,EAAE,CAAC;SACb,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,6MAA6M,CAC9M;IACH,cAAc,EAAE,CAAC;SACd,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CACP,mGAA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CAAC;IACxC,WAAW,EAAE,CAAC;SACX,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,QAAQ,CAAC,4DAA4D,CAAC;CAC1E,CAAC,CAAC"}
|
|
@@ -5,8 +5,10 @@ export const getPoolFeesPerLiquidity = async (env, params) => {
|
|
|
5
5
|
try {
|
|
6
6
|
const contract = await getContract(provider, 'core');
|
|
7
7
|
const { poolKey } = await preparePoolKeyFromParams(env.provider, {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
token0_symbol: params.token0_symbol,
|
|
9
|
+
token0_address: params.token0_address,
|
|
10
|
+
token1_symbol: params.token1_symbol,
|
|
11
|
+
token1_address: params.token1_address,
|
|
10
12
|
fee: params.fee,
|
|
11
13
|
tick_spacing: params.tick_spacing,
|
|
12
14
|
extension: params.extension,
|
|
@@ -22,9 +24,12 @@ export const getPoolFeesPerLiquidity = async (env, params) => {
|
|
|
22
24
|
}
|
|
23
25
|
catch (error) {
|
|
24
26
|
console.error('Error getting pool fees per liquidity:', error);
|
|
27
|
+
const errorMessage = error instanceof Error
|
|
28
|
+
? error.message
|
|
29
|
+
: 'Unknown error while getting pool fees per liquidity';
|
|
25
30
|
return {
|
|
26
31
|
status: 'failure',
|
|
27
|
-
error:
|
|
32
|
+
error: errorMessage,
|
|
28
33
|
};
|
|
29
34
|
}
|
|
30
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPoolFeesPerLiquidity.js","sourceRoot":"","sources":["../../../src/tools/read/getPoolFeesPerLiquidity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,GAAgB,EAChB,MAAe,EACf,EAAE;IACF,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B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,EAAE;aAClD;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;QAC/D,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK;YACpB,CAAC,CAAC,KAAK,CAAC,OAAO;YACf,CAAC,CAAC,qDAAqD,CAAC;QAC5D,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,KAAK,EAAE,YAAY;SACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -5,13 +5,16 @@ export const getPoolInfo = async (env, params) => {
|
|
|
5
5
|
const provider = env.provider;
|
|
6
6
|
try {
|
|
7
7
|
const contract = await getContract(provider, 'core');
|
|
8
|
-
const { poolKey, token0, token1 } = await preparePoolKeyFromParams(env.provider, {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const { poolKey, token0: t0, token1: t1, isTokenALower, } = await preparePoolKeyFromParams(env.provider, {
|
|
9
|
+
token0_symbol: params.token0_symbol,
|
|
10
|
+
token0_address: params.token0_address,
|
|
11
|
+
token1_symbol: params.token1_symbol,
|
|
12
|
+
token1_address: params.token1_address,
|
|
11
13
|
fee: params.fee,
|
|
12
14
|
tick_spacing: params.tick_spacing,
|
|
13
15
|
extension: params.extension,
|
|
14
16
|
});
|
|
17
|
+
const [token0, token1] = isTokenALower ? [t0, t1] : [t1, t0];
|
|
15
18
|
const priceResult = await contract.get_pool_price(poolKey);
|
|
16
19
|
const liquidityResult = await contract.get_pool_liquidity(poolKey);
|
|
17
20
|
const feesResult = await contract.get_pool_fees_per_liquidity(poolKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPoolInfo.js","sourceRoot":"","sources":["../../../src/tools/read/getPoolInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,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,10 @@ export const getPoolLiquidity = async (env, params) => {
|
|
|
5
5
|
try {
|
|
6
6
|
const contract = await getContract(provider, 'core');
|
|
7
7
|
const { poolKey } = await preparePoolKeyFromParams(env.provider, {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
token0_symbol: params.token0_symbol,
|
|
9
|
+
token0_address: params.token0_address,
|
|
10
|
+
token1_symbol: params.token1_symbol,
|
|
11
|
+
token1_address: params.token1_address,
|
|
10
12
|
fee: params.fee,
|
|
11
13
|
tick_spacing: params.tick_spacing,
|
|
12
14
|
extension: params.extension,
|
|
@@ -21,9 +23,12 @@ export const getPoolLiquidity = async (env, params) => {
|
|
|
21
23
|
}
|
|
22
24
|
catch (error) {
|
|
23
25
|
console.error('Error getting pool liquidity:', error);
|
|
26
|
+
const errorMessage = error instanceof Error
|
|
27
|
+
? error.message
|
|
28
|
+
: 'Unknown error while getting pool liquidity';
|
|
24
29
|
return {
|
|
25
30
|
status: 'failure',
|
|
26
|
-
error:
|
|
31
|
+
error: errorMessage,
|
|
27
32
|
};
|
|
28
33
|
}
|
|
29
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPoolLiquidity.js","sourceRoot":"","sources":["../../../src/tools/read/getPoolLiquidity.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,GAAgB,EAAE,MAAe,EAAE,EAAE;IAC1E,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;IAC9B,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAErD,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,wBAAwB,CAAC,GAAG,CAAC,QAAQ,EAAE;YAC/D,MAAM,EAAE,MAAM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ACjB,KAAK,EAAE,YAAY;SACpB,CAAC;IACJ,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { onchainRead } from '@kasarlabs/ask-starknet-core';
|
|
2
|
+
import { GetPositionSchema } from '../../schemas/index.js';
|
|
3
|
+
export declare const getPosition: (env: onchainRead, params: GetPositionSchema) => Promise<{
|
|
4
|
+
status: string;
|
|
5
|
+
data: {
|
|
6
|
+
position_id: number;
|
|
7
|
+
owner_address: string;
|
|
8
|
+
liquidity: any;
|
|
9
|
+
amount0: any;
|
|
10
|
+
amount1: any;
|
|
11
|
+
fees0: any;
|
|
12
|
+
fees1: any;
|
|
13
|
+
token0: string;
|
|
14
|
+
token1: string;
|
|
15
|
+
lower_tick: number;
|
|
16
|
+
upper_tick: number;
|
|
17
|
+
pool_fee: number;
|
|
18
|
+
tick_spacing: number;
|
|
19
|
+
};
|
|
20
|
+
error?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
status: string;
|
|
23
|
+
error: string;
|
|
24
|
+
data?: undefined;
|
|
25
|
+
}>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { getContract } from '../../lib/utils/contracts.js';
|
|
2
|
+
import { preparePoolKeyFromParams } from '../../lib/utils/pools.js';
|
|
3
|
+
import { buildBounds } from '../../lib/utils/liquidity.js';
|
|
4
|
+
import { convertTickSpacingExponentToPercent, convertFeeU128ToPercent, } from '../../lib/utils/math.js';
|
|
5
|
+
import { fetchPositionData, fetchPositionOwner, } from '../../lib/utils/position.js';
|
|
6
|
+
export const getPosition = async (env, params) => {
|
|
7
|
+
const provider = env.provider;
|
|
8
|
+
try {
|
|
9
|
+
const positionsContract = await getContract(provider, 'positions');
|
|
10
|
+
const positionData = await fetchPositionData(params.position_id);
|
|
11
|
+
const ownerAddress = await fetchPositionOwner(params.position_id);
|
|
12
|
+
const token0_address = positionData.token0;
|
|
13
|
+
const token1_address = positionData.token1;
|
|
14
|
+
const fee = convertFeeU128ToPercent(positionData.fee);
|
|
15
|
+
const tick_spacing = convertTickSpacingExponentToPercent(Number(positionData.tick_spacing));
|
|
16
|
+
const extension = positionData.extension || '0x0';
|
|
17
|
+
const { poolKey, token0, token1 } = await preparePoolKeyFromParams(provider, {
|
|
18
|
+
token0_address,
|
|
19
|
+
token1_address,
|
|
20
|
+
fee,
|
|
21
|
+
tick_spacing,
|
|
22
|
+
extension,
|
|
23
|
+
});
|
|
24
|
+
const lowerTick = Number(positionData.tick_lower);
|
|
25
|
+
const upperTick = Number(positionData.tick_upper);
|
|
26
|
+
if (isNaN(lowerTick) || isNaN(upperTick)) {
|
|
27
|
+
throw new Error(`Invalid tick values: lower=${positionData.tick_lower}, upper=${positionData.tick_upper}`);
|
|
28
|
+
}
|
|
29
|
+
if (lowerTick >= upperTick) {
|
|
30
|
+
throw new Error(`Lower tick (${lowerTick}) must be less than upper tick (${upperTick})`);
|
|
31
|
+
}
|
|
32
|
+
const bounds = buildBounds(lowerTick, upperTick);
|
|
33
|
+
const positionResult = await positionsContract.get_token_info(params.position_id, poolKey, bounds);
|
|
34
|
+
return {
|
|
35
|
+
status: 'success',
|
|
36
|
+
data: {
|
|
37
|
+
position_id: params.position_id,
|
|
38
|
+
owner_address: ownerAddress,
|
|
39
|
+
liquidity: positionResult.liquidity.toString(),
|
|
40
|
+
amount0: positionResult.amount0.toString(),
|
|
41
|
+
amount1: positionResult.amount1.toString(),
|
|
42
|
+
fees0: positionResult.fees0.toString(),
|
|
43
|
+
fees1: positionResult.fees1.toString(),
|
|
44
|
+
token0: token0.symbol || token0.address,
|
|
45
|
+
token1: token1.symbol || token1.address,
|
|
46
|
+
lower_tick: lowerTick,
|
|
47
|
+
upper_tick: upperTick,
|
|
48
|
+
pool_fee: fee,
|
|
49
|
+
tick_spacing: tick_spacing,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error('Error getting position:', error);
|
|
55
|
+
const errorMessage = error instanceof Error
|
|
56
|
+
? error.message
|
|
57
|
+
: 'Unknown error while getting position';
|
|
58
|
+
return {
|
|
59
|
+
status: 'failure',
|
|
60
|
+
error: errorMessage,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=getPosition.js.map
|