Skip to content

Commit 4137e09

Browse files
committed
feat: add getQuote util & useGetQuote hook
1 parent c3c29bc commit 4137e09

File tree

7 files changed

+726
-2
lines changed

7 files changed

+726
-2
lines changed

src/constants/abis/V4Quoter.ts

Lines changed: 343 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,343 @@
1+
export const V4QuoterAbi = [
2+
{
3+
inputs: [
4+
{
5+
internalType: "contract IPoolManager",
6+
name: "_poolManager",
7+
type: "address",
8+
},
9+
],
10+
stateMutability: "nonpayable",
11+
type: "constructor",
12+
},
13+
{
14+
inputs: [{ internalType: "PoolId", name: "poolId", type: "bytes32" }],
15+
name: "NotEnoughLiquidity",
16+
type: "error",
17+
},
18+
{ inputs: [], name: "NotPoolManager", type: "error" },
19+
{ inputs: [], name: "NotSelf", type: "error" },
20+
{
21+
inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
22+
name: "QuoteSwap",
23+
type: "error",
24+
},
25+
{ inputs: [], name: "UnexpectedCallSuccess", type: "error" },
26+
{
27+
inputs: [{ internalType: "bytes", name: "revertData", type: "bytes" }],
28+
name: "UnexpectedRevertBytes",
29+
type: "error",
30+
},
31+
{
32+
inputs: [
33+
{
34+
components: [
35+
{ internalType: "Currency", name: "exactCurrency", type: "address" },
36+
{
37+
components: [
38+
{
39+
internalType: "Currency",
40+
name: "intermediateCurrency",
41+
type: "address",
42+
},
43+
{ internalType: "uint24", name: "fee", type: "uint24" },
44+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
45+
{
46+
internalType: "contract IHooks",
47+
name: "hooks",
48+
type: "address",
49+
},
50+
{ internalType: "bytes", name: "hookData", type: "bytes" },
51+
],
52+
internalType: "struct PathKey[]",
53+
name: "path",
54+
type: "tuple[]",
55+
},
56+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
57+
],
58+
internalType: "struct IV4Quoter.QuoteExactParams",
59+
name: "params",
60+
type: "tuple",
61+
},
62+
],
63+
name: "_quoteExactInput",
64+
outputs: [{ internalType: "bytes", name: "", type: "bytes" }],
65+
stateMutability: "nonpayable",
66+
type: "function",
67+
},
68+
{
69+
inputs: [
70+
{
71+
components: [
72+
{
73+
components: [
74+
{ internalType: "Currency", name: "currency0", type: "address" },
75+
{ internalType: "Currency", name: "currency1", type: "address" },
76+
{ internalType: "uint24", name: "fee", type: "uint24" },
77+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
78+
{
79+
internalType: "contract IHooks",
80+
name: "hooks",
81+
type: "address",
82+
},
83+
],
84+
internalType: "struct PoolKey",
85+
name: "poolKey",
86+
type: "tuple",
87+
},
88+
{ internalType: "bool", name: "zeroForOne", type: "bool" },
89+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
90+
{ internalType: "bytes", name: "hookData", type: "bytes" },
91+
],
92+
internalType: "struct IV4Quoter.QuoteExactSingleParams",
93+
name: "params",
94+
type: "tuple",
95+
},
96+
],
97+
name: "_quoteExactInputSingle",
98+
outputs: [{ internalType: "bytes", name: "", type: "bytes" }],
99+
stateMutability: "nonpayable",
100+
type: "function",
101+
},
102+
{
103+
inputs: [
104+
{
105+
components: [
106+
{ internalType: "Currency", name: "exactCurrency", type: "address" },
107+
{
108+
components: [
109+
{
110+
internalType: "Currency",
111+
name: "intermediateCurrency",
112+
type: "address",
113+
},
114+
{ internalType: "uint24", name: "fee", type: "uint24" },
115+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
116+
{
117+
internalType: "contract IHooks",
118+
name: "hooks",
119+
type: "address",
120+
},
121+
{ internalType: "bytes", name: "hookData", type: "bytes" },
122+
],
123+
internalType: "struct PathKey[]",
124+
name: "path",
125+
type: "tuple[]",
126+
},
127+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
128+
],
129+
internalType: "struct IV4Quoter.QuoteExactParams",
130+
name: "params",
131+
type: "tuple",
132+
},
133+
],
134+
name: "_quoteExactOutput",
135+
outputs: [{ internalType: "bytes", name: "", type: "bytes" }],
136+
stateMutability: "nonpayable",
137+
type: "function",
138+
},
139+
{
140+
inputs: [
141+
{
142+
components: [
143+
{
144+
components: [
145+
{ internalType: "Currency", name: "currency0", type: "address" },
146+
{ internalType: "Currency", name: "currency1", type: "address" },
147+
{ internalType: "uint24", name: "fee", type: "uint24" },
148+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
149+
{
150+
internalType: "contract IHooks",
151+
name: "hooks",
152+
type: "address",
153+
},
154+
],
155+
internalType: "struct PoolKey",
156+
name: "poolKey",
157+
type: "tuple",
158+
},
159+
{ internalType: "bool", name: "zeroForOne", type: "bool" },
160+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
161+
{ internalType: "bytes", name: "hookData", type: "bytes" },
162+
],
163+
internalType: "struct IV4Quoter.QuoteExactSingleParams",
164+
name: "params",
165+
type: "tuple",
166+
},
167+
],
168+
name: "_quoteExactOutputSingle",
169+
outputs: [{ internalType: "bytes", name: "", type: "bytes" }],
170+
stateMutability: "nonpayable",
171+
type: "function",
172+
},
173+
{
174+
inputs: [],
175+
name: "poolManager",
176+
outputs: [
177+
{ internalType: "contract IPoolManager", name: "", type: "address" },
178+
],
179+
stateMutability: "view",
180+
type: "function",
181+
},
182+
{
183+
inputs: [
184+
{
185+
components: [
186+
{ internalType: "Currency", name: "exactCurrency", type: "address" },
187+
{
188+
components: [
189+
{
190+
internalType: "Currency",
191+
name: "intermediateCurrency",
192+
type: "address",
193+
},
194+
{ internalType: "uint24", name: "fee", type: "uint24" },
195+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
196+
{
197+
internalType: "contract IHooks",
198+
name: "hooks",
199+
type: "address",
200+
},
201+
{ internalType: "bytes", name: "hookData", type: "bytes" },
202+
],
203+
internalType: "struct PathKey[]",
204+
name: "path",
205+
type: "tuple[]",
206+
},
207+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
208+
],
209+
internalType: "struct IV4Quoter.QuoteExactParams",
210+
name: "params",
211+
type: "tuple",
212+
},
213+
],
214+
name: "quoteExactInput",
215+
outputs: [
216+
{ internalType: "uint256", name: "amountOut", type: "uint256" },
217+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
218+
],
219+
stateMutability: "nonpayable",
220+
type: "function",
221+
},
222+
{
223+
inputs: [
224+
{
225+
components: [
226+
{
227+
components: [
228+
{ internalType: "Currency", name: "currency0", type: "address" },
229+
{ internalType: "Currency", name: "currency1", type: "address" },
230+
{ internalType: "uint24", name: "fee", type: "uint24" },
231+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
232+
{
233+
internalType: "contract IHooks",
234+
name: "hooks",
235+
type: "address",
236+
},
237+
],
238+
internalType: "struct PoolKey",
239+
name: "poolKey",
240+
type: "tuple",
241+
},
242+
{ internalType: "bool", name: "zeroForOne", type: "bool" },
243+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
244+
{ internalType: "bytes", name: "hookData", type: "bytes" },
245+
],
246+
internalType: "struct IV4Quoter.QuoteExactSingleParams",
247+
name: "params",
248+
type: "tuple",
249+
},
250+
],
251+
name: "quoteExactInputSingle",
252+
outputs: [
253+
{ internalType: "uint256", name: "amountOut", type: "uint256" },
254+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
255+
],
256+
stateMutability: "nonpayable",
257+
type: "function",
258+
},
259+
{
260+
inputs: [
261+
{
262+
components: [
263+
{ internalType: "Currency", name: "exactCurrency", type: "address" },
264+
{
265+
components: [
266+
{
267+
internalType: "Currency",
268+
name: "intermediateCurrency",
269+
type: "address",
270+
},
271+
{ internalType: "uint24", name: "fee", type: "uint24" },
272+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
273+
{
274+
internalType: "contract IHooks",
275+
name: "hooks",
276+
type: "address",
277+
},
278+
{ internalType: "bytes", name: "hookData", type: "bytes" },
279+
],
280+
internalType: "struct PathKey[]",
281+
name: "path",
282+
type: "tuple[]",
283+
},
284+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
285+
],
286+
internalType: "struct IV4Quoter.QuoteExactParams",
287+
name: "params",
288+
type: "tuple",
289+
},
290+
],
291+
name: "quoteExactOutput",
292+
outputs: [
293+
{ internalType: "uint256", name: "amountIn", type: "uint256" },
294+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
295+
],
296+
stateMutability: "nonpayable",
297+
type: "function",
298+
},
299+
{
300+
inputs: [
301+
{
302+
components: [
303+
{
304+
components: [
305+
{ internalType: "Currency", name: "currency0", type: "address" },
306+
{ internalType: "Currency", name: "currency1", type: "address" },
307+
{ internalType: "uint24", name: "fee", type: "uint24" },
308+
{ internalType: "int24", name: "tickSpacing", type: "int24" },
309+
{
310+
internalType: "contract IHooks",
311+
name: "hooks",
312+
type: "address",
313+
},
314+
],
315+
internalType: "struct PoolKey",
316+
name: "poolKey",
317+
type: "tuple",
318+
},
319+
{ internalType: "bool", name: "zeroForOne", type: "bool" },
320+
{ internalType: "uint128", name: "exactAmount", type: "uint128" },
321+
{ internalType: "bytes", name: "hookData", type: "bytes" },
322+
],
323+
internalType: "struct IV4Quoter.QuoteExactSingleParams",
324+
name: "params",
325+
type: "tuple",
326+
},
327+
],
328+
name: "quoteExactOutputSingle",
329+
outputs: [
330+
{ internalType: "uint256", name: "amountIn", type: "uint256" },
331+
{ internalType: "uint256", name: "gasEstimate", type: "uint256" },
332+
],
333+
stateMutability: "nonpayable",
334+
type: "function",
335+
},
336+
{
337+
inputs: [{ internalType: "bytes", name: "data", type: "bytes" }],
338+
name: "unlockCallback",
339+
outputs: [{ internalType: "bytes", name: "", type: "bytes" }],
340+
stateMutability: "nonpayable",
341+
type: "function",
342+
},
343+
] as const;

src/hooks/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
// Placeholder for future React hooks
2-
export {};
1+
export { useGetQuote } from "./useGetQuote";

0 commit comments

Comments
 (0)