Skip to content

Commit 7628731

Browse files
committed
fix redirect deposit wrapper
1 parent 494cdeb commit 7628731

File tree

1 file changed

+56
-35
lines changed

1 file changed

+56
-35
lines changed

src/swapService/strategies/strategyRedirectDepositWrapper.ts

Lines changed: 56 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,48 +76,69 @@ export class StrategyRedirectDepositWrapper {
7676

7777
const innerSwapParams = {
7878
...swapParams,
79-
receiver: swapParams.from,
79+
// receiver: swapParams.from,
8080
routingOverride: routing,
8181
}
8282

8383
const innerSwaps = await runPipeline(innerSwapParams)
8484

8585
// split target debt repay into swap to Swapper, repay and deposit into escrow vault
8686
result.quotes = innerSwaps.map((innerSwap) => {
87-
const newMulticallItems = innerSwap.swap.multicallItems.flatMap(
88-
(item) => {
89-
if (
90-
item.functionName === "swap" &&
91-
item.args[0].mode === String(SwapperMode.TARGET_DEBT)
92-
) {
93-
const exactInSwapItemArgs = {
94-
...item.args[0],
95-
mode: SwapperMode.EXACT_IN,
96-
}
97-
98-
const swapItem = encodeSwapMulticallItem(exactInSwapItemArgs)
99-
// if target debt is 0, encode repay(max) to repay all debt, otherwise use all of the available Swapper balance
100-
const repayAmount =
101-
swapParams.targetDebt === 0n ? maxUint256 : maxUint256 - 1n
102-
103-
const repayItem = encodeRepayMulticallItem(
104-
vaultData.asset,
105-
swapParams.receiver,
106-
repayAmount,
107-
swapParams.accountOut,
108-
)
109-
const depositItem = encodeDepositMulticallItem(
110-
vaultData.asset,
111-
vaultData.assetDustEVault,
112-
5n,
113-
swapParams.accountOut,
114-
)
115-
116-
return [swapItem, repayItem, depositItem]
117-
}
118-
return item
119-
},
120-
)
87+
// const newMulticallItems = innerSwap.swap.multicallItems.flatMap(
88+
// (item) => {
89+
// if (
90+
// item.functionName === "swap" &&
91+
// item.args[0].mode === String(SwapperMode.TARGET_DEBT)
92+
// ) {
93+
// const exactInSwapItemArgs = {
94+
// ...item.args[0],
95+
// receiver: swapParams.receiver,
96+
// mode: SwapperMode.EXACT_IN,
97+
// }
98+
99+
// const swapItem = encodeSwapMulticallItem(exactInSwapItemArgs)
100+
// // if target debt is 0, encode repay(max) to repay all debt, otherwise use all of the available Swapper balance
101+
// const repayAmount =
102+
// swapParams.targetDebt === 0n ? maxUint256 : maxUint256 - 1n
103+
104+
// const repayItem = encodeRepayMulticallItem(
105+
// vaultData.asset,
106+
// swapParams.receiver,
107+
// repayAmount,
108+
// swapParams.accountOut,
109+
// )
110+
// console.log('swapParams.receiver: ', swapParams.receiver);
111+
// const depositItem = encodeDepositMulticallItem(
112+
// vaultData.asset,
113+
// vaultData.assetDustEVault,
114+
// 5n,
115+
// swapParams.accountOut,
116+
// )
117+
118+
// console.log('repayItem: ', repayItem);
119+
// return [swapItem, repayItem, depositItem]
120+
// }
121+
// return item
122+
// },
123+
// )
124+
125+
const newMulticallItems = innerSwap.swap.multicallItems.map((item) => {
126+
// Redirect deposits to receiver (debt vault) to designated vault
127+
if (
128+
item.functionName === "deposit" &&
129+
item.args[1] === swapParams.receiver
130+
) {
131+
item.args[1] = vaultData.assetDustEVault
132+
item = encodeDepositMulticallItem(
133+
item.args[0],
134+
vaultData.assetDustEVault,
135+
5n,
136+
swapParams.accountOut,
137+
)
138+
}
139+
140+
return item
141+
})
121142

122143
// reencode everything
123144

0 commit comments

Comments
 (0)