@upshiftfinance/sdk 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +408 -2
  3. package/lib/abis/AddressResolver.d.ts +28 -0
  4. package/lib/abis/AddressResolver.js +23 -0
  5. package/lib/abis/ChainlinkV3.d.ts +87 -0
  6. package/lib/abis/ChainlinkV3.js +117 -0
  7. package/lib/abis/ERC20.d.ts +168 -0
  8. package/lib/abis/ERC20.js +226 -0
  9. package/lib/abis/ERC20_Bytes32.d.ts +139 -0
  10. package/lib/abis/ERC20_Bytes32.js +196 -0
  11. package/lib/abis/ERC4626.d.ts +364 -0
  12. package/lib/abis/ERC4626.js +507 -0
  13. package/lib/abis/ERC721.d.ts +231 -0
  14. package/lib/abis/ERC721.js +321 -0
  15. package/lib/abis/FeeOracle.d.ts +120 -0
  16. package/lib/abis/FeeOracle.js +162 -0
  17. package/lib/abis/LendingPool.d.ts +1393 -0
  18. package/lib/abis/LendingPool.js +1807 -0
  19. package/lib/abis/LendingPoolV2.d.ts +1413 -0
  20. package/lib/abis/LendingPoolV2.js +1833 -0
  21. package/lib/abis/LendingPoolV3.d.ts +1677 -0
  22. package/lib/abis/LendingPoolV3.js +1160 -0
  23. package/lib/abis/Loan.d.ts +837 -0
  24. package/lib/abis/Loan.js +1080 -0
  25. package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
  26. package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
  27. package/lib/abis/Multicall3.d.ts +30 -0
  28. package/lib/abis/Multicall3.js +97 -0
  29. package/lib/abis/OFT.d.ts +116 -0
  30. package/lib/abis/OFT.js +85 -0
  31. package/lib/abis/PoolAdapter.d.ts +36 -0
  32. package/lib/abis/PoolAdapter.js +51 -0
  33. package/lib/abis/RewardDistributor.d.ts +267 -0
  34. package/lib/abis/RewardDistributor.js +352 -0
  35. package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
  36. package/lib/abis/RwaRedeemSubaccount.js +548 -0
  37. package/lib/abis/SmartAccount.d.ts +17 -0
  38. package/lib/abis/SmartAccount.js +19 -0
  39. package/lib/abis/SwapRouter.d.ts +953 -0
  40. package/lib/abis/SwapRouter.js +1228 -0
  41. package/lib/abis/TextResolver.d.ts +16 -0
  42. package/lib/abis/TextResolver.js +16 -0
  43. package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
  44. package/lib/abis/TokenizedVaultV2.js +1041 -0
  45. package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
  46. package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
  47. package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
  48. package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
  49. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
  50. package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
  51. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
  52. package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
  53. package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
  54. package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
  55. package/lib/abis/UniversalResolverResolve.d.ts +69 -0
  56. package/lib/abis/UniversalResolverResolve.js +35 -0
  57. package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
  58. package/lib/abis/UniversalSignatureValidator.js +30 -0
  59. package/lib/abis/WrapperAdapter.d.ts +71 -0
  60. package/lib/abis/WrapperAdapter.js +77 -0
  61. package/lib/abis/index.d.ts +34 -0
  62. package/lib/abis/index.js +51 -0
  63. package/lib/adapters/evm/getters.d.ts +19 -0
  64. package/lib/adapters/evm/getters.js +249 -0
  65. package/lib/adapters/evm/index.d.ts +539 -0
  66. package/lib/adapters/evm/index.js +656 -0
  67. package/lib/adapters/evm/utils.d.ts +8 -0
  68. package/lib/adapters/evm/utils.js +51 -0
  69. package/lib/adapters/solana/confirm.d.ts +88 -0
  70. package/lib/adapters/solana/confirm.js +291 -0
  71. package/lib/adapters/solana/constants.d.ts +42 -0
  72. package/lib/adapters/solana/constants.js +59 -0
  73. package/lib/adapters/solana/getters.d.ts +42 -0
  74. package/lib/adapters/solana/getters.js +275 -0
  75. package/lib/adapters/solana/idl/vault-idl.d.ts +700 -0
  76. package/lib/adapters/solana/idl/vault-idl.js +2101 -0
  77. package/lib/adapters/solana/idl/withdrawal-queue-idl.d.ts +795 -0
  78. package/lib/adapters/solana/idl/withdrawal-queue-idl.js +1864 -0
  79. package/lib/adapters/solana/index.d.ts +372 -0
  80. package/lib/adapters/solana/index.js +459 -0
  81. package/lib/adapters/solana/pricing.d.ts +184 -0
  82. package/lib/adapters/solana/pricing.js +239 -0
  83. package/lib/adapters/solana/queue-hints.d.ts +29 -0
  84. package/lib/adapters/solana/queue-hints.js +59 -0
  85. package/lib/adapters/solana/queue.actions.d.ts +97 -0
  86. package/lib/adapters/solana/queue.actions.js +468 -0
  87. package/lib/adapters/solana/token-reads.d.ts +108 -0
  88. package/lib/adapters/solana/token-reads.js +145 -0
  89. package/lib/adapters/solana/types.d.ts +325 -0
  90. package/lib/adapters/solana/types.js +3 -0
  91. package/lib/adapters/solana/utils.d.ts +229 -0
  92. package/lib/adapters/solana/utils.js +773 -0
  93. package/lib/adapters/solana/vault.actions.d.ts +140 -0
  94. package/lib/adapters/solana/vault.actions.js +657 -0
  95. package/lib/adapters/solana/withdrawal-queue.d.ts +125 -0
  96. package/lib/adapters/solana/withdrawal-queue.js +301 -0
  97. package/lib/adapters/stellar/actions.d.ts +41 -0
  98. package/lib/adapters/stellar/actions.js +126 -0
  99. package/lib/adapters/stellar/constants.d.ts +43 -0
  100. package/lib/adapters/stellar/constants.js +53 -0
  101. package/lib/adapters/stellar/getters.d.ts +68 -0
  102. package/lib/adapters/stellar/getters.js +290 -0
  103. package/lib/adapters/stellar/index.d.ts +126 -0
  104. package/lib/adapters/stellar/index.js +187 -0
  105. package/lib/adapters/stellar/invocation.d.ts +55 -0
  106. package/lib/adapters/stellar/invocation.js +92 -0
  107. package/lib/adapters/stellar/soroban.d.ts +131 -0
  108. package/lib/adapters/stellar/soroban.js +617 -0
  109. package/lib/adapters/stellar/submit.d.ts +42 -0
  110. package/lib/adapters/stellar/submit.js +195 -0
  111. package/lib/adapters/stellar/types.d.ts +57 -0
  112. package/lib/adapters/stellar/types.js +6 -0
  113. package/lib/adapters/stellar/utils.d.ts +24 -0
  114. package/lib/adapters/stellar/utils.js +34 -0
  115. package/lib/adapters/sui/client.d.ts +83 -0
  116. package/lib/adapters/sui/client.js +216 -0
  117. package/lib/adapters/sui/constants.d.ts +33 -0
  118. package/lib/adapters/sui/constants.js +31 -0
  119. package/lib/adapters/sui/index.d.ts +57 -0
  120. package/lib/adapters/sui/index.js +100 -0
  121. package/lib/adapters/sui/targets.d.ts +171 -0
  122. package/lib/adapters/sui/targets.js +225 -0
  123. package/lib/adapters/sui/utils.d.ts +8 -0
  124. package/lib/adapters/sui/utils.js +17 -0
  125. package/lib/core/analytics/app-name.d.ts +27 -0
  126. package/lib/core/analytics/app-name.js +48 -0
  127. package/lib/core/analytics/chain-name.d.ts +9 -0
  128. package/lib/core/analytics/chain-name.js +34 -0
  129. package/lib/core/analytics/constants.d.ts +15 -0
  130. package/lib/core/analytics/constants.js +28 -0
  131. package/lib/core/analytics/env.d.ts +46 -0
  132. package/lib/core/analytics/env.js +147 -0
  133. package/lib/core/analytics/index.d.ts +39 -0
  134. package/lib/core/analytics/index.js +83 -0
  135. package/lib/core/analytics/instrumentation.d.ts +29 -0
  136. package/lib/core/analytics/instrumentation.js +292 -0
  137. package/lib/core/analytics/method-taxonomy.d.ts +19 -0
  138. package/lib/core/analytics/method-taxonomy.js +156 -0
  139. package/lib/core/analytics/metrics.d.ts +48 -0
  140. package/lib/core/analytics/metrics.js +142 -0
  141. package/lib/core/analytics/sanitize.d.ts +57 -0
  142. package/lib/core/analytics/sanitize.js +272 -0
  143. package/lib/core/analytics/sentry-runtime.d.ts +15 -0
  144. package/lib/core/analytics/sentry-runtime.js +131 -0
  145. package/lib/core/analytics/sentry.d.ts +100 -0
  146. package/lib/core/analytics/sentry.js +696 -0
  147. package/lib/core/analytics/types.d.ts +55 -0
  148. package/lib/core/analytics/types.js +3 -0
  149. package/lib/core/analytics/user-identity.d.ts +55 -0
  150. package/lib/core/analytics/user-identity.js +218 -0
  151. package/lib/core/analytics/version.d.ts +6 -0
  152. package/lib/core/analytics/version.js +10 -0
  153. package/lib/core/attribution.d.ts +159 -0
  154. package/lib/core/attribution.js +194 -0
  155. package/lib/core/auth/index.d.ts +1 -0
  156. package/lib/core/auth/index.js +18 -0
  157. package/lib/core/auth/verify.d.ts +2 -0
  158. package/lib/core/auth/verify.js +35 -0
  159. package/lib/core/base.class.d.ts +193 -0
  160. package/lib/core/base.class.js +163 -0
  161. package/lib/core/cache.d.ts +9 -0
  162. package/lib/core/cache.js +31 -0
  163. package/lib/core/constants/adapters.d.ts +103 -0
  164. package/lib/core/constants/adapters.js +180 -0
  165. package/lib/core/constants/core.d.ts +162 -0
  166. package/lib/core/constants/core.js +281 -0
  167. package/lib/core/constants/swap-router.d.ts +180 -0
  168. package/lib/core/constants/swap-router.js +203 -0
  169. package/lib/core/constants/vaults.d.ts +93 -0
  170. package/lib/core/constants/vaults.js +277 -0
  171. package/lib/core/constants/web3.d.ts +106 -0
  172. package/lib/core/constants/web3.js +251 -0
  173. package/lib/core/errors/index.d.ts +177 -0
  174. package/lib/core/errors/index.js +257 -0
  175. package/lib/core/fetcher.d.ts +237 -0
  176. package/lib/core/fetcher.js +1103 -0
  177. package/lib/core/helpers/adapters.d.ts +13 -0
  178. package/lib/core/helpers/adapters.js +39 -0
  179. package/lib/core/helpers/chain-address.d.ts +13 -0
  180. package/lib/core/helpers/chain-address.js +47 -0
  181. package/lib/core/helpers/chain-error.d.ts +207 -0
  182. package/lib/core/helpers/chain-error.js +697 -0
  183. package/lib/core/helpers/chain-support.d.ts +98 -0
  184. package/lib/core/helpers/chain-support.js +139 -0
  185. package/lib/core/helpers/concurrency.d.ts +51 -0
  186. package/lib/core/helpers/concurrency.js +79 -0
  187. package/lib/core/helpers/core.d.ts +92 -0
  188. package/lib/core/helpers/core.js +368 -0
  189. package/lib/core/helpers/explorer-link.d.ts +16 -0
  190. package/lib/core/helpers/explorer-link.js +26 -0
  191. package/lib/core/helpers/multicall.d.ts +68 -0
  192. package/lib/core/helpers/multicall.js +103 -0
  193. package/lib/core/helpers/revert-decode.d.ts +248 -0
  194. package/lib/core/helpers/revert-decode.js +515 -0
  195. package/lib/core/helpers/signer.d.ts +61 -0
  196. package/lib/core/helpers/signer.js +184 -0
  197. package/lib/core/helpers/swap-router.d.ts +269 -0
  198. package/lib/core/helpers/swap-router.js +542 -0
  199. package/lib/core/helpers/vault-version.d.ts +24 -0
  200. package/lib/core/helpers/vault-version.js +83 -0
  201. package/lib/core/helpers/vaults.d.ts +89 -0
  202. package/lib/core/helpers/vaults.js +241 -0
  203. package/lib/core/helpers/web3.d.ts +366 -0
  204. package/lib/core/helpers/web3.js +1034 -0
  205. package/lib/core/index.d.ts +23 -0
  206. package/lib/core/index.js +40 -0
  207. package/lib/core/logger/curator-alert.d.ts +217 -0
  208. package/lib/core/logger/curator-alert.js +276 -0
  209. package/lib/core/logger/index.d.ts +99 -0
  210. package/lib/core/logger/index.js +163 -0
  211. package/lib/core/logger/slack.d.ts +49 -0
  212. package/lib/core/logger/slack.js +111 -0
  213. package/lib/core/vault-metadata.d.ts +12 -0
  214. package/lib/core/vault-metadata.js +42 -0
  215. package/lib/core/version-check.d.ts +58 -0
  216. package/lib/core/version-check.js +182 -0
  217. package/lib/evm/index.d.ts +2 -0
  218. package/lib/evm/index.js +19 -0
  219. package/lib/evm/methods/crossChainVault.d.ts +132 -0
  220. package/lib/evm/methods/crossChainVault.js +857 -0
  221. package/lib/evm/methods/crossChainVaultRegistry.d.ts +92 -0
  222. package/lib/evm/methods/crossChainVaultRegistry.js +239 -0
  223. package/lib/evm/methods/index.d.ts +2 -0
  224. package/lib/evm/methods/index.js +19 -0
  225. package/lib/evm/types/crossChain.d.ts +363 -0
  226. package/lib/evm/types/crossChain.js +20 -0
  227. package/lib/evm/types/index.d.ts +1 -0
  228. package/lib/evm/types/index.js +18 -0
  229. package/lib/index.d.ts +30 -0
  230. package/lib/index.js +52 -0
  231. package/lib/main.d.ts +596 -0
  232. package/lib/main.js +681 -0
  233. package/lib/modules/api/fetcher.d.ts +108 -0
  234. package/lib/modules/api/fetcher.js +187 -0
  235. package/lib/modules/api/index.d.ts +1 -0
  236. package/lib/modules/api/index.js +6 -0
  237. package/lib/modules/api/main.d.ts +587 -0
  238. package/lib/modules/api/main.js +911 -0
  239. package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
  240. package/lib/modules/sub-accounts/fetcher.js +96 -0
  241. package/lib/modules/sub-accounts/index.d.ts +2 -0
  242. package/lib/modules/sub-accounts/index.js +19 -0
  243. package/lib/modules/sub-accounts/main.d.ts +249 -0
  244. package/lib/modules/sub-accounts/main.js +211 -0
  245. package/lib/modules/sub-accounts/utils.d.ts +106 -0
  246. package/lib/modules/sub-accounts/utils.js +112 -0
  247. package/lib/modules/vaults/adapter.helpers.d.ts +84 -0
  248. package/lib/modules/vaults/adapter.helpers.js +202 -0
  249. package/lib/modules/vaults/fetcher.d.ts +147 -0
  250. package/lib/modules/vaults/fetcher.js +357 -0
  251. package/lib/modules/vaults/getters.d.ts +1060 -0
  252. package/lib/modules/vaults/getters.js +4079 -0
  253. package/lib/modules/vaults/index.d.ts +20 -0
  254. package/lib/modules/vaults/index.js +44 -0
  255. package/lib/modules/vaults/main.d.ts +607 -0
  256. package/lib/modules/vaults/main.js +1687 -0
  257. package/lib/modules/vaults/prefetch.d.ts +65 -0
  258. package/lib/modules/vaults/prefetch.js +120 -0
  259. package/lib/modules/vaults/read.actions.d.ts +406 -0
  260. package/lib/modules/vaults/read.actions.js +891 -0
  261. package/lib/modules/vaults/types.d.ts +149 -0
  262. package/lib/modules/vaults/types.js +3 -0
  263. package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
  264. package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
  265. package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
  266. package/lib/modules/vaults/utils/date-utils.js +84 -0
  267. package/lib/modules/vaults/utils.d.ts +153 -0
  268. package/lib/modules/vaults/utils.js +818 -0
  269. package/lib/modules/vaults/write.actions.d.ts +812 -0
  270. package/lib/modules/vaults/write.actions.js +2377 -0
  271. package/lib/polyfills.d.ts +1 -0
  272. package/lib/polyfills.js +12 -0
  273. package/lib/sdk.d.ts +30173 -0
  274. package/lib/services/coingecko/fetcher.d.ts +15 -0
  275. package/lib/services/coingecko/fetcher.js +67 -0
  276. package/lib/services/coingecko/index.d.ts +2 -0
  277. package/lib/services/coingecko/index.js +19 -0
  278. package/lib/services/coingecko/utils.d.ts +1 -0
  279. package/lib/services/coingecko/utils.js +24 -0
  280. package/lib/services/debank/fetcher.d.ts +126 -0
  281. package/lib/services/debank/fetcher.js +47 -0
  282. package/lib/services/debank/index.d.ts +2 -0
  283. package/lib/services/debank/index.js +19 -0
  284. package/lib/services/debank/utils.d.ts +50 -0
  285. package/lib/services/debank/utils.js +325 -0
  286. package/lib/services/layerzero/deposits.d.ts +55 -0
  287. package/lib/services/layerzero/deposits.js +174 -0
  288. package/lib/services/layerzero/redeems.d.ts +20 -0
  289. package/lib/services/layerzero/redeems.js +92 -0
  290. package/lib/services/layerzero/utils.d.ts +9 -0
  291. package/lib/services/layerzero/utils.js +22 -0
  292. package/lib/services/octavfi/fetcher.d.ts +33 -0
  293. package/lib/services/octavfi/fetcher.js +39 -0
  294. package/lib/services/octavfi/index.d.ts +3 -0
  295. package/lib/services/octavfi/index.js +20 -0
  296. package/lib/services/octavfi/types.d.ts +34 -0
  297. package/lib/services/octavfi/types.js +3 -0
  298. package/lib/services/octavfi/utils.d.ts +16 -0
  299. package/lib/services/octavfi/utils.js +244 -0
  300. package/lib/services/subgraph/fetcher.d.ts +2 -0
  301. package/lib/services/subgraph/fetcher.js +66 -0
  302. package/lib/services/subgraph/index.d.ts +2 -0
  303. package/lib/services/subgraph/index.js +19 -0
  304. package/lib/services/subgraph/schema.d.ts +48 -0
  305. package/lib/services/subgraph/schema.js +87 -0
  306. package/lib/services/subgraph/vaults.d.ts +83 -0
  307. package/lib/services/subgraph/vaults.js +1282 -0
  308. package/lib/services/swap-quotes/index.d.ts +105 -0
  309. package/lib/services/swap-quotes/index.js +77 -0
  310. package/lib/services/swap-quotes/paraswap.d.ts +51 -0
  311. package/lib/services/swap-quotes/paraswap.js +138 -0
  312. package/lib/services/untangled/fetcher.d.ts +40 -0
  313. package/lib/services/untangled/fetcher.js +110 -0
  314. package/lib/services/untangled/index.d.ts +3 -0
  315. package/lib/services/untangled/index.js +20 -0
  316. package/lib/services/untangled/types.d.ts +83 -0
  317. package/lib/services/untangled/types.js +10 -0
  318. package/lib/services/untangled/utils.d.ts +91 -0
  319. package/lib/services/untangled/utils.js +339 -0
  320. package/lib/types/api.d.ts +498 -0
  321. package/lib/types/api.js +3 -0
  322. package/lib/types/index.d.ts +12 -0
  323. package/lib/types/index.js +28 -0
  324. package/lib/types/points.d.ts +28 -0
  325. package/lib/types/points.js +3 -0
  326. package/lib/types/pools.d.ts +144 -0
  327. package/lib/types/pools.js +3 -0
  328. package/lib/types/staking.d.ts +28 -0
  329. package/lib/types/staking.js +3 -0
  330. package/lib/types/sub-accounts.d.ts +150 -0
  331. package/lib/types/sub-accounts.js +3 -0
  332. package/lib/types/subgraph.d.ts +84 -0
  333. package/lib/types/subgraph.js +3 -0
  334. package/lib/types/typed-contract.d.ts +102 -0
  335. package/lib/types/typed-contract.js +3 -0
  336. package/lib/types/user.d.ts +1 -0
  337. package/lib/types/user.js +3 -0
  338. package/lib/types/vaults.d.ts +886 -0
  339. package/lib/types/vaults.js +30 -0
  340. package/lib/types/web3.d.ts +100 -0
  341. package/lib/types/web3.js +14 -0
  342. package/lib/types/webserver.d.ts +730 -0
  343. package/lib/types/webserver.js +3 -0
  344. package/package.json +79 -3
@@ -0,0 +1,89 @@
1
+ import type { IAddress, IContractRunner } from '../../types';
2
+ /**
3
+ * Bad transactions that should be ignored
4
+ * these transactions are usually from tests and can skew data
5
+ */
6
+ export declare const isBadTransaction: (hash: string, chainId: number) => boolean;
7
+ export declare const isBadVault: (address?: string) => boolean;
8
+ import { getAddressChainType, getVaultVersion, getVaultVersionV2 } from './vault-version';
9
+ export { getAddressChainType, getVaultVersion, getVaultVersionV2 };
10
+ export declare const REWARD_DISTRIBUTOR_ADDRESS: (chainId: number) => string[];
11
+ export declare const AVAX_PRICE_FEED_ADDRESS: (chainId: number) => "0x" | "0xFF3EEb22B5E3dE6e705b44749C2559d704923FD7";
12
+ export declare function getVaultSymbol(vault: IAddress, provider: IContractRunner): Promise<string | undefined>;
13
+ /**
14
+ * @deprecated
15
+ * Replaced by SUBGRAPH_VAULT_URLS which are subgraphs deployed on Goldsky.
16
+ */
17
+ export declare const SUBGRAPH_POOL_URLS: (apiKey: string, chainId?: number, pool?: IAddress) => {
18
+ 1: string;
19
+ 8453: string;
20
+ 43114: string;
21
+ 42161: string;
22
+ 56: string;
23
+ } | {
24
+ 999: string;
25
+ };
26
+ /**
27
+ * Previously fabricated a Goldsky subgraph URL from the chain name and vault
28
+ * symbol. That guess is unreliable and produced dead endpoints:
29
+ * - The path segment `/v1/subgraphs/name/goldsky/` is legacy hosted-service
30
+ * syntax, not Goldsky's current scheme (cf. {@link SUBGRAPH_VAULT_URLS}).
31
+ * - The chain name isn't the subgraph slug — ethers reports Citrea's network as
32
+ * `unknown`, and mainnet as `mainnet` where the subgraph uses `eth`.
33
+ * - A vault's symbol isn't its subgraph name — e.g. on-chain `EctUSD` vs the
34
+ * deployed `earn-ctusd`.
35
+ *
36
+ * A fabricated URL 404s silently, so a missing subgraph reads as "no data"
37
+ * rather than an error (this masked the Citrea Earn ctUSD outage). Subgraph URLs
38
+ * must now come from backend vault metadata (`fetchVaultMetadata → subgraph`).
39
+ * This returns `undefined` so callers hit their existing "Missing Subgraph"
40
+ * branch (warn + Slack alert) instead of querying a dead endpoint.
41
+ *
42
+ * @param _network - Unused. Kept for call-site compatibility.
43
+ * @param _symbol - Unused. Kept for call-site compatibility.
44
+ * @returns `undefined` — the SDK no longer guesses subgraph URLs.
45
+ * @deprecated Resolve subgraph URLs from `fetchVaultMetadata`; do not rely on a
46
+ * generated fallback.
47
+ */
48
+ export declare const getDefaultSubgraphUrl: (_network: string, _symbol: string) => string | undefined;
49
+ /**
50
+ * Resolve whether a single fee (management or performance) is currently waived.
51
+ *
52
+ * Backend-driven. This centralizes logic that previously lived —
53
+ * and diverged — across two upshift-app components. The resolution is deliberately
54
+ * split between the backend and the SDK:
55
+ *
56
+ * - The backend `isFeeWaivedToggle` (`platform_fee_override.is_fee_waived`) is both
57
+ * the master enable AND the TVL latch. Retool config takes precedence over live
58
+ * TVL, and the backend flips this flag `false` once live TVL crosses the
59
+ * configured threshold. That flip is one-way: if TVL later falls back below the
60
+ * threshold the waiver does NOT re-apply. The SDK therefore does no TVL math and
61
+ * never reads `latest_reported_tvl` here — trusting the flag preserves the latch.
62
+ * - The **date** window is time-dependent, so it cannot be a static DB flag; the SDK
63
+ * evaluates it live against the clock.
64
+ *
65
+ * Resolution:
66
+ * - Toggle off → never waived (also the only "hide" path once TVL trips the latch).
67
+ * - Toggle on, both date and TVL blank → indefinite manual waiver → waived.
68
+ * - Toggle on with a date window → waived while `now < waivedUntilDate`.
69
+ * - Toggle on with a TVL threshold configured → waived (the backend keeps the toggle
70
+ * on only while live TVL is under the threshold).
71
+ *
72
+ * @param isFeeWaivedToggle - Backend master/TVL-latch flag. `false` ⇒ never waived.
73
+ * @param waivedUntilDate - ISO datetime string the waiver runs until, or `null` for
74
+ * no date window. An unparseable string yields `NaN`, which is never `> now`, so
75
+ * it correctly contributes no date-based waiver.
76
+ * @param waivedUntilTvl - Configured TVL threshold in whole USD, or `null`. Used only
77
+ * to detect that a TVL-based waiver was set (values `<= 0` are treated as unset);
78
+ * the threshold comparison itself is owned by the backend.
79
+ * @param now - Clock, injected for deterministic testing. Defaults to `new Date()`.
80
+ * @returns `true` if the UI should present this fee as "Fee Waived" right now.
81
+ * @example
82
+ * ```ts
83
+ * // Toggle on, 30-day window still open → waived.
84
+ * resolveFeeWaived(true, '2099-01-01T00:00:00Z', null); // true
85
+ * // Toggle off overrides everything → not waived.
86
+ * resolveFeeWaived(false, '2099-01-01T00:00:00Z', 10_000_000); // false
87
+ * ```
88
+ */
89
+ export declare function resolveFeeWaived(isFeeWaivedToggle: boolean, waivedUntilDate: string | null, waivedUntilTvl: number | null, now?: Date): boolean;
@@ -0,0 +1,241 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDefaultSubgraphUrl = exports.SUBGRAPH_POOL_URLS = exports.AVAX_PRICE_FEED_ADDRESS = exports.REWARD_DISTRIBUTOR_ADDRESS = exports.getVaultVersionV2 = exports.getVaultVersion = exports.getAddressChainType = exports.isBadVault = exports.isBadTransaction = void 0;
4
+ exports.getVaultSymbol = getVaultSymbol;
5
+ exports.resolveFeeWaived = resolveFeeWaived;
6
+ const ethers_1 = require("ethers");
7
+ const vaults_1 = require("../constants/vaults");
8
+ const web3_1 = require("./web3");
9
+ const chain_address_1 = require("./chain-address");
10
+ const vault_metadata_1 = require("../vault-metadata");
11
+ const logger_1 = require("../logger");
12
+ /** @internal */
13
+ const VAULT_SYMBOLS_LOWERCASE = Object.fromEntries(Object.entries(vaults_1.VAULT_SYMBOLS).map(([k, v]) => [k.toLowerCase(), v]));
14
+ /**
15
+ * Bad transactions that should be ignored
16
+ * these transactions are usually from tests and can skew data
17
+ */
18
+ const isBadTransaction = (hash, chainId) => {
19
+ const badTxs = {
20
+ 1: [
21
+ // farmBOLD deposit test tx due to a decimal error
22
+ '0xaba75b16e74a7a2457bfdcded853edd2bb4d3b305919baf84fb1f6b54b864889',
23
+ '0xc4c30185198672cbc91a95520d1bf91634ece37c199b2f1f15d29e8290c7ed4b',
24
+ '0x8e319576413897d1750f16bb93c7f59759b5bbafcb5bd9ef956f6bc0b0314aef',
25
+ '0x49057f8ea86b84a21808269558474686c9de02d31dc9e03a201b61104afbcdd3',
26
+ '0x7146dd528423705e225dd508f06cc6b4dab490c767400652ef82e7c96031359d',
27
+ '0x826340b2f376e71795177e9d68fee07e0c45263b45d22c36327db81db36d70a6',
28
+ '0xd79f4cf16dd4a794809448bf021bb64b6bfd22fb42094403baad4da5664b7519',
29
+ ],
30
+ };
31
+ if (chainId in badTxs) {
32
+ return badTxs[chainId].includes(hash);
33
+ }
34
+ return false;
35
+ };
36
+ exports.isBadTransaction = isBadTransaction;
37
+ const isBadVault = (address) => {
38
+ if (!address)
39
+ return false;
40
+ if ((0, vault_version_1.getAddressChainType)(address) !== 'evm')
41
+ return false;
42
+ switch ((0, ethers_1.getAddress)(address)) {
43
+ case (0, ethers_1.getAddress)('0x706162790b601A8514c18718d0c63C9D1268e89C'):
44
+ return true;
45
+ case (0, ethers_1.getAddress)('0xd684AF965b1c17D628ee0d77cae94259c41260F4'):
46
+ return true; // ETH: sUSDe
47
+ case (0, ethers_1.getAddress)('0xB78dAf3fD674B81ebeaaa88d711506fa069E1C5E'):
48
+ return true; // ETH: ETH Optimizer
49
+ case (0, ethers_1.getAddress)('0x4e2D90f0307A93b54ACA31dc606F93FE6b9132d2'):
50
+ return true; // Base: LBTC
51
+ case (0, ethers_1.getAddress)('0x18a5a3D575F34e5eBa92ac99B0976dBe26f9F869'):
52
+ return true; // ETH: LBTC
53
+ case (0, ethers_1.getAddress)('0xD0b717ef23817b1a127139830Cf0FcD449ef74F0'):
54
+ return true; // BNB: Sienna USDT Tulipa
55
+ case (0, ethers_1.getAddress)('0xeb402fc96C7ed2f889d837C9976D6d821c1B5f01'):
56
+ return true; // ETH: Kelp TAC Vault
57
+ case (0, ethers_1.getAddress)('0xEBac5e50003d4B17Be422ff9775043cD61002f7f'):
58
+ return true; // ETH: Upshift BTC
59
+ case (0, ethers_1.getAddress)('0x419386E3Ef42368e602720CC458e00c0B28c47A7'):
60
+ return true; // ETH: Kelp TAC Vault
61
+ default:
62
+ return false;
63
+ }
64
+ };
65
+ exports.isBadVault = isBadVault;
66
+ const vault_version_1 = require("./vault-version");
67
+ Object.defineProperty(exports, "getAddressChainType", { enumerable: true, get: function () { return vault_version_1.getAddressChainType; } });
68
+ Object.defineProperty(exports, "getVaultVersion", { enumerable: true, get: function () { return vault_version_1.getVaultVersion; } });
69
+ Object.defineProperty(exports, "getVaultVersionV2", { enumerable: true, get: function () { return vault_version_1.getVaultVersionV2; } });
70
+ // Used for Upshift
71
+ const REWARD_DISTRIBUTOR_ADDRESS = (chainId) => {
72
+ switch (chainId) {
73
+ case 43114:
74
+ return [
75
+ '0xAeAc5f82B140c0f7309f7E9Ec43019062A5e5BE2',
76
+ '0xd3e653A9f6F3d96B26Dd4487a53D151140B697C4',
77
+ ];
78
+ default:
79
+ return ['0x0000000000000000000000000000000000000000'];
80
+ }
81
+ };
82
+ exports.REWARD_DISTRIBUTOR_ADDRESS = REWARD_DISTRIBUTOR_ADDRESS;
83
+ // Used for Upshift
84
+ const AVAX_PRICE_FEED_ADDRESS = (chainId) => {
85
+ switch (chainId) {
86
+ case 1:
87
+ return '0xFF3EEb22B5E3dE6e705b44749C2559d704923FD7';
88
+ default:
89
+ return '0x';
90
+ }
91
+ };
92
+ exports.AVAX_PRICE_FEED_ADDRESS = AVAX_PRICE_FEED_ADDRESS;
93
+ async function getVaultSymbol(vault, provider) {
94
+ if ((0, chain_address_1.isStellarAddress)(vault)) {
95
+ logger_1.Logger.log.warn('getVaultSymbol', `Vault symbol lookup is not yet supported for Stellar vaults: ${vault}`);
96
+ return undefined;
97
+ }
98
+ // Sui object IDs are 64 hex digits, which ethers' `getAddress` rejects; they
99
+ // have no checksum form, so compare them lowercase as they are.
100
+ const address = (0, chain_address_1.isSuiAddress)(vault) ? vault.toLowerCase() : (0, ethers_1.getAddress)(vault);
101
+ let vaultsMetadata = {};
102
+ try {
103
+ vaultsMetadata = await (0, vault_metadata_1.fetchVaultMetadata)();
104
+ }
105
+ catch (e) {
106
+ logger_1.Logger.log.error('getVaultSymbol:fetchMetadata', e, { vault });
107
+ }
108
+ const entries = Object.entries(vaultsMetadata);
109
+ for (const [_, metadata] of entries) {
110
+ if (metadata.address.toLowerCase() === address.toLowerCase()) {
111
+ return metadata.symbol;
112
+ }
113
+ }
114
+ const hardcodedSymbol = vaults_1.VAULT_SYMBOLS[address] ??
115
+ VAULT_SYMBOLS_LOWERCASE[address.toLowerCase()];
116
+ if (hardcodedSymbol) {
117
+ return hardcodedSymbol;
118
+ }
119
+ // The on-chain fallback below is an EVM `symbol()` call; a Sui vault has no
120
+ // such contract, so a metadata miss is the end of the lookup.
121
+ if ((0, chain_address_1.isSuiAddress)(vault))
122
+ return undefined;
123
+ const symbol = await (0, web3_1.getSymbol)(provider, vault);
124
+ return symbol;
125
+ }
126
+ /**
127
+ * @deprecated
128
+ * Replaced by SUBGRAPH_VAULT_URLS which are subgraphs deployed on Goldsky.
129
+ */
130
+ const SUBGRAPH_POOL_URLS = (apiKey, chainId, pool) => {
131
+ if (chainId === 999) {
132
+ if (!pool) {
133
+ throw new Error(`Pool address is required for chainId ${chainId}`);
134
+ }
135
+ switch (pool) {
136
+ // hbHYPE
137
+ case '0x96C6cBB6251Ee1c257b2162ca0f39AA5Fa44B1FB':
138
+ return {
139
+ 999: 'https://api.goldsky.com/api/public/project_cm9g0xy3o4j6v01vd34r3hvv9/subgraphs/august-hyperevm-hyperbeat/1.0.0/gn',
140
+ };
141
+ // hbBTC
142
+ case '0xc061d38903b99aC12713B550C2CB44B221674F94':
143
+ return {
144
+ 999: 'https://api.goldsky.com/api/public/project_cm9g0xy3o4j6v01vd34r3hvv9/subgraphs/august-hyperevm-hbBTC/1.0.0/gn',
145
+ };
146
+ default:
147
+ throw new Error(`Unsupported pool for chainId ${chainId}: ${pool}`);
148
+ }
149
+ }
150
+ const urls = {
151
+ 1: `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/BtbHLe7XtX2x9Ude9PKv2uagNHj6JYhjjFcimxvk7NPD`,
152
+ 8453: `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/E96gN4ZAmtCwLfsYccy3TqCTBbizGPWssFFeZfJ5QSQP`,
153
+ 43114: `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/Ho15f2DBGndTMAYx9bPxJzasQRsAd5oLdci4oZvWs2u6`,
154
+ 42161: `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/BrqNoj6FWm678yFRKdVWBncwt3zUnpbA3u4n9A9puUSg`,
155
+ 56: `https://gateway.thegraph.com/api/${apiKey}/subgraphs/id/4BDCXZvSBuNGX3ck6C6nTGos7Dg5SxjfHMjrKnQz4YE2`,
156
+ };
157
+ if (chainId && !(chainId in urls)) {
158
+ throw new Error(`Unsupported chainId: ${chainId}. Supported chains: ${Object.keys(urls).join(', ')}`);
159
+ }
160
+ return urls;
161
+ };
162
+ exports.SUBGRAPH_POOL_URLS = SUBGRAPH_POOL_URLS;
163
+ /**
164
+ * Previously fabricated a Goldsky subgraph URL from the chain name and vault
165
+ * symbol. That guess is unreliable and produced dead endpoints:
166
+ * - The path segment `/v1/subgraphs/name/goldsky/` is legacy hosted-service
167
+ * syntax, not Goldsky's current scheme (cf. {@link SUBGRAPH_VAULT_URLS}).
168
+ * - The chain name isn't the subgraph slug — ethers reports Citrea's network as
169
+ * `unknown`, and mainnet as `mainnet` where the subgraph uses `eth`.
170
+ * - A vault's symbol isn't its subgraph name — e.g. on-chain `EctUSD` vs the
171
+ * deployed `earn-ctusd`.
172
+ *
173
+ * A fabricated URL 404s silently, so a missing subgraph reads as "no data"
174
+ * rather than an error (this masked the Citrea Earn ctUSD outage). Subgraph URLs
175
+ * must now come from backend vault metadata (`fetchVaultMetadata → subgraph`).
176
+ * This returns `undefined` so callers hit their existing "Missing Subgraph"
177
+ * branch (warn + Slack alert) instead of querying a dead endpoint.
178
+ *
179
+ * @param _network - Unused. Kept for call-site compatibility.
180
+ * @param _symbol - Unused. Kept for call-site compatibility.
181
+ * @returns `undefined` — the SDK no longer guesses subgraph URLs.
182
+ * @deprecated Resolve subgraph URLs from `fetchVaultMetadata`; do not rely on a
183
+ * generated fallback.
184
+ */
185
+ const getDefaultSubgraphUrl = (_network, _symbol) => {
186
+ return undefined;
187
+ };
188
+ exports.getDefaultSubgraphUrl = getDefaultSubgraphUrl;
189
+ /**
190
+ * Resolve whether a single fee (management or performance) is currently waived.
191
+ *
192
+ * Backend-driven. This centralizes logic that previously lived —
193
+ * and diverged — across two upshift-app components. The resolution is deliberately
194
+ * split between the backend and the SDK:
195
+ *
196
+ * - The backend `isFeeWaivedToggle` (`platform_fee_override.is_fee_waived`) is both
197
+ * the master enable AND the TVL latch. Retool config takes precedence over live
198
+ * TVL, and the backend flips this flag `false` once live TVL crosses the
199
+ * configured threshold. That flip is one-way: if TVL later falls back below the
200
+ * threshold the waiver does NOT re-apply. The SDK therefore does no TVL math and
201
+ * never reads `latest_reported_tvl` here — trusting the flag preserves the latch.
202
+ * - The **date** window is time-dependent, so it cannot be a static DB flag; the SDK
203
+ * evaluates it live against the clock.
204
+ *
205
+ * Resolution:
206
+ * - Toggle off → never waived (also the only "hide" path once TVL trips the latch).
207
+ * - Toggle on, both date and TVL blank → indefinite manual waiver → waived.
208
+ * - Toggle on with a date window → waived while `now < waivedUntilDate`.
209
+ * - Toggle on with a TVL threshold configured → waived (the backend keeps the toggle
210
+ * on only while live TVL is under the threshold).
211
+ *
212
+ * @param isFeeWaivedToggle - Backend master/TVL-latch flag. `false` ⇒ never waived.
213
+ * @param waivedUntilDate - ISO datetime string the waiver runs until, or `null` for
214
+ * no date window. An unparseable string yields `NaN`, which is never `> now`, so
215
+ * it correctly contributes no date-based waiver.
216
+ * @param waivedUntilTvl - Configured TVL threshold in whole USD, or `null`. Used only
217
+ * to detect that a TVL-based waiver was set (values `<= 0` are treated as unset);
218
+ * the threshold comparison itself is owned by the backend.
219
+ * @param now - Clock, injected for deterministic testing. Defaults to `new Date()`.
220
+ * @returns `true` if the UI should present this fee as "Fee Waived" right now.
221
+ * @example
222
+ * ```ts
223
+ * // Toggle on, 30-day window still open → waived.
224
+ * resolveFeeWaived(true, '2099-01-01T00:00:00Z', null); // true
225
+ * // Toggle off overrides everything → not waived.
226
+ * resolveFeeWaived(false, '2099-01-01T00:00:00Z', 10_000_000); // false
227
+ * ```
228
+ */
229
+ function resolveFeeWaived(isFeeWaivedToggle, waivedUntilDate, waivedUntilTvl, now = new Date()) {
230
+ // Master toggle off ⇒ never waived. Also satisfies the one-way TVL latch: the
231
+ // backend has already flipped this false when live TVL crossed the threshold.
232
+ if (!isFeeWaivedToggle)
233
+ return false;
234
+ const isDateActive = waivedUntilDate != null && new Date(waivedUntilDate) > now;
235
+ const isTvlConfigured = waivedUntilTvl != null && waivedUntilTvl > 0;
236
+ // Toggle on but neither trigger configured ⇒ indefinite manual waiver.
237
+ if (waivedUntilDate == null && !isTvlConfigured)
238
+ return true;
239
+ return isDateActive || isTvlConfigured;
240
+ }
241
+ //# sourceMappingURL=vaults.js.map