Skip to content

Commit 98a0f62

Browse files
committed
feat: comment out deprecated
1 parent 9c61dd7 commit 98a0f62

File tree

4 files changed

+449
-449
lines changed

4 files changed

+449
-449
lines changed
Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
import * as chains from "viem/chains"
2-
import { SwapperMode } from "../interface"
3-
import { fetch1InchQuote } from "../quoters/quoter1Inch"
4-
import type { StrategyResult, SwapParams } from "../types"
5-
import { buildApiResponseExactInputFromQuote, matchParams } from "../utils"
6-
7-
export const defaultConfig = {
8-
chainsSupported: [
9-
chains.arbitrum.id,
10-
chains.aurora.id,
11-
chains.avalanche.id,
12-
chains.mainnet.id,
13-
chains.base.id,
14-
chains.bsc.id,
15-
chains.zksync.id,
16-
chains.fantom.id,
17-
chains.gnosis.id,
18-
chains.klaytn.id,
19-
chains.optimism.id,
20-
chains.polygon.id,
21-
] as number[],
22-
}
23-
24-
export class Strategy1Inch {
25-
static name() {
26-
return "1inch"
27-
}
28-
readonly match
29-
readonly config
30-
31-
constructor(match = {}, config = defaultConfig) {
32-
this.match = match
33-
this.config = config
34-
}
35-
36-
async supports(swapParams: SwapParams) {
37-
return (
38-
this.config.chainsSupported.includes(swapParams.chainId) &&
39-
!swapParams.isRepay &&
40-
swapParams.swapperMode === SwapperMode.EXACT_IN
41-
)
42-
}
43-
44-
async findSwap(swapParams: SwapParams): Promise<StrategyResult> {
45-
const result: StrategyResult = {
46-
strategy: Strategy1Inch.name(),
47-
supports: await this.supports(swapParams),
48-
match: matchParams(swapParams, this.match),
49-
}
50-
51-
if (!result.supports || !result.match) return result
52-
53-
try {
54-
const quote = await fetch1InchQuote(swapParams)
55-
56-
result.response = buildApiResponseExactInputFromQuote(swapParams, quote)
57-
} catch (error) {
58-
result.error = error instanceof Error ? error.message : error
59-
}
60-
61-
return result
62-
}
63-
}
1+
// import * as chains from "viem/chains"
2+
// import { SwapperMode } from "../interface"
3+
// import { fetch1InchQuote } from "../quoters/quoter1Inch"
4+
// import type { StrategyResult, SwapParams } from "../types"
5+
// import { buildApiResponseExactInputFromQuote, matchParams } from "../utils"
6+
7+
// export const defaultConfig = {
8+
// chainsSupported: [
9+
// chains.arbitrum.id,
10+
// chains.aurora.id,
11+
// chains.avalanche.id,
12+
// chains.mainnet.id,
13+
// chains.base.id,
14+
// chains.bsc.id,
15+
// chains.zksync.id,
16+
// chains.fantom.id,
17+
// chains.gnosis.id,
18+
// chains.klaytn.id,
19+
// chains.optimism.id,
20+
// chains.polygon.id,
21+
// ] as number[],
22+
// }
23+
24+
// export class Strategy1Inch {
25+
// static name() {
26+
// return "1inch"
27+
// }
28+
// readonly match
29+
// readonly config
30+
31+
// constructor(match = {}, config = defaultConfig) {
32+
// this.match = match
33+
// this.config = config
34+
// }
35+
36+
// async supports(swapParams: SwapParams) {
37+
// return (
38+
// this.config.chainsSupported.includes(swapParams.chainId) &&
39+
// !swapParams.isRepay &&
40+
// swapParams.swapperMode === SwapperMode.EXACT_IN
41+
// )
42+
// }
43+
44+
// async findSwap(swapParams: SwapParams): Promise<StrategyResult> {
45+
// const result: StrategyResult = {
46+
// strategy: Strategy1Inch.name(),
47+
// supports: await this.supports(swapParams),
48+
// match: matchParams(swapParams, this.match),
49+
// }
50+
51+
// if (!result.supports || !result.match) return result
52+
53+
// try {
54+
// const quote = await fetch1InchQuote(swapParams)
55+
56+
// result.response = buildApiResponseExactInputFromQuote(swapParams, quote)
57+
// } catch (error) {
58+
// result.error = error instanceof Error ? error.message : error
59+
// }
60+
61+
// return result
62+
// }
63+
// }
Lines changed: 127 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,142 @@
1-
import * as chains from "viem/chains"
2-
import { SwapperMode } from "../interface"
3-
import { fetchKyberswapOverswapQuote, fetchKyberswapQuote } from "../quoters"
4-
import type { StrategyResult, SwapParams } from "../types"
5-
import {
6-
SWAPPER_HANDLER_GENERIC,
7-
buildApiResponseExactInputFromQuote,
8-
buildApiResponseSwap,
9-
buildApiResponseVerifyDebtMax,
10-
encodeSwapMulticallItem,
11-
isExactInRepay,
12-
matchParams,
13-
} from "../utils"
1+
// import * as chains from "viem/chains"
2+
// import { SwapperMode } from "../interface"
3+
// import { fetchKyberswapOverswapQuote, fetchKyberswapQuote } from "../quoters"
4+
// import type { StrategyResult, SwapParams } from "../types"
5+
// import {
6+
// SWAPPER_HANDLER_GENERIC,
7+
// buildApiResponseExactInputFromQuote,
8+
// buildApiResponseSwap,
9+
// buildApiResponseVerifyDebtMax,
10+
// encodeSwapMulticallItem,
11+
// isExactInRepay,
12+
// matchParams,
13+
// } from "../utils"
1414

15-
export const defaultConfig = {
16-
chainsSupported: [
17-
chains.arbitrum.id,
18-
chains.aurora.id,
19-
chains.avalanche.id,
20-
chains.bsc.id,
21-
chains.bitTorrent.id,
22-
chains.cronos.id,
23-
chains.mainnet.id,
24-
chains.fantom.id,
25-
chains.polygon.id,
26-
chains.optimism.id,
27-
chains.linea.id,
28-
chains.base.id,
29-
chains.polygonZkEvm.id,
30-
chains.scroll.id,
31-
chains.blast.id,
32-
chains.mantle.id,
33-
] as number[],
34-
}
15+
// export const defaultConfig = {
16+
// chainsSupported: [
17+
// chains.arbitrum.id,
18+
// chains.aurora.id,
19+
// chains.avalanche.id,
20+
// chains.bsc.id,
21+
// chains.bitTorrent.id,
22+
// chains.cronos.id,
23+
// chains.mainnet.id,
24+
// chains.fantom.id,
25+
// chains.polygon.id,
26+
// chains.optimism.id,
27+
// chains.linea.id,
28+
// chains.base.id,
29+
// chains.polygonZkEvm.id,
30+
// chains.scroll.id,
31+
// chains.blast.id,
32+
// chains.mantle.id,
33+
// ] as number[],
34+
// }
3535

36-
export class StrategyKyberswap {
37-
static name() {
38-
return "kyberswap"
39-
}
40-
readonly match
41-
readonly config
36+
// export class StrategyKyberswap {
37+
// static name() {
38+
// return "kyberswap"
39+
// }
40+
// readonly match
41+
// readonly config
4242

43-
constructor(match = {}, config = defaultConfig) {
44-
this.match = match
45-
this.config = config
46-
}
43+
// constructor(match = {}, config = defaultConfig) {
44+
// this.match = match
45+
// this.config = config
46+
// }
4747

48-
async supports(swapParams: SwapParams) {
49-
return (
50-
!isExactInRepay(swapParams) &&
51-
this.config.chainsSupported.includes(swapParams.chainId)
52-
)
53-
}
48+
// async supports(swapParams: SwapParams) {
49+
// return (
50+
// !isExactInRepay(swapParams) &&
51+
// this.config.chainsSupported.includes(swapParams.chainId)
52+
// )
53+
// }
5454

55-
async findSwap(swapParams: SwapParams): Promise<StrategyResult> {
56-
const result: StrategyResult = {
57-
strategy: StrategyKyberswap.name(),
58-
supports: await this.supports(swapParams),
59-
match: matchParams(swapParams, this.match),
60-
}
55+
// async findSwap(swapParams: SwapParams): Promise<StrategyResult> {
56+
// const result: StrategyResult = {
57+
// strategy: StrategyKyberswap.name(),
58+
// supports: await this.supports(swapParams),
59+
// match: matchParams(swapParams, this.match),
60+
// }
6161

62-
if (!result.supports || !result.match) return result
62+
// if (!result.supports || !result.match) return result
6363

64-
try {
65-
switch (swapParams.swapperMode) {
66-
case SwapperMode.EXACT_IN: {
67-
result.response = await this.exactIn(swapParams)
68-
break
69-
}
70-
case SwapperMode.TARGET_DEBT: {
71-
result.response = await this.targetDebt(swapParams)
72-
break
73-
}
74-
// case SwapperMode.EXACT_OUT:
75-
default: {
76-
result.error = "Unsupported swap mode"
77-
}
78-
}
79-
} catch (error) {
80-
result.error = error
81-
}
64+
// try {
65+
// switch (swapParams.swapperMode) {
66+
// case SwapperMode.EXACT_IN: {
67+
// result.response = await this.exactIn(swapParams)
68+
// break
69+
// }
70+
// case SwapperMode.TARGET_DEBT: {
71+
// result.response = await this.targetDebt(swapParams)
72+
// break
73+
// }
74+
// // case SwapperMode.EXACT_OUT:
75+
// default: {
76+
// result.error = "Unsupported swap mode"
77+
// }
78+
// }
79+
// } catch (error) {
80+
// result.error = error
81+
// }
8282

83-
return result
84-
}
83+
// return result
84+
// }
8585

86-
async exactIn(swapParams: SwapParams) {
87-
const quote = await fetchKyberswapQuote(swapParams)
86+
// async exactIn(swapParams: SwapParams) {
87+
// const quote = await fetchKyberswapQuote(swapParams)
8888

89-
return buildApiResponseExactInputFromQuote(swapParams, quote)
90-
}
89+
// return buildApiResponseExactInputFromQuote(swapParams, quote)
90+
// }
9191

92-
async targetDebt(swapParams: SwapParams) {
93-
// into the swapper
94-
const innerSwapParams = {
95-
...swapParams,
96-
receiver: swapParams.from,
97-
}
98-
const innerSwap = await fetchKyberswapOverswapQuote(innerSwapParams)
92+
// async targetDebt(swapParams: SwapParams) {
93+
// // into the swapper
94+
// const innerSwapParams = {
95+
// ...swapParams,
96+
// receiver: swapParams.from,
97+
// }
98+
// const innerSwap = await fetchKyberswapOverswapQuote(innerSwapParams)
9999

100-
const multicallItems = [
101-
encodeSwapMulticallItem({
102-
handler: SWAPPER_HANDLER_GENERIC,
103-
mode: BigInt(SwapperMode.TARGET_DEBT),
104-
account: swapParams.accountOut,
105-
tokenIn: swapParams.tokenIn.addressInfo,
106-
tokenOut: swapParams.tokenOut.addressInfo,
107-
vaultIn: swapParams.vaultIn,
108-
accountIn: swapParams.accountIn,
109-
receiver: swapParams.receiver,
110-
amountOut: swapParams.targetDebt,
111-
data: innerSwap.swap.multicallItems[0].args[0].data, // TODO fix kyber quoter returns just a single swap multicall with the original pendle payload
112-
}),
113-
]
100+
// const multicallItems = [
101+
// encodeSwapMulticallItem({
102+
// handler: SWAPPER_HANDLER_GENERIC,
103+
// mode: BigInt(SwapperMode.TARGET_DEBT),
104+
// account: swapParams.accountOut,
105+
// tokenIn: swapParams.tokenIn.addressInfo,
106+
// tokenOut: swapParams.tokenOut.addressInfo,
107+
// vaultIn: swapParams.vaultIn,
108+
// accountIn: swapParams.accountIn,
109+
// receiver: swapParams.receiver,
110+
// amountOut: swapParams.targetDebt,
111+
// data: innerSwap.swap.multicallItems[0].args[0].data, // TODO fix kyber quoter returns just a single swap multicall with the original pendle payload
112+
// }),
113+
// ]
114114

115-
const swap = buildApiResponseSwap(swapParams.from, multicallItems)
115+
// const swap = buildApiResponseSwap(swapParams.from, multicallItems)
116116

117-
const verify = buildApiResponseVerifyDebtMax(
118-
swapParams.chainId,
119-
swapParams.receiver,
120-
swapParams.accountOut,
121-
swapParams.targetDebt,
122-
swapParams.deadline,
123-
)
117+
// const verify = buildApiResponseVerifyDebtMax(
118+
// swapParams.chainId,
119+
// swapParams.receiver,
120+
// swapParams.accountOut,
121+
// swapParams.targetDebt,
122+
// swapParams.deadline,
123+
// )
124124

125-
return {
126-
amountIn: innerSwap.amountIn,
127-
amountInMax: innerSwap.amountInMax,
128-
amountOut: innerSwap.amountOut,
129-
amountOutMin: innerSwap.amountOutMin,
130-
vaultIn: swapParams.vaultIn,
131-
receiver: swapParams.receiver,
132-
accountIn: swapParams.accountIn,
133-
accountOut: swapParams.accountOut,
134-
tokenIn: swapParams.tokenIn,
135-
tokenOut: swapParams.tokenOut,
136-
slippage: swapParams.slippage,
137-
route: innerSwap.route,
138-
swap,
139-
verify,
140-
}
141-
}
142-
}
125+
// return {
126+
// amountIn: innerSwap.amountIn,
127+
// amountInMax: innerSwap.amountInMax,
128+
// amountOut: innerSwap.amountOut,
129+
// amountOutMin: innerSwap.amountOutMin,
130+
// vaultIn: swapParams.vaultIn,
131+
// receiver: swapParams.receiver,
132+
// accountIn: swapParams.accountIn,
133+
// accountOut: swapParams.accountOut,
134+
// tokenIn: swapParams.tokenIn,
135+
// tokenOut: swapParams.tokenOut,
136+
// slippage: swapParams.slippage,
137+
// route: innerSwap.route,
138+
// swap,
139+
// verify,
140+
// }
141+
// }
142+
// }

0 commit comments

Comments
 (0)