@oobe-protocol-labs/synapse-client-sdk 1.0.0-beta

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 (460) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1393 -0
  3. package/dist/cjs/advanced/circuit-breaker.d.ts +111 -0
  4. package/dist/cjs/advanced/circuit-breaker.d.ts.map +1 -0
  5. package/dist/cjs/advanced/circuit-breaker.js +278 -0
  6. package/dist/cjs/advanced/circuit-breaker.js.map +1 -0
  7. package/dist/cjs/advanced/index.d.ts +8 -0
  8. package/dist/cjs/advanced/index.d.ts.map +1 -0
  9. package/dist/cjs/advanced/index.js +13 -0
  10. package/dist/cjs/advanced/index.js.map +1 -0
  11. package/dist/cjs/advanced/load-balancer.d.ts +114 -0
  12. package/dist/cjs/advanced/load-balancer.d.ts.map +1 -0
  13. package/dist/cjs/advanced/load-balancer.js +354 -0
  14. package/dist/cjs/advanced/load-balancer.js.map +1 -0
  15. package/dist/cjs/advanced/smart-caching.d.ts +113 -0
  16. package/dist/cjs/advanced/smart-caching.d.ts.map +1 -0
  17. package/dist/cjs/advanced/smart-caching.js +461 -0
  18. package/dist/cjs/advanced/smart-caching.js.map +1 -0
  19. package/dist/cjs/advanced/types.d.ts +228 -0
  20. package/dist/cjs/advanced/types.d.ts.map +1 -0
  21. package/dist/cjs/advanced/types.js +7 -0
  22. package/dist/cjs/advanced/types.js.map +1 -0
  23. package/dist/cjs/ai/index.d.ts +15 -0
  24. package/dist/cjs/ai/index.d.ts.map +1 -0
  25. package/dist/cjs/ai/index.js +20 -0
  26. package/dist/cjs/ai/index.js.map +1 -0
  27. package/dist/cjs/ai/merkle-operation.d.ts +245 -0
  28. package/dist/cjs/ai/merkle-operation.d.ts.map +1 -0
  29. package/dist/cjs/ai/merkle-operation.js +522 -0
  30. package/dist/cjs/ai/merkle-operation.js.map +1 -0
  31. package/dist/cjs/ai/pda-manager.d.ts +134 -0
  32. package/dist/cjs/ai/pda-manager.d.ts.map +1 -0
  33. package/dist/cjs/ai/pda-manager.js +250 -0
  34. package/dist/cjs/ai/pda-manager.js.map +1 -0
  35. package/dist/cjs/ai/types.ai.d.ts +172 -0
  36. package/dist/cjs/ai/types.ai.d.ts.map +1 -0
  37. package/dist/cjs/ai/types.ai.js +14 -0
  38. package/dist/cjs/ai/types.ai.js.map +1 -0
  39. package/dist/cjs/ai/zero-combine-fetcher.d.ts +171 -0
  40. package/dist/cjs/ai/zero-combine-fetcher.d.ts.map +1 -0
  41. package/dist/cjs/ai/zero-combine-fetcher.js +412 -0
  42. package/dist/cjs/ai/zero-combine-fetcher.js.map +1 -0
  43. package/dist/cjs/client.d.ts +83 -0
  44. package/dist/cjs/client.d.ts.map +1 -0
  45. package/dist/cjs/client.js +287 -0
  46. package/dist/cjs/client.js.map +1 -0
  47. package/dist/cjs/defi/advanced-features.d.ts +207 -0
  48. package/dist/cjs/defi/advanced-features.d.ts.map +1 -0
  49. package/dist/cjs/defi/advanced-features.js +382 -0
  50. package/dist/cjs/defi/advanced-features.js.map +1 -0
  51. package/dist/cjs/defi/index.d.ts +29 -0
  52. package/dist/cjs/defi/index.d.ts.map +1 -0
  53. package/dist/cjs/defi/index.js +50 -0
  54. package/dist/cjs/defi/index.js.map +1 -0
  55. package/dist/cjs/defi/jito.d.ts +118 -0
  56. package/dist/cjs/defi/jito.d.ts.map +1 -0
  57. package/dist/cjs/defi/jito.js +291 -0
  58. package/dist/cjs/defi/jito.js.map +1 -0
  59. package/dist/cjs/defi/jupiter.d.ts +143 -0
  60. package/dist/cjs/defi/jupiter.d.ts.map +1 -0
  61. package/dist/cjs/defi/jupiter.js +219 -0
  62. package/dist/cjs/defi/jupiter.js.map +1 -0
  63. package/dist/cjs/defi/price-feed.d.ts +63 -0
  64. package/dist/cjs/defi/price-feed.d.ts.map +1 -0
  65. package/dist/cjs/defi/price-feed.js +153 -0
  66. package/dist/cjs/defi/price-feed.js.map +1 -0
  67. package/dist/cjs/defi/token-data.d.ts +83 -0
  68. package/dist/cjs/defi/token-data.d.ts.map +1 -0
  69. package/dist/cjs/defi/token-data.js +205 -0
  70. package/dist/cjs/defi/token-data.js.map +1 -0
  71. package/dist/cjs/defi/unstable-features.d.ts +207 -0
  72. package/dist/cjs/defi/unstable-features.d.ts.map +1 -0
  73. package/dist/cjs/defi/unstable-features.js +382 -0
  74. package/dist/cjs/defi/unstable-features.js.map +1 -0
  75. package/dist/cjs/defi/utils.d.ts +265 -0
  76. package/dist/cjs/defi/utils.d.ts.map +1 -0
  77. package/dist/cjs/defi/utils.js +619 -0
  78. package/dist/cjs/defi/utils.js.map +1 -0
  79. package/dist/cjs/index.d.ts +31 -0
  80. package/dist/cjs/index.d.ts.map +1 -0
  81. package/dist/cjs/index.js +71 -0
  82. package/dist/cjs/index.js.map +1 -0
  83. package/dist/cjs/methods/solana-rpc.d.ts +362 -0
  84. package/dist/cjs/methods/solana-rpc.d.ts.map +1 -0
  85. package/dist/cjs/methods/solana-rpc.js +584 -0
  86. package/dist/cjs/methods/solana-rpc.js.map +1 -0
  87. package/dist/cjs/nft/advanced-features.d.ts +205 -0
  88. package/dist/cjs/nft/advanced-features.d.ts.map +1 -0
  89. package/dist/cjs/nft/advanced-features.js +529 -0
  90. package/dist/cjs/nft/advanced-features.js.map +1 -0
  91. package/dist/cjs/nft/clients/index.d.ts +8 -0
  92. package/dist/cjs/nft/clients/index.d.ts.map +1 -0
  93. package/dist/cjs/nft/clients/index.js +14 -0
  94. package/dist/cjs/nft/clients/index.js.map +1 -0
  95. package/dist/cjs/nft/clients/magic-eden-client.d.ts +101 -0
  96. package/dist/cjs/nft/clients/magic-eden-client.d.ts.map +1 -0
  97. package/dist/cjs/nft/clients/magic-eden-client.js +263 -0
  98. package/dist/cjs/nft/clients/magic-eden-client.js.map +1 -0
  99. package/dist/cjs/nft/clients/metaplex-onchain-client.d.ts +154 -0
  100. package/dist/cjs/nft/clients/metaplex-onchain-client.d.ts.map +1 -0
  101. package/dist/cjs/nft/clients/metaplex-onchain-client.js +408 -0
  102. package/dist/cjs/nft/clients/metaplex-onchain-client.js.map +1 -0
  103. package/dist/cjs/nft/clients/tensor-client.d.ts +79 -0
  104. package/dist/cjs/nft/clients/tensor-client.d.ts.map +1 -0
  105. package/dist/cjs/nft/clients/tensor-client.js +222 -0
  106. package/dist/cjs/nft/clients/tensor-client.js.map +1 -0
  107. package/dist/cjs/nft/index.d.ts +13 -0
  108. package/dist/cjs/nft/index.d.ts.map +1 -0
  109. package/dist/cjs/nft/index.js +37 -0
  110. package/dist/cjs/nft/index.js.map +1 -0
  111. package/dist/cjs/nft/types.nft.d.ts +342 -0
  112. package/dist/cjs/nft/types.nft.d.ts.map +1 -0
  113. package/dist/cjs/nft/types.nft.js +3 -0
  114. package/dist/cjs/nft/types.nft.js.map +1 -0
  115. package/dist/cjs/nft/utils.d.ts +46 -0
  116. package/dist/cjs/nft/utils.d.ts.map +1 -0
  117. package/dist/cjs/nft/utils.js +281 -0
  118. package/dist/cjs/nft/utils.js.map +1 -0
  119. package/dist/cjs/types.d.ts +525 -0
  120. package/dist/cjs/types.d.ts.map +1 -0
  121. package/dist/cjs/types.js +192 -0
  122. package/dist/cjs/types.js.map +1 -0
  123. package/dist/cjs/utils/constant.d.ts +8 -0
  124. package/dist/cjs/utils/constant.d.ts.map +1 -0
  125. package/dist/cjs/utils/constant.js +12 -0
  126. package/dist/cjs/utils/constant.js.map +1 -0
  127. package/dist/cjs/utils/helpers.d.ts +92 -0
  128. package/dist/cjs/utils/helpers.d.ts.map +1 -0
  129. package/dist/cjs/utils/helpers.js +248 -0
  130. package/dist/cjs/utils/helpers.js.map +1 -0
  131. package/dist/cjs/websocket/client.d.ts +182 -0
  132. package/dist/cjs/websocket/client.d.ts.map +1 -0
  133. package/dist/cjs/websocket/client.js +465 -0
  134. package/dist/cjs/websocket/client.js.map +1 -0
  135. package/dist/cjs/websocket/index.d.ts +6 -0
  136. package/dist/cjs/websocket/index.d.ts.map +1 -0
  137. package/dist/cjs/websocket/index.js +9 -0
  138. package/dist/cjs/websocket/index.js.map +1 -0
  139. package/dist/docs/.nojekyll +1 -0
  140. package/dist/docs/assets/highlight.css +113 -0
  141. package/dist/docs/assets/icons.js +18 -0
  142. package/dist/docs/assets/icons.svg +1 -0
  143. package/dist/docs/assets/main.js +60 -0
  144. package/dist/docs/assets/navigation.js +1 -0
  145. package/dist/docs/assets/search.js +1 -0
  146. package/dist/docs/assets/style.css +1493 -0
  147. package/dist/docs/classes/AIError.html +40 -0
  148. package/dist/docs/classes/AIInvestmentAdvisor.html +26 -0
  149. package/dist/docs/classes/AIRarityCalculator.html +28 -0
  150. package/dist/docs/classes/ArbitrageDetector.html +30 -0
  151. package/dist/docs/classes/BatchingError.html +40 -0
  152. package/dist/docs/classes/CacheError.html +40 -0
  153. package/dist/docs/classes/CircuitBreaker.html +38 -0
  154. package/dist/docs/classes/CircuitBreakerError.html +40 -0
  155. package/dist/docs/classes/CollectionAnalytics.html +30 -0
  156. package/dist/docs/classes/DeFiError.html +40 -0
  157. package/dist/docs/classes/FlashLoanSimulator.html +26 -0
  158. package/dist/docs/classes/JitoIntegration.html +53 -0
  159. package/dist/docs/classes/JupiterIntegration.html +43 -0
  160. package/dist/docs/classes/Keypair.html +28 -0
  161. package/dist/docs/classes/LoadBalancer.html +34 -0
  162. package/dist/docs/classes/MEVProtection.html +28 -0
  163. package/dist/docs/classes/MarketplaceAggregator.html +28 -0
  164. package/dist/docs/classes/MerkleOperation.html +74 -0
  165. package/dist/docs/classes/NFTEngine.html +29 -0
  166. package/dist/docs/classes/NFTError.html +40 -0
  167. package/dist/docs/classes/NetworkError.html +40 -0
  168. package/dist/docs/classes/PDAManager.html +46 -0
  169. package/dist/docs/classes/PortfolioAnalytics.html +26 -0
  170. package/dist/docs/classes/PriceFeedIntegration.html +37 -0
  171. package/dist/docs/classes/PublicKey.html +46 -0
  172. package/dist/docs/classes/RateLimitError.html +39 -0
  173. package/dist/docs/classes/SmartCaching.html +42 -0
  174. package/dist/docs/classes/Synapse.html +6 -0
  175. package/dist/docs/classes/SynapseClient.html +55 -0
  176. package/dist/docs/classes/SynapseError.html +37 -0
  177. package/dist/docs/classes/SynapseSolanaEngine.html +49 -0
  178. package/dist/docs/classes/SynapseUtils.html +25 -0
  179. package/dist/docs/classes/TokenDataIntegration.html +41 -0
  180. package/dist/docs/classes/Transaction.html +87 -0
  181. package/dist/docs/classes/TransactionInstruction.html +10 -0
  182. package/dist/docs/classes/UpstreamError.html +39 -0
  183. package/dist/docs/classes/WebSocketClient.html +47 -0
  184. package/dist/docs/classes/WebSocketError.html +40 -0
  185. package/dist/docs/classes/YieldFarmingFinder.html +26 -0
  186. package/dist/docs/classes/ZeroCombineFetcher.html +25 -0
  187. package/dist/docs/functions/createSynapseClient.html +2 -0
  188. package/dist/docs/hierarchy.html +1 -0
  189. package/dist/docs/index.html +776 -0
  190. package/dist/docs/interfaces/AIAgentConfig.html +11 -0
  191. package/dist/docs/interfaces/AIAgentContext.html +7 -0
  192. package/dist/docs/interfaces/AIContext.html +6 -0
  193. package/dist/docs/interfaces/AIMethodResult.html +6 -0
  194. package/dist/docs/interfaces/AIRarityAnalysis.html +3 -0
  195. package/dist/docs/interfaces/AIResponse.html +5 -0
  196. package/dist/docs/interfaces/AccountInfo.html +8 -0
  197. package/dist/docs/interfaces/AdvancedClientConfig.html +7 -0
  198. package/dist/docs/interfaces/AdvancedEvents.html +9 -0
  199. package/dist/docs/interfaces/AdvancedMetricsData.html +5 -0
  200. package/dist/docs/interfaces/AdvancedPerformanceMetrics.html +6 -0
  201. package/dist/docs/interfaces/AgentAdapter.html +6 -0
  202. package/dist/docs/interfaces/AgentRiskReport.html +6 -0
  203. package/dist/docs/interfaces/AgentTradeSuggestion.html +10 -0
  204. package/dist/docs/interfaces/AggregatedCollectionStats.html +36 -0
  205. package/dist/docs/interfaces/ArbitrageOpportunity.html +8 -0
  206. package/dist/docs/interfaces/AutoTradingStrategy.html +13 -0
  207. package/dist/docs/interfaces/BatchResponse.html +4 -0
  208. package/dist/docs/interfaces/BatchResult.html +6 -0
  209. package/dist/docs/interfaces/BatcherConfig.html +5 -0
  210. package/dist/docs/interfaces/BirdeyeTokenPrice.html +4 -0
  211. package/dist/docs/interfaces/BlockhashInfo.html +5 -0
  212. package/dist/docs/interfaces/BuildSwapTxResult.html +7 -0
  213. package/dist/docs/interfaces/CacheStats.html +9 -0
  214. package/dist/docs/interfaces/ChunkInfo.html +10 -0
  215. package/dist/docs/interfaces/CircuitBreakerConfig.html +6 -0
  216. package/dist/docs/interfaces/ClientStats.html +14 -0
  217. package/dist/docs/interfaces/CollectionStats.html +17 -0
  218. package/dist/docs/interfaces/CollectionTrends.html +7 -0
  219. package/dist/docs/interfaces/CompressedNFTInfo.html +13 -0
  220. package/dist/docs/interfaces/ConfirmedTransaction.html +6 -0
  221. package/dist/docs/interfaces/ConnectionEvents.html +11 -0
  222. package/dist/docs/interfaces/DeFiConfig.html +16 -0
  223. package/dist/docs/interfaces/DiagnosticsResult.html +6 -0
  224. package/dist/docs/interfaces/EpochInfo.html +9 -0
  225. package/dist/docs/interfaces/ExecuteSwapParams.html +10 -0
  226. package/dist/docs/interfaces/FetchConfig.html +7 -0
  227. package/dist/docs/interfaces/FlashLoanAction.html +6 -0
  228. package/dist/docs/interfaces/FlashLoanSimulation.html +9 -0
  229. package/dist/docs/interfaces/GatewayStats.html +7 -0
  230. package/dist/docs/interfaces/InscriptionResult.html +18 -0
  231. package/dist/docs/interfaces/InvestmentRecommendation.html +10 -0
  232. package/dist/docs/interfaces/JitoBundleParams.html +4 -0
  233. package/dist/docs/interfaces/JitoBundleResult.html +6 -0
  234. package/dist/docs/interfaces/JitoBundleStatus.html +6 -0
  235. package/dist/docs/interfaces/JitoTipAccount.html +3 -0
  236. package/dist/docs/interfaces/JupiterQuoteParams.html +10 -0
  237. package/dist/docs/interfaces/JupiterQuoteRequest.html +17 -0
  238. package/dist/docs/interfaces/JupiterQuoteResponse.html +13 -0
  239. package/dist/docs/interfaces/JupiterSwapOptions.html +8 -0
  240. package/dist/docs/interfaces/JupiterSwapResponse.html +4 -0
  241. package/dist/docs/interfaces/JupiterTokenPrice.html +5 -0
  242. package/dist/docs/interfaces/LoadBalancerConfig.html +5 -0
  243. package/dist/docs/interfaces/MEVProtectionConfig.html +11 -0
  244. package/dist/docs/interfaces/MEVProtectionResult.html +6 -0
  245. package/dist/docs/interfaces/MagicEdenActivity.html +22 -0
  246. package/dist/docs/interfaces/MagicEdenCollection.html +22 -0
  247. package/dist/docs/interfaces/MagicEdenCollectionStats.html +17 -0
  248. package/dist/docs/interfaces/MagicEdenErrorResponse.html +4 -0
  249. package/dist/docs/interfaces/MagicEdenListing.html +24 -0
  250. package/dist/docs/interfaces/MarketplaceClientConfig.html +14 -0
  251. package/dist/docs/interfaces/MarketplaceFloorPrices.html +7 -0
  252. package/dist/docs/interfaces/MarketplaceListing.html +9 -0
  253. package/dist/docs/interfaces/MerkleLeaf.html +6 -0
  254. package/dist/docs/interfaces/MerkleProof.html +8 -0
  255. package/dist/docs/interfaces/MerkleValidationResult.html +10 -0
  256. package/dist/docs/interfaces/MultiChainSignal.html +8 -0
  257. package/dist/docs/interfaces/NFTAttribute.html +4 -0
  258. package/dist/docs/interfaces/NFTConfig.html +6 -0
  259. package/dist/docs/interfaces/NFTInfo.html +10 -0
  260. package/dist/docs/interfaces/NFTMetadata.html +9 -0
  261. package/dist/docs/interfaces/NormalizedMarketplaceListing.html +18 -0
  262. package/dist/docs/interfaces/OOBECompatibleAgent.html +8 -0
  263. package/dist/docs/interfaces/PDAConfig.html +10 -0
  264. package/dist/docs/interfaces/ParsedAccountInfo.html +8 -0
  265. package/dist/docs/interfaces/PerformanceMetrics.html +9 -0
  266. package/dist/docs/interfaces/PortfolioMetrics.html +10 -0
  267. package/dist/docs/interfaces/PriceData.html +8 -0
  268. package/dist/docs/interfaces/ProofRecord.html +12 -0
  269. package/dist/docs/interfaces/QuoteRequestCommon.html +11 -0
  270. package/dist/docs/interfaces/QuoteResponse.html +6 -0
  271. package/dist/docs/interfaces/RarityAlgorithmConfig.html +3 -0
  272. package/dist/docs/interfaces/RarityScore.html +8 -0
  273. package/dist/docs/interfaces/RaydiumBuildSwapParams.html +14 -0
  274. package/dist/docs/interfaces/RaydiumQuoteRequest.html +14 -0
  275. package/dist/docs/interfaces/RequestOptions.html +12 -0
  276. package/dist/docs/interfaces/RetryAttempt.html +5 -0
  277. package/dist/docs/interfaces/RpcError.html +5 -0
  278. package/dist/docs/interfaces/RpcRequest.html +6 -0
  279. package/dist/docs/interfaces/RpcResponse.html +6 -0
  280. package/dist/docs/interfaces/SecurityThreat.html +6 -0
  281. package/dist/docs/interfaces/SignatureInfo.html +8 -0
  282. package/dist/docs/interfaces/Signer.html +4 -0
  283. package/dist/docs/interfaces/SmartCacheConfig.html +7 -0
  284. package/dist/docs/interfaces/SmartQueryOptions.html +10 -0
  285. package/dist/docs/interfaces/StressTestOptions.html +8 -0
  286. package/dist/docs/interfaces/StressTestResult.html +9 -0
  287. package/dist/docs/interfaces/SubscriptionConfig.html +9 -0
  288. package/dist/docs/interfaces/SubscriptionOptions.html +7 -0
  289. package/dist/docs/interfaces/SubscriptionResult.html +7 -0
  290. package/dist/docs/interfaces/SynapseConfig.html +13 -0
  291. package/dist/docs/interfaces/SynapseLikeClient.html +4 -0
  292. package/dist/docs/interfaces/TensorCollectionStats.html +33 -0
  293. package/dist/docs/interfaces/TensorErrorResponse.html +5 -0
  294. package/dist/docs/interfaces/TensorListing.html +16 -0
  295. package/dist/docs/interfaces/TensorSale.html +16 -0
  296. package/dist/docs/interfaces/TokenAccount.html +7 -0
  297. package/dist/docs/interfaces/TokenAccountInfo.html +12 -0
  298. package/dist/docs/interfaces/TokenHolding.html +8 -0
  299. package/dist/docs/interfaces/TokenInfo.html +7 -0
  300. package/dist/docs/interfaces/TokenLargestAccount.html +5 -0
  301. package/dist/docs/interfaces/TokenSupply.html +5 -0
  302. package/dist/docs/interfaces/TradeExecution.html +14 -0
  303. package/dist/docs/interfaces/TransactionSignature.html +8 -0
  304. package/dist/docs/interfaces/UpstreamHealth.html +8 -0
  305. package/dist/docs/interfaces/UserPDAs.html +10 -0
  306. package/dist/docs/interfaces/WebSocketConfig.html +12 -0
  307. package/dist/docs/interfaces/WebSocketMessage.html +6 -0
  308. package/dist/docs/interfaces/YieldOpportunity.html +8 -0
  309. package/dist/docs/interfaces/ZeroChunk.html +8 -0
  310. package/dist/docs/interfaces/ZeroCombineResult.html +3 -0
  311. package/dist/docs/media/LICENSE +21 -0
  312. package/dist/docs/media/README-1.md +778 -0
  313. package/dist/docs/media/README-2.md +1050 -0
  314. package/dist/docs/media/README-3.md +1522 -0
  315. package/dist/docs/media/README-4.md +869 -0
  316. package/dist/docs/media/README-5.md +857 -0
  317. package/dist/docs/media/README-6.md +727 -0
  318. package/dist/docs/media/README.md +766 -0
  319. package/dist/docs/modules.html +168 -0
  320. package/dist/docs/types/BlockhashWithExpiryBlockHeight.html +1 -0
  321. package/dist/docs/types/Commitment.html +3 -0
  322. package/dist/docs/types/RiskTolerance.html +1 -0
  323. package/dist/docs/types/SimulatedTransactionResponse.html +1 -0
  324. package/dist/esm/advanced/circuit-breaker.d.ts +111 -0
  325. package/dist/esm/advanced/circuit-breaker.d.ts.map +1 -0
  326. package/dist/esm/advanced/circuit-breaker.js +274 -0
  327. package/dist/esm/advanced/circuit-breaker.js.map +1 -0
  328. package/dist/esm/advanced/index.d.ts +8 -0
  329. package/dist/esm/advanced/index.d.ts.map +1 -0
  330. package/dist/esm/advanced/index.js +7 -0
  331. package/dist/esm/advanced/index.js.map +1 -0
  332. package/dist/esm/advanced/load-balancer.d.ts +114 -0
  333. package/dist/esm/advanced/load-balancer.d.ts.map +1 -0
  334. package/dist/esm/advanced/load-balancer.js +350 -0
  335. package/dist/esm/advanced/load-balancer.js.map +1 -0
  336. package/dist/esm/advanced/smart-caching.d.ts +113 -0
  337. package/dist/esm/advanced/smart-caching.d.ts.map +1 -0
  338. package/dist/esm/advanced/smart-caching.js +457 -0
  339. package/dist/esm/advanced/smart-caching.js.map +1 -0
  340. package/dist/esm/advanced/types.d.ts +228 -0
  341. package/dist/esm/advanced/types.d.ts.map +1 -0
  342. package/dist/esm/advanced/types.js +6 -0
  343. package/dist/esm/advanced/types.js.map +1 -0
  344. package/dist/esm/ai/index.d.ts +15 -0
  345. package/dist/esm/ai/index.d.ts.map +1 -0
  346. package/dist/esm/ai/index.js +14 -0
  347. package/dist/esm/ai/index.js.map +1 -0
  348. package/dist/esm/ai/merkle-operation.d.ts +245 -0
  349. package/dist/esm/ai/merkle-operation.d.ts.map +1 -0
  350. package/dist/esm/ai/merkle-operation.js +485 -0
  351. package/dist/esm/ai/merkle-operation.js.map +1 -0
  352. package/dist/esm/ai/pda-manager.d.ts +134 -0
  353. package/dist/esm/ai/pda-manager.d.ts.map +1 -0
  354. package/dist/esm/ai/pda-manager.js +213 -0
  355. package/dist/esm/ai/pda-manager.js.map +1 -0
  356. package/dist/esm/ai/types.ai.d.ts +172 -0
  357. package/dist/esm/ai/types.ai.d.ts.map +1 -0
  358. package/dist/esm/ai/types.ai.js +13 -0
  359. package/dist/esm/ai/types.ai.js.map +1 -0
  360. package/dist/esm/ai/zero-combine-fetcher.d.ts +171 -0
  361. package/dist/esm/ai/zero-combine-fetcher.d.ts.map +1 -0
  362. package/dist/esm/ai/zero-combine-fetcher.js +408 -0
  363. package/dist/esm/ai/zero-combine-fetcher.js.map +1 -0
  364. package/dist/esm/client.d.ts +83 -0
  365. package/dist/esm/client.d.ts.map +1 -0
  366. package/dist/esm/client.js +283 -0
  367. package/dist/esm/client.js.map +1 -0
  368. package/dist/esm/defi/advanced-features.d.ts +207 -0
  369. package/dist/esm/defi/advanced-features.d.ts.map +1 -0
  370. package/dist/esm/defi/advanced-features.js +374 -0
  371. package/dist/esm/defi/advanced-features.js.map +1 -0
  372. package/dist/esm/defi/index.d.ts +29 -0
  373. package/dist/esm/defi/index.d.ts.map +1 -0
  374. package/dist/esm/defi/index.js +37 -0
  375. package/dist/esm/defi/index.js.map +1 -0
  376. package/dist/esm/defi/jito.d.ts +118 -0
  377. package/dist/esm/defi/jito.d.ts.map +1 -0
  378. package/dist/esm/defi/jito.js +287 -0
  379. package/dist/esm/defi/jito.js.map +1 -0
  380. package/dist/esm/defi/jupiter.d.ts +143 -0
  381. package/dist/esm/defi/jupiter.d.ts.map +1 -0
  382. package/dist/esm/defi/jupiter.js +215 -0
  383. package/dist/esm/defi/jupiter.js.map +1 -0
  384. package/dist/esm/defi/price-feed.d.ts +63 -0
  385. package/dist/esm/defi/price-feed.d.ts.map +1 -0
  386. package/dist/esm/defi/price-feed.js +149 -0
  387. package/dist/esm/defi/price-feed.js.map +1 -0
  388. package/dist/esm/defi/token-data.d.ts +83 -0
  389. package/dist/esm/defi/token-data.d.ts.map +1 -0
  390. package/dist/esm/defi/token-data.js +201 -0
  391. package/dist/esm/defi/token-data.js.map +1 -0
  392. package/dist/esm/defi/unstable-features.d.ts +207 -0
  393. package/dist/esm/defi/unstable-features.d.ts.map +1 -0
  394. package/dist/esm/defi/unstable-features.js +374 -0
  395. package/dist/esm/defi/unstable-features.js.map +1 -0
  396. package/dist/esm/defi/utils.d.ts +265 -0
  397. package/dist/esm/defi/utils.d.ts.map +1 -0
  398. package/dist/esm/defi/utils.js +582 -0
  399. package/dist/esm/defi/utils.js.map +1 -0
  400. package/dist/esm/index.d.ts +31 -0
  401. package/dist/esm/index.d.ts.map +1 -0
  402. package/dist/esm/index.js +47 -0
  403. package/dist/esm/index.js.map +1 -0
  404. package/dist/esm/methods/solana-rpc.d.ts +362 -0
  405. package/dist/esm/methods/solana-rpc.d.ts.map +1 -0
  406. package/dist/esm/methods/solana-rpc.js +532 -0
  407. package/dist/esm/methods/solana-rpc.js.map +1 -0
  408. package/dist/esm/nft/advanced-features.d.ts +205 -0
  409. package/dist/esm/nft/advanced-features.d.ts.map +1 -0
  410. package/dist/esm/nft/advanced-features.js +489 -0
  411. package/dist/esm/nft/advanced-features.js.map +1 -0
  412. package/dist/esm/nft/clients/index.d.ts +8 -0
  413. package/dist/esm/nft/clients/index.d.ts.map +1 -0
  414. package/dist/esm/nft/clients/index.js +8 -0
  415. package/dist/esm/nft/clients/index.js.map +1 -0
  416. package/dist/esm/nft/clients/magic-eden-client.d.ts +101 -0
  417. package/dist/esm/nft/clients/magic-eden-client.d.ts.map +1 -0
  418. package/dist/esm/nft/clients/magic-eden-client.js +259 -0
  419. package/dist/esm/nft/clients/magic-eden-client.js.map +1 -0
  420. package/dist/esm/nft/clients/metaplex-onchain-client.d.ts +154 -0
  421. package/dist/esm/nft/clients/metaplex-onchain-client.d.ts.map +1 -0
  422. package/dist/esm/nft/clients/metaplex-onchain-client.js +404 -0
  423. package/dist/esm/nft/clients/metaplex-onchain-client.js.map +1 -0
  424. package/dist/esm/nft/clients/tensor-client.d.ts +79 -0
  425. package/dist/esm/nft/clients/tensor-client.d.ts.map +1 -0
  426. package/dist/esm/nft/clients/tensor-client.js +218 -0
  427. package/dist/esm/nft/clients/tensor-client.js.map +1 -0
  428. package/dist/esm/nft/index.d.ts +13 -0
  429. package/dist/esm/nft/index.d.ts.map +1 -0
  430. package/dist/esm/nft/index.js +15 -0
  431. package/dist/esm/nft/index.js.map +1 -0
  432. package/dist/esm/nft/types.nft.d.ts +342 -0
  433. package/dist/esm/nft/types.nft.d.ts.map +1 -0
  434. package/dist/esm/nft/types.nft.js +2 -0
  435. package/dist/esm/nft/types.nft.js.map +1 -0
  436. package/dist/esm/nft/utils.d.ts +46 -0
  437. package/dist/esm/nft/utils.d.ts.map +1 -0
  438. package/dist/esm/nft/utils.js +276 -0
  439. package/dist/esm/nft/utils.js.map +1 -0
  440. package/dist/esm/types.d.ts +525 -0
  441. package/dist/esm/types.d.ts.map +1 -0
  442. package/dist/esm/types.js +178 -0
  443. package/dist/esm/types.js.map +1 -0
  444. package/dist/esm/utils/constant.d.ts +8 -0
  445. package/dist/esm/utils/constant.d.ts.map +1 -0
  446. package/dist/esm/utils/constant.js +8 -0
  447. package/dist/esm/utils/constant.js.map +1 -0
  448. package/dist/esm/utils/helpers.d.ts +92 -0
  449. package/dist/esm/utils/helpers.d.ts.map +1 -0
  450. package/dist/esm/utils/helpers.js +243 -0
  451. package/dist/esm/utils/helpers.js.map +1 -0
  452. package/dist/esm/websocket/client.d.ts +182 -0
  453. package/dist/esm/websocket/client.d.ts.map +1 -0
  454. package/dist/esm/websocket/client.js +458 -0
  455. package/dist/esm/websocket/client.js.map +1 -0
  456. package/dist/esm/websocket/index.d.ts +6 -0
  457. package/dist/esm/websocket/index.d.ts.map +1 -0
  458. package/dist/esm/websocket/index.js +5 -0
  459. package/dist/esm/websocket/index.js.map +1 -0
  460. package/package.json +160 -0
@@ -0,0 +1,1522 @@
1
+ # NFT Module - Production-Ready Implementation
2
+
3
+ Enterprise-grade NFT toolkit for Solana blockchain with real-time marketplace integration, collection analytics, rarity calculation, and investment analysis. Built on Tensor and Magic Eden APIs for accurate, production-ready data.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Architecture](#architecture)
8
+ - [Marketplace Clients](#marketplace-clients)
9
+ - [Features](#features)
10
+ - [Components](#components)
11
+ - [Implementation Guide](#implementation-guide)
12
+ - [Collection Analytics](#collection-analytics)
13
+ - [Marketplace Aggregation](#marketplace-aggregation)
14
+ - [AI Rarity Calculator](#ai-rarity-calculator)
15
+ - [Investment Advisor](#investment-advisor)
16
+ - [Configuration](#configuration)
17
+ - [Best Practices](#best-practices)
18
+ - [API Reference](#api-reference)
19
+ - [Performance Metrics](#performance-metrics)
20
+ - [Troubleshooting](#troubleshooting)
21
+
22
+ ---
23
+
24
+ ## Architecture
25
+
26
+ ```
27
+ ┌─────────────────────────────────────────────────────────────────────────┐
28
+ │ NFT Module Architecture │
29
+ ├─────────────────────────────────────────────────────────────────────────┤
30
+ │ │
31
+ │ ┌──────────────────┐ ┌──────────────────┐ ┌────────────────────┐ │
32
+ │ │ NFT Engine │ │ Collection │ │ Marketplace │ │
33
+ │ │ (Core Layer) │→ │ Analytics │→ │ Aggregator │ │
34
+ │ │ │ │ │ │ │ │
35
+ │ └──────────────────┘ └──────────────────┘ └────────────────────┘ │
36
+ │ ↓ │
37
+ │ ┌──────────────────┐ ┌──────────────────┐ ┌────────────────────┐ │
38
+ │ │ AI Rarity │ │ Investment │ │ Marketplace │ │
39
+ │ │ Calculator │ │ Advisor │ │ API Clients │ │
40
+ │ │ (Statistical) │ │ (Data-driven) │ │ │ │
41
+ │ └──────────────────┘ └──────────────────┘ └────────────────────┘ │
42
+ │ ↓ │
43
+ │ ┌─────────────────────────────────────────────────────────────────┐ │
44
+ │ │ Marketplace API Clients │ │
45
+ │ ├─────────────────────────────────────────────────────────────────┤ │
46
+ │ │ TensorClient │ MagicEdenClient │ Future Clients │ │
47
+ │ │ - getStats() │ - getStats() │ - Solanart │ │
48
+ │ │ - getFloorPrice() │ - getFloorPrice() │ - Hyperspace │ │
49
+ │ │ - getListings() │ - getListings() │ - OpenSea │ │
50
+ │ │ - getSales() │ - getActivities() │ │ │
51
+ │ │ - Rate Limiting │ - Rate Limiting │ │ │
52
+ │ └─────────────────────────────────────────────────────────────────┘ │
53
+ │ ↓ │
54
+ │ ┌─────────────────────────────────────────────────────────────────┐ │
55
+ │ │ Solana RPC Layer │ │
56
+ │ │ (Metadata, On-chain Data, Transaction History) │ │
57
+ │ └─────────────────────────────────────────────────────────────────┘ │
58
+ └─────────────────────────────────────────────────────────────────────────┘
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Marketplace Clients
64
+
65
+ The NFT module integrates with production-ready marketplace API clients for real-time data access.
66
+
67
+ ### TensorClient
68
+
69
+ Production-ready client for Tensor marketplace API integration.
70
+
71
+ **Features:**
72
+ - Real-time floor price tracking
73
+ - Collection statistics aggregation
74
+ - Active listings retrieval
75
+ - Sales history analysis
76
+ - Built-in rate limiting (10 req/s default)
77
+ - Automatic retry logic
78
+ - Cross-platform fetch support (Node.js 18+, browser)
79
+
80
+ **API Endpoints:**
81
+ - `https://api.tensor.so/api/v1/collections/{slug}/stats`
82
+ - `https://api.tensor.so/api/v1/collections/{slug}/listings`
83
+ - `https://api.tensor.so/api/v1/collections/{slug}/sales`
84
+ - `https://api.tensor.so/api/v1/mints/{mint}/listing`
85
+
86
+ ### MagicEdenClient
87
+
88
+ Production-ready client for Magic Eden marketplace API integration.
89
+
90
+ **Features:**
91
+ - Collection statistics and metadata
92
+ - Real-time listing data
93
+ - Activity tracking (sales, bids, listings)
94
+ - Collection search functionality
95
+ - Built-in rate limiting (10 req/s default)
96
+ - Automatic error handling
97
+ - Cross-platform fetch support
98
+
99
+ **API Endpoints:**
100
+ - `https://api-mainnet.magiceden.dev/v2/collections/{symbol}/stats`
101
+ - `https://api-mainnet.magiceden.dev/v2/collections/{symbol}/listings`
102
+ - `https://api-mainnet.magiceden.dev/v2/collections/{symbol}/activities`
103
+ - `https://api-mainnet.magiceden.dev/v2/tokens/{mint}/listings`
104
+
105
+ ### MetaplexOnChainClient
106
+
107
+ On-chain NFT analysis client using Solana RPC and DAS API for trustless, decentralized data.
108
+
109
+ **Features:**
110
+ - Direct on-chain data queries (no marketplace dependency)
111
+ - Holder distribution analysis with concentration risk (HHI)
112
+ - Collection supply verification
113
+ - Wallet NFT portfolio retrieval
114
+ - DAS API support (Helius, Triton) for fast bulk operations
115
+ - Metaplex standard compliance
116
+ - Zero centralized API dependencies
117
+
118
+ **Use Cases:**
119
+ - Collections not listed on marketplaces
120
+ - Trustless data verification
121
+ - Real-time holder analysis
122
+ - Decentralized applications requiring on-chain proof
123
+ - Supply and holder count validation
124
+ - Whale detection and distribution metrics
125
+
126
+ **Data Sources:**
127
+ - Primary: DAS API (Digital Asset Standard) - Helius, Triton, etc.
128
+ - Fallback: Solana RPC direct queries (slower, more expensive)
129
+ - Standard: Metaplex Token Metadata program
130
+
131
+ **Trade-offs:**
132
+ - **Pros:** Trustless, decentralized, no API keys required, real holder data
133
+ - **Cons:** No price history, no marketplace metrics, slower than centralized APIs, higher RPC costs for large collections
134
+
135
+ ### Client Configuration
136
+
137
+ Both clients support optional API keys for higher rate limits and custom configurations.
138
+
139
+ ```typescript
140
+ import { TensorClient, MagicEdenClient } from '@synapse/client-sdk/nft/clients';
141
+
142
+ // Tensor client configuration
143
+ const tensorClient = new TensorClient({
144
+ baseUrl: 'https://api.tensor.so', // Optional: custom endpoint
145
+ apiKey: process.env.TENSOR_API_KEY, // Optional: for higher limits
146
+ rateLimit: 10, // Requests per second
147
+ timeout: 10000, // Request timeout (ms)
148
+ logLevel: 'error', // 'debug' | 'info' | 'error' | 'none'
149
+ });
150
+
151
+ // Magic Eden client configuration
152
+ const magicEdenClient = new MagicEdenClient({
153
+ baseUrl: 'https://api-mainnet.magiceden.dev/v2',
154
+ apiKey: process.env.MAGIC_EDEN_API_KEY,
155
+ rateLimit: 10,
156
+ timeout: 10000,
157
+ logLevel: 'error',
158
+ });
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Features
164
+
165
+ ### Core Capabilities
166
+
167
+ | Feature | Description | Status | Dependencies |
168
+ |---------|-------------|--------|--------------|
169
+ | **Metadata Parsing** | NFT metadata retrieval from Arweave/IPFS | Production | Solana RPC |
170
+ | **Collection Analytics** | Real-time floor price, volume, trends | Production | Tensor, Magic Eden |
171
+ | **Marketplace Aggregation** | Multi-marketplace listing comparison | Production | Tensor, Magic Eden |
172
+ | **AI Rarity Calculation** | Statistical rarity scoring | Production | On-chain data |
173
+ | **Investment Analysis** | Data-driven investment recommendations | Production | All APIs |
174
+ | **Price Tracking** | Historical price data aggregation | Production | Marketplace APIs |
175
+ | **Holder Analysis** | Distribution and whale detection | Production | On-chain analysis |
176
+ | **Trend Detection** | Momentum and market sentiment | Production | Marketplace APIs |
177
+
178
+ ### Supported Marketplaces
179
+
180
+ | Marketplace | Status | API Client | Features Available |
181
+ |-------------|--------|------------|-------------------|
182
+ | **Tensor** | Production | `TensorClient` | Floor price, listings, sales, statistics |
183
+ | **Magic Eden** | Production | `MagicEdenClient` | Floor price, listings, activities, search |
184
+ | **Solanart** | Planned | N/A | Future integration |
185
+ | **Hyperspace** | Planned | N/A | Future integration |
186
+ | **OpenSea** | Planned | N/A | Cross-chain support |
187
+
188
+ ---
189
+
190
+ ## Components
191
+
192
+ ### 1. NFT Engine
193
+
194
+ Core NFT operations and metadata handling using Solana RPC and Metaplex standards.
195
+
196
+ ```typescript
197
+ import { NFTEngine } from '@synapse/client-sdk/nft';
198
+
199
+ const nft = new NFTEngine(client);
200
+
201
+ // Retrieve NFT metadata from on-chain and off-chain sources
202
+ const metadata = await nft.getNFTMetadata('mintAddress');
203
+ console.log('Name:', metadata.name);
204
+ console.log('Attributes:', metadata.attributes);
205
+ console.log('Collection:', metadata.collection);
206
+ ```
207
+
208
+ ### 2. Collection Analytics
209
+
210
+ Real-time collection statistics using Tensor and Magic Eden API clients.
211
+
212
+ ```typescript
213
+ import { CollectionAnalytics } from '@synapse/client-sdk/nft';
214
+
215
+ const analytics = new CollectionAnalytics(client);
216
+
217
+ // Fetch collection statistics (aggregates data from Tensor and Magic Eden)
218
+ const stats = await analytics.getStats('collectionMint');
219
+ console.log('Floor price:', stats.floorPrice, 'SOL');
220
+ console.log('24h Volume:', stats.volume24h, 'SOL');
221
+ console.log('Total holders:', stats.uniqueHolders);
222
+ console.log('Listed percentage:', stats.listedPercent.toFixed(2), '%');
223
+ ```
224
+
225
+ **Data Sources:**
226
+ - Primary: Tensor API (floor price, volume, sales)
227
+ - Secondary: Magic Eden API (listings, activities)
228
+ - Fallback: On-chain data aggregation
229
+
230
+ ### 3. Marketplace Aggregator
231
+
232
+ Multi-marketplace price comparison using TensorClient and MagicEdenClient.
233
+
234
+ ```typescript
235
+ import { MarketplaceAggregator } from '@synapse/client-sdk/nft';
236
+
237
+ const aggregator = new MarketplaceAggregator(client);
238
+
239
+ // Find best price across Tensor and Magic Eden
240
+ const prices = await aggregator.compareFloorPrices('mintAddress');
241
+ console.log('Lowest price:', prices.lowestPrice, 'SOL');
242
+ console.log('Best marketplace:', prices.bestMarketplace);
243
+ console.log('Price difference:', prices.priceDifference, 'SOL');
244
+ console.log('Savings percentage:', prices.savings.toFixed(2), '%');
245
+ ```
246
+
247
+ ### 4. AI Rarity Calculator
248
+
249
+ Statistical rarity calculation based on trait distribution analysis.
250
+
251
+ ```typescript
252
+ import { AIRarityCalculator } from '@synapse/client-sdk/nft';
253
+
254
+ const rarityCalc = new AIRarityCalculator(client);
255
+
256
+ // Calculate rarity score using statistical analysis
257
+ const rarity = await rarityCalc.calculateRarity('mintAddress', 'collectionAddress');
258
+ console.log('Overall rarity:', rarity.overallRarity.toFixed(2), '/100');
259
+ console.log('Statistical rarity:', rarity.statisticalRarity);
260
+ console.log('AI-enhanced rarity:', rarity.aiEnhancedRarity);
261
+ console.log('Estimated value:', rarity.valueEstimate, 'SOL');
262
+ ```
263
+
264
+ ### 5. AI Investment Advisor
265
+
266
+ Data-driven investment recommendations based on market metrics.
267
+
268
+ ```typescript
269
+ import { AIInvestmentAdvisor } from '@synapse/client-sdk/nft';
270
+
271
+ const advisor = new AIInvestmentAdvisor(client);
272
+
273
+ // Generate investment recommendation
274
+ const recommendation = await advisor.getRecommendation(
275
+ 'mintAddress',
276
+ 'collectionAddress',
277
+ 2.5 // current price in SOL
278
+ );
279
+
280
+ console.log('Recommendation:', recommendation.recommendation);
281
+ console.log('Confidence:', recommendation.confidence, '%');
282
+ console.log('Target price:', recommendation.targetPrice, 'SOL');
283
+ console.log('Reasoning:', recommendation.reasoning);
284
+ console.log('Risks:', recommendation.risks);
285
+ console.log('Time horizon:', recommendation.timeHorizon);
286
+ ```
287
+
288
+ ---
289
+
290
+ ## Implementation Guide
291
+
292
+ ### Basic Setup
293
+
294
+ ```typescript
295
+ import { SynapseClient } from '@synapse/client-sdk';
296
+ import {
297
+ NFTEngine,
298
+ CollectionAnalytics,
299
+ MarketplaceAggregator,
300
+ AIRarityCalculator
301
+ } from '@synapse/client-sdk/nft';
302
+
303
+ // Initialize Synapse client
304
+ const client = new SynapseClient({
305
+ endpoint: process.env.SYNAPSE_ENDPOINT!,
306
+ apiKey: process.env.SYNAPSE_API_KEY,
307
+ });
308
+
309
+ // Initialize NFT components
310
+ const nft = new NFTEngine(client);
311
+ const analytics = new CollectionAnalytics(client);
312
+ const aggregator = new MarketplaceAggregator(client);
313
+ const rarityCalc = new AIRarityCalculator(client);
314
+ ```
315
+
316
+ ### Complete Workflow Example
317
+
318
+ ```typescript
319
+ // Step 1: Retrieve NFT metadata
320
+ const metadata = await nft.getNFTMetadata('mintAddress');
321
+ console.log('NFT:', metadata.name);
322
+ console.log('Collection:', metadata.collection);
323
+
324
+ // Step 2: Get collection statistics (uses Tensor + Magic Eden)
325
+ const stats = await analytics.getStats(metadata.collection);
326
+ console.log('Floor price:', stats.floorPrice, 'SOL');
327
+ console.log('24h Volume:', stats.volume24h, 'SOL');
328
+ console.log('Total supply:', stats.totalSupply);
329
+ console.log('Listed:', stats.listed, '/', stats.totalSupply);
330
+
331
+ // Step 3: Calculate rarity
332
+ const rarity = await rarityCalc.calculateRarity('mintAddress', metadata.collection);
333
+ console.log('Rarity score:', rarity.overallRarity.toFixed(2));
334
+ console.log('Value estimate:', rarity.valueEstimate, 'SOL');
335
+
336
+ // Step 4: Compare marketplace prices
337
+ const prices = await aggregator.compareFloorPrices('mintAddress');
338
+ console.log('Lowest price:', prices.lowestPrice, 'SOL on', prices.bestMarketplace);
339
+ console.log('Available on', prices.prices.length, 'marketplaces');
340
+
341
+ // Output marketplace comparison table
342
+ console.table(prices.prices);
343
+ ```
344
+
345
+ ---
346
+
347
+ ## Collection Analytics
348
+
349
+ ### Using Tensor and Magic Eden APIs
350
+
351
+ The `CollectionAnalytics` class automatically aggregates data from multiple marketplace APIs.
352
+
353
+ ```typescript
354
+ const analytics = new CollectionAnalytics(client);
355
+
356
+ // Data is fetched from:
357
+ // 1. TensorClient.getCollectionStats() - Primary source for Solana NFTs
358
+ // 2. MagicEdenClient.getCollectionStats() - Secondary/fallback source
359
+ // 3. Aggregation logic combines best data from both sources
360
+
361
+ const stats = await analytics.getStats('collectionAddress');
362
+ ```
363
+
364
+ ### Collection Statistics Interface
365
+
366
+ ```typescript
367
+ interface CollectionStats {
368
+ collectionAddress: string;
369
+ totalSupply: number; // From Tensor or Magic Eden
370
+ holders: number; // Estimated from on-chain data
371
+ floorPrice: number; // Lowest floor price (SOL)
372
+ volume24h: number; // 24h trading volume (SOL)
373
+ volume7d: number; // 7d trading volume (SOL)
374
+ volume30d: number; // 30d trading volume (SOL)
375
+ avgPrice24h: number; // Average sale price in 24h (SOL)
376
+ sales24h: number; // Number of sales in 24h
377
+ listed: number; // Current listings count
378
+ listedPercent: number; // Percentage of supply listed
379
+ uniqueHolders: number; // Unique holder addresses
380
+ holderDistribution: {
381
+ whales: number; // Holders with >10% supply
382
+ medium: number; // Holders with 1-10% supply
383
+ retail: number; // Holders with <1% supply
384
+ };
385
+ priceHistory: Array<{
386
+ timestamp: number;
387
+ floorPrice: number;
388
+ volume: number;
389
+ }>;
390
+ topSales: Array<{
391
+ mint: string;
392
+ price: number;
393
+ timestamp: number;
394
+ buyer?: string;
395
+ seller?: string;
396
+ }>;
397
+ }
398
+ ```
399
+
400
+ ### Trend Analysis
401
+
402
+ ```typescript
403
+ interface CollectionTrends {
404
+ trending: 'up' | 'down' | 'stable';
405
+ volumeChange24h: number; // Percentage change
406
+ priceChange24h: number; // Percentage change
407
+ momentum: number; // Score from -100 to 100
408
+ sentiment: 'bullish' | 'bearish' | 'neutral';
409
+ signals: string[]; // Market signals
410
+ }
411
+
412
+ // Analyze trends using aggregated marketplace data
413
+ const trends = await analytics.analyzeTrends('collectionMint');
414
+
415
+ console.log('Market Analysis:');
416
+ console.log(' Trend direction:', trends.trending);
417
+ console.log(' Volume change:', trends.volumeChange24h.toFixed(2), '%');
418
+ console.log(' Price change:', trends.priceChange24h.toFixed(2), '%');
419
+ console.log(' Market momentum:', trends.momentum);
420
+ console.log(' Sentiment:', trends.sentiment);
421
+ console.log(' Signals:', trends.signals.join(', '));
422
+ ```
423
+
424
+ ### Collection Comparison
425
+
426
+ ```typescript
427
+ // Compare multiple collections using marketplace APIs
428
+ const comparison = await analytics.compareCollections([
429
+ 'collection1',
430
+ 'collection2',
431
+ 'collection3',
432
+ ]);
433
+
434
+ // Display rankings
435
+ console.log('Rankings by 24h Volume:');
436
+ comparison.rankings.byVolume.forEach((addr, index) => {
437
+ const coll = comparison.collections.find(c => c.collectionAddress === addr);
438
+ console.log(` ${index + 1}. ${coll?.name || addr}`);
439
+ console.log(` Volume: ${coll?.volume24h.toFixed(2)} SOL`);
440
+ });
441
+
442
+ console.log('\nRankings by Floor Price:');
443
+ comparison.rankings.byFloorPrice.forEach((addr, index) => {
444
+ const coll = comparison.collections.find(c => c.collectionAddress === addr);
445
+ console.log(` ${index + 1}. ${coll?.name || addr}`);
446
+ console.log(` Floor: ${coll?.floorPrice.toFixed(2)} SOL`);
447
+ });
448
+
449
+ console.log('\nRankings by Momentum:');
450
+ comparison.rankings.byMomentum.forEach((addr, index) => {
451
+ const coll = comparison.collections.find(c => c.collectionAddress === addr);
452
+ console.log(` ${index + 1}. ${coll?.name || addr}`);
453
+ console.log(` Momentum: ${coll?.trends.momentum}/100`);
454
+ });
455
+ ```
456
+
457
+ ---
458
+
459
+ ## Marketplace Aggregation
460
+
461
+ ### TensorClient and MagicEdenClient Integration
462
+
463
+ The `MarketplaceAggregator` uses both marketplace clients to find the best prices.
464
+
465
+ ```typescript
466
+ import { MarketplaceAggregator } from '@synapse/client-sdk/nft';
467
+
468
+ const aggregator = new MarketplaceAggregator(client);
469
+
470
+ // Automatically queries:
471
+ // - TensorClient.getMintListing(mint) for Tensor marketplace
472
+ // - MagicEdenClient.getTokenListing(mint) for Magic Eden marketplace
473
+
474
+ const listings = await aggregator.findListings('mintAddress');
475
+ ```
476
+
477
+ ### Marketplace Listing Interface
478
+
479
+ ```typescript
480
+ interface MarketplaceListing {
481
+ marketplace: 'tensor' | 'magiceden' | 'solanart' | 'opensea' | 'hyperspace';
482
+ mint: string; // NFT mint address
483
+ price: number; // Listing price (SOL)
484
+ seller: string; // Seller wallet address
485
+ listingUrl: string; // Direct marketplace URL
486
+ timestamp: number; // Listing timestamp (Unix)
487
+ royalties?: number; // Royalty percentage
488
+ attributes?: Record<string, string>;
489
+ }
490
+ ```
491
+
492
+ ### Price Comparison
493
+
494
+ ```typescript
495
+ interface MarketplaceFloorPrices {
496
+ mint: string;
497
+ prices: Array<{
498
+ marketplace: string; // 'tensor' or 'magiceden'
499
+ price: number; // Price in SOL
500
+ url: string; // Direct listing URL
501
+ }>;
502
+ lowestPrice: number; // Best available price
503
+ bestMarketplace: string; // Marketplace with lowest price
504
+ priceDifference: number; // Highest - lowest price
505
+ savings: number; // Percentage saved at best marketplace
506
+ }
507
+
508
+ // Compare prices across marketplaces
509
+ const comparison = await aggregator.compareFloorPrices('mintAddress');
510
+
511
+ console.log('\nMarketplace Price Comparison:');
512
+ console.log('─'.repeat(60));
513
+ comparison.prices.forEach(({ marketplace, price, url }) => {
514
+ console.log(`${marketplace.padEnd(15)} ${price.toFixed(4)} SOL`);
515
+ console.log(`${''.padEnd(15)} ${url}`);
516
+ });
517
+ console.log('─'.repeat(60));
518
+ console.log(`Best price: ${comparison.lowestPrice} SOL on ${comparison.bestMarketplace}`);
519
+ console.log(`Save ${comparison.savings.toFixed(1)}% vs highest price`);
520
+ ```
521
+
522
+ ### Finding All Listings
523
+
524
+ ```typescript
525
+ // Fetch all available listings from Tensor and Magic Eden
526
+ const allListings = await aggregator.findListings('mintAddress', {
527
+ marketplaces: ['tensor', 'magiceden'],
528
+ maxPrice: 5.0, // Optional: filter by maximum price
529
+ });
530
+
531
+ // Sort by price ascending (automatically done)
532
+ console.log('\nAll Available Listings:');
533
+ allListings.forEach((listing, index) => {
534
+ console.log(`\n${index + 1}. ${listing.marketplace.toUpperCase()}`);
535
+ console.log(` Price: ${listing.price.toFixed(4)} SOL`);
536
+ console.log(` Seller: ${listing.seller.substring(0, 8)}...`);
537
+ console.log(` URL: ${listing.listingUrl}`);
538
+ });
539
+ ```
540
+
541
+ ---
542
+
543
+ ## AI Rarity Calculator
544
+
545
+ ### Statistical Rarity Analysis
546
+
547
+ The `AIRarityCalculator` performs trait-based statistical analysis to calculate rarity scores.
548
+
549
+ ```typescript
550
+ interface RarityScore {
551
+ mint: string;
552
+ overallRarity: number; // 0-100 composite score
553
+ rank?: number; // Rank within collection
554
+ traits: Array<{
555
+ trait: string; // Trait category
556
+ value: string; // Trait value
557
+ rarity: number; // Rarity score for this trait
558
+ occurrence: number; // Frequency in collection
559
+ }>;
560
+ statisticalRarity: number; // Pure statistical calculation
561
+ aiEnhancedRarity: number; // ML-weighted calculation
562
+ valueEstimate: number; // Estimated value in SOL
563
+ }
564
+ ```
565
+
566
+ ### Algorithm Configuration
567
+
568
+ ```typescript
569
+ interface RarityAlgorithmConfig {
570
+ algorithm: 'statistical' | 'trait-normalized' | 'ai-enhanced' | 'hybrid';
571
+ weights?: {
572
+ traitRarity?: number; // Weight for trait rarity (default: 0.6)
573
+ traitCount?: number; // Weight for trait count (default: 0.2)
574
+ aesthetic?: number; // Weight for aesthetic score (default: 0.2)
575
+ };
576
+ }
577
+
578
+ // Configure calculator with custom algorithm
579
+ const rarityCalc = new AIRarityCalculator(client, {
580
+ algorithm: 'hybrid',
581
+ weights: {
582
+ traitRarity: 0.6,
583
+ traitCount: 0.2,
584
+ aesthetic: 0.2,
585
+ },
586
+ });
587
+ ```
588
+
589
+ ### Calculate Rarity
590
+
591
+ ```typescript
592
+ // Calculate rarity for a single NFT
593
+ const rarity = await rarityCalc.calculateRarity('mintAddress', 'collectionAddress');
594
+
595
+ console.log('\nRarity Analysis:');
596
+ console.log('─'.repeat(60));
597
+ console.log('Overall Rarity Score:', rarity.overallRarity.toFixed(2), '/100');
598
+ console.log('Statistical Rarity:', rarity.statisticalRarity.toFixed(2));
599
+ console.log('AI-Enhanced Rarity:', rarity.aiEnhancedRarity.toFixed(2));
600
+ console.log('Estimated Value:', rarity.valueEstimate.toFixed(4), 'SOL');
601
+
602
+ if (rarity.rank) {
603
+ console.log('Collection Rank: #', rarity.rank);
604
+ }
605
+
606
+ console.log('\nTrait Breakdown:');
607
+ rarity.traits.forEach(trait => {
608
+ console.log(` ${trait.trait}: ${trait.value}`);
609
+ console.log(` Rarity: ${trait.rarity.toFixed(2)}`);
610
+ console.log(` Occurrence: ${trait.occurrence} in collection`);
611
+ });
612
+ ```
613
+
614
+ ### Batch Rarity Calculation
615
+
616
+ ```typescript
617
+ // Calculate rarity for multiple NFTs efficiently
618
+ const mints = ['mint1', 'mint2', 'mint3', 'mint4'];
619
+ const rarityScores = await rarityCalc.batchCalculateRarity(
620
+ mints,
621
+ 'collectionAddress'
622
+ );
623
+
624
+ // Results are automatically ranked
625
+ rarityScores.forEach((score, index) => {
626
+ console.log(`\n${index + 1}. Rank #${score.rank}`);
627
+ console.log(` Mint: ${score.mint.substring(0, 8)}...`);
628
+ console.log(` Rarity: ${score.overallRarity.toFixed(2)}/100`);
629
+ console.log(` Value Estimate: ${score.valueEstimate.toFixed(4)} SOL`);
630
+ });
631
+ ```
632
+
633
+ ---
634
+
635
+ ## Investment Advisor
636
+
637
+ ### Investment Recommendation Interface
638
+
639
+ ```typescript
640
+ interface InvestmentRecommendation {
641
+ mint: string;
642
+ collectionAddress: string;
643
+ recommendation: 'strong-buy' | 'buy' | 'hold' | 'sell' | 'strong-sell';
644
+ confidence: number; // 0-100 confidence score
645
+ targetPrice: number; // Target price in SOL
646
+ reasoning: string[]; // List of reasoning points
647
+ metrics: {
648
+ rarityScore: number; // 0-100
649
+ volumeTrend: number; // Percentage
650
+ priceMomentum: number; // Percentage
651
+ holderQuality: number; // 0-100
652
+ };
653
+ risks: string[]; // Identified risks
654
+ timeHorizon: 'short' | 'medium' | 'long';
655
+ }
656
+ ```
657
+
658
+ ### Generate Recommendation
659
+
660
+ ```typescript
661
+ const advisor = new AIInvestmentAdvisor(client);
662
+
663
+ // Generate data-driven investment recommendation
664
+ const recommendation = await advisor.getRecommendation(
665
+ 'mintAddress',
666
+ 'collectionAddress',
667
+ 2.5 // current price in SOL
668
+ );
669
+
670
+ console.log('\nInvestment Analysis:');
671
+ console.log('─'.repeat(60));
672
+ console.log('Recommendation:', recommendation.recommendation.toUpperCase());
673
+ console.log('Confidence:', recommendation.confidence, '%');
674
+ console.log('Target Price:', recommendation.targetPrice.toFixed(4), 'SOL');
675
+ console.log('Time Horizon:', recommendation.timeHorizon);
676
+
677
+ console.log('\nKey Metrics:');
678
+ console.log(' Rarity Score:', recommendation.metrics.rarityScore.toFixed(2), '/100');
679
+ console.log(' Volume Trend:', recommendation.metrics.volumeTrend.toFixed(2), '%');
680
+ console.log(' Price Momentum:', recommendation.metrics.priceMomentum.toFixed(2), '%');
681
+ console.log(' Holder Quality:', recommendation.metrics.holderQuality.toFixed(2), '/100');
682
+
683
+ console.log('\nReasoning:');
684
+ recommendation.reasoning.forEach((reason, index) => {
685
+ console.log(` ${index + 1}. ${reason}`);
686
+ });
687
+
688
+ if (recommendation.risks.length > 0) {
689
+ console.log('\nRisks:');
690
+ recommendation.risks.forEach((risk, index) => {
691
+ console.log(` ${index + 1}. ${risk}`);
692
+ });
693
+ }
694
+ ```
695
+
696
+ ### Investment Metrics
697
+
698
+ The investment advisor analyzes multiple data sources:
699
+
700
+ | Metric | Source | Weight | Description |
701
+ |--------|--------|--------|-------------|
702
+ | **Rarity Score** | AIRarityCalculator | 30% | Statistical trait rarity |
703
+ | **Volume Trend** | Tensor + Magic Eden | 20% | 24h volume change |
704
+ | **Price Momentum** | Tensor + Magic Eden | 20% | Price direction and strength |
705
+ | **Holder Quality** | On-chain Analysis | 30% | Distribution and whale ratio |
706
+
707
+ ---
708
+
709
+ ## Configuration
710
+
711
+ ### NFT Module Configuration
712
+
713
+ ```typescript
714
+ interface NFTConfig {
715
+ client: SynapseLikeClient;
716
+ defaultCommitment?: Commitment;
717
+ fetch?: typeof fetch;
718
+ das?: {
719
+ baseUrl: string;
720
+ getAssetPath?: string;
721
+ getAssetByIdPath?: string;
722
+ getAssetProofPath?: string;
723
+ headers?: Record<string, string>;
724
+ };
725
+ marketplaces?: MarketplaceClientConfig;
726
+ }
727
+
728
+ interface MarketplaceClientConfig {
729
+ tensor?: {
730
+ baseUrl?: string;
731
+ apiKey?: string;
732
+ rateLimit?: number;
733
+ };
734
+ magicEden?: {
735
+ baseUrl?: string;
736
+ apiKey?: string;
737
+ rateLimit?: number;
738
+ };
739
+ helius?: {
740
+ apiKey: string;
741
+ cluster?: 'mainnet-beta' | 'devnet';
742
+ };
743
+ fetch?: typeof fetch;
744
+ timeout?: number;
745
+ logLevel?: 'debug' | 'info' | 'error' | 'none';
746
+ }
747
+ ```
748
+
749
+ ### Complete Configuration Example
750
+
751
+ ```typescript
752
+ import { SynapseClient } from '@synapse/client-sdk';
753
+ import { NFTEngine } from '@synapse/client-sdk/nft';
754
+
755
+ const client = new SynapseClient({
756
+ endpoint: process.env.SYNAPSE_ENDPOINT!,
757
+ apiKey: process.env.SYNAPSE_API_KEY,
758
+ });
759
+
760
+ const nft = new NFTEngine({
761
+ client,
762
+ defaultCommitment: 'confirmed',
763
+
764
+ // Compressed NFT support (optional)
765
+ das: {
766
+ baseUrl: 'https://mainnet.helius-rpc.com',
767
+ headers: {
768
+ 'Authorization': `Bearer ${process.env.HELIUS_API_KEY}`,
769
+ },
770
+ },
771
+
772
+ // Marketplace API configurations (optional)
773
+ marketplaces: {
774
+ tensor: {
775
+ baseUrl: 'https://api.tensor.so',
776
+ apiKey: process.env.TENSOR_API_KEY,
777
+ rateLimit: 10, // requests per second
778
+ },
779
+ magicEden: {
780
+ baseUrl: 'https://api-mainnet.magiceden.dev/v2',
781
+ apiKey: process.env.MAGIC_EDEN_API_KEY,
782
+ rateLimit: 10,
783
+ },
784
+ timeout: 10000, // 10 seconds
785
+ logLevel: 'error',
786
+ },
787
+ });
788
+ ```
789
+
790
+ ### Environment Variables
791
+
792
+ ```bash
793
+ # Synapse Gateway
794
+ SYNAPSE_ENDPOINT=https://api.synapse.example.com
795
+ SYNAPSE_API_KEY=your_synapse_api_key
796
+
797
+ # Marketplace APIs (optional - for higher rate limits)
798
+ TENSOR_API_KEY=your_tensor_api_key
799
+ MAGIC_EDEN_API_KEY=your_magic_eden_api_key
800
+
801
+ # Helius (for compressed NFTs)
802
+ HELIUS_API_KEY=your_helius_api_key
803
+ ```
804
+
805
+ ---
806
+
807
+ ## Best Practices
808
+
809
+ ### 1. Caching Strategy
810
+
811
+ Implement caching to reduce API calls and improve performance.
812
+
813
+ ```typescript
814
+ const cache = new Map<string, { stats: CollectionStats; timestamp: number }>();
815
+ const CACHE_TTL = 300000; // 5 minutes
816
+
817
+ async function getCollectionStatsCached(collection: string) {
818
+ const cached = cache.get(collection);
819
+ if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
820
+ console.log('Cache hit for', collection);
821
+ return cached.stats;
822
+ }
823
+
824
+ console.log('Fetching fresh data for', collection);
825
+ const stats = await analytics.getStats(collection);
826
+ cache.set(collection, { stats, timestamp: Date.now() });
827
+ return stats;
828
+ }
829
+ ```
830
+
831
+ ### 2. Event-Driven Updates
832
+
833
+ Use event emitters for real-time monitoring.
834
+
835
+ ```typescript
836
+ // Monitor collection statistics updates
837
+ analytics.on('collection-stats-complete', (stats) => {
838
+ console.log('Stats updated:', stats.collectionAddress);
839
+ console.log('Floor price:', stats.floorPrice, 'SOL');
840
+ });
841
+
842
+ analytics.on('collection-stats-error', (error) => {
843
+ console.error('Failed to fetch stats:', error);
844
+ });
845
+
846
+ // Monitor marketplace searches
847
+ aggregator.on('listings-search-start', ({ mint }) => {
848
+ console.log('Searching marketplaces for:', mint);
849
+ });
850
+
851
+ aggregator.on('listings-search-complete', ({ found }) => {
852
+ console.log('Found', found, 'listings');
853
+ });
854
+ ```
855
+
856
+ ### 3. Error Handling
857
+
858
+ Implement robust error handling for marketplace failures.
859
+
860
+ ```typescript
861
+ async function safeGetFloorPrice(collection: string): Promise<number> {
862
+ try {
863
+ const stats = await analytics.getStats(collection);
864
+ return stats.floorPrice;
865
+ } catch (error) {
866
+ console.error('Primary API failed:', error);
867
+
868
+ // Fallback to direct Tensor API
869
+ try {
870
+ const TensorClient = (await import('@synapse/client-sdk/nft/clients')).TensorClient;
871
+ const tensorClient = new TensorClient({ logLevel: 'error' });
872
+ const tensorStats = await tensorClient.getCollectionStats(collection);
873
+ return tensorStats.floorPrice / 1e9;
874
+ } catch (fallbackError) {
875
+ console.error('Fallback failed:', fallbackError);
876
+ throw new Error('All marketplace APIs unavailable');
877
+ }
878
+ }
879
+ }
880
+ ```
881
+
882
+ ### 4. Batch Operations
883
+
884
+ Process multiple operations efficiently.
885
+
886
+ ```typescript
887
+ // Efficient: Single API call for comparison
888
+ const comparison = await analytics.compareCollections([
889
+ 'collection1',
890
+ 'collection2',
891
+ 'collection3',
892
+ ]);
893
+
894
+ // Inefficient: Multiple separate calls
895
+ // DON'T DO THIS:
896
+ const stats1 = await analytics.getStats('collection1');
897
+ const stats2 = await analytics.getStats('collection2');
898
+ const stats3 = await analytics.getStats('collection3');
899
+ ```
900
+
901
+ ### 5. Rate Limit Awareness
902
+
903
+ Both TensorClient and MagicEdenClient implement automatic rate limiting.
904
+
905
+ ```typescript
906
+ // Clients automatically enforce rate limits
907
+ const tensorClient = new TensorClient({
908
+ rateLimit: 10, // 10 requests per second (default)
909
+ });
910
+
911
+ const magicEdenClient = new MagicEdenClient({
912
+ rateLimit: 10, // 10 requests per second (default)
913
+ });
914
+
915
+ // No need for manual rate limiting - clients handle it automatically
916
+ ```
917
+
918
+ ### 6. Marketplace Fallback Strategy
919
+
920
+ ```typescript
921
+ async function getFloorPriceWithFallback(symbol: string): Promise<number> {
922
+ const errors: string[] = [];
923
+
924
+ // Try Tensor first (primary for Solana NFTs)
925
+ try {
926
+ const tensorClient = new TensorClient({ logLevel: 'error' });
927
+ return await tensorClient.getFloorPrice(symbol);
928
+ } catch (error) {
929
+ errors.push(`Tensor: ${(error as Error).message}`);
930
+ }
931
+
932
+ // Fallback to Magic Eden
933
+ try {
934
+ const magicEdenClient = new MagicEdenClient({ logLevel: 'error' });
935
+ return await magicEdenClient.getFloorPrice(symbol);
936
+ } catch (error) {
937
+ errors.push(`MagicEden: ${(error as Error).message}`);
938
+ }
939
+
940
+ throw new Error(`All marketplaces failed: ${errors.join(', ')}`);
941
+ }
942
+ ```
943
+
944
+ ---
945
+
946
+ ## API Reference
947
+
948
+ ### TensorClient
949
+
950
+ Production-ready Tensor marketplace API client.
951
+
952
+ #### getCollectionStats()
953
+
954
+ ```typescript
955
+ async getCollectionStats(slug: string): Promise<TensorCollectionStats>
956
+ ```
957
+
958
+ Retrieves comprehensive collection statistics from Tensor API.
959
+
960
+ **Parameters:**
961
+ - `slug` - Collection slug identifier (e.g., "mad_lads")
962
+
963
+ **Returns:** `TensorCollectionStats` object containing floor price, volume, sales data
964
+
965
+ **Example:**
966
+ ```typescript
967
+ const tensorClient = new TensorClient();
968
+ const stats = await tensorClient.getCollectionStats('okay_bears');
969
+ console.log('Floor:', stats.floorPrice / 1e9, 'SOL');
970
+ console.log('24h Volume:', stats.volume24h / 1e9, 'SOL');
971
+ ```
972
+
973
+ #### getFloorPrice()
974
+
975
+ ```typescript
976
+ async getFloorPrice(slug: string): Promise<number>
977
+ ```
978
+
979
+ Retrieves current floor price for a collection.
980
+
981
+ **Returns:** Floor price in lamports
982
+
983
+ #### getListings()
984
+
985
+ ```typescript
986
+ async getListings(
987
+ slug: string,
988
+ options?: {
989
+ limit?: number;
990
+ page?: number;
991
+ sortBy?: 'price' | 'listedAt';
992
+ sortDirection?: 'asc' | 'desc';
993
+ }
994
+ ): Promise<TensorListing[]>
995
+ ```
996
+
997
+ Retrieves active listings for a collection with pagination support.
998
+
999
+ **Returns:** Array of `TensorListing` objects
1000
+
1001
+ #### getSales()
1002
+
1003
+ ```typescript
1004
+ async getSales(
1005
+ slug: string,
1006
+ options?: {
1007
+ limit?: number;
1008
+ page?: number;
1009
+ }
1010
+ ): Promise<TensorSale[]>
1011
+ ```
1012
+
1013
+ Retrieves recent sales for a collection.
1014
+
1015
+ **Returns:** Array of `TensorSale` objects
1016
+
1017
+ #### getMintListing()
1018
+
1019
+ ```typescript
1020
+ async getMintListing(mint: string): Promise<TensorListing | null>
1021
+ ```
1022
+
1023
+ Retrieves listing information for a specific NFT mint.
1024
+
1025
+ **Returns:** `TensorListing` object or null if not listed
1026
+
1027
+ #### healthCheck()
1028
+
1029
+ ```typescript
1030
+ async healthCheck(): Promise<boolean>
1031
+ ```
1032
+
1033
+ Verifies Tensor API connectivity and accessibility.
1034
+
1035
+ **Returns:** `true` if API is healthy, `false` otherwise
1036
+
1037
+ ---
1038
+
1039
+ ### MagicEdenClient
1040
+
1041
+ Production-ready Magic Eden marketplace API client.
1042
+
1043
+ #### getCollectionStats()
1044
+
1045
+ ```typescript
1046
+ async getCollectionStats(symbol: string): Promise<MagicEdenCollectionStats>
1047
+ ```
1048
+
1049
+ Retrieves collection statistics from Magic Eden API.
1050
+
1051
+ **Parameters:**
1052
+ - `symbol` - Collection symbol (e.g., "okay_bears")
1053
+
1054
+ **Returns:** `MagicEdenCollectionStats` object with floor price and volume data
1055
+
1056
+ **Example:**
1057
+ ```typescript
1058
+ const magicEdenClient = new MagicEdenClient();
1059
+ const stats = await magicEdenClient.getCollectionStats('okay_bears');
1060
+ console.log('Floor:', stats.floorPrice, 'SOL');
1061
+ console.log('24h Volume:', stats.volume24hr, 'SOL');
1062
+ ```
1063
+
1064
+ #### getCollectionInfo()
1065
+
1066
+ ```typescript
1067
+ async getCollectionInfo(symbol: string): Promise<MagicEdenCollection>
1068
+ ```
1069
+
1070
+ Retrieves collection metadata and information.
1071
+
1072
+ **Returns:** `MagicEdenCollection` object with metadata
1073
+
1074
+ #### getFloorPrice()
1075
+
1076
+ ```typescript
1077
+ async getFloorPrice(symbol: string): Promise<number>
1078
+ ```
1079
+
1080
+ Retrieves current floor price for a collection.
1081
+
1082
+ **Returns:** Floor price in SOL (not lamports)
1083
+
1084
+ #### getListings()
1085
+
1086
+ ```typescript
1087
+ async getListings(
1088
+ symbol: string,
1089
+ options?: {
1090
+ offset?: number;
1091
+ limit?: number;
1092
+ }
1093
+ ): Promise<MagicEdenListing[]>
1094
+ ```
1095
+
1096
+ Retrieves active listings with pagination support.
1097
+
1098
+ **Returns:** Array of `MagicEdenListing` objects
1099
+
1100
+ #### getCollectionActivities()
1101
+
1102
+ ```typescript
1103
+ async getCollectionActivities(
1104
+ symbol: string,
1105
+ options?: {
1106
+ offset?: number;
1107
+ limit?: number;
1108
+ }
1109
+ ): Promise<MagicEdenActivity[]>
1110
+ ```
1111
+
1112
+ Retrieves collection activities (sales, listings, bids).
1113
+
1114
+ **Returns:** Array of `MagicEdenActivity` objects
1115
+
1116
+ #### getTokenListing()
1117
+
1118
+ ```typescript
1119
+ async getTokenListing(mintAddress: string): Promise<MagicEdenListing | null>
1120
+ ```
1121
+
1122
+ Retrieves listing information for a specific NFT token.
1123
+
1124
+ **Returns:** `MagicEdenListing` object or null if not listed
1125
+
1126
+ #### getSales()
1127
+
1128
+ ```typescript
1129
+ async getSales(
1130
+ symbol: string,
1131
+ options?: {
1132
+ offset?: number;
1133
+ limit?: number;
1134
+ }
1135
+ ): Promise<MagicEdenActivity[]>
1136
+ ```
1137
+
1138
+ Retrieves recent sales (filtered buyNow activities).
1139
+
1140
+ **Returns:** Array of sale activities
1141
+
1142
+ #### searchCollections()
1143
+
1144
+ ```typescript
1145
+ async searchCollections(query: string, limit?: number): Promise<MagicEdenCollection[]>
1146
+ ```
1147
+
1148
+ Searches for collections by name.
1149
+
1150
+ **Returns:** Array of matching collections
1151
+
1152
+ #### healthCheck()
1153
+
1154
+ ```typescript
1155
+ async healthCheck(): Promise<boolean>
1156
+ ```
1157
+
1158
+ Verifies Magic Eden API connectivity and accessibility.
1159
+
1160
+ **Returns:** `true` if API is healthy, `false` otherwise
1161
+
1162
+ ---
1163
+
1164
+ ### CollectionAnalytics
1165
+
1166
+ #### getStats()
1167
+
1168
+ ```typescript
1169
+ async getStats(
1170
+ collectionAddress: string,
1171
+ options?: { useCache?: boolean }
1172
+ ): Promise<CollectionStats>
1173
+ ```
1174
+
1175
+ Retrieves comprehensive collection statistics aggregated from Tensor and Magic Eden.
1176
+
1177
+ **Parameters:**
1178
+ - `collectionAddress` - Collection mint address or slug
1179
+ - `options.useCache` - Use cached data if available (default: true)
1180
+
1181
+ **Returns:** `CollectionStats` object with aggregated marketplace data
1182
+
1183
+ **Data Sources:**
1184
+ - Primary: TensorClient (floor price, volume, sales)
1185
+ - Secondary: MagicEdenClient (listings, activities)
1186
+ - Aggregation: Combines best data from both sources
1187
+
1188
+ #### analyzeTrends()
1189
+
1190
+ ```typescript
1191
+ async analyzeTrends(collectionAddress: string): Promise<CollectionTrends>
1192
+ ```
1193
+
1194
+ Analyzes collection market trends and momentum.
1195
+
1196
+ **Returns:** `CollectionTrends` object with trend analysis
1197
+
1198
+ #### compareCollections()
1199
+
1200
+ ```typescript
1201
+ async compareCollections(collectionAddresses: string[]): Promise<{
1202
+ collections: Array<CollectionStats & { trends: CollectionTrends }>;
1203
+ rankings: {
1204
+ byVolume: string[];
1205
+ byFloorPrice: string[];
1206
+ byMomentum: string[];
1207
+ };
1208
+ }>
1209
+ ```
1210
+
1211
+ Compares multiple collections side-by-side.
1212
+
1213
+ **Returns:** Comparison data with rankings by various metrics
1214
+
1215
+ ---
1216
+
1217
+ ### MarketplaceAggregator
1218
+
1219
+ #### findListings()
1220
+
1221
+ ```typescript
1222
+ async findListings(mint: string, options?: {
1223
+ marketplaces?: string[];
1224
+ maxPrice?: number;
1225
+ }): Promise<MarketplaceListing[]>
1226
+ ```
1227
+
1228
+ Finds all listings for an NFT across Tensor and Magic Eden marketplaces.
1229
+
1230
+ **Parameters:**
1231
+ - `mint` - NFT mint address
1232
+ - `options.marketplaces` - List of marketplaces to search (default: ['tensor', 'magiceden'])
1233
+ - `options.maxPrice` - Maximum price filter in SOL
1234
+
1235
+ **Returns:** Array of listings sorted by price (ascending)
1236
+
1237
+ **Marketplace Integration:**
1238
+ - Calls TensorClient.getMintListing() for Tensor marketplace
1239
+ - Calls MagicEdenClient.getTokenListing() for Magic Eden marketplace
1240
+ - Parallel execution with individual error handling
1241
+
1242
+ #### compareFloorPrices()
1243
+
1244
+ ```typescript
1245
+ async compareFloorPrices(mint: string): Promise<MarketplaceFloorPrices>
1246
+ ```
1247
+
1248
+ Compares floor prices across all available marketplaces.
1249
+
1250
+ **Returns:** `MarketplaceFloorPrices` object with price comparison data
1251
+
1252
+ ---
1253
+
1254
+ ### AIRarityCalculator
1255
+
1256
+ #### calculateRarity()
1257
+
1258
+ ```typescript
1259
+ async calculateRarity(
1260
+ mint: string,
1261
+ collectionAddress?: string
1262
+ ): Promise<RarityScore>
1263
+ ```
1264
+
1265
+ Calculates NFT rarity score using statistical analysis.
1266
+
1267
+ **Parameters:**
1268
+ - `mint` - NFT mint address
1269
+ - `collectionAddress` - Collection address for ranking (optional)
1270
+
1271
+ **Returns:** `RarityScore` object with detailed trait analysis
1272
+
1273
+ #### batchCalculateRarity()
1274
+
1275
+ ```typescript
1276
+ async batchCalculateRarity(
1277
+ mints: string[],
1278
+ collectionAddress?: string
1279
+ ): Promise<RarityScore[]>
1280
+ ```
1281
+
1282
+ Calculates rarity for multiple NFTs efficiently with automatic ranking.
1283
+
1284
+ **Returns:** Array of `RarityScore` objects sorted by rarity
1285
+
1286
+ ---
1287
+
1288
+ ### AIInvestmentAdvisor
1289
+
1290
+ #### getRecommendation()
1291
+
1292
+ ```typescript
1293
+ async getRecommendation(
1294
+ mint: string,
1295
+ collectionAddress: string,
1296
+ currentPrice: number
1297
+ ): Promise<InvestmentRecommendation>
1298
+ ```
1299
+
1300
+ Generates data-driven investment recommendation for an NFT.
1301
+
1302
+ **Parameters:**
1303
+ - `mint` - NFT mint address
1304
+ - `collectionAddress` - Collection address
1305
+ - `currentPrice` - Current price in SOL
1306
+
1307
+ **Returns:** `InvestmentRecommendation` object with analysis and metrics
1308
+
1309
+ **Analysis Components:**
1310
+ - Rarity analysis from AIRarityCalculator
1311
+ - Collection statistics from CollectionAnalytics
1312
+ - Trend analysis with momentum calculation
1313
+ - Holder quality assessment
1314
+
1315
+ ---
1316
+
1317
+ ## Performance Metrics
1318
+
1319
+ ### API Response Times
1320
+
1321
+ | Operation | Average Latency | Cache Hit Rate | Notes |
1322
+ |-----------|----------------|----------------|-------|
1323
+ | **TensorClient.getCollectionStats()** | 150-300ms | N/A | Direct API call |
1324
+ | **MagicEdenClient.getCollectionStats()** | 200-400ms | N/A | Direct API call |
1325
+ | **CollectionAnalytics.getStats()** | 200-600ms | 70% | Aggregates both APIs |
1326
+ | **MarketplaceAggregator.findListings()** | 300-800ms | 60% | Parallel marketplace queries |
1327
+ | **AIRarityCalculator.calculateRarity()** | 100-500ms | 90% | Metadata + computation |
1328
+ | **AIInvestmentAdvisor.getRecommendation()** | 500-1500ms | 50% | Multiple API calls + analysis |
1329
+
1330
+ ### Rate Limits
1331
+
1332
+ | Client | Default Rate Limit | With API Key | Burst Tolerance |
1333
+ |--------|-------------------|--------------|-----------------|
1334
+ | **TensorClient** | 10 req/s | 20 req/s | 20 requests |
1335
+ | **MagicEdenClient** | 10 req/s | 20 req/s | 20 requests |
1336
+
1337
+ **Note:** Both clients implement automatic rate limiting to prevent API throttling.
1338
+
1339
+ ### Caching Strategy
1340
+
1341
+ | Component | Default TTL | Cache Key | Invalidation |
1342
+ |-----------|------------|-----------|--------------|
1343
+ | **Collection Stats** | 5 minutes | Collection address | Time-based |
1344
+ | **Rarity Scores** | 24 hours | Mint address | Manual |
1345
+ | **Marketplace Listings** | 1 minute | Mint address | Time-based |
1346
+
1347
+ ---
1348
+
1349
+ ## Troubleshooting
1350
+
1351
+ ### TensorClient Issues
1352
+
1353
+ #### Error: "Tensor API request timeout"
1354
+
1355
+ **Cause:** Request exceeded timeout limit (default: 10s)
1356
+
1357
+ **Solution:**
1358
+ ```typescript
1359
+ const tensorClient = new TensorClient({
1360
+ timeout: 20000, // Increase to 20 seconds
1361
+ });
1362
+ ```
1363
+
1364
+ #### Error: "Tensor API error: 429"
1365
+
1366
+ **Cause:** Rate limit exceeded
1367
+
1368
+ **Solution:**
1369
+ ```typescript
1370
+ const tensorClient = new TensorClient({
1371
+ rateLimit: 5, // Reduce to 5 req/s
1372
+ apiKey: process.env.TENSOR_API_KEY, // Use API key for higher limits
1373
+ });
1374
+ ```
1375
+
1376
+ #### Error: "Collection not found"
1377
+
1378
+ **Cause:** Invalid collection slug or collection not indexed on Tensor
1379
+
1380
+ **Solution:**
1381
+ - Verify collection slug is correct (use collection symbol, not address)
1382
+ - Try Magic Eden as fallback
1383
+ - Check if collection is listed on Tensor marketplace
1384
+
1385
+ ---
1386
+
1387
+ ### MagicEdenClient Issues
1388
+
1389
+ #### Error: "Magic Eden API error: 404"
1390
+
1391
+ **Cause:** Collection symbol not found
1392
+
1393
+ **Solution:**
1394
+ ```typescript
1395
+ // Try searching for the collection first
1396
+ const magicEdenClient = new MagicEdenClient();
1397
+ const results = await magicEdenClient.searchCollections('collection name');
1398
+ console.log('Found symbols:', results.map(r => r.symbol));
1399
+ ```
1400
+
1401
+ #### Error: "No listings found"
1402
+
1403
+ **Cause:** NFT not currently listed on Magic Eden
1404
+
1405
+ **Solution:**
1406
+ - Check Tensor marketplace as alternative
1407
+ - Verify mint address is correct
1408
+ - Check if NFT exists and is not burned
1409
+
1410
+ ---
1411
+
1412
+ ### CollectionAnalytics Issues
1413
+
1414
+ #### Issue: "Failed to fetch collection stats from all marketplaces"
1415
+
1416
+ **Cause:** Both Tensor and Magic Eden APIs failed
1417
+
1418
+ **Solution:**
1419
+ ```typescript
1420
+ try {
1421
+ const stats = await analytics.getStats(collection);
1422
+ } catch (error) {
1423
+ console.error('All marketplaces failed:', error);
1424
+
1425
+ // Try individual clients with extended timeouts
1426
+ const tensorClient = new TensorClient({ timeout: 30000 });
1427
+ const stats = await tensorClient.getCollectionStats(collection);
1428
+ }
1429
+ ```
1430
+
1431
+ #### Issue: Inaccurate floor price
1432
+
1433
+ **Cause:** Price discrepancy between marketplaces or stale cache
1434
+
1435
+ **Solution:**
1436
+ ```typescript
1437
+ // Force fresh data fetch
1438
+ const stats = await analytics.getStats(collection, { useCache: false });
1439
+
1440
+ // Or compare prices directly
1441
+ const aggregator = new MarketplaceAggregator(client);
1442
+ const prices = await aggregator.compareFloorPrices(mint);
1443
+ console.log('Tensor floor:', prices.prices.find(p => p.marketplace === 'tensor')?.price);
1444
+ console.log('Magic Eden floor:', prices.prices.find(p => p.marketplace === 'magiceden')?.price);
1445
+ ```
1446
+
1447
+ ---
1448
+
1449
+ ### MarketplaceAggregator Issues
1450
+
1451
+ #### Issue: Empty listings array
1452
+
1453
+ **Cause:** NFT not listed on any marketplace
1454
+
1455
+ **Solution:**
1456
+ ```typescript
1457
+ const listings = await aggregator.findListings(mint);
1458
+ if (listings.length === 0) {
1459
+ console.log('NFT is not currently listed');
1460
+ // Check floor price from collection stats instead
1461
+ const stats = await analytics.getStats(collection);
1462
+ console.log('Collection floor price:', stats.floorPrice, 'SOL');
1463
+ }
1464
+ ```
1465
+
1466
+ ---
1467
+
1468
+ ### General Best Practices
1469
+
1470
+ 1. **Enable debug logging during development:**
1471
+ ```typescript
1472
+ const tensorClient = new TensorClient({ logLevel: 'debug' });
1473
+ const magicEdenClient = new MagicEdenClient({ logLevel: 'debug' });
1474
+ ```
1475
+
1476
+ 2. **Implement health checks:**
1477
+ ```typescript
1478
+ const tensorHealthy = await tensorClient.healthCheck();
1479
+ const magicEdenHealthy = await magicEdenClient.healthCheck();
1480
+
1481
+ if (!tensorHealthy && !magicEdenHealthy) {
1482
+ console.error('All marketplace APIs are down');
1483
+ }
1484
+ ```
1485
+
1486
+ 3. **Use fallback strategies:**
1487
+ ```typescript
1488
+ async function getFloorPriceRobust(collection: string): Promise<number> {
1489
+ try {
1490
+ return await tensorClient.getFloorPrice(collection);
1491
+ } catch (error) {
1492
+ console.warn('Tensor failed, trying Magic Eden:', error);
1493
+ return await magicEdenClient.getFloorPrice(collection);
1494
+ }
1495
+ }
1496
+ ```
1497
+
1498
+ ---
1499
+
1500
+ ## Summary
1501
+
1502
+ The NFT Module provides production-ready integration with Tensor and Magic Eden marketplaces through:
1503
+
1504
+ - **TensorClient:** High-performance Solana NFT marketplace data
1505
+ - **MagicEdenClient:** Comprehensive marketplace listings and activities
1506
+ - **Automatic Aggregation:** Best price discovery across multiple sources
1507
+ - **Built-in Rate Limiting:** Prevents API throttling
1508
+ - **Robust Error Handling:** Automatic fallback strategies
1509
+ - **Type Safety:** Full TypeScript support with comprehensive interfaces
1510
+
1511
+ **Recommended Usage:**
1512
+ 1. Use `CollectionAnalytics` for collection-level statistics (auto-aggregates Tensor + Magic Eden)
1513
+ 2. Use `MarketplaceAggregator` for price comparison and listing discovery
1514
+ 3. Use direct clients (`TensorClient`, `MagicEdenClient`) for specific marketplace features
1515
+ 4. Implement caching for frequently accessed data
1516
+ 5. Enable error logging in development, disable in production
1517
+
1518
+ ---
1519
+
1520
+ **NFT Module v2.0.0** - Production-Ready Marketplace Integration
1521
+
1522
+ Built with enterprise-grade reliability for professional NFT trading applications.