|
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" |
14 | 14 |
|
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 | +// } |
35 | 35 |
|
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 |
42 | 42 |
|
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 | +// } |
47 | 47 |
|
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 | +// } |
54 | 54 |
|
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 | +// } |
61 | 61 |
|
62 |
| - if (!result.supports || !result.match) return result |
| 62 | +// if (!result.supports || !result.match) return result |
63 | 63 |
|
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 | +// } |
82 | 82 |
|
83 |
| - return result |
84 |
| - } |
| 83 | +// return result |
| 84 | +// } |
85 | 85 |
|
86 |
| - async exactIn(swapParams: SwapParams) { |
87 |
| - const quote = await fetchKyberswapQuote(swapParams) |
| 86 | +// async exactIn(swapParams: SwapParams) { |
| 87 | +// const quote = await fetchKyberswapQuote(swapParams) |
88 | 88 |
|
89 |
| - return buildApiResponseExactInputFromQuote(swapParams, quote) |
90 |
| - } |
| 89 | +// return buildApiResponseExactInputFromQuote(swapParams, quote) |
| 90 | +// } |
91 | 91 |
|
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) |
99 | 99 |
|
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 | +// ] |
114 | 114 |
|
115 |
| - const swap = buildApiResponseSwap(swapParams.from, multicallItems) |
| 115 | +// const swap = buildApiResponseSwap(swapParams.from, multicallItems) |
116 | 116 |
|
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 | +// ) |
124 | 124 |
|
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