Skip to content

Commit cdbf213

Browse files
committed
add skip sweep flag
1 parent bbc7a96 commit cdbf213

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/api/routes/swap/swapModel.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,19 @@ const getSwapSchema = z.object({
262262
},
263263
example: "0x8A54C278D117854486db0F6460D901a180Fff5aa",
264264
}),
265+
skipSweepDepositOut: z
266+
.string()
267+
.toLowerCase()
268+
.transform((s) => JSON.parse(s))
269+
.pipe(z.boolean())
270+
.optional()
271+
.openapi({
272+
param: {
273+
description:
274+
"Do not add a final deposit of the output token (sweep). Leave the assets in the swapper. Useful if receiver is the Swapper",
275+
},
276+
example: "false",
277+
}),
265278
routingOverride: z
266279
.string()
267280
.transform((s) => JSON.parse(s))

src/swapService/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface SwapParams {
2727
routingOverride?: ChainRoutingConfig
2828
onlyFixedInputExactOut?: boolean // only fetch quotes where amountIn is fixed and not subject to slippage
2929
noRepayEncoding?: boolean // FIXME workaround for composite repays (ERC4626 strategy / overswap)
30+
skipSweepDepositOut?: boolean // don't add the final deposit of the bought asset (sweep), leave the assets in Swapper
3031
}
3132

3233
export interface SwapQuote {

src/swapService/utils.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,19 @@ export function addInOutDeposits(
277277
5n, // avoid zero shares error
278278
swapParams.accountIn,
279279
),
280-
encodeDepositMulticallItem(
281-
swapParams.tokenOut.addressInfo,
282-
swapParams.receiver,
283-
5n, // avoid zero shares error
284-
swapParams.dustAccount,
285-
),
286280
]
281+
282+
if (!swapParams.skipSweepDepositOut) {
283+
multicallItems.push(
284+
encodeDepositMulticallItem(
285+
swapParams.tokenOut.addressInfo,
286+
swapParams.receiver,
287+
5n, // avoid zero shares error
288+
swapParams.dustAccount,
289+
),
290+
)
291+
}
292+
287293
response.swap = buildApiResponseSwap(swapParams.from, multicallItems)
288294

289295
return response

0 commit comments

Comments
 (0)