Skip to content
This repository was archived by the owner on Jun 19, 2025. It is now read-only.

Commit ff2da13

Browse files
committed
add fee option to route method and build swap method
1 parent 7d166a0 commit ff2da13

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/routers/alpha-router/alpha-router.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ import {
120120
SwapAndAddConfig,
121121
SwapAndAddOptions,
122122
SwapAndAddParameters,
123+
SwapConfig,
123124
SwapOptions,
124125
SwapRoute,
125126
SwapToRatioResponse,
@@ -1082,7 +1083,7 @@ export class AlphaRouter
10821083
amount: CurrencyAmount,
10831084
quoteCurrency: Currency,
10841085
tradeType: TradeType,
1085-
swapConfig?: SwapOptions,
1086+
swapConfig?: SwapConfig,
10861087
partialRoutingConfig: Partial<AlphaRouterConfig> = {}
10871088
): Promise<SwapRoute | null> {
10881089
const originalAmount = amount;

src/routers/router.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ export type SwapOptionsSwapRouter02 = {
188188

189189
export type SwapOptions = SwapOptionsUniversalRouter | SwapOptionsSwapRouter02;
190190

191+
export type SwapConfig = SwapOptions & { fee?: { fee: Percent; recipient: string } };
192+
191193
// Config passed in to determine configurations on acceptable liquidity
192194
// to add to a position and max iterations on the route-finding algorithm
193195
export type SwapAndAddConfig = {

src/util/methodParameters.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
MixedRouteWithValidQuote,
2121
RouteWithValidQuote,
2222
SWAP_ROUTER_02_ADDRESSES,
23-
SwapOptions,
23+
SwapConfig,
2424
SwapType,
2525
V2RouteWithValidQuote,
2626
V3RouteWithValidQuote,
@@ -236,7 +236,7 @@ export function buildTrade<TTradeType extends TradeType>(
236236

237237
export function buildSwapMethodParameters(
238238
trade: Trade<Currency, Currency, TradeType>,
239-
swapConfig: SwapOptions,
239+
swapConfig: SwapConfig,
240240
chainId: ChainId
241241
): MethodParameters {
242242
if (swapConfig.type == SwapType.UNIVERSAL_ROUTER) {
@@ -245,7 +245,7 @@ export function buildSwapMethodParameters(
245245
to: UNIVERSAL_ROUTER_ADDRESS(chainId),
246246
};
247247
} else if (swapConfig.type == SwapType.SWAP_ROUTER_02) {
248-
const { recipient, slippageTolerance, deadline, inputTokenPermit } =
248+
const { recipient, slippageTolerance, deadline, inputTokenPermit, fee } =
249249
swapConfig;
250250

251251
return {
@@ -254,6 +254,7 @@ export function buildSwapMethodParameters(
254254
slippageTolerance,
255255
deadlineOrPreviousBlockhash: deadline,
256256
inputTokenPermit,
257+
fee
257258
}),
258259
to: SWAP_ROUTER_02_ADDRESSES(chainId),
259260
};

0 commit comments

Comments
 (0)