@merkl/api 0.10.198 → 0.10.200

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. package/dist/src/eden/index.d.ts +2 -6398
  2. package/dist/src/errors/HttpError.d.ts +5 -0
  3. package/dist/src/errors/HttpError.js +6 -0
  4. package/dist/src/errors/NotFound.error.d.ts +4 -0
  5. package/dist/src/errors/NotFound.error.js +5 -0
  6. package/dist/src/index.d.ts +1 -2464
  7. package/dist/src/index.js +56 -7
  8. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicData.js +15 -22
  9. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/factoryFinder.js +1 -0
  10. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.d.ts +3 -1
  11. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/helpers/tokenType.js +8 -0
  12. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GammaProcessor.d.ts +43 -0
  13. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GammaProcessor.js +63 -0
  14. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.d.ts +3 -3
  15. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/GenericProcessor.js +3 -1
  16. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/NoLinkVaultProcessor.d.ts +36 -0
  17. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/NoLinkVaultProcessor.js +51 -0
  18. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/StakingProcessor.d.ts +0 -1
  19. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/StakingProcessor.js +15 -7
  20. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/processor/processorMapping.js +4 -0
  21. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPrices.d.ts +1 -1
  22. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPrices.js +13 -572
  23. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.d.ts +2 -21
  24. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1.js +197 -1174
  25. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2.d.ts +1 -5
  26. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2.js +11 -634
  27. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3.d.ts +1 -4
  28. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3.js +10 -380
  29. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4.d.ts +3 -3
  30. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4.js +11 -312
  31. package/dist/src/libs/campaigns/campaignTypes/EulerDynamicData.js +8 -8
  32. package/dist/src/libs/campaigns/campaignTypes/RadiantDynamicData.js +3 -4
  33. package/dist/src/libs/campaigns/campaignsDynamicData.js +0 -5
  34. package/dist/src/modules/v4/accounting/accounting.controller.js +1 -1
  35. package/dist/src/modules/v4/apr/apr.model.d.ts +26 -0
  36. package/dist/src/modules/v4/apr/apr.model.js +15 -1
  37. package/dist/src/modules/v4/blacklist/blacklist.controller.js +1 -1
  38. package/dist/src/modules/v4/campaign/campaign.controller.d.ts +4 -4
  39. package/dist/src/modules/v4/campaign/campaign.controller.js +14 -4
  40. package/dist/src/modules/v4/campaign/campaign.model.d.ts +50 -5
  41. package/dist/src/modules/v4/campaign/campaign.model.js +47 -13
  42. package/dist/src/modules/v4/campaign/campaign.repository.d.ts +2 -2
  43. package/dist/src/modules/v4/campaign/campaign.service.d.ts +2 -2
  44. package/dist/src/modules/v4/chain/chain.controller.d.ts +2 -2
  45. package/dist/src/modules/v4/chain/chain.controller.js +7 -2
  46. package/dist/src/modules/v4/chain/chain.model.d.ts +6 -1
  47. package/dist/src/modules/v4/chain/chain.model.js +8 -1
  48. package/dist/src/modules/v4/chain/chain.repository.js +1 -1
  49. package/dist/src/modules/v4/claims/claims.controller.js +1 -1
  50. package/dist/src/modules/v4/dynamicData/dynamicData.controller.js +4 -1
  51. package/dist/src/modules/v4/enso/enso.model.d.ts +1 -1
  52. package/dist/src/modules/v4/enso/enso.model.js +2 -1
  53. package/dist/src/modules/v4/enso/enso.service.d.ts +0 -1
  54. package/dist/src/modules/v4/enso/enso.service.js +4 -4
  55. package/dist/src/modules/v4/interaction/interaction.controller.d.ts +26 -17
  56. package/dist/src/modules/v4/interaction/interaction.controller.js +19 -28
  57. package/dist/src/modules/v4/interaction/interaction.model.d.ts +17 -5
  58. package/dist/src/modules/v4/interaction/interaction.model.js +3 -3
  59. package/dist/src/modules/v4/interaction/interaction.service.d.ts +18 -3
  60. package/dist/src/modules/v4/interaction/interaction.service.js +89 -11
  61. package/dist/src/modules/v4/kyberzap/kyberzap.model.d.ts +72 -0
  62. package/dist/src/modules/v4/kyberzap/kyberzap.model.js +79 -0
  63. package/dist/src/modules/v4/kyberzap/kyberzap.service.d.ts +15 -0
  64. package/dist/src/modules/v4/kyberzap/kyberzap.service.js +84 -0
  65. package/dist/src/modules/v4/liquidity/liquidity.controller.js +1 -1
  66. package/dist/src/modules/v4/merklRoot/merklRoot.controller.js +1 -1
  67. package/dist/src/modules/v4/opportunity/opportunity.controller.d.ts +224 -213
  68. package/dist/src/modules/v4/opportunity/opportunity.controller.js +39 -10
  69. package/dist/src/modules/v4/opportunity/opportunity.model.d.ts +252 -22
  70. package/dist/src/modules/v4/opportunity/opportunity.model.js +58 -15
  71. package/dist/src/modules/v4/opportunity/opportunity.repository.d.ts +11 -11
  72. package/dist/src/modules/v4/opportunity/opportunity.service.d.ts +12 -232
  73. package/dist/src/modules/v4/opportunity/opportunity.service.js +0 -32
  74. package/dist/src/modules/v4/price/price.controller.js +1 -1
  75. package/dist/src/modules/v4/protocol/protocol.controller.d.ts +23 -24
  76. package/dist/src/modules/v4/protocol/protocol.controller.js +15 -9
  77. package/dist/src/modules/v4/protocol/protocol.model.d.ts +13 -1
  78. package/dist/src/modules/v4/protocol/protocol.model.js +12 -8
  79. package/dist/src/modules/v4/reward/reward.controller.js +1 -1
  80. package/dist/src/modules/v4/reward/reward.model.d.ts +44 -1
  81. package/dist/src/modules/v4/reward/reward.model.js +15 -0
  82. package/dist/src/modules/v4/reward/reward.repository.d.ts +2 -2
  83. package/dist/src/modules/v4/reward/reward.service.d.ts +11 -11
  84. package/dist/src/modules/v4/reward/reward.service.js +1 -2
  85. package/dist/src/modules/v4/router.d.ts +287 -268
  86. package/dist/src/modules/v4/status/status.controller.js +2 -3
  87. package/dist/src/modules/v4/status/status.model.d.ts +12 -0
  88. package/dist/src/modules/v4/status/status.model.js +12 -0
  89. package/dist/src/modules/v4/status/status.service.js +0 -1
  90. package/dist/src/modules/v4/token/token.controller.d.ts +4 -4
  91. package/dist/src/modules/v4/token/token.controller.js +1 -1
  92. package/dist/src/modules/v4/token/token.model.d.ts +12 -0
  93. package/dist/src/modules/v4/token/token.model.js +12 -0
  94. package/dist/src/modules/v4/token/token.repository.d.ts +2 -2
  95. package/dist/src/modules/v4/token/token.service.d.ts +7 -7
  96. package/dist/src/modules/v4/tvl/tvl.model.d.ts +24 -0
  97. package/dist/src/modules/v4/tvl/tvl.model.js +15 -1
  98. package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.d.ts +1 -1
  99. package/dist/src/modules/v4/uniswapV4/uniswapV4.controller.js +9 -8
  100. package/dist/src/modules/v4/user/user.controller.d.ts +4 -4
  101. package/dist/src/modules/v4/user/user.controller.js +20 -17
  102. package/dist/src/modules/v4/user/user.model.d.ts +30 -0
  103. package/dist/src/modules/v4/user/user.model.js +27 -0
  104. package/dist/src/modules/v4/zyfi/zyfi.model.d.ts +45 -0
  105. package/dist/src/modules/v4/zyfi/zyfi.model.js +1 -0
  106. package/dist/src/modules/v4/zyfi/zyfi.service.d.ts +30 -0
  107. package/dist/src/modules/v4/zyfi/zyfi.service.js +35 -0
  108. package/dist/src/plugins/error-handling.plugin.d.ts +2 -2
  109. package/dist/src/plugins/error-handling.plugin.js +9 -3
  110. package/dist/src/plugins/logger.plugin.js +1 -20
  111. package/dist/src/routes/v1/allowances.d.ts +1 -1
  112. package/dist/src/routes/v1/allowances.js +1 -1
  113. package/dist/src/routes/v1/balances.d.ts +1 -1
  114. package/dist/src/routes/v1/balances.js +1 -1
  115. package/dist/src/routes/v1/prices.d.ts +1 -1
  116. package/dist/src/routes/v1/prices.js +1 -1
  117. package/dist/src/routes/v1/router.d.ts +102 -0
  118. package/dist/src/routes/v1/router.js +6 -0
  119. package/dist/src/routes/v1/tokens.d.ts +1 -1
  120. package/dist/src/routes/v1/tokens.js +1 -1
  121. package/dist/src/routes/v2/merkl.d.ts +5 -5
  122. package/dist/src/routes/v2/merkl.js +1 -1
  123. package/dist/src/routes/v2/router.d.ts +46 -0
  124. package/dist/src/routes/v2/router.js +3 -0
  125. package/dist/src/routes/v3/app.d.ts +1 -1
  126. package/dist/src/routes/v3/app.js +1 -1
  127. package/dist/src/routes/v3/blacklist.d.ts +1 -2479
  128. package/dist/src/routes/v3/blacklist.js +1 -1
  129. package/dist/src/routes/v3/campaignClaims.d.ts +1 -1
  130. package/dist/src/routes/v3/campaignClaims.js +1 -1
  131. package/dist/src/routes/v3/campaignReport.d.ts +1 -1
  132. package/dist/src/routes/v3/campaignReport.js +1 -1
  133. package/dist/src/routes/v3/campaignUnclaimed.d.ts +1 -1
  134. package/dist/src/routes/v3/campaignUnclaimed.js +1 -1
  135. package/dist/src/routes/v3/campaigns.d.ts +1 -2483
  136. package/dist/src/routes/v3/campaigns.js +1 -1
  137. package/dist/src/routes/v3/campaignsForMainParameter.d.ts +1 -1
  138. package/dist/src/routes/v3/campaignsForMainParameter.js +1 -1
  139. package/dist/src/routes/v3/campaignsInfo.d.ts +1 -2481
  140. package/dist/src/routes/v3/campaignsInfo.js +1 -1
  141. package/dist/src/routes/v3/campaignsRewardsReport.d.ts +1 -1
  142. package/dist/src/routes/v3/campaignsRewardsReport.js +1 -1
  143. package/dist/src/routes/v3/claims.d.ts +1 -1
  144. package/dist/src/routes/v3/claims.js +1 -1
  145. package/dist/src/routes/v3/compoundV2.d.ts +1 -1
  146. package/dist/src/routes/v3/compoundV2.js +1 -1
  147. package/dist/src/routes/v3/createCampaign.d.ts +1 -1
  148. package/dist/src/routes/v3/createCampaign.js +1 -1
  149. package/dist/src/routes/v3/dolomite.d.ts +1 -1
  150. package/dist/src/routes/v3/dolomite.js +1 -1
  151. package/dist/src/routes/v3/euler.d.ts +1 -1
  152. package/dist/src/routes/v3/euler.js +1 -1
  153. package/dist/src/routes/v3/fetch.d.ts +1 -1
  154. package/dist/src/routes/v3/fetch.js +1 -1
  155. package/dist/src/routes/v3/health.d.ts +1 -1
  156. package/dist/src/routes/v3/health.js +1 -1
  157. package/dist/src/routes/v3/lostyield.d.ts +1 -1
  158. package/dist/src/routes/v3/lostyield.js +1 -1
  159. package/dist/src/routes/v3/merkl.d.ts +1 -1
  160. package/dist/src/routes/v3/merkl.js +1 -1
  161. package/dist/src/routes/v3/morphoMarkets.d.ts +1 -1
  162. package/dist/src/routes/v3/morphoMarkets.js +1 -1
  163. package/dist/src/routes/v3/morphoVaults.d.ts +1 -1
  164. package/dist/src/routes/v3/morphoVaults.js +1 -1
  165. package/dist/src/routes/v3/multiChainPositions.d.ts +1 -2480
  166. package/dist/src/routes/v3/multiChainPositions.js +1 -1
  167. package/dist/src/routes/v3/opportunity.d.ts +1 -2483
  168. package/dist/src/routes/v3/opportunity.js +1 -1
  169. package/dist/src/routes/v3/overview.d.ts +1 -1
  170. package/dist/src/routes/v3/overview.js +1 -1
  171. package/dist/src/routes/v3/parse.d.ts +1 -1
  172. package/dist/src/routes/v3/parse.js +1 -1
  173. package/dist/src/routes/v3/payload.d.ts +1 -1
  174. package/dist/src/routes/v3/payload.js +1 -1
  175. package/dist/src/routes/v3/poolInfo.js +1 -1
  176. package/dist/src/routes/v3/positions.d.ts +1 -2479
  177. package/dist/src/routes/v3/positions.js +1 -1
  178. package/dist/src/routes/v3/radiant.d.ts +1 -1
  179. package/dist/src/routes/v3/radiant.js +1 -1
  180. package/dist/src/routes/v3/recipients.d.ts +1 -1
  181. package/dist/src/routes/v3/recipients.js +1 -1
  182. package/dist/src/routes/v3/rewards.d.ts +1 -2508
  183. package/dist/src/routes/v3/rewards.js +1 -1
  184. package/dist/src/routes/v3/rewardsReport.d.ts +1 -1
  185. package/dist/src/routes/v3/rewardsReport.js +1 -1
  186. package/dist/src/routes/v3/router.d.ts +1 -0
  187. package/dist/src/routes/v3/router.js +74 -0
  188. package/dist/src/routes/v3/silo.d.ts +1 -1
  189. package/dist/src/routes/v3/silo.js +1 -1
  190. package/dist/src/routes/v3/token.d.ts +1 -1
  191. package/dist/src/routes/v3/token.js +1 -1
  192. package/dist/src/routes/v3/tokenUnclaimed.d.ts +1 -1
  193. package/dist/src/routes/v3/tokenUnclaimed.js +1 -1
  194. package/dist/src/routes/v3/updates.d.ts +1 -2483
  195. package/dist/src/routes/v3/updates.js +1 -1
  196. package/dist/src/routes/v3/userRewards.d.ts +1 -2499
  197. package/dist/src/routes/v3/userRewards.js +1 -1
  198. package/dist/src/utils/decodeCalls.js +12 -1
  199. package/dist/src/utils/encodeCalls.js +26 -3
  200. package/dist/src/utils/generateCardName.js +2 -0
  201. package/dist/tsconfig.package.tsbuildinfo +1 -1
  202. package/package.json +2 -3
  203. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicDataRefacto.d.ts +0 -3
  204. package/dist/src/libs/campaigns/campaignTypes/ERC20DynamicDataRefacto.js +0 -155
  205. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPricesRefactoFinal.d.ts +0 -4
  206. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesPricesRefactoFinal.js +0 -24
  207. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.d.ts +0 -4
  208. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound1RefactoFinal.js +0 -230
  209. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2RefactoFinal.d.ts +0 -3
  210. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound2RefactoFinal.js +0 -22
  211. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3RefactoFinal.d.ts +0 -3
  212. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound3RefactoFinal.js +0 -22
  213. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4RefactoFinal.d.ts +0 -4
  214. package/dist/src/libs/campaigns/campaignTypes/ERC20SubTypes/subtypesRound4RefactoFinal.js +0 -22
  215. package/dist/src/libs/campaigns/campaignsDynamicDataRefacto.d.ts +0 -3
  216. package/dist/src/libs/campaigns/campaignsDynamicDataRefacto.js +0 -75
@@ -1,33 +1,111 @@
1
+ import { decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
2
+ import { ChainInteractionService } from "../chainInteraction";
1
3
  import { EnsoService } from "../enso/enso.service";
2
- import { TokenService } from "../token";
4
+ import { KyberZapService } from "../kyberzap/kyberzap.service";
3
5
  export class InteractionService {
4
6
  static async getTarget(chainId, protocolId, identifier) {
7
+ const targets = [];
8
+ const slug = EnsoService.getSlug(protocolId);
9
+ if (slug) {
10
+ const tokens = await EnsoService.getTokens(chainId, slug, identifier);
11
+ const ensoTargets = await InteractionService.getTargetsFromEnsoTokens(tokens);
12
+ targets.push(ensoTargets?.[0]);
13
+ }
14
+ return targets;
15
+ }
16
+ static getTargetFromKyberZap(chainId, protocolId, identifier) {
17
+ const dexId = KyberZapService.getDexId(protocolId);
18
+ const chainLabel = KyberZapService.getChainLabel(chainId);
19
+ if (!dexId || !chainLabel)
20
+ return;
21
+ return {
22
+ provider: "zap",
23
+ chainId: chainId,
24
+ identifier: identifier,
25
+ };
26
+ }
27
+ static async getTargetFromEnso(chainId, protocolId, identifier) {
5
28
  const slug = EnsoService.getSlug(protocolId);
6
29
  if (!slug)
7
30
  return;
8
31
  const tokens = await EnsoService.getTokens(chainId, slug, identifier);
9
- return await InteractionService.getTargetsFromEnsoTokens(tokens);
32
+ const ensoTargets = await InteractionService.getTargetsFromEnsoTokens(tokens);
33
+ return ensoTargets?.[0];
10
34
  }
11
35
  static async getTargetsFromEnsoTokens(tokens) {
12
36
  const targets = [];
13
37
  for (const { address, underlyingTokens, ...target } of tokens) {
14
38
  try {
15
- const [utilityToken, ...assetTokens] = await TokenService.getManyOrCreate([{ chainId: target.chainId, address }].concat(underlyingTokens));
16
39
  targets.push({
40
+ provider: "enso",
41
+ chainId: target.chainId,
17
42
  identifier: address,
18
- name: `${utilityToken?.symbol}: ${assetTokens.map(t => t?.symbol).join("/")}`,
19
- tokens: assetTokens.filter(t => t !== undefined),
20
43
  });
21
44
  }
22
45
  catch { }
23
46
  }
24
47
  return targets;
25
48
  }
26
- static async getTargets(chainId, protocolId) {
27
- const slug = EnsoService.getSlug(protocolId);
28
- if (!slug)
29
- return;
30
- const tokens = await EnsoService.getTokens(chainId, slug);
31
- return await InteractionService.getTargetsFromEnsoTokens(tokens);
49
+ static async getTargets(chainId, protocolId, identifier) {
50
+ const targets = [];
51
+ const ensoTarget = await InteractionService.getTargetFromEnso(chainId, protocolId, identifier);
52
+ const zapTarget = InteractionService.getTargetFromKyberZap(chainId, protocolId, identifier);
53
+ if (zapTarget)
54
+ targets.push(zapTarget);
55
+ if (ensoTarget)
56
+ targets.push(ensoTarget);
57
+ return targets;
58
+ }
59
+ /**
60
+ * Gets approval information onchain
61
+ * @returns approved?, approval tx & allowance amount
62
+ */
63
+ static async getApproval(chainId, owner, spender, tokenAddress, amount) {
64
+ //TODO: add utils to make using viem type-safety more concise
65
+ const abi = parseAbi([
66
+ "function approve(address, uint256) returns (bool)",
67
+ "function allowance(address owner, address spender) returns (uint256)",
68
+ ]);
69
+ const decode = (r) => decodeFunctionResult({
70
+ abi,
71
+ functionName: "allowance",
72
+ data: r?.returnData,
73
+ });
74
+ const allowance = await ChainInteractionService(chainId).fetchAndDecode({
75
+ target: tokenAddress,
76
+ allowFailure: true,
77
+ callData: encodeFunctionData({
78
+ abi,
79
+ functionName: "allowance",
80
+ args: [owner, spender],
81
+ }),
82
+ }, decode);
83
+ const approved = allowance >= amount;
84
+ return {
85
+ approved,
86
+ allowance,
87
+ approval: {
88
+ to: tokenAddress,
89
+ data: encodeFunctionData({
90
+ abi,
91
+ functionName: "approve",
92
+ args: [spender, amount],
93
+ }),
94
+ },
95
+ };
96
+ }
97
+ static async getTransaction(provider, chainId, protocolId, identifier, userAddress, fromTokenAddress, fromTokenAmount) {
98
+ if (provider === "zap")
99
+ return await KyberZapService.getTransaction(chainId, protocolId, identifier, userAddress, fromTokenAddress, fromTokenAmount);
100
+ const { tx, ...quote } = await EnsoService.getTransaction({
101
+ fromAddress: userAddress,
102
+ tokenIn: [fromTokenAddress],
103
+ tokenOut: [identifier],
104
+ amountIn: [fromTokenAmount.toString()],
105
+ routingStrategy: "router",
106
+ chainId,
107
+ });
108
+ const { allowance, approval, approved } = await InteractionService.getApproval(chainId, userAddress, tx.to, fromTokenAddress, fromTokenAmount);
109
+ return { ...quote, allowance, approval, approved, transaction: tx };
32
110
  }
33
111
  }
@@ -0,0 +1,72 @@
1
+ export declare const dexIdToProtocolId: {
2
+ readonly DEX_UNISWAPV3: "uniswap-v3";
3
+ readonly DEX_UNISWAPV2: "uniswap-v2";
4
+ readonly DEX_PANCAKESWAPV3: "pancakeswap-v3";
5
+ readonly DEX_SUSHISWAPV3: "sushiswap-v3";
6
+ readonly DEX_CURVE: "curve";
7
+ readonly DEX_QUICKSWAPV3UNI: "quickswap-uni";
8
+ readonly DEX_QUICKSWAPV3ALGEBRA: "quickswap-algebra";
9
+ readonly DEX_THRUSTERV3: "thruster";
10
+ readonly DEX_CAMELOTV3: "camelot";
11
+ readonly DEX_BEEFY: "beefy";
12
+ readonly DEX_KOICL: "koi";
13
+ readonly DEX_AERODROMECL: "aerodrome";
14
+ readonly DEX_BALANCER: "balancer";
15
+ };
16
+ export declare const chainToKyberLabel: {
17
+ [chainId: number]: string;
18
+ };
19
+ export type KyberZapDexId = keyof typeof dexIdToProtocolId;
20
+ export declare const apiTypes: {
21
+ readonly "/api/v1/in/route": {
22
+ readonly query: import("@sinclair/typebox").TObject<{
23
+ dex: import("@sinclair/typebox").TString;
24
+ "pool.id": import("@sinclair/typebox").TString;
25
+ "position.tickLower": import("@sinclair/typebox").TString;
26
+ "position.tickUpper": import("@sinclair/typebox").TString;
27
+ tokenIn: import("@sinclair/typebox").TString;
28
+ amountIn: import("@sinclair/typebox").TString;
29
+ feeAddress: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
30
+ feePcm: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TNumber>;
31
+ }>;
32
+ readonly response: import("@sinclair/typebox").TObject<{
33
+ message: import("@sinclair/typebox").TString;
34
+ data: import("@sinclair/typebox").TObject<{
35
+ poolDetails: import("@sinclair/typebox").TObject<{}>;
36
+ positionDetails: import("@sinclair/typebox").TObject<{}>;
37
+ zapDetails: import("@sinclair/typebox").TObject<{
38
+ actions: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{}>>;
39
+ finalAmountUsd: import("@sinclair/typebox").TString;
40
+ priceImpact: import("@sinclair/typebox").TNumber;
41
+ }>;
42
+ route: import("@sinclair/typebox").TString;
43
+ routerAddress: import("@sinclair/typebox").TString;
44
+ }>;
45
+ requestId: import("@sinclair/typebox").TString;
46
+ }>;
47
+ };
48
+ readonly "/api/v1/in/route/build": {
49
+ readonly query: import("@sinclair/typebox").TObject<{}>;
50
+ readonly body: import("@sinclair/typebox").TObject<{
51
+ sender: import("@sinclair/typebox").TString;
52
+ recipient: import("@sinclair/typebox").TString;
53
+ route: import("@sinclair/typebox").TString;
54
+ deadline: import("@sinclair/typebox").TNumber;
55
+ source: import("@sinclair/typebox").TString;
56
+ }>;
57
+ readonly response: import("@sinclair/typebox").TObject<{
58
+ message: import("@sinclair/typebox").TString;
59
+ data: import("@sinclair/typebox").TObject<{
60
+ routerAddress: import("@sinclair/typebox").TString;
61
+ callData: import("@sinclair/typebox").TString;
62
+ value: import("@sinclair/typebox").TString;
63
+ }>;
64
+ requestId: import("@sinclair/typebox").TString;
65
+ }>;
66
+ };
67
+ };
68
+ export type KyberZapRoute = keyof typeof apiTypes;
69
+ export type KyberZapPostRoute = {
70
+ [R in KyberZapRoute]: "body" extends keyof KyberZapApi<R> ? R : never;
71
+ }[KyberZapRoute];
72
+ export type KyberZapApi<T extends KyberZapRoute> = (typeof apiTypes)[T];
@@ -0,0 +1,79 @@
1
+ import { ChainId } from "@sdk";
2
+ import { t } from "elysia";
3
+ export const dexIdToProtocolId = {
4
+ DEX_UNISWAPV3: "uniswap-v3",
5
+ DEX_UNISWAPV2: "uniswap-v2",
6
+ DEX_PANCAKESWAPV3: "pancakeswap-v3",
7
+ DEX_SUSHISWAPV3: "sushiswap-v3",
8
+ DEX_CURVE: "curve",
9
+ DEX_QUICKSWAPV3UNI: "quickswap-uni",
10
+ DEX_QUICKSWAPV3ALGEBRA: "quickswap-algebra",
11
+ DEX_THRUSTERV3: "thruster",
12
+ DEX_CAMELOTV3: "camelot",
13
+ DEX_BEEFY: "beefy",
14
+ DEX_KOICL: "koi",
15
+ DEX_AERODROMECL: "aerodrome",
16
+ DEX_BALANCER: "balancer",
17
+ };
18
+ export const chainToKyberLabel = {
19
+ [ChainId.ARBITRUM]: "arbitrum",
20
+ [ChainId.AVALANCHE]: "avalance",
21
+ [ChainId.BASE]: "base",
22
+ [ChainId.BLAST]: "blast",
23
+ [ChainId.BSC]: "bsc",
24
+ [ChainId.MAINNET]: "ethereum",
25
+ [ChainId.LINEA]: "linea",
26
+ [ChainId.OPTIMISM]: "optimism",
27
+ [ChainId.POLYGON]: "polygon",
28
+ [ChainId.POLYGONZKEVM]: "polygon-zkevm",
29
+ [ChainId.SCROLL]: "scroll",
30
+ [ChainId.ZKSYNC]: "zksync",
31
+ };
32
+ export const apiTypes = {
33
+ "/api/v1/in/route": {
34
+ query: t.Object({
35
+ dex: t.String({ example: "DEX_UNISWAPV3" }),
36
+ "pool.id": t.String({ example: "0x2f5e87c9312fa29aed5c179e456625d79015299c" }),
37
+ "position.tickLower": t.String(),
38
+ "position.tickUpper": t.String(),
39
+ tokenIn: t.String(),
40
+ amountIn: t.String(),
41
+ feeAddress: t.Optional(t.String()),
42
+ feePcm: t.Optional(t.Number()),
43
+ }),
44
+ response: t.Object({
45
+ message: t.String({ example: "OK" }),
46
+ data: t.Object({
47
+ poolDetails: t.Object({}),
48
+ positionDetails: t.Object({}),
49
+ zapDetails: t.Object({
50
+ actions: t.Array(t.Object({})),
51
+ finalAmountUsd: t.String(),
52
+ priceImpact: t.Number(),
53
+ }),
54
+ route: t.String(),
55
+ routerAddress: t.String(),
56
+ }),
57
+ requestId: t.String(),
58
+ }),
59
+ },
60
+ "/api/v1/in/route/build": {
61
+ query: t.Object({}),
62
+ body: t.Object({
63
+ sender: t.String(),
64
+ recipient: t.String(),
65
+ route: t.String(),
66
+ deadline: t.Number(),
67
+ source: t.String(),
68
+ }),
69
+ response: t.Object({
70
+ message: t.String({ example: "OK" }),
71
+ data: t.Object({
72
+ routerAddress: t.String(),
73
+ callData: t.String(),
74
+ value: t.String(),
75
+ }),
76
+ requestId: t.String(),
77
+ }),
78
+ },
79
+ };
@@ -0,0 +1,15 @@
1
+ import type { InteractionQuote } from "../interaction/interaction.model";
2
+ import type { ProtocolId } from "../protocol";
3
+ import { type KyberZapDexId } from "./kyberzap.model";
4
+ export declare abstract class KyberZapService {
5
+ #private;
6
+ static getDexId(protocolId: ProtocolId | string): KyberZapDexId | undefined;
7
+ static getChainLabel(chainId: number): string | undefined;
8
+ static getProtocolId(dexId: KyberZapDexId | string): ProtocolId | undefined;
9
+ /**
10
+ * @notice We don't handle tick setting in the UI for now, until we do this give the full-range ticks
11
+ * @param param0
12
+ */
13
+ static getFullRangeTicks(): number[];
14
+ static getTransaction(chainId: number, protocol: ProtocolId, identifier: string, userAddress: string, fromTokenAddress: string, fromTokenAmount: bigint): Promise<InteractionQuote>;
15
+ }
@@ -0,0 +1,84 @@
1
+ import { InteractionService } from "../interaction/interaction.service";
2
+ import { chainToKyberLabel, dexIdToProtocolId, } from "./kyberzap.model";
3
+ const KYBERZAP = `https://zap-api.kyberswap.com/`;
4
+ export class KyberZapService {
5
+ static async #fetch(route, params) {
6
+ const res = await fetch(`${KYBERZAP}${chainToKyberLabel[params?.chainId] ?? ""}${route}?${params?.query ? new URLSearchParams(params?.query) : ""}`, {
7
+ headers: new Headers({
8
+ Authorization: `Bearer ${process.env.KYBERSWAP_ZAP_API_KEY}`,
9
+ "Content-Type": "application/json",
10
+ }),
11
+ });
12
+ if (res.status !== 200)
13
+ throw new Error((await res.json())?.message);
14
+ return (await res.json());
15
+ }
16
+ static async #post(route, params) {
17
+ const res = await fetch(`${KYBERZAP}${chainToKyberLabel[params?.chainId] ?? ""}${route}`, {
18
+ method: "POST",
19
+ body: JSON.stringify(params?.body),
20
+ headers: new Headers({
21
+ Authorization: `Bearer ${"8dbbda50-6ed5-4bda-bf54-ea2796602057"}`,
22
+ "Content-Type": "application/json",
23
+ }),
24
+ });
25
+ if (res.status !== 200)
26
+ throw new Error((await res.json())?.message);
27
+ return (await res.json());
28
+ }
29
+ static getDexId(protocolId) {
30
+ const dexId = Object.entries(dexIdToProtocolId).find(([_, id]) => id === protocolId)?.[0];
31
+ return dexId;
32
+ }
33
+ static getChainLabel(chainId) {
34
+ return chainToKyberLabel?.[chainId];
35
+ }
36
+ static getProtocolId(dexId) {
37
+ return dexIdToProtocolId[dexId];
38
+ }
39
+ /**
40
+ * @notice We don't handle tick setting in the UI for now, until we do this give the full-range ticks
41
+ * @param param0
42
+ */
43
+ static getFullRangeTicks() {
44
+ return [-886800, 886800];
45
+ }
46
+ static async getTransaction(chainId, protocol, identifier, userAddress, fromTokenAddress, fromTokenAmount) {
47
+ const [lower, upper] = KyberZapService.getFullRangeTicks();
48
+ const { data: route } = await KyberZapService.#fetch("/api/v1/in/route", {
49
+ query: {
50
+ tokenIn: fromTokenAddress,
51
+ amountIn: fromTokenAmount?.toString(),
52
+ "pool.id": identifier,
53
+ "position.tickLower": lower?.toString(),
54
+ "position.tickUpper": upper?.toString(),
55
+ dex: KyberZapService.getDexId(protocol),
56
+ },
57
+ chainId,
58
+ });
59
+ const { data: transaction } = await KyberZapService.#post("/api/v1/in/route/build", {
60
+ query: {},
61
+ body: {
62
+ //TODO: add a more relevant value here
63
+ deadline: 1800000000,
64
+ recipient: userAddress,
65
+ sender: userAddress,
66
+ route: route.route,
67
+ source: "merkl",
68
+ },
69
+ chainId,
70
+ });
71
+ const { allowance, approval, approved } = await InteractionService.getApproval(chainId, userAddress, route.routerAddress, fromTokenAddress, fromTokenAmount);
72
+ return {
73
+ allowance,
74
+ approval,
75
+ approved,
76
+ amountIn: fromTokenAmount,
77
+ transaction: {
78
+ to: transaction.routerAddress,
79
+ data: transaction.callData,
80
+ value: 0n,
81
+ },
82
+ };
83
+ }
84
+ }
@@ -3,7 +3,7 @@ import { Elysia } from "elysia";
3
3
  import { PositionsInputDto } from "./liquidity.model";
4
4
  import { LiquidityService } from "./liquidity.service";
5
5
  // ─── Positions Controller ──────────────────────────────────────────────
6
- export const LiquidityController = new Elysia({ prefix: "/liquidity", detail: { tags: ["Positions"] } })
6
+ export const LiquidityController = new Elysia({ prefix: "/liquidity", detail: { tags: ["Positions"], hide: true } })
7
7
  // ─── Get User Positions on a Chain ───────────────────────────────────
8
8
  .get("/", async ({ query }) => {
9
9
  return await LiquidityService.fetchPositions(query);
@@ -4,7 +4,7 @@ import Elysia from "elysia";
4
4
  import { CreateRootDto, RootByTimestampsDto } from "./merklRoot.model";
5
5
  import { MerklRootService } from "./merklRoot.service";
6
6
  // ─── Merkl Roots Controller ─────────────────────────────────────────────
7
- export const MerklRootController = new Elysia({ prefix: "/roots", detail: { tags: ["Roots"] } })
7
+ export const MerklRootController = new Elysia({ prefix: "/roots", detail: { tags: ["Roots"], hide: true } })
8
8
  // ─── Get Merkl Root By Timestamp ─────────────────────────────────────
9
9
  .get("/", async ({ query }) => await MerklRootService.rootForTimestamp(query), {
10
10
  query: RootByTimestampsDto,