Skip to content

Commit 2f0a747

Browse files
committed
fix: getQuote types
1 parent 0af8ad2 commit 2f0a747

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/types/utils/getQuote.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { FeeTier } from "@/types/utils/getPool";
12
import type { Address, Hex } from "viem";
23

34
/**
@@ -10,14 +11,14 @@ export interface QuoteParams {
1011
tokens: [Address, Address];
1112

1213
/**
13-
* The fee tier of the pool (e.g., 500, 3000, 10000).
14+
* The fee tier of the pool (e.g., FeeTier.MEDIUM).
1415
*/
15-
feeTier: number;
16+
feeTier: FeeTier;
1617

1718
/**
18-
* The tick spacing for the pool. Must be a positive integer.
19+
* The tick spacing for the pool. If not provided, it will be derived from the fee tier.
1920
*/
20-
tickSpacing: number;
21+
tickSpacing?: number;
2122

2223
/**
2324
* The amount of tokens being swapped, expressed as a bigint.

src/utils/getQuote.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { V4QuoterAbi } from "@/constants/abis/V4Quoter";
22
import { getInstance } from "@/core/uniDevKitV4Factory";
33
import { sortTokens } from "@/helpers/tokens";
4+
import { FeeTier, TICK_SPACING_BY_FEE } from "@/types/utils/getPool";
45
import type { QuoteParams, QuoteResponse } from "@/types/utils/getQuote";
56
import { zeroAddress } from "viem";
67

@@ -35,12 +36,16 @@ export async function getQuote(
3536
params.tokens[1],
3637
);
3738

39+
// Use provided tick spacing or derive from fee tier
40+
const fee = (params.feeTier ?? FeeTier.MEDIUM) as FeeTier;
41+
const tickSpacing = params.tickSpacing ?? TICK_SPACING_BY_FEE[fee];
42+
3843
// Construct the poolKey
3944
const poolKey = {
4045
currency0,
4146
currency1,
42-
fee: params.feeTier,
43-
tickSpacing: params.tickSpacing,
47+
fee,
48+
tickSpacing,
4449
hooks: params.hooks || zeroAddress,
4550
};
4651

0 commit comments

Comments
 (0)