@waiaas/daemon 2.0.0-rc.1

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 (480) hide show
  1. package/dist/api/error-hints.d.ts +15 -0
  2. package/dist/api/error-hints.d.ts.map +1 -0
  3. package/dist/api/error-hints.js +71 -0
  4. package/dist/api/error-hints.js.map +1 -0
  5. package/dist/api/index.d.ts +11 -0
  6. package/dist/api/index.d.ts.map +1 -0
  7. package/dist/api/index.js +14 -0
  8. package/dist/api/index.js.map +1 -0
  9. package/dist/api/middleware/address-validation.d.ts +38 -0
  10. package/dist/api/middleware/address-validation.d.ts.map +1 -0
  11. package/dist/api/middleware/address-validation.js +134 -0
  12. package/dist/api/middleware/address-validation.js.map +1 -0
  13. package/dist/api/middleware/csp.d.ts +17 -0
  14. package/dist/api/middleware/csp.d.ts.map +1 -0
  15. package/dist/api/middleware/csp.js +31 -0
  16. package/dist/api/middleware/csp.js.map +1 -0
  17. package/dist/api/middleware/error-handler.d.ts +16 -0
  18. package/dist/api/middleware/error-handler.d.ts.map +1 -0
  19. package/dist/api/middleware/error-handler.js +46 -0
  20. package/dist/api/middleware/error-handler.js.map +1 -0
  21. package/dist/api/middleware/host-guard.d.ts +11 -0
  22. package/dist/api/middleware/host-guard.d.ts.map +1 -0
  23. package/dist/api/middleware/host-guard.js +25 -0
  24. package/dist/api/middleware/host-guard.js.map +1 -0
  25. package/dist/api/middleware/index.d.ts +13 -0
  26. package/dist/api/middleware/index.d.ts.map +1 -0
  27. package/dist/api/middleware/index.js +13 -0
  28. package/dist/api/middleware/index.js.map +1 -0
  29. package/dist/api/middleware/kill-switch-guard.d.ts +19 -0
  30. package/dist/api/middleware/kill-switch-guard.d.ts.map +1 -0
  31. package/dist/api/middleware/kill-switch-guard.js +49 -0
  32. package/dist/api/middleware/kill-switch-guard.js.map +1 -0
  33. package/dist/api/middleware/master-auth.d.ts +15 -0
  34. package/dist/api/middleware/master-auth.d.ts.map +1 -0
  35. package/dist/api/middleware/master-auth.js +35 -0
  36. package/dist/api/middleware/master-auth.js.map +1 -0
  37. package/dist/api/middleware/owner-auth.d.ts +30 -0
  38. package/dist/api/middleware/owner-auth.d.ts.map +1 -0
  39. package/dist/api/middleware/owner-auth.js +133 -0
  40. package/dist/api/middleware/owner-auth.js.map +1 -0
  41. package/dist/api/middleware/request-id.d.ts +10 -0
  42. package/dist/api/middleware/request-id.d.ts.map +1 -0
  43. package/dist/api/middleware/request-id.js +18 -0
  44. package/dist/api/middleware/request-id.js.map +1 -0
  45. package/dist/api/middleware/request-logger.d.ts +9 -0
  46. package/dist/api/middleware/request-logger.d.ts.map +1 -0
  47. package/dist/api/middleware/request-logger.js +18 -0
  48. package/dist/api/middleware/request-logger.js.map +1 -0
  49. package/dist/api/middleware/session-auth.d.ts +21 -0
  50. package/dist/api/middleware/session-auth.d.ts.map +1 -0
  51. package/dist/api/middleware/session-auth.js +51 -0
  52. package/dist/api/middleware/session-auth.js.map +1 -0
  53. package/dist/api/middleware/siwe-verify.d.ts +31 -0
  54. package/dist/api/middleware/siwe-verify.d.ts.map +1 -0
  55. package/dist/api/middleware/siwe-verify.js +55 -0
  56. package/dist/api/middleware/siwe-verify.js.map +1 -0
  57. package/dist/api/routes/actions.d.ts +56 -0
  58. package/dist/api/routes/actions.d.ts.map +1 -0
  59. package/dist/api/routes/actions.js +291 -0
  60. package/dist/api/routes/actions.js.map +1 -0
  61. package/dist/api/routes/admin.d.ts +99 -0
  62. package/dist/api/routes/admin.d.ts.map +1 -0
  63. package/dist/api/routes/admin.js +1304 -0
  64. package/dist/api/routes/admin.js.map +1 -0
  65. package/dist/api/routes/display-currency-helper.d.ts +26 -0
  66. package/dist/api/routes/display-currency-helper.d.ts.map +1 -0
  67. package/dist/api/routes/display-currency-helper.js +47 -0
  68. package/dist/api/routes/display-currency-helper.js.map +1 -0
  69. package/dist/api/routes/health.d.ts +14 -0
  70. package/dist/api/routes/health.d.ts.map +1 -0
  71. package/dist/api/routes/health.js +47 -0
  72. package/dist/api/routes/health.js.map +1 -0
  73. package/dist/api/routes/index.d.ts +15 -0
  74. package/dist/api/routes/index.d.ts.map +1 -0
  75. package/dist/api/routes/index.js +15 -0
  76. package/dist/api/routes/index.js.map +1 -0
  77. package/dist/api/routes/mcp.d.ts +30 -0
  78. package/dist/api/routes/mcp.d.ts.map +1 -0
  79. package/dist/api/routes/mcp.js +156 -0
  80. package/dist/api/routes/mcp.js.map +1 -0
  81. package/dist/api/routes/nonce.d.ts +20 -0
  82. package/dist/api/routes/nonce.d.ts.map +1 -0
  83. package/dist/api/routes/nonce.js +48 -0
  84. package/dist/api/routes/nonce.js.map +1 -0
  85. package/dist/api/routes/openapi-schemas.d.ts +2281 -0
  86. package/dist/api/routes/openapi-schemas.d.ts.map +1 -0
  87. package/dist/api/routes/openapi-schemas.js +770 -0
  88. package/dist/api/routes/openapi-schemas.js.map +1 -0
  89. package/dist/api/routes/policies.d.ts +29 -0
  90. package/dist/api/routes/policies.d.ts.map +1 -0
  91. package/dist/api/routes/policies.js +332 -0
  92. package/dist/api/routes/policies.js.map +1 -0
  93. package/dist/api/routes/sessions.d.ts +35 -0
  94. package/dist/api/routes/sessions.d.ts.map +1 -0
  95. package/dist/api/routes/sessions.js +347 -0
  96. package/dist/api/routes/sessions.js.map +1 -0
  97. package/dist/api/routes/skills.d.ts +9 -0
  98. package/dist/api/routes/skills.d.ts.map +1 -0
  99. package/dist/api/routes/skills.js +59 -0
  100. package/dist/api/routes/skills.js.map +1 -0
  101. package/dist/api/routes/tokens.d.ts +25 -0
  102. package/dist/api/routes/tokens.d.ts.map +1 -0
  103. package/dist/api/routes/tokens.js +161 -0
  104. package/dist/api/routes/tokens.js.map +1 -0
  105. package/dist/api/routes/transactions.d.ts +68 -0
  106. package/dist/api/routes/transactions.d.ts.map +1 -0
  107. package/dist/api/routes/transactions.js +576 -0
  108. package/dist/api/routes/transactions.js.map +1 -0
  109. package/dist/api/routes/utils.d.ts +9 -0
  110. package/dist/api/routes/utils.d.ts.map +1 -0
  111. package/dist/api/routes/utils.js +52 -0
  112. package/dist/api/routes/utils.js.map +1 -0
  113. package/dist/api/routes/wallet.d.ts +36 -0
  114. package/dist/api/routes/wallet.d.ts.map +1 -0
  115. package/dist/api/routes/wallet.js +358 -0
  116. package/dist/api/routes/wallet.js.map +1 -0
  117. package/dist/api/routes/wallets.d.ts +43 -0
  118. package/dist/api/routes/wallets.d.ts.map +1 -0
  119. package/dist/api/routes/wallets.js +630 -0
  120. package/dist/api/routes/wallets.js.map +1 -0
  121. package/dist/api/routes/wc.d.ts +46 -0
  122. package/dist/api/routes/wc.d.ts.map +1 -0
  123. package/dist/api/routes/wc.js +354 -0
  124. package/dist/api/routes/wc.js.map +1 -0
  125. package/dist/api/routes/x402.d.ts +61 -0
  126. package/dist/api/routes/x402.d.ts.map +1 -0
  127. package/dist/api/routes/x402.js +493 -0
  128. package/dist/api/routes/x402.js.map +1 -0
  129. package/dist/api/server.d.ts +81 -0
  130. package/dist/api/server.d.ts.map +1 -0
  131. package/dist/api/server.js +406 -0
  132. package/dist/api/server.js.map +1 -0
  133. package/dist/index.d.ts +35 -0
  134. package/dist/index.d.ts.map +1 -0
  135. package/dist/index.js +43 -0
  136. package/dist/index.js.map +1 -0
  137. package/dist/infrastructure/action/action-provider-registry.d.ts +77 -0
  138. package/dist/infrastructure/action/action-provider-registry.d.ts.map +1 -0
  139. package/dist/infrastructure/action/action-provider-registry.js +239 -0
  140. package/dist/infrastructure/action/action-provider-registry.js.map +1 -0
  141. package/dist/infrastructure/action/api-key-store.d.ts +60 -0
  142. package/dist/infrastructure/action/api-key-store.d.ts.map +1 -0
  143. package/dist/infrastructure/action/api-key-store.js +130 -0
  144. package/dist/infrastructure/action/api-key-store.js.map +1 -0
  145. package/dist/infrastructure/action/index.d.ts +10 -0
  146. package/dist/infrastructure/action/index.d.ts.map +1 -0
  147. package/dist/infrastructure/action/index.js +9 -0
  148. package/dist/infrastructure/action/index.js.map +1 -0
  149. package/dist/infrastructure/adapter-pool.d.ts +50 -0
  150. package/dist/infrastructure/adapter-pool.d.ts.map +1 -0
  151. package/dist/infrastructure/adapter-pool.js +110 -0
  152. package/dist/infrastructure/adapter-pool.js.map +1 -0
  153. package/dist/infrastructure/backup/backup-service.d.ts +53 -0
  154. package/dist/infrastructure/backup/backup-service.d.ts.map +1 -0
  155. package/dist/infrastructure/backup/backup-service.js +158 -0
  156. package/dist/infrastructure/backup/backup-service.js.map +1 -0
  157. package/dist/infrastructure/backup/index.d.ts +2 -0
  158. package/dist/infrastructure/backup/index.d.ts.map +1 -0
  159. package/dist/infrastructure/backup/index.js +2 -0
  160. package/dist/infrastructure/backup/index.js.map +1 -0
  161. package/dist/infrastructure/config/index.d.ts +8 -0
  162. package/dist/infrastructure/config/index.d.ts.map +1 -0
  163. package/dist/infrastructure/config/index.js +7 -0
  164. package/dist/infrastructure/config/index.js.map +1 -0
  165. package/dist/infrastructure/config/loader.d.ts +555 -0
  166. package/dist/infrastructure/config/loader.d.ts.map +1 -0
  167. package/dist/infrastructure/config/loader.js +311 -0
  168. package/dist/infrastructure/config/loader.js.map +1 -0
  169. package/dist/infrastructure/database/checks.d.ts +19 -0
  170. package/dist/infrastructure/database/checks.d.ts.map +1 -0
  171. package/dist/infrastructure/database/checks.js +27 -0
  172. package/dist/infrastructure/database/checks.js.map +1 -0
  173. package/dist/infrastructure/database/compatibility.d.ts +36 -0
  174. package/dist/infrastructure/database/compatibility.d.ts.map +1 -0
  175. package/dist/infrastructure/database/compatibility.js +75 -0
  176. package/dist/infrastructure/database/compatibility.js.map +1 -0
  177. package/dist/infrastructure/database/connection.d.ts +36 -0
  178. package/dist/infrastructure/database/connection.d.ts.map +1 -0
  179. package/dist/infrastructure/database/connection.js +47 -0
  180. package/dist/infrastructure/database/connection.js.map +1 -0
  181. package/dist/infrastructure/database/id.d.ts +17 -0
  182. package/dist/infrastructure/database/id.d.ts.map +1 -0
  183. package/dist/infrastructure/database/id.js +20 -0
  184. package/dist/infrastructure/database/id.js.map +1 -0
  185. package/dist/infrastructure/database/index.d.ts +15 -0
  186. package/dist/infrastructure/database/index.d.ts.map +1 -0
  187. package/dist/infrastructure/database/index.js +12 -0
  188. package/dist/infrastructure/database/index.js.map +1 -0
  189. package/dist/infrastructure/database/migrate.d.ts +76 -0
  190. package/dist/infrastructure/database/migrate.d.ts.map +1 -0
  191. package/dist/infrastructure/database/migrate.js +1214 -0
  192. package/dist/infrastructure/database/migrate.js.map +1 -0
  193. package/dist/infrastructure/database/schema.d.ts +2352 -0
  194. package/dist/infrastructure/database/schema.d.ts.map +1 -0
  195. package/dist/infrastructure/database/schema.js +288 -0
  196. package/dist/infrastructure/database/schema.js.map +1 -0
  197. package/dist/infrastructure/jwt/index.d.ts +2 -0
  198. package/dist/infrastructure/jwt/index.d.ts.map +1 -0
  199. package/dist/infrastructure/jwt/index.js +2 -0
  200. package/dist/infrastructure/jwt/index.js.map +1 -0
  201. package/dist/infrastructure/jwt/jwt-secret-manager.d.ts +58 -0
  202. package/dist/infrastructure/jwt/jwt-secret-manager.d.ts.map +1 -0
  203. package/dist/infrastructure/jwt/jwt-secret-manager.js +222 -0
  204. package/dist/infrastructure/jwt/jwt-secret-manager.js.map +1 -0
  205. package/dist/infrastructure/keystore/crypto.d.ts +62 -0
  206. package/dist/infrastructure/keystore/crypto.d.ts.map +1 -0
  207. package/dist/infrastructure/keystore/crypto.js +89 -0
  208. package/dist/infrastructure/keystore/crypto.js.map +1 -0
  209. package/dist/infrastructure/keystore/index.d.ts +4 -0
  210. package/dist/infrastructure/keystore/index.d.ts.map +1 -0
  211. package/dist/infrastructure/keystore/index.js +5 -0
  212. package/dist/infrastructure/keystore/index.js.map +1 -0
  213. package/dist/infrastructure/keystore/keystore.d.ts +115 -0
  214. package/dist/infrastructure/keystore/keystore.d.ts.map +1 -0
  215. package/dist/infrastructure/keystore/keystore.js +327 -0
  216. package/dist/infrastructure/keystore/keystore.js.map +1 -0
  217. package/dist/infrastructure/keystore/memory.d.ts +45 -0
  218. package/dist/infrastructure/keystore/memory.d.ts.map +1 -0
  219. package/dist/infrastructure/keystore/memory.js +105 -0
  220. package/dist/infrastructure/keystore/memory.js.map +1 -0
  221. package/dist/infrastructure/oracle/coingecko-forex.d.ts +35 -0
  222. package/dist/infrastructure/oracle/coingecko-forex.d.ts.map +1 -0
  223. package/dist/infrastructure/oracle/coingecko-forex.js +69 -0
  224. package/dist/infrastructure/oracle/coingecko-forex.js.map +1 -0
  225. package/dist/infrastructure/oracle/coingecko-oracle.d.ts +73 -0
  226. package/dist/infrastructure/oracle/coingecko-oracle.d.ts.map +1 -0
  227. package/dist/infrastructure/oracle/coingecko-oracle.js +199 -0
  228. package/dist/infrastructure/oracle/coingecko-oracle.js.map +1 -0
  229. package/dist/infrastructure/oracle/coingecko-platform-ids.d.ts +32 -0
  230. package/dist/infrastructure/oracle/coingecko-platform-ids.d.ts.map +1 -0
  231. package/dist/infrastructure/oracle/coingecko-platform-ids.js +30 -0
  232. package/dist/infrastructure/oracle/coingecko-platform-ids.js.map +1 -0
  233. package/dist/infrastructure/oracle/forex-currencies.d.ts +36 -0
  234. package/dist/infrastructure/oracle/forex-currencies.d.ts.map +1 -0
  235. package/dist/infrastructure/oracle/forex-currencies.js +71 -0
  236. package/dist/infrastructure/oracle/forex-currencies.js.map +1 -0
  237. package/dist/infrastructure/oracle/forex-rate-service.d.ts +51 -0
  238. package/dist/infrastructure/oracle/forex-rate-service.d.ts.map +1 -0
  239. package/dist/infrastructure/oracle/forex-rate-service.js +149 -0
  240. package/dist/infrastructure/oracle/forex-rate-service.js.map +1 -0
  241. package/dist/infrastructure/oracle/index.d.ts +18 -0
  242. package/dist/infrastructure/oracle/index.d.ts.map +1 -0
  243. package/dist/infrastructure/oracle/index.js +19 -0
  244. package/dist/infrastructure/oracle/index.js.map +1 -0
  245. package/dist/infrastructure/oracle/oracle-chain.d.ts +101 -0
  246. package/dist/infrastructure/oracle/oracle-chain.d.ts.map +1 -0
  247. package/dist/infrastructure/oracle/oracle-chain.js +163 -0
  248. package/dist/infrastructure/oracle/oracle-chain.js.map +1 -0
  249. package/dist/infrastructure/oracle/oracle-errors.d.ts +42 -0
  250. package/dist/infrastructure/oracle/oracle-errors.d.ts.map +1 -0
  251. package/dist/infrastructure/oracle/oracle-errors.js +53 -0
  252. package/dist/infrastructure/oracle/oracle-errors.js.map +1 -0
  253. package/dist/infrastructure/oracle/price-age.d.ts +38 -0
  254. package/dist/infrastructure/oracle/price-age.d.ts.map +1 -0
  255. package/dist/infrastructure/oracle/price-age.js +44 -0
  256. package/dist/infrastructure/oracle/price-age.js.map +1 -0
  257. package/dist/infrastructure/oracle/price-cache.d.ts +99 -0
  258. package/dist/infrastructure/oracle/price-cache.d.ts.map +1 -0
  259. package/dist/infrastructure/oracle/price-cache.js +173 -0
  260. package/dist/infrastructure/oracle/price-cache.js.map +1 -0
  261. package/dist/infrastructure/oracle/pyth-feed-ids.d.ts +31 -0
  262. package/dist/infrastructure/oracle/pyth-feed-ids.d.ts.map +1 -0
  263. package/dist/infrastructure/oracle/pyth-feed-ids.js +44 -0
  264. package/dist/infrastructure/oracle/pyth-feed-ids.js.map +1 -0
  265. package/dist/infrastructure/oracle/pyth-oracle.d.ts +69 -0
  266. package/dist/infrastructure/oracle/pyth-oracle.d.ts.map +1 -0
  267. package/dist/infrastructure/oracle/pyth-oracle.js +149 -0
  268. package/dist/infrastructure/oracle/pyth-oracle.js.map +1 -0
  269. package/dist/infrastructure/settings/hot-reload.d.ts +71 -0
  270. package/dist/infrastructure/settings/hot-reload.d.ts.map +1 -0
  271. package/dist/infrastructure/settings/hot-reload.js +315 -0
  272. package/dist/infrastructure/settings/hot-reload.js.map +1 -0
  273. package/dist/infrastructure/settings/index.d.ts +13 -0
  274. package/dist/infrastructure/settings/index.d.ts.map +1 -0
  275. package/dist/infrastructure/settings/index.js +10 -0
  276. package/dist/infrastructure/settings/index.js.map +1 -0
  277. package/dist/infrastructure/settings/setting-keys.d.ts +28 -0
  278. package/dist/infrastructure/settings/setting-keys.d.ts.map +1 -0
  279. package/dist/infrastructure/settings/setting-keys.js +105 -0
  280. package/dist/infrastructure/settings/setting-keys.js.map +1 -0
  281. package/dist/infrastructure/settings/settings-crypto.d.ts +39 -0
  282. package/dist/infrastructure/settings/settings-crypto.d.ts.map +1 -0
  283. package/dist/infrastructure/settings/settings-crypto.js +73 -0
  284. package/dist/infrastructure/settings/settings-crypto.js.map +1 -0
  285. package/dist/infrastructure/settings/settings-service.d.ts +82 -0
  286. package/dist/infrastructure/settings/settings-service.d.ts.map +1 -0
  287. package/dist/infrastructure/settings/settings-service.js +267 -0
  288. package/dist/infrastructure/settings/settings-service.js.map +1 -0
  289. package/dist/infrastructure/telegram/index.d.ts +6 -0
  290. package/dist/infrastructure/telegram/index.d.ts.map +1 -0
  291. package/dist/infrastructure/telegram/index.js +5 -0
  292. package/dist/infrastructure/telegram/index.js.map +1 -0
  293. package/dist/infrastructure/telegram/telegram-api.d.ts +35 -0
  294. package/dist/infrastructure/telegram/telegram-api.d.ts.map +1 -0
  295. package/dist/infrastructure/telegram/telegram-api.js +82 -0
  296. package/dist/infrastructure/telegram/telegram-api.js.map +1 -0
  297. package/dist/infrastructure/telegram/telegram-auth.d.ts +57 -0
  298. package/dist/infrastructure/telegram/telegram-auth.d.ts.map +1 -0
  299. package/dist/infrastructure/telegram/telegram-auth.js +88 -0
  300. package/dist/infrastructure/telegram/telegram-auth.js.map +1 -0
  301. package/dist/infrastructure/telegram/telegram-bot-service.d.ts +95 -0
  302. package/dist/infrastructure/telegram/telegram-bot-service.d.ts.map +1 -0
  303. package/dist/infrastructure/telegram/telegram-bot-service.js +564 -0
  304. package/dist/infrastructure/telegram/telegram-bot-service.js.map +1 -0
  305. package/dist/infrastructure/telegram/telegram-keyboard.d.ts +27 -0
  306. package/dist/infrastructure/telegram/telegram-keyboard.d.ts.map +1 -0
  307. package/dist/infrastructure/telegram/telegram-keyboard.js +52 -0
  308. package/dist/infrastructure/telegram/telegram-keyboard.js.map +1 -0
  309. package/dist/infrastructure/telegram/telegram-types.d.ts +43 -0
  310. package/dist/infrastructure/telegram/telegram-types.d.ts.map +1 -0
  311. package/dist/infrastructure/telegram/telegram-types.js +8 -0
  312. package/dist/infrastructure/telegram/telegram-types.js.map +1 -0
  313. package/dist/infrastructure/token-registry/builtin-tokens.d.ts +39 -0
  314. package/dist/infrastructure/token-registry/builtin-tokens.d.ts.map +1 -0
  315. package/dist/infrastructure/token-registry/builtin-tokens.js +135 -0
  316. package/dist/infrastructure/token-registry/builtin-tokens.js.map +1 -0
  317. package/dist/infrastructure/token-registry/index.d.ts +8 -0
  318. package/dist/infrastructure/token-registry/index.d.ts.map +1 -0
  319. package/dist/infrastructure/token-registry/index.js +8 -0
  320. package/dist/infrastructure/token-registry/index.js.map +1 -0
  321. package/dist/infrastructure/token-registry/token-registry-service.d.ts +49 -0
  322. package/dist/infrastructure/token-registry/token-registry-service.d.ts.map +1 -0
  323. package/dist/infrastructure/token-registry/token-registry-service.js +93 -0
  324. package/dist/infrastructure/token-registry/token-registry-service.js.map +1 -0
  325. package/dist/infrastructure/version/index.d.ts +5 -0
  326. package/dist/infrastructure/version/index.d.ts.map +1 -0
  327. package/dist/infrastructure/version/index.js +5 -0
  328. package/dist/infrastructure/version/index.js.map +1 -0
  329. package/dist/infrastructure/version/version-check-service.d.ts +35 -0
  330. package/dist/infrastructure/version/version-check-service.d.ts.map +1 -0
  331. package/dist/infrastructure/version/version-check-service.js +92 -0
  332. package/dist/infrastructure/version/version-check-service.js.map +1 -0
  333. package/dist/lifecycle/daemon.d.ts +103 -0
  334. package/dist/lifecycle/daemon.d.ts.map +1 -0
  335. package/dist/lifecycle/daemon.js +934 -0
  336. package/dist/lifecycle/daemon.js.map +1 -0
  337. package/dist/lifecycle/index.d.ts +9 -0
  338. package/dist/lifecycle/index.d.ts.map +1 -0
  339. package/dist/lifecycle/index.js +9 -0
  340. package/dist/lifecycle/index.js.map +1 -0
  341. package/dist/lifecycle/signal-handler.d.ts +18 -0
  342. package/dist/lifecycle/signal-handler.d.ts.map +1 -0
  343. package/dist/lifecycle/signal-handler.js +37 -0
  344. package/dist/lifecycle/signal-handler.js.map +1 -0
  345. package/dist/lifecycle/workers.d.ts +46 -0
  346. package/dist/lifecycle/workers.d.ts.map +1 -0
  347. package/dist/lifecycle/workers.js +101 -0
  348. package/dist/lifecycle/workers.js.map +1 -0
  349. package/dist/notifications/channels/discord.d.ts +10 -0
  350. package/dist/notifications/channels/discord.d.ts.map +1 -0
  351. package/dist/notifications/channels/discord.js +54 -0
  352. package/dist/notifications/channels/discord.js.map +1 -0
  353. package/dist/notifications/channels/ntfy.d.ts +13 -0
  354. package/dist/notifications/channels/ntfy.d.ts.map +1 -0
  355. package/dist/notifications/channels/ntfy.js +58 -0
  356. package/dist/notifications/channels/ntfy.js.map +1 -0
  357. package/dist/notifications/channels/slack.d.ts +10 -0
  358. package/dist/notifications/channels/slack.d.ts.map +1 -0
  359. package/dist/notifications/channels/slack.js +55 -0
  360. package/dist/notifications/channels/slack.js.map +1 -0
  361. package/dist/notifications/channels/telegram.d.ts +10 -0
  362. package/dist/notifications/channels/telegram.d.ts.map +1 -0
  363. package/dist/notifications/channels/telegram.js +40 -0
  364. package/dist/notifications/channels/telegram.js.map +1 -0
  365. package/dist/notifications/index.d.ts +9 -0
  366. package/dist/notifications/index.d.ts.map +1 -0
  367. package/dist/notifications/index.js +7 -0
  368. package/dist/notifications/index.js.map +1 -0
  369. package/dist/notifications/notification-service.d.ts +75 -0
  370. package/dist/notifications/notification-service.d.ts.map +1 -0
  371. package/dist/notifications/notification-service.js +213 -0
  372. package/dist/notifications/notification-service.js.map +1 -0
  373. package/dist/notifications/templates/message-templates.d.ts +12 -0
  374. package/dist/notifications/templates/message-templates.d.ts.map +1 -0
  375. package/dist/notifications/templates/message-templates.js +22 -0
  376. package/dist/notifications/templates/message-templates.js.map +1 -0
  377. package/dist/pipeline/database-policy-engine.d.ts +286 -0
  378. package/dist/pipeline/database-policy-engine.d.ts.map +1 -0
  379. package/dist/pipeline/database-policy-engine.js +992 -0
  380. package/dist/pipeline/database-policy-engine.js.map +1 -0
  381. package/dist/pipeline/default-policy-engine.d.ts +26 -0
  382. package/dist/pipeline/default-policy-engine.d.ts.map +1 -0
  383. package/dist/pipeline/default-policy-engine.js +25 -0
  384. package/dist/pipeline/default-policy-engine.js.map +1 -0
  385. package/dist/pipeline/index.d.ts +9 -0
  386. package/dist/pipeline/index.d.ts.map +1 -0
  387. package/dist/pipeline/index.js +9 -0
  388. package/dist/pipeline/index.js.map +1 -0
  389. package/dist/pipeline/network-resolver.d.ts +22 -0
  390. package/dist/pipeline/network-resolver.d.ts.map +1 -0
  391. package/dist/pipeline/network-resolver.js +32 -0
  392. package/dist/pipeline/network-resolver.js.map +1 -0
  393. package/dist/pipeline/pipeline.d.ts +72 -0
  394. package/dist/pipeline/pipeline.d.ts.map +1 -0
  395. package/dist/pipeline/pipeline.js +87 -0
  396. package/dist/pipeline/pipeline.js.map +1 -0
  397. package/dist/pipeline/resolve-effective-amount-usd.d.ts +41 -0
  398. package/dist/pipeline/resolve-effective-amount-usd.d.ts.map +1 -0
  399. package/dist/pipeline/resolve-effective-amount-usd.js +208 -0
  400. package/dist/pipeline/resolve-effective-amount-usd.js.map +1 -0
  401. package/dist/pipeline/sign-only.d.ts +99 -0
  402. package/dist/pipeline/sign-only.d.ts.map +1 -0
  403. package/dist/pipeline/sign-only.js +267 -0
  404. package/dist/pipeline/sign-only.js.map +1 -0
  405. package/dist/pipeline/sleep.d.ts +6 -0
  406. package/dist/pipeline/sleep.d.ts.map +1 -0
  407. package/dist/pipeline/sleep.js +8 -0
  408. package/dist/pipeline/sleep.js.map +1 -0
  409. package/dist/pipeline/stages.d.ts +82 -0
  410. package/dist/pipeline/stages.d.ts.map +1 -0
  411. package/dist/pipeline/stages.js +784 -0
  412. package/dist/pipeline/stages.js.map +1 -0
  413. package/dist/services/autostop-rules.d.ts +79 -0
  414. package/dist/services/autostop-rules.d.ts.map +1 -0
  415. package/dist/services/autostop-rules.js +174 -0
  416. package/dist/services/autostop-rules.js.map +1 -0
  417. package/dist/services/autostop-service.d.ts +82 -0
  418. package/dist/services/autostop-service.d.ts.map +1 -0
  419. package/dist/services/autostop-service.js +223 -0
  420. package/dist/services/autostop-service.js.map +1 -0
  421. package/dist/services/kill-switch-service.d.ts +118 -0
  422. package/dist/services/kill-switch-service.d.ts.map +1 -0
  423. package/dist/services/kill-switch-service.js +291 -0
  424. package/dist/services/kill-switch-service.js.map +1 -0
  425. package/dist/services/monitoring/balance-monitor-service.d.ts +65 -0
  426. package/dist/services/monitoring/balance-monitor-service.d.ts.map +1 -0
  427. package/dist/services/monitoring/balance-monitor-service.js +207 -0
  428. package/dist/services/monitoring/balance-monitor-service.js.map +1 -0
  429. package/dist/services/wc-session-service.d.ts +123 -0
  430. package/dist/services/wc-session-service.d.ts.map +1 -0
  431. package/dist/services/wc-session-service.js +363 -0
  432. package/dist/services/wc-session-service.js.map +1 -0
  433. package/dist/services/wc-signing-bridge.d.ts +60 -0
  434. package/dist/services/wc-signing-bridge.d.ts.map +1 -0
  435. package/dist/services/wc-signing-bridge.js +334 -0
  436. package/dist/services/wc-signing-bridge.js.map +1 -0
  437. package/dist/services/wc-storage.d.ts +32 -0
  438. package/dist/services/wc-storage.d.ts.map +1 -0
  439. package/dist/services/wc-storage.js +64 -0
  440. package/dist/services/wc-storage.js.map +1 -0
  441. package/dist/services/x402/payment-signer.d.ts +88 -0
  442. package/dist/services/x402/payment-signer.d.ts.map +1 -0
  443. package/dist/services/x402/payment-signer.js +311 -0
  444. package/dist/services/x402/payment-signer.js.map +1 -0
  445. package/dist/services/x402/ssrf-guard.d.ts +27 -0
  446. package/dist/services/x402/ssrf-guard.d.ts.map +1 -0
  447. package/dist/services/x402/ssrf-guard.js +236 -0
  448. package/dist/services/x402/ssrf-guard.js.map +1 -0
  449. package/dist/services/x402/x402-domain-policy.d.ts +50 -0
  450. package/dist/services/x402/x402-domain-policy.d.ts.map +1 -0
  451. package/dist/services/x402/x402-domain-policy.js +78 -0
  452. package/dist/services/x402/x402-domain-policy.js.map +1 -0
  453. package/dist/services/x402/x402-handler.d.ts +71 -0
  454. package/dist/services/x402/x402-handler.d.ts.map +1 -0
  455. package/dist/services/x402/x402-handler.js +195 -0
  456. package/dist/services/x402/x402-handler.js.map +1 -0
  457. package/dist/services/x402/x402-usd-resolver.d.ts +26 -0
  458. package/dist/services/x402/x402-usd-resolver.d.ts.map +1 -0
  459. package/dist/services/x402/x402-usd-resolver.js +79 -0
  460. package/dist/services/x402/x402-usd-resolver.js.map +1 -0
  461. package/dist/workflow/approval-workflow.d.ts +103 -0
  462. package/dist/workflow/approval-workflow.d.ts.map +1 -0
  463. package/dist/workflow/approval-workflow.js +202 -0
  464. package/dist/workflow/approval-workflow.js.map +1 -0
  465. package/dist/workflow/delay-queue.d.ts +78 -0
  466. package/dist/workflow/delay-queue.d.ts.map +1 -0
  467. package/dist/workflow/delay-queue.js +174 -0
  468. package/dist/workflow/delay-queue.js.map +1 -0
  469. package/dist/workflow/index.d.ts +11 -0
  470. package/dist/workflow/index.d.ts.map +1 -0
  471. package/dist/workflow/index.js +9 -0
  472. package/dist/workflow/index.js.map +1 -0
  473. package/dist/workflow/owner-state.d.ts +97 -0
  474. package/dist/workflow/owner-state.d.ts.map +1 -0
  475. package/dist/workflow/owner-state.js +168 -0
  476. package/dist/workflow/owner-state.js.map +1 -0
  477. package/package.json +71 -0
  478. package/public/admin/assets/index-BPoUSH8W.css +1 -0
  479. package/public/admin/assets/index-CDi1qoXB.js +1 -0
  480. package/public/admin/index.html +13 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle-chain.js","sourceRoot":"","sources":["../../../src/infrastructure/oracle/oracle-chain.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAkB5D,8EAA8E;AAC9E,UAAU;AACV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AC,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAC3D,MAAM,SAAS,GAAG,kBAAkB,CAAC,aAAa,CAAC,QAAQ,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;oBACtF,IAAI,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;wBAC/B,yCAAyC;wBACzC,OAAO,EAAE,GAAG,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;oBAC7C,CAAC;gBACH,CAAC;gBAAC,MAAM,CAAC;oBACP,iEAAiE;gBACnE,CAAC;YACH,CAAC;YACD,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,0DAA0D;QAC1D,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAC7C,CAAC;YAAC,MAAM,CAAC;gBACP,uBAAuB;YACzB,CAAC;QACH,CAAC;QAED,iDAAiD;QACjD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAgB,EAAE,CAAC;QAC/D,CAAC;QAED,6BAA6B;QAC7B,MAAM,IAAI,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Shared error classes for price oracle implementations.
3
+ *
4
+ * Extracted to a separate module so PythOracle and CoinGeckoOracle
5
+ * can share error types without circular dependencies.
6
+ */
7
+ /**
8
+ * Thrown when a price is not available for a token from any oracle source.
9
+ *
10
+ * This is a normal flow error (not a bug) -- it means the oracle has no data
11
+ * for the requested token. OracleChain handles this by trying fallback sources.
12
+ */
13
+ export declare class PriceNotAvailableError extends Error {
14
+ readonly cacheKey: string;
15
+ /**
16
+ * @param cacheKey - Cache key or descriptive message identifying the missing price.
17
+ */
18
+ constructor(cacheKey: string);
19
+ }
20
+ /**
21
+ * Thrown when forex rate is not available for a currency.
22
+ *
23
+ * ForexRateService catches this internally and returns null (graceful fallback).
24
+ * This class exists for internal logging/debugging purposes.
25
+ */
26
+ export declare class ForexNotAvailableError extends Error {
27
+ readonly currency: string;
28
+ /**
29
+ * @param currency - Currency code that was requested.
30
+ */
31
+ constructor(currency: string);
32
+ }
33
+ /**
34
+ * Thrown when CoinGecko API key is not configured.
35
+ *
36
+ * CoinGecko Demo API requires an API key. This error is thrown at query time
37
+ * (not construction time) to allow lazy configuration via SettingsService.
38
+ */
39
+ export declare class CoinGeckoNotConfiguredError extends Error {
40
+ constructor();
41
+ }
42
+ //# sourceMappingURL=oracle-errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle-errors.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/oracle/oracle-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAInB,QAAQ,EAAE,MAAM;IAH5C;;OAEG;gBACyB,QAAQ,EAAE,MAAM;CAI7C;AAED;;;;;GAKG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAInB,QAAQ,EAAE,MAAM;IAH5C;;OAEG;gBACyB,QAAQ,EAAE,MAAM;CAI7C;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;;CAKrD"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Shared error classes for price oracle implementations.
3
+ *
4
+ * Extracted to a separate module so PythOracle and CoinGeckoOracle
5
+ * can share error types without circular dependencies.
6
+ */
7
+ /**
8
+ * Thrown when a price is not available for a token from any oracle source.
9
+ *
10
+ * This is a normal flow error (not a bug) -- it means the oracle has no data
11
+ * for the requested token. OracleChain handles this by trying fallback sources.
12
+ */
13
+ export class PriceNotAvailableError extends Error {
14
+ cacheKey;
15
+ /**
16
+ * @param cacheKey - Cache key or descriptive message identifying the missing price.
17
+ */
18
+ constructor(cacheKey) {
19
+ super(`Price not available for ${cacheKey}`);
20
+ this.cacheKey = cacheKey;
21
+ this.name = 'PriceNotAvailableError';
22
+ }
23
+ }
24
+ /**
25
+ * Thrown when forex rate is not available for a currency.
26
+ *
27
+ * ForexRateService catches this internally and returns null (graceful fallback).
28
+ * This class exists for internal logging/debugging purposes.
29
+ */
30
+ export class ForexNotAvailableError extends Error {
31
+ currency;
32
+ /**
33
+ * @param currency - Currency code that was requested.
34
+ */
35
+ constructor(currency) {
36
+ super(`Forex rate not available for USD/${currency}`);
37
+ this.currency = currency;
38
+ this.name = 'ForexNotAvailableError';
39
+ }
40
+ }
41
+ /**
42
+ * Thrown when CoinGecko API key is not configured.
43
+ *
44
+ * CoinGecko Demo API requires an API key. This error is thrown at query time
45
+ * (not construction time) to allow lazy configuration via SettingsService.
46
+ */
47
+ export class CoinGeckoNotConfiguredError extends Error {
48
+ constructor() {
49
+ super('CoinGecko API key not configured');
50
+ this.name = 'CoinGeckoNotConfiguredError';
51
+ }
52
+ }
53
+ //# sourceMappingURL=oracle-errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oracle-errors.js","sourceRoot":"","sources":["../../../src/infrastructure/oracle/oracle-errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAInB;IAH5B;;OAEG;IACH,YAA4B,QAAgB;QAC1C,KAAK,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAC;QADnB,aAAQ,GAAR,QAAQ,CAAQ;QAE1C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAInB;IAH5B;;OAEG;IACH,YAA4B,QAAgB;QAC1C,KAAK,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;QAD5B,aAAQ,GAAR,QAAQ,CAAQ;QAE1C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD;QACE,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;IAC5C,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Price age classification utility.
3
+ *
4
+ * Classifies how old a price observation is into three buckets:
5
+ * - FRESH (< 5 minutes): Safe to use directly
6
+ * - AGING (5-30 minutes): Usable with warning, may trigger re-fetch
7
+ * - STALE (>= 30 minutes): Should not be used for policy evaluation
8
+ *
9
+ * Note: These thresholds align with InMemoryPriceCache:
10
+ * - FRESH_MAX_MS matches cache TTL (5 min)
11
+ * - AGING_MAX_MS matches cache staleMax (30 min)
12
+ *
13
+ * IMPORTANT: Do not confuse PriceInfo.isStale (cache TTL expired, >5min)
14
+ * with PriceAge 'STALE' (>30min). They are different concepts.
15
+ */
16
+ import { z } from 'zod';
17
+ /** Valid price age categories. */
18
+ export declare const PRICE_AGES: readonly ["FRESH", "AGING", "STALE"];
19
+ /** Price age discriminant type. */
20
+ export type PriceAge = (typeof PRICE_AGES)[number];
21
+ /** Zod enum for runtime validation of PriceAge values. */
22
+ export declare const PriceAgeEnum: z.ZodEnum<["FRESH", "AGING", "STALE"]>;
23
+ /** Threshold constants for price age classification (milliseconds). */
24
+ export declare const PRICE_AGE_THRESHOLDS: {
25
+ /** Maximum age for FRESH classification: 5 minutes. */
26
+ readonly FRESH_MAX_MS: number;
27
+ /** Maximum age for AGING classification: 30 minutes. Beyond this = STALE. */
28
+ readonly AGING_MAX_MS: number;
29
+ };
30
+ /**
31
+ * Classify the age of a price observation.
32
+ *
33
+ * @param fetchedAt - Unix timestamp (ms) when price was fetched.
34
+ * @param now - Current time (ms). Defaults to Date.now(). Inject for testing.
35
+ * @returns PriceAge discriminant: 'FRESH', 'AGING', or 'STALE'.
36
+ */
37
+ export declare function classifyPriceAge(fetchedAt: number, now?: number): PriceAge;
38
+ //# sourceMappingURL=price-age.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-age.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/oracle/price-age.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kCAAkC;AAClC,eAAO,MAAM,UAAU,sCAAuC,CAAC;AAE/D,mCAAmC;AACnC,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnD,0DAA0D;AAC1D,eAAO,MAAM,YAAY,wCAAqB,CAAC;AAE/C,uEAAuE;AACvE,eAAO,MAAM,oBAAoB;IAC/B,uDAAuD;;IAEvD,6EAA6E;;CAErE,CAAC;AAEX;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,QAAQ,CAO1E"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Price age classification utility.
3
+ *
4
+ * Classifies how old a price observation is into three buckets:
5
+ * - FRESH (< 5 minutes): Safe to use directly
6
+ * - AGING (5-30 minutes): Usable with warning, may trigger re-fetch
7
+ * - STALE (>= 30 minutes): Should not be used for policy evaluation
8
+ *
9
+ * Note: These thresholds align with InMemoryPriceCache:
10
+ * - FRESH_MAX_MS matches cache TTL (5 min)
11
+ * - AGING_MAX_MS matches cache staleMax (30 min)
12
+ *
13
+ * IMPORTANT: Do not confuse PriceInfo.isStale (cache TTL expired, >5min)
14
+ * with PriceAge 'STALE' (>30min). They are different concepts.
15
+ */
16
+ import { z } from 'zod';
17
+ /** Valid price age categories. */
18
+ export const PRICE_AGES = ['FRESH', 'AGING', 'STALE'];
19
+ /** Zod enum for runtime validation of PriceAge values. */
20
+ export const PriceAgeEnum = z.enum(PRICE_AGES);
21
+ /** Threshold constants for price age classification (milliseconds). */
22
+ export const PRICE_AGE_THRESHOLDS = {
23
+ /** Maximum age for FRESH classification: 5 minutes. */
24
+ FRESH_MAX_MS: 5 * 60 * 1000, // 300,000 ms
25
+ /** Maximum age for AGING classification: 30 minutes. Beyond this = STALE. */
26
+ AGING_MAX_MS: 30 * 60 * 1000, // 1,800,000 ms
27
+ };
28
+ /**
29
+ * Classify the age of a price observation.
30
+ *
31
+ * @param fetchedAt - Unix timestamp (ms) when price was fetched.
32
+ * @param now - Current time (ms). Defaults to Date.now(). Inject for testing.
33
+ * @returns PriceAge discriminant: 'FRESH', 'AGING', or 'STALE'.
34
+ */
35
+ export function classifyPriceAge(fetchedAt, now) {
36
+ const currentTime = now ?? Date.now();
37
+ const ageMs = currentTime - fetchedAt;
38
+ if (ageMs < PRICE_AGE_THRESHOLDS.FRESH_MAX_MS)
39
+ return 'FRESH';
40
+ if (ageMs < PRICE_AGE_THRESHOLDS.AGING_MAX_MS)
41
+ return 'AGING';
42
+ return 'STALE';
43
+ }
44
+ //# sourceMappingURL=price-age.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-age.js","sourceRoot":"","sources":["../../../src/infrastructure/oracle/price-age.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kCAAkC;AAClC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AAK/D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAE/C,uEAAuE;AACvE,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,uDAAuD;IACvD,YAAY,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI,EAAI,aAAa;IAC5C,6EAA6E;IAC7E,YAAY,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,EAAG,eAAe;CACtC,CAAC;AAEX;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAAiB,EAAE,GAAY;IAC9D,MAAM,WAAW,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;IAEtC,IAAI,KAAK,GAAG,oBAAoB,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC;IAC9D,IAAI,KAAK,GAAG,oBAAoB,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC;IAC9D,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * In-memory price cache with LRU eviction and stampede prevention.
3
+ *
4
+ * Uses ES Map insertion order for O(1) LRU eviction (delete+set to touch).
5
+ * No external dependencies -- v1.5 decision: 0 new npm packages.
6
+ *
7
+ * Terminology:
8
+ * - TTL (5 min default): Time after which get() returns null (cache miss).
9
+ * - staleMax (30 min default): Time after which getStale() also returns null.
10
+ * Between TTL and staleMax, getStale() returns the old value for fallback use.
11
+ * - maxEntries (128 default): LRU capacity. Oldest entry evicted on overflow.
12
+ */
13
+ import type { PriceInfo, CacheStats } from '@waiaas/core';
14
+ /**
15
+ * Build a normalized cache key for a token.
16
+ *
17
+ * EVM addresses are lowercased for consistency with CoinGecko API responses
18
+ * and EIP-55 checksum normalization.
19
+ *
20
+ * @param chain - Chain identifier ('solana' | 'ethereum').
21
+ * @param address - Token address (mint for Solana, contract for EVM).
22
+ * @returns Normalized cache key in format `chain:address`.
23
+ */
24
+ export declare function buildCacheKey(chain: string, address: string): string;
25
+ /**
26
+ * In-memory price cache with LRU eviction and cache stampede prevention.
27
+ *
28
+ * - LRU: Map insertion order tracks access recency. get() does delete+set to touch.
29
+ * - TTL: Entries expire after ttlMs. get() returns null for expired entries.
30
+ * - Stale: getStale() returns expired-but-not-too-old entries for fallback.
31
+ * - Stampede: getOrFetch() coalesces concurrent requests for the same key.
32
+ */
33
+ export declare class InMemoryPriceCache {
34
+ private readonly ttlMs;
35
+ private readonly staleMaxMs;
36
+ private readonly maxEntries;
37
+ /** Default TTL: 5 minutes. */
38
+ static readonly DEFAULT_TTL_MS: number;
39
+ /** Default stale max: 30 minutes. */
40
+ static readonly DEFAULT_STALE_MAX_MS: number;
41
+ /** Default max entries: 128. */
42
+ static readonly DEFAULT_MAX_ENTRIES = 128;
43
+ private readonly cache;
44
+ private readonly inflightRequests;
45
+ private stats;
46
+ constructor(ttlMs?: number, staleMaxMs?: number, maxEntries?: number);
47
+ /**
48
+ * Get a cached price entry.
49
+ *
50
+ * Returns null if the key doesn't exist or the entry has expired past TTL.
51
+ * On hit, performs LRU touch (delete+set to move to most recent position).
52
+ *
53
+ * @param key - Cache key (use buildCacheKey to generate).
54
+ * @returns PriceInfo if cached and within TTL, null otherwise.
55
+ */
56
+ get(key: string): PriceInfo | null;
57
+ /**
58
+ * Get stale cached data (past TTL but within staleMax).
59
+ *
60
+ * Used as fallback when oracle is temporarily unavailable.
61
+ *
62
+ * @param key - Cache key.
63
+ * @returns PriceInfo if within staleMax window, null otherwise.
64
+ */
65
+ getStale(key: string): PriceInfo | null;
66
+ /**
67
+ * Store a price in the cache.
68
+ *
69
+ * If the cache is at capacity and the key is new, the oldest entry (first
70
+ * Map key per insertion order) is evicted.
71
+ *
72
+ * @param key - Cache key.
73
+ * @param price - Price data to cache.
74
+ */
75
+ set(key: string, price: PriceInfo): void;
76
+ /**
77
+ * Get a price from cache, or fetch it if not cached.
78
+ *
79
+ * Implements cache stampede prevention: concurrent calls for the same key
80
+ * share a single inflight Promise. On error, the inflight is cleared so
81
+ * subsequent calls can retry.
82
+ *
83
+ * @param key - Cache key.
84
+ * @param fetcher - Async function to fetch the price on cache miss.
85
+ * @returns The cached or freshly fetched PriceInfo.
86
+ */
87
+ getOrFetch(key: string, fetcher: () => Promise<PriceInfo>): Promise<PriceInfo>;
88
+ /**
89
+ * Get cache statistics.
90
+ *
91
+ * @returns Current cache stats including hits, misses, staleHits, size, evictions.
92
+ */
93
+ getStats(): CacheStats;
94
+ /**
95
+ * Clear all cached entries and reset statistics.
96
+ */
97
+ clear(): void;
98
+ }
99
+ //# sourceMappingURL=price-cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-cache.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/oracle/price-cache.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAc1D;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAKpE;AAED;;;;;;;GAOG;AACH,qBAAa,kBAAkB;IAa3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAd7B,8BAA8B;IAC9B,MAAM,CAAC,QAAQ,CAAC,cAAc,SAAiB;IAC/C,qCAAqC;IACrC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,SAAkB;IACtD,gCAAgC;IAChC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,OAAO;IAE1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyC;IAC1E,OAAO,CAAC,KAAK,CAAsD;gBAGhD,KAAK,GAAE,MAA0C,EACjD,UAAU,GAAE,MAAgD,EAC5D,UAAU,GAAE,MAA+C;IAG9E;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAoBlC;;;;;;;OAOG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAkBvC;;;;;;;;OAQG;IACH,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAuBxC;;;;;;;;;;OAUG;IACG,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC;IAuBpF;;;;OAIG;IACH,QAAQ,IAAI,UAAU;IAOtB;;OAEG;IACH,KAAK,IAAI,IAAI;CAKd"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Build a normalized cache key for a token.
3
+ *
4
+ * EVM addresses are lowercased for consistency with CoinGecko API responses
5
+ * and EIP-55 checksum normalization.
6
+ *
7
+ * @param chain - Chain identifier ('solana' | 'ethereum').
8
+ * @param address - Token address (mint for Solana, contract for EVM).
9
+ * @returns Normalized cache key in format `chain:address`.
10
+ */
11
+ export function buildCacheKey(chain, address) {
12
+ const normalizedAddress = chain === 'ethereum'
13
+ ? address.toLowerCase()
14
+ : address;
15
+ return `${chain}:${normalizedAddress}`;
16
+ }
17
+ /**
18
+ * In-memory price cache with LRU eviction and cache stampede prevention.
19
+ *
20
+ * - LRU: Map insertion order tracks access recency. get() does delete+set to touch.
21
+ * - TTL: Entries expire after ttlMs. get() returns null for expired entries.
22
+ * - Stale: getStale() returns expired-but-not-too-old entries for fallback.
23
+ * - Stampede: getOrFetch() coalesces concurrent requests for the same key.
24
+ */
25
+ export class InMemoryPriceCache {
26
+ ttlMs;
27
+ staleMaxMs;
28
+ maxEntries;
29
+ /** Default TTL: 5 minutes. */
30
+ static DEFAULT_TTL_MS = 5 * 60 * 1000;
31
+ /** Default stale max: 30 minutes. */
32
+ static DEFAULT_STALE_MAX_MS = 30 * 60 * 1000;
33
+ /** Default max entries: 128. */
34
+ static DEFAULT_MAX_ENTRIES = 128;
35
+ cache = new Map();
36
+ inflightRequests = new Map();
37
+ stats = { hits: 0, misses: 0, staleHits: 0, evictions: 0 };
38
+ constructor(ttlMs = InMemoryPriceCache.DEFAULT_TTL_MS, staleMaxMs = InMemoryPriceCache.DEFAULT_STALE_MAX_MS, maxEntries = InMemoryPriceCache.DEFAULT_MAX_ENTRIES) {
39
+ this.ttlMs = ttlMs;
40
+ this.staleMaxMs = staleMaxMs;
41
+ this.maxEntries = maxEntries;
42
+ }
43
+ /**
44
+ * Get a cached price entry.
45
+ *
46
+ * Returns null if the key doesn't exist or the entry has expired past TTL.
47
+ * On hit, performs LRU touch (delete+set to move to most recent position).
48
+ *
49
+ * @param key - Cache key (use buildCacheKey to generate).
50
+ * @returns PriceInfo if cached and within TTL, null otherwise.
51
+ */
52
+ get(key) {
53
+ const entry = this.cache.get(key);
54
+ if (!entry) {
55
+ this.stats.misses++;
56
+ return null;
57
+ }
58
+ const now = Date.now();
59
+ if (now >= entry.expiresAt) {
60
+ this.stats.misses++;
61
+ return null;
62
+ }
63
+ // LRU touch: delete and re-insert to move to end (most recent)
64
+ this.cache.delete(key);
65
+ this.cache.set(key, entry);
66
+ this.stats.hits++;
67
+ return entry.price;
68
+ }
69
+ /**
70
+ * Get stale cached data (past TTL but within staleMax).
71
+ *
72
+ * Used as fallback when oracle is temporarily unavailable.
73
+ *
74
+ * @param key - Cache key.
75
+ * @returns PriceInfo if within staleMax window, null otherwise.
76
+ */
77
+ getStale(key) {
78
+ const entry = this.cache.get(key);
79
+ if (!entry) {
80
+ return null;
81
+ }
82
+ const now = Date.now();
83
+ if (now >= entry.staleExpiresAt) {
84
+ return null;
85
+ }
86
+ // Only count as staleHit if actually past TTL
87
+ if (now >= entry.expiresAt) {
88
+ this.stats.staleHits++;
89
+ }
90
+ return entry.price;
91
+ }
92
+ /**
93
+ * Store a price in the cache.
94
+ *
95
+ * If the cache is at capacity and the key is new, the oldest entry (first
96
+ * Map key per insertion order) is evicted.
97
+ *
98
+ * @param key - Cache key.
99
+ * @param price - Price data to cache.
100
+ */
101
+ set(key, price) {
102
+ // Evict oldest if at capacity and this is a new key
103
+ if (this.cache.size >= this.maxEntries && !this.cache.has(key)) {
104
+ const oldestKey = this.cache.keys().next().value;
105
+ if (oldestKey !== undefined) {
106
+ this.cache.delete(oldestKey);
107
+ this.stats.evictions++;
108
+ }
109
+ }
110
+ const now = Date.now();
111
+ const entry = {
112
+ price,
113
+ cachedAt: now,
114
+ expiresAt: now + this.ttlMs,
115
+ staleExpiresAt: now + this.staleMaxMs,
116
+ };
117
+ // Delete first to ensure insertion at end (most recent position)
118
+ this.cache.delete(key);
119
+ this.cache.set(key, entry);
120
+ }
121
+ /**
122
+ * Get a price from cache, or fetch it if not cached.
123
+ *
124
+ * Implements cache stampede prevention: concurrent calls for the same key
125
+ * share a single inflight Promise. On error, the inflight is cleared so
126
+ * subsequent calls can retry.
127
+ *
128
+ * @param key - Cache key.
129
+ * @param fetcher - Async function to fetch the price on cache miss.
130
+ * @returns The cached or freshly fetched PriceInfo.
131
+ */
132
+ async getOrFetch(key, fetcher) {
133
+ // 1. Cache hit
134
+ const cached = this.get(key);
135
+ if (cached)
136
+ return cached;
137
+ // 2. Join existing inflight request (stampede prevention)
138
+ const inflight = this.inflightRequests.get(key);
139
+ if (inflight)
140
+ return inflight;
141
+ // 3. Start new fetch
142
+ const promise = fetcher()
143
+ .then((price) => {
144
+ this.set(key, price);
145
+ return price;
146
+ })
147
+ .finally(() => {
148
+ this.inflightRequests.delete(key);
149
+ });
150
+ this.inflightRequests.set(key, promise);
151
+ return promise;
152
+ }
153
+ /**
154
+ * Get cache statistics.
155
+ *
156
+ * @returns Current cache stats including hits, misses, staleHits, size, evictions.
157
+ */
158
+ getStats() {
159
+ return {
160
+ ...this.stats,
161
+ size: this.cache.size,
162
+ };
163
+ }
164
+ /**
165
+ * Clear all cached entries and reset statistics.
166
+ */
167
+ clear() {
168
+ this.cache.clear();
169
+ this.inflightRequests.clear();
170
+ this.stats = { hits: 0, misses: 0, staleHits: 0, evictions: 0 };
171
+ }
172
+ }
173
+ //# sourceMappingURL=price-cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price-cache.js","sourceRoot":"","sources":["../../../src/infr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,CAAC;QAEL,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO;YACL,GAAG,IAAI,CAAC,KAAK;YACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC;IAClE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Pyth Hermes feed ID hardcoded mappings.
3
+ *
4
+ * Maps cache keys (`chain:address`) to Pyth price feed IDs (hex, no 0x prefix).
5
+ * These feed IDs are chain-agnostic -- Pyth uses the same feed for SOL/USD
6
+ * regardless of whether the query comes from Solana or EVM context.
7
+ *
8
+ * Only major tokens are hardcoded. Tokens without a feed ID will trigger
9
+ * PriceNotAvailableError in PythOracle, causing OracleChain to fall back
10
+ * to CoinGecko.
11
+ *
12
+ * Feed IDs verified via Pyth Hermes /v2/price_feeds API (2026-02-15).
13
+ */
14
+ import type { ChainType } from '@waiaas/core';
15
+ /** Hardcoded Pyth price feed IDs for major tokens. */
16
+ export declare const PYTH_FEED_IDS: ReadonlyMap<string, string>;
17
+ /**
18
+ * Look up a Pyth feed ID by cache key.
19
+ *
20
+ * @param cacheKey - Normalized cache key (e.g. `solana:native`, `ethereum:0xaddr`).
21
+ * @returns Feed ID hex string (no 0x prefix) or undefined if not registered.
22
+ */
23
+ export declare function getFeedId(cacheKey: string): string | undefined;
24
+ /**
25
+ * Get the Pyth feed ID for a chain's native token.
26
+ *
27
+ * @param chain - Chain type ('solana' or 'ethereum').
28
+ * @returns Feed ID hex string or undefined if chain not supported.
29
+ */
30
+ export declare function getNativeFeedId(chain: ChainType): string | undefined;
31
+ //# sourceMappingURL=pyth-feed-ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pyth-feed-ids.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/oracle/pyth-feed-ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9C,sDAAsD;AACtD,eAAO,MAAM,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAWpD,CAAC;AAgBH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE9D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEpE"}
@@ -0,0 +1,44 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Feed ID Map: cacheKey -> Pyth feed ID (hex, no 0x)
3
+ // ---------------------------------------------------------------------------
4
+ /** Hardcoded Pyth price feed IDs for major tokens. */
5
+ export const PYTH_FEED_IDS = new Map([
6
+ // Native tokens
7
+ ['solana:native', 'ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d'], // SOL/USD
8
+ ['ethereum:native', 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace'], // ETH/USD
9
+ // Solana SPL tokens
10
+ ['solana:EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a'], // USDC/USD
11
+ ['solana:Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB', '2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b'], // USDT/USD
12
+ // BTC (chain-agnostic feed, mapped for common BTC token addresses)
13
+ ['ethereum:native_btc', 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43'], // BTC/USD
14
+ ]);
15
+ // ---------------------------------------------------------------------------
16
+ // Native token -> feed ID mapping
17
+ // ---------------------------------------------------------------------------
18
+ /** Map from ChainType to the native token's Pyth feed ID. */
19
+ const NATIVE_FEED_MAP = new Map([
20
+ ['solana', 'ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d'], // SOL/USD
21
+ ['ethereum', 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace'], // ETH/USD
22
+ ]);
23
+ // ---------------------------------------------------------------------------
24
+ // Public helpers
25
+ // ---------------------------------------------------------------------------
26
+ /**
27
+ * Look up a Pyth feed ID by cache key.
28
+ *
29
+ * @param cacheKey - Normalized cache key (e.g. `solana:native`, `ethereum:0xaddr`).
30
+ * @returns Feed ID hex string (no 0x prefix) or undefined if not registered.
31
+ */
32
+ export function getFeedId(cacheKey) {
33
+ return PYTH_FEED_IDS.get(cacheKey);
34
+ }
35
+ /**
36
+ * Get the Pyth feed ID for a chain's native token.
37
+ *
38
+ * @param chain - Chain type ('solana' or 'ethereum').
39
+ * @returns Feed ID hex string or undefined if chain not supported.
40
+ */
41
+ export function getNativeFeedId(chain) {
42
+ return NATIVE_FEED_MAP.get(chain);
43
+ }
44
+ //# sourceMappingURL=pyth-feed-ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pyth-feed-ids.js","sourceRoot":"","sources":["../../../src/infrastructure/oracle/pyth-feed-ids.ts"],"names":[],"mappings":"AAeA,8EAA8E;AAC9E,qDAAqD;AACrD,8EAA8E;AAE9E,sDAAsD;AACtD,MAAM,CAAC,MAAM,aAAa,GAAgC,IAAI,GAAG,CAAC;IAChE,gBAAgB;IAChB,CAAC,eAAe,EAAE,kEAAkE,CAAC,EAAK,UAAU;IACpG,CAAC,iBAAiB,EAAE,kEAAkE,CAAC,EAAI,UAAU;IAErG,oBAAoB;IACpB,CAAC,qDAAqD,EAAE,kEAAkE,CAAC,EAAE,WAAW;IACxI,CAAC,qDAAqD,EAAE,kEAAkE,CAAC,EAAG,WAAW;IAEzI,mEAAmE;IACnE,CAAC,qBAAqB,EAAE,kEAAkE,CAAC,EAAE,UAAU;CACxG,CAAC,CAAC;AAEH,8EAA8E;AAC9E,kCAAkC;AAClC,8EAA8E;AAE9E,6DAA6D;AAC7D,MAAM,eAAe,GAAmC,IAAI,GAAG,CAAC;IAC9D,CAAC,QAAQ,EAAE,kEAAkE,CAAC,EAAI,UAAU;IAC5F,CAAC,UAAU,EAAE,kEAAkE,CAAC,EAAG,UAAU;CAC9F,CAAC,CAAC;AAEH,8EAA8E;AAC9E,iBAAiB;AACjB,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,OAAO,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAgB;IAC9C,OAAO,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * PythOracle: IPriceOracle implementation using Pyth Hermes REST API.
3
+ *
4
+ * Fetches real-time price data from the public Pyth Hermes instance
5
+ * (https://hermes.pyth.network) with zero-config (no API key required).
6
+ *
7
+ * Design decisions:
8
+ * - No internal cache: cache management is OracleChain's responsibility.
9
+ * - Feed IDs from hardcoded map (pyth-feed-ids.ts). Unknown tokens throw
10
+ * PriceNotAvailableError to trigger OracleChain's CoinGecko fallback.
11
+ * - 5-second timeout via AbortSignal.timeout() (Node.js 22 built-in).
12
+ * - Price conversion: Number(price) * 10^expo for USD value.
13
+ */
14
+ import type { ChainType, PriceInfo, CacheStats, IPriceOracle, TokenRef } from '@waiaas/core';
15
+ export { PriceNotAvailableError } from './oracle-errors.js';
16
+ /**
17
+ * Price oracle backed by the Pyth Hermes REST API.
18
+ *
19
+ * Implements IPriceOracle with pure API-call semantics (no caching).
20
+ * Supports single and batch price queries via the `/v2/updates/price/latest`
21
+ * endpoint.
22
+ */
23
+ export declare class PythOracle implements IPriceOracle {
24
+ private static readonly HERMES_BASE_URL;
25
+ private static readonly TIMEOUT_MS;
26
+ private static readonly PRICE_TTL_MS;
27
+ /**
28
+ * Get price for a single token.
29
+ *
30
+ * @param token - Token reference with address, decimals, and chain.
31
+ * @returns PriceInfo with USD price, confidence, and metadata.
32
+ * @throws PriceNotAvailableError if token has no registered Pyth feed ID.
33
+ * @throws Error if Pyth API returns HTTP error or invalid response.
34
+ */
35
+ getPrice(token: TokenRef): Promise<PriceInfo>;
36
+ /**
37
+ * Get prices for multiple tokens in a single batch API call.
38
+ *
39
+ * Tokens without a registered feed ID are silently skipped (they will be
40
+ * handled by OracleChain's fallback).
41
+ *
42
+ * @param tokens - Array of token references.
43
+ * @returns Map from cache key to PriceInfo for tokens that have feed IDs.
44
+ */
45
+ getPrices(tokens: TokenRef[]): Promise<Map<string, PriceInfo>>;
46
+ /**
47
+ * Get native token price (SOL or ETH).
48
+ *
49
+ * @param chain - Chain type ('solana' or 'ethereum').
50
+ * @returns PriceInfo for the chain's native token.
51
+ * @throws PriceNotAvailableError if chain has no native feed mapping.
52
+ */
53
+ getNativePrice(chain: ChainType): Promise<PriceInfo>;
54
+ /**
55
+ * Get cache statistics.
56
+ *
57
+ * PythOracle does not manage its own cache (OracleChain handles caching),
58
+ * so all counters are zero.
59
+ */
60
+ getCacheStats(): CacheStats;
61
+ /**
62
+ * Convert a Pyth price feed to PriceInfo.
63
+ *
64
+ * Price formula: usdPrice = Number(price) * 10^expo
65
+ * Confidence: 1 - (confUsd / usdPrice) clamped to [0, 1]
66
+ */
67
+ private static convertFeedToPrice;
68
+ }
69
+ //# sourceMappingURL=pyth-oracle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pyth-oracle.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/oracle/pyth-oracle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAM7F,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AA8B5D;;;;;;GAMG;AACH,qBAAa,UAAW,YAAW,YAAY;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAiC;IACxE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAQ;IAC1C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAW;IAE/C;;;;;;;OAOG;IACG,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;IA+BnD;;;;;;;;OAQG;IACG,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAgDpE;;;;;;OAMG;IACG,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAK1D;;;;;OAKG;IACH,aAAa,IAAI,UAAU;IAc3B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAoBlC"}