@centrifuge/sdk 0.0.0-alpha.5 → 0.0.0-alpha.51

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 (428) hide show
  1. package/README.md +19 -8
  2. package/dist/Centrifuge.d.ts +281 -427
  3. package/dist/Centrifuge.d.ts.map +1 -1
  4. package/dist/Centrifuge.js +643 -145
  5. package/dist/Centrifuge.js.map +1 -1
  6. package/dist/Centrifuge.test.d.ts +2 -0
  7. package/dist/Centrifuge.test.d.ts.map +1 -0
  8. package/dist/Centrifuge.test.js +529 -0
  9. package/dist/Centrifuge.test.js.map +1 -0
  10. package/dist/abi/Accounting.abi.d.ts +3 -0
  11. package/dist/abi/Accounting.abi.d.ts.map +1 -0
  12. package/dist/abi/Accounting.abi.js +33 -0
  13. package/dist/abi/Accounting.abi.js.map +1 -0
  14. package/dist/abi/AsyncRequestManager.abi.d.ts +3 -0
  15. package/dist/abi/AsyncRequestManager.abi.d.ts.map +1 -0
  16. package/dist/abi/AsyncRequestManager.abi.js +78 -0
  17. package/dist/abi/AsyncRequestManager.abi.js.map +1 -0
  18. package/dist/abi/AsyncVault.abi.d.ts +3 -0
  19. package/dist/abi/AsyncVault.abi.d.ts.map +1 -0
  20. package/dist/abi/AsyncVault.abi.js +101 -0
  21. package/dist/abi/AsyncVault.abi.js.map +1 -0
  22. package/dist/abi/BalanceSheet.abi.d.ts +3 -0
  23. package/dist/abi/BalanceSheet.abi.d.ts.map +1 -0
  24. package/dist/abi/BalanceSheet.abi.js +55 -0
  25. package/dist/abi/BalanceSheet.abi.js.map +1 -0
  26. package/dist/abi/Currency.abi.d.ts +3 -0
  27. package/dist/abi/Currency.abi.d.ts.map +1 -0
  28. package/dist/abi/Currency.abi.js +16 -0
  29. package/dist/abi/Currency.abi.js.map +1 -0
  30. package/dist/abi/ERC6909.abi.d.ts +3 -0
  31. package/dist/abi/ERC6909.abi.d.ts.map +1 -0
  32. package/dist/abi/ERC6909.abi.js +22 -0
  33. package/dist/abi/ERC6909.abi.js.map +1 -0
  34. package/dist/abi/GasService.abi.d.ts +3 -0
  35. package/dist/abi/GasService.abi.d.ts.map +1 -0
  36. package/dist/abi/GasService.abi.js +32 -0
  37. package/dist/abi/GasService.abi.js.map +1 -0
  38. package/dist/abi/Holdings.abi.d.ts +3 -0
  39. package/dist/abi/Holdings.abi.d.ts.map +1 -0
  40. package/dist/abi/Holdings.abi.js +43 -0
  41. package/dist/abi/Holdings.abi.js.map +1 -0
  42. package/dist/abi/Hub.abi.d.ts +3 -0
  43. package/dist/abi/Hub.abi.d.ts.map +1 -0
  44. package/dist/abi/Hub.abi.js +89 -0
  45. package/dist/abi/Hub.abi.js.map +1 -0
  46. package/dist/abi/HubRegistry.abi.d.ts +3 -0
  47. package/dist/abi/HubRegistry.abi.d.ts.map +1 -0
  48. package/dist/abi/HubRegistry.abi.js +39 -0
  49. package/dist/abi/HubRegistry.abi.js.map +1 -0
  50. package/dist/abi/MessageDispatcher.abi.d.ts +3 -0
  51. package/dist/abi/MessageDispatcher.abi.d.ts.map +1 -0
  52. package/dist/abi/MessageDispatcher.abi.js +49 -0
  53. package/dist/abi/MessageDispatcher.abi.js.map +1 -0
  54. package/dist/abi/MultiAdapter.abi.d.ts +3 -0
  55. package/dist/abi/MultiAdapter.abi.d.ts.map +1 -0
  56. package/dist/abi/MultiAdapter.abi.js +53 -0
  57. package/dist/abi/MultiAdapter.abi.js.map +1 -0
  58. package/dist/abi/PoolEscrow.abi.d.ts +3 -0
  59. package/dist/abi/PoolEscrow.abi.d.ts.map +1 -0
  60. package/dist/abi/PoolEscrow.abi.js +32 -0
  61. package/dist/abi/PoolEscrow.abi.js.map +1 -0
  62. package/dist/abi/PoolEscrowFactory.abi.d.ts +3 -0
  63. package/dist/abi/PoolEscrowFactory.abi.d.ts.map +1 -0
  64. package/dist/abi/PoolEscrowFactory.abi.js +19 -0
  65. package/dist/abi/PoolEscrowFactory.abi.js.map +1 -0
  66. package/dist/abi/RestrictionManager.abi.d.ts +3 -0
  67. package/dist/abi/RestrictionManager.abi.d.ts.map +1 -0
  68. package/dist/abi/RestrictionManager.abi.js +23 -0
  69. package/dist/abi/RestrictionManager.abi.js.map +1 -0
  70. package/dist/abi/ShareClassManager.abi.d.ts +3 -0
  71. package/dist/abi/ShareClassManager.abi.d.ts.map +1 -0
  72. package/dist/abi/ShareClassManager.abi.js +89 -0
  73. package/dist/abi/ShareClassManager.abi.js.map +1 -0
  74. package/dist/abi/Spoke.abi.d.ts +3 -0
  75. package/dist/abi/Spoke.abi.d.ts.map +1 -0
  76. package/dist/abi/Spoke.abi.js +90 -0
  77. package/dist/abi/Spoke.abi.js.map +1 -0
  78. package/dist/abi/SyncRequestManager.abi.d.ts +3 -0
  79. package/dist/abi/SyncRequestManager.abi.d.ts.map +1 -0
  80. package/dist/abi/SyncRequestManager.abi.js +61 -0
  81. package/dist/abi/SyncRequestManager.abi.js.map +1 -0
  82. package/dist/abi/Valuation.abi.d.ts +3 -0
  83. package/dist/abi/Valuation.abi.d.ts.map +1 -0
  84. package/dist/abi/Valuation.abi.js +2 -0
  85. package/dist/abi/Valuation.abi.js.map +1 -0
  86. package/dist/abi/VaultRouter.abi.d.ts +3 -0
  87. package/dist/abi/VaultRouter.abi.d.ts.map +1 -0
  88. package/dist/abi/VaultRouter.abi.js +50 -0
  89. package/dist/abi/VaultRouter.abi.js.map +1 -0
  90. package/dist/abi/index.d.ts +8696 -8
  91. package/dist/abi/index.d.ts.map +1 -1
  92. package/dist/abi/index.js +40 -16
  93. package/dist/abi/index.js.map +1 -1
  94. package/dist/config/chains.d.ts +184 -925
  95. package/dist/config/chains.d.ts.map +1 -1
  96. package/dist/config/chains.js +2 -2
  97. package/dist/config/chains.js.map +1 -1
  98. package/dist/config/protocol.d.ts +3 -0
  99. package/dist/config/protocol.d.ts.map +1 -0
  100. package/dist/config/protocol.js +7 -0
  101. package/dist/config/protocol.js.map +1 -0
  102. package/dist/entities/BalanceSheet.d.ts +48 -0
  103. package/dist/entities/BalanceSheet.d.ts.map +1 -0
  104. package/dist/entities/BalanceSheet.js +94 -0
  105. package/dist/entities/BalanceSheet.js.map +1 -0
  106. package/dist/entities/BalanceSheet.test.d.ts +2 -0
  107. package/dist/entities/BalanceSheet.test.d.ts.map +1 -0
  108. package/dist/entities/BalanceSheet.test.js +64 -0
  109. package/dist/entities/BalanceSheet.test.js.map +1 -0
  110. package/dist/entities/Entity.d.ts +8 -0
  111. package/dist/entities/Entity.d.ts.map +1 -0
  112. package/dist/{Entity.js → entities/Entity.js} +5 -3
  113. package/dist/entities/Entity.js.map +1 -0
  114. package/dist/{IndexerQueries → entities/IndexerQueries}/assetSnapshots.d.ts +14 -14
  115. package/dist/entities/IndexerQueries/assetSnapshots.d.ts.map +1 -0
  116. package/dist/{IndexerQueries → entities/IndexerQueries}/assetSnapshots.js +16 -16
  117. package/dist/entities/IndexerQueries/assetSnapshots.js.map +1 -0
  118. package/dist/{IndexerQueries → entities/IndexerQueries}/assetTransactions.d.ts +9 -6
  119. package/dist/entities/IndexerQueries/assetTransactions.d.ts.map +1 -0
  120. package/dist/{IndexerQueries → entities/IndexerQueries}/assetTransactions.js +8 -7
  121. package/dist/entities/IndexerQueries/assetTransactions.js.map +1 -0
  122. package/dist/entities/IndexerQueries/epochs.d.ts +45 -0
  123. package/dist/entities/IndexerQueries/epochs.d.ts.map +1 -0
  124. package/dist/entities/IndexerQueries/epochs.js +51 -0
  125. package/dist/entities/IndexerQueries/epochs.js.map +1 -0
  126. package/dist/{IndexerQueries → entities/IndexerQueries}/index.d.ts +24 -22
  127. package/dist/entities/IndexerQueries/index.d.ts.map +1 -0
  128. package/dist/{IndexerQueries → entities/IndexerQueries}/index.js +10 -6
  129. package/dist/entities/IndexerQueries/index.js.map +1 -0
  130. package/dist/{IndexerQueries → entities/IndexerQueries}/investorTransactions.d.ts +4 -4
  131. package/dist/entities/IndexerQueries/investorTransactions.d.ts.map +1 -0
  132. package/dist/{IndexerQueries → entities/IndexerQueries}/investorTransactions.js +4 -4
  133. package/dist/entities/IndexerQueries/investorTransactions.js.map +1 -0
  134. package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeSnapshots.d.ts +8 -8
  135. package/dist/entities/IndexerQueries/poolFeeSnapshots.d.ts.map +1 -0
  136. package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeSnapshots.js +8 -8
  137. package/dist/entities/IndexerQueries/poolFeeSnapshots.js.map +1 -0
  138. package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeTransactions.d.ts +3 -3
  139. package/dist/entities/IndexerQueries/poolFeeTransactions.d.ts.map +1 -0
  140. package/dist/{IndexerQueries → entities/IndexerQueries}/poolFeeTransactions.js +3 -3
  141. package/dist/entities/IndexerQueries/poolFeeTransactions.js.map +1 -0
  142. package/dist/{IndexerQueries → entities/IndexerQueries}/poolSnapshots.d.ts +30 -24
  143. package/dist/entities/IndexerQueries/poolSnapshots.d.ts.map +1 -0
  144. package/dist/{IndexerQueries → entities/IndexerQueries}/poolSnapshots.js +29 -23
  145. package/dist/entities/IndexerQueries/poolSnapshots.js.map +1 -0
  146. package/dist/{IndexerQueries → entities/IndexerQueries}/trancheCurrencyBalance.d.ts +15 -17
  147. package/dist/entities/IndexerQueries/trancheCurrencyBalance.d.ts.map +1 -0
  148. package/dist/entities/IndexerQueries/trancheCurrencyBalance.js +63 -0
  149. package/dist/entities/IndexerQueries/trancheCurrencyBalance.js.map +1 -0
  150. package/dist/{IndexerQueries → entities/IndexerQueries}/trancheSnapshots.d.ts +6 -6
  151. package/dist/entities/IndexerQueries/trancheSnapshots.d.ts.map +1 -0
  152. package/dist/{IndexerQueries → entities/IndexerQueries}/trancheSnapshots.js +6 -6
  153. package/dist/entities/IndexerQueries/trancheSnapshots.js.map +1 -0
  154. package/dist/entities/Investor.d.ts +33 -0
  155. package/dist/entities/Investor.d.ts.map +1 -0
  156. package/dist/entities/Investor.js +59 -0
  157. package/dist/entities/Investor.js.map +1 -0
  158. package/dist/entities/Investor.test.d.ts +2 -0
  159. package/dist/entities/Investor.test.d.ts.map +1 -0
  160. package/dist/entities/Investor.test.js +74 -0
  161. package/dist/entities/Investor.test.js.map +1 -0
  162. package/dist/entities/MerkleProofManager.d.ts +30 -0
  163. package/dist/entities/MerkleProofManager.d.ts.map +1 -0
  164. package/dist/entities/MerkleProofManager.js +140 -0
  165. package/dist/entities/MerkleProofManager.js.map +1 -0
  166. package/dist/entities/MerkleProofManager.test.d.ts +2 -0
  167. package/dist/entities/MerkleProofManager.test.d.ts.map +1 -0
  168. package/dist/entities/MerkleProofManager.test.js +27 -0
  169. package/dist/entities/MerkleProofManager.test.js.map +1 -0
  170. package/dist/entities/Pool.d.ts +155 -0
  171. package/dist/entities/Pool.d.ts.map +1 -0
  172. package/dist/entities/Pool.js +590 -0
  173. package/dist/entities/Pool.js.map +1 -0
  174. package/dist/entities/Pool.test.d.ts +2 -0
  175. package/dist/entities/Pool.test.d.ts.map +1 -0
  176. package/dist/entities/Pool.test.js +270 -0
  177. package/dist/entities/Pool.test.js.map +1 -0
  178. package/dist/entities/PoolNetwork.d.ts +73 -0
  179. package/dist/entities/PoolNetwork.d.ts.map +1 -0
  180. package/dist/entities/PoolNetwork.js +318 -0
  181. package/dist/entities/PoolNetwork.js.map +1 -0
  182. package/dist/entities/PoolNetwork.test.d.ts +2 -0
  183. package/dist/entities/PoolNetwork.test.d.ts.map +1 -0
  184. package/dist/entities/PoolNetwork.test.js +112 -0
  185. package/dist/entities/PoolNetwork.test.js.map +1 -0
  186. package/dist/entities/Reports/PoolReports.d.ts +8 -0
  187. package/dist/entities/Reports/PoolReports.d.ts.map +1 -0
  188. package/dist/entities/Reports/PoolReports.js +14 -0
  189. package/dist/entities/Reports/PoolReports.js.map +1 -0
  190. package/dist/entities/Reports/PoolSharePricesReport.d.ts +25 -0
  191. package/dist/entities/Reports/PoolSharePricesReport.d.ts.map +1 -0
  192. package/dist/entities/Reports/PoolSharePricesReport.js +64 -0
  193. package/dist/entities/Reports/PoolSharePricesReport.js.map +1 -0
  194. package/dist/entities/Reports/PoolSharePricesReport.test.d.ts +2 -0
  195. package/dist/entities/Reports/PoolSharePricesReport.test.d.ts.map +1 -0
  196. package/dist/entities/Reports/PoolSharePricesReport.test.js +35 -0
  197. package/dist/entities/Reports/PoolSharePricesReport.test.js.map +1 -0
  198. package/dist/{Reports → entities/Reports}/Processor.d.ts +3 -1
  199. package/dist/entities/Reports/Processor.d.ts.map +1 -0
  200. package/dist/{Reports → entities/Reports}/Processor.js +100 -22
  201. package/dist/entities/Reports/Processor.js.map +1 -0
  202. package/dist/entities/Reports/Processor.test.d.ts +2 -0
  203. package/dist/entities/Reports/Processor.test.d.ts.map +1 -0
  204. package/dist/entities/Reports/Processor.test.js +767 -0
  205. package/dist/entities/Reports/Processor.test.js.map +1 -0
  206. package/dist/entities/Reports/Reports.test.d.ts +2 -0
  207. package/dist/entities/Reports/Reports.test.d.ts.map +1 -0
  208. package/dist/entities/Reports/Reports.test.js +559 -0
  209. package/dist/entities/Reports/Reports.test.js.map +1 -0
  210. package/dist/entities/Reports/index.d.ts +21 -0
  211. package/dist/entities/Reports/index.d.ts.map +1 -0
  212. package/dist/{Reports → entities/Reports}/index.js +25 -7
  213. package/dist/entities/Reports/index.js.map +1 -0
  214. package/dist/entities/Reports/types.d.ts +9 -0
  215. package/dist/entities/Reports/types.d.ts.map +1 -0
  216. package/dist/entities/Reports/types.js +2 -0
  217. package/dist/entities/Reports/types.js.map +1 -0
  218. package/dist/entities/Reports/utils.d.ts +20 -0
  219. package/dist/entities/Reports/utils.d.ts.map +1 -0
  220. package/dist/entities/Reports/utils.js +47 -0
  221. package/dist/entities/Reports/utils.js.map +1 -0
  222. package/dist/entities/ShareClass.d.ts +196 -0
  223. package/dist/entities/ShareClass.d.ts.map +1 -0
  224. package/dist/entities/ShareClass.js +1189 -0
  225. package/dist/entities/ShareClass.js.map +1 -0
  226. package/dist/entities/ShareClass.test.d.ts +2 -0
  227. package/dist/entities/ShareClass.test.d.ts.map +1 -0
  228. package/dist/entities/ShareClass.test.js +500 -0
  229. package/dist/entities/ShareClass.test.js.map +1 -0
  230. package/dist/entities/Vault.d.ts +92 -0
  231. package/dist/entities/Vault.d.ts.map +1 -0
  232. package/dist/entities/Vault.js +434 -0
  233. package/dist/entities/Vault.js.map +1 -0
  234. package/dist/entities/Vault.test.d.ts +2 -0
  235. package/dist/entities/Vault.test.d.ts.map +1 -0
  236. package/dist/entities/Vault.test.js +306 -0
  237. package/dist/entities/Vault.test.js.map +1 -0
  238. package/dist/index.d.ts +15 -6
  239. package/dist/index.d.ts.map +1 -1
  240. package/dist/index.js +10 -6
  241. package/dist/index.js.map +1 -1
  242. package/dist/tests/forkServer.d.mts +2 -0
  243. package/dist/tests/forkServer.d.mts.map +1 -0
  244. package/dist/tests/forkServer.mjs +104 -0
  245. package/dist/tests/forkServer.mjs.map +1 -0
  246. package/dist/tests/mocks/mockAssetSnapshots.d.ts +1 -1
  247. package/dist/tests/mocks/mockAssetSnapshots.d.ts.map +1 -1
  248. package/dist/tests/mocks/mockAssetSnapshots.js +27 -27
  249. package/dist/tests/mocks/mockAssetSnapshots.js.map +1 -1
  250. package/dist/tests/mocks/mockAssetTransactions.d.ts +1 -1
  251. package/dist/tests/mocks/mockAssetTransactions.d.ts.map +1 -1
  252. package/dist/tests/mocks/mockAssetTransactions.js +24 -19
  253. package/dist/tests/mocks/mockAssetTransactions.js.map +1 -1
  254. package/dist/tests/mocks/mockEpochs.d.ts +3 -0
  255. package/dist/tests/mocks/mockEpochs.d.ts.map +1 -0
  256. package/dist/tests/mocks/mockEpochs.js +26 -0
  257. package/dist/tests/mocks/mockEpochs.js.map +1 -0
  258. package/dist/tests/mocks/mockInvestorCurrencyBalance.d.ts +1 -1
  259. package/dist/tests/mocks/mockInvestorCurrencyBalance.d.ts.map +1 -1
  260. package/dist/tests/mocks/mockInvestorCurrencyBalance.js +15 -15
  261. package/dist/tests/mocks/mockInvestorCurrencyBalance.js.map +1 -1
  262. package/dist/tests/mocks/mockInvestorTransactions.d.ts +1 -1
  263. package/dist/tests/mocks/mockInvestorTransactions.d.ts.map +1 -1
  264. package/dist/tests/mocks/mockInvestorTransactions.js +5 -5
  265. package/dist/tests/mocks/mockInvestorTransactions.js.map +1 -1
  266. package/dist/tests/mocks/mockPoolFeeSnapshot.d.ts +1 -1
  267. package/dist/tests/mocks/mockPoolFeeSnapshot.d.ts.map +1 -1
  268. package/dist/tests/mocks/mockPoolFeeSnapshot.js +29 -29
  269. package/dist/tests/mocks/mockPoolFeeSnapshot.js.map +1 -1
  270. package/dist/tests/mocks/mockPoolFeeTransactions.d.ts +3 -3
  271. package/dist/tests/mocks/mockPoolFeeTransactions.d.ts.map +1 -1
  272. package/dist/tests/mocks/mockPoolFeeTransactions.js +3 -3
  273. package/dist/tests/mocks/mockPoolFeeTransactions.js.map +1 -1
  274. package/dist/tests/mocks/mockPoolMetadata.d.ts.map +1 -1
  275. package/dist/tests/mocks/mockPoolMetadata.js +7 -17
  276. package/dist/tests/mocks/mockPoolMetadata.js.map +1 -1
  277. package/dist/tests/mocks/mockPoolSnapshots.d.ts +1 -1
  278. package/dist/tests/mocks/mockPoolSnapshots.d.ts.map +1 -1
  279. package/dist/tests/mocks/mockPoolSnapshots.js +47 -45
  280. package/dist/tests/mocks/mockPoolSnapshots.js.map +1 -1
  281. package/dist/tests/mocks/mockTrancheSnapshots.d.ts +1 -1
  282. package/dist/tests/mocks/mockTrancheSnapshots.d.ts.map +1 -1
  283. package/dist/tests/mocks/mockTrancheSnapshots.js +21 -21
  284. package/dist/tests/mocks/mockTrancheSnapshots.js.map +1 -1
  285. package/dist/tests/setup.d.ts.map +1 -1
  286. package/dist/tests/setup.js +4 -3
  287. package/dist/tests/setup.js.map +1 -1
  288. package/dist/tests/tenderly.d.ts +15 -2
  289. package/dist/tests/tenderly.d.ts.map +1 -1
  290. package/dist/tests/tenderly.js +74 -67
  291. package/dist/tests/tenderly.js.map +1 -1
  292. package/dist/tests/utils.d.ts +3 -0
  293. package/dist/tests/utils.d.ts.map +1 -0
  294. package/dist/tests/utils.js +4 -0
  295. package/dist/tests/utils.js.map +1 -0
  296. package/dist/types/holdings.d.ts +9 -0
  297. package/dist/types/holdings.d.ts.map +1 -0
  298. package/dist/types/holdings.js +10 -0
  299. package/dist/types/holdings.js.map +1 -0
  300. package/dist/types/index.d.ts +64 -0
  301. package/dist/types/index.d.ts.map +1 -1
  302. package/dist/types/indexer.d.ts +4189 -0
  303. package/dist/types/indexer.d.ts.map +1 -0
  304. package/dist/types/indexer.js +56 -0
  305. package/dist/types/indexer.js.map +1 -0
  306. package/dist/types/poolInput.d.ts +71 -0
  307. package/dist/types/poolInput.d.ts.map +1 -0
  308. package/dist/types/poolInput.js +2 -0
  309. package/dist/types/poolInput.js.map +1 -0
  310. package/dist/types/poolMetadata.d.ts +14 -13
  311. package/dist/types/poolMetadata.d.ts.map +1 -1
  312. package/dist/types/reports.d.ts +130 -69
  313. package/dist/types/reports.d.ts.map +1 -1
  314. package/dist/types/transaction.d.ts +60 -3
  315. package/dist/types/transaction.d.ts.map +1 -1
  316. package/dist/types/transaction.js +55 -1
  317. package/dist/types/transaction.js.map +1 -1
  318. package/dist/utils/BigInt.d.ts +16 -35
  319. package/dist/utils/BigInt.d.ts.map +1 -1
  320. package/dist/utils/BigInt.js +18 -25
  321. package/dist/utils/BigInt.js.map +1 -1
  322. package/dist/utils/BigInt.test.d.ts +2 -0
  323. package/dist/utils/BigInt.test.d.ts.map +1 -0
  324. package/dist/utils/BigInt.test.js +298 -0
  325. package/dist/utils/BigInt.test.js.map +1 -0
  326. package/dist/utils/currencies.d.ts +5 -0
  327. package/dist/utils/currencies.d.ts.map +1 -0
  328. package/dist/utils/currencies.js +7 -0
  329. package/dist/utils/currencies.js.map +1 -0
  330. package/dist/utils/decimal.d.ts +2 -2
  331. package/dist/utils/decimal.d.ts.map +1 -1
  332. package/dist/utils/decimal.js.map +1 -1
  333. package/dist/utils/index.d.ts +4 -0
  334. package/dist/utils/index.d.ts.map +1 -0
  335. package/dist/utils/index.js +24 -0
  336. package/dist/utils/index.js.map +1 -0
  337. package/dist/utils/ipfs.d.ts +7 -0
  338. package/dist/utils/ipfs.d.ts.map +1 -0
  339. package/dist/utils/ipfs.js +64 -0
  340. package/dist/utils/ipfs.js.map +1 -0
  341. package/dist/utils/ipfs.test.d.ts +2 -0
  342. package/dist/utils/ipfs.test.d.ts.map +1 -0
  343. package/dist/utils/ipfs.test.js +54 -0
  344. package/dist/utils/ipfs.test.js.map +1 -0
  345. package/dist/utils/permit.d.ts +13 -0
  346. package/dist/utils/permit.d.ts.map +1 -0
  347. package/dist/utils/permit.js +82 -0
  348. package/dist/utils/permit.js.map +1 -0
  349. package/dist/utils/permit.test.d.ts +2 -0
  350. package/dist/utils/permit.test.d.ts.map +1 -0
  351. package/dist/utils/permit.test.js +22 -0
  352. package/dist/utils/permit.test.js.map +1 -0
  353. package/dist/utils/rx.d.ts +1 -1
  354. package/dist/utils/rx.d.ts.map +1 -1
  355. package/dist/utils/rx.js +4 -0
  356. package/dist/utils/rx.js.map +1 -1
  357. package/dist/utils/transaction.d.ts +15 -10
  358. package/dist/utils/transaction.d.ts.map +1 -1
  359. package/dist/utils/transaction.js +57 -21
  360. package/dist/utils/transaction.js.map +1 -1
  361. package/dist/utils/types.d.ts +39 -0
  362. package/dist/utils/types.d.ts.map +1 -0
  363. package/dist/utils/types.js +89 -0
  364. package/dist/utils/types.js.map +1 -0
  365. package/dist/utils/types.test.d.ts +2 -0
  366. package/dist/utils/types.test.d.ts.map +1 -0
  367. package/dist/utils/types.test.js +89 -0
  368. package/dist/utils/types.test.js.map +1 -0
  369. package/package.json +14 -9
  370. package/dist/Account.d.ts +0 -11
  371. package/dist/Account.d.ts.map +0 -1
  372. package/dist/Account.js +0 -46
  373. package/dist/Account.js.map +0 -1
  374. package/dist/Entity.d.ts +0 -12
  375. package/dist/Entity.d.ts.map +0 -1
  376. package/dist/Entity.js.map +0 -1
  377. package/dist/IndexerQueries/assetSnapshots.d.ts.map +0 -1
  378. package/dist/IndexerQueries/assetSnapshots.js.map +0 -1
  379. package/dist/IndexerQueries/assetTransactions.d.ts.map +0 -1
  380. package/dist/IndexerQueries/assetTransactions.js.map +0 -1
  381. package/dist/IndexerQueries/index.d.ts.map +0 -1
  382. package/dist/IndexerQueries/index.js.map +0 -1
  383. package/dist/IndexerQueries/investorTransactions.d.ts.map +0 -1
  384. package/dist/IndexerQueries/investorTransactions.js.map +0 -1
  385. package/dist/IndexerQueries/poolFeeSnapshots.d.ts.map +0 -1
  386. package/dist/IndexerQueries/poolFeeSnapshots.js.map +0 -1
  387. package/dist/IndexerQueries/poolFeeTransactions.d.ts.map +0 -1
  388. package/dist/IndexerQueries/poolFeeTransactions.js.map +0 -1
  389. package/dist/IndexerQueries/poolSnapshots.d.ts.map +0 -1
  390. package/dist/IndexerQueries/poolSnapshots.js.map +0 -1
  391. package/dist/IndexerQueries/trancheCurrencyBalance.d.ts.map +0 -1
  392. package/dist/IndexerQueries/trancheCurrencyBalance.js +0 -103
  393. package/dist/IndexerQueries/trancheCurrencyBalance.js.map +0 -1
  394. package/dist/IndexerQueries/trancheSnapshots.d.ts.map +0 -1
  395. package/dist/IndexerQueries/trancheSnapshots.js.map +0 -1
  396. package/dist/Pool.d.ts +0 -27
  397. package/dist/Pool.d.ts.map +0 -1
  398. package/dist/Pool.js +0 -76
  399. package/dist/Pool.js.map +0 -1
  400. package/dist/PoolNetwork.d.ts +0 -82
  401. package/dist/PoolNetwork.d.ts.map +0 -1
  402. package/dist/PoolNetwork.js +0 -236
  403. package/dist/PoolNetwork.js.map +0 -1
  404. package/dist/Reports/Processor.d.ts.map +0 -1
  405. package/dist/Reports/Processor.js.map +0 -1
  406. package/dist/Reports/index.d.ts +0 -27
  407. package/dist/Reports/index.d.ts.map +0 -1
  408. package/dist/Reports/index.js.map +0 -1
  409. package/dist/Vault.d.ts +0 -96
  410. package/dist/Vault.d.ts.map +0 -1
  411. package/dist/Vault.js +0 -330
  412. package/dist/Vault.js.map +0 -1
  413. package/dist/abi/CentrifugeRouter.abi.json +0 -43
  414. package/dist/abi/Currency.abi.json +0 -14
  415. package/dist/abi/Gateway.abi.json +0 -1
  416. package/dist/abi/InvestmentManager.abi.json +0 -4
  417. package/dist/abi/LiquidityPool.abi.json +0 -79
  418. package/dist/abi/PoolManager.abi.json +0 -55
  419. package/dist/abi/RestrictionManager.abi.json +0 -22
  420. package/dist/abi/Router.abi.json +0 -1
  421. package/dist/config/lp.d.ts +0 -17
  422. package/dist/config/lp.d.ts.map +0 -1
  423. package/dist/config/lp.js +0 -35
  424. package/dist/config/lp.js.map +0 -1
  425. package/dist/utils/pinToApi.d.ts +0 -2
  426. package/dist/utils/pinToApi.d.ts.map +0 -1
  427. package/dist/utils/pinToApi.js +0 -10
  428. package/dist/utils/pinToApi.js.map +0 -1
@@ -0,0 +1,767 @@
1
+ import { expect } from 'chai';
2
+ import { mockAssetSnapshots } from '../../tests/mocks/mockAssetSnapshots.js';
3
+ import { mockAssetTransactions } from '../../tests/mocks/mockAssetTransactions.js';
4
+ import { mockEpochs } from '../../tests/mocks/mockEpochs.js';
5
+ import { mockInvestorCurrencyBalances } from '../../tests/mocks/mockInvestorCurrencyBalance.js';
6
+ import { mockInvestorTransactions } from '../../tests/mocks/mockInvestorTransactions.js';
7
+ import { mockPoolFeeSnapshots } from '../../tests/mocks/mockPoolFeeSnapshot.js';
8
+ import { mockFeeTransactions } from '../../tests/mocks/mockPoolFeeTransactions.js';
9
+ import { mockPoolMetadata } from '../../tests/mocks/mockPoolMetadata.js';
10
+ import { mockPoolSnapshots } from '../../tests/mocks/mockPoolSnapshots.js';
11
+ import { mockTrancheSnapshots } from '../../tests/mocks/mockTrancheSnapshots.js';
12
+ import { Balance, Price } from '../../utils/BigInt.js';
13
+ import { processor } from './Processor.js';
14
+ describe('Processor', () => {
15
+ describe('balanceSheet processor', () => {
16
+ it('should return empty array when no pool snapshots found', () => {
17
+ expect(processor.balanceSheet({
18
+ poolSnapshots: [],
19
+ trancheSnapshots: {},
20
+ })).to.deep.equal([]);
21
+ });
22
+ it('should process pool and tranche data correctly', () => {
23
+ const result = processor.balanceSheet({
24
+ poolSnapshots: mockPoolSnapshots,
25
+ trancheSnapshots: mockTrancheSnapshots,
26
+ });
27
+ expect(result).to.have.lengthOf(2);
28
+ const report = result[0];
29
+ expect(report.timestamp).to.equal('2024-01-01T12:00:00Z');
30
+ expect(report.assetValuation.toBigInt()).to.equal(0n);
31
+ expect(report.onchainReserve.toBigInt()).to.equal(0n);
32
+ expect(report.offchainCash.toBigInt()).to.equal(0n);
33
+ expect(report.accruedFees.toBigInt()).to.equal(0n);
34
+ expect(report.netAssetValue.toBigInt()).to.equal(0n);
35
+ expect(report.tranches.length).to.equal(2);
36
+ const seniorTranche = report.tranches.find((t) => t.tokenId === 'senior');
37
+ const juniorTranche = report.tranches.find((t) => t.tokenId === 'junior');
38
+ expect(seniorTranche?.tokenPrice.toBigInt()).to.equal(1000000000000000000n);
39
+ expect(juniorTranche?.tokenPrice.toBigInt()).to.equal(1120000000000000000n);
40
+ expect(report.totalCapital?.toBigInt()).to.equal(0n);
41
+ });
42
+ it('should group data by day when specified', () => {
43
+ const result = processor.balanceSheet({
44
+ poolSnapshots: mockPoolSnapshots,
45
+ trancheSnapshots: mockTrancheSnapshots,
46
+ }, { groupBy: 'day' });
47
+ expect(result).to.have.lengthOf(2);
48
+ expect(result?.[0]?.timestamp.slice(0, 10)).to.equal('2024-01-01');
49
+ expect(result?.[1]?.timestamp.slice(0, 10)).to.equal('2024-01-02');
50
+ });
51
+ it('should group data by month when specified', () => {
52
+ const result = processor.balanceSheet({
53
+ poolSnapshots: mockPoolSnapshots,
54
+ trancheSnapshots: mockTrancheSnapshots,
55
+ }, { groupBy: 'month' });
56
+ expect(result).to.have.lengthOf(1);
57
+ expect(result?.[0]?.timestamp.slice(0, 10)).to.equal('2024-01-02');
58
+ });
59
+ });
60
+ describe('cashflow processor', () => {
61
+ const mockCashflowPoolSnapshots = [
62
+ {
63
+ ...mockPoolSnapshots[0],
64
+ id: 'pool-10',
65
+ timestamp: '2024-01-01T12:00:00Z',
66
+ sumPrincipalRepaidAmountByPeriod: Balance.fromFloat(1, 6), // 1.0
67
+ sumInterestRepaidAmountByPeriod: Balance.fromFloat(0.05, 6), // 0.05
68
+ sumBorrowedAmountByPeriod: Balance.fromFloat(2, 6), // 2.0
69
+ },
70
+ {
71
+ ...mockPoolSnapshots[0],
72
+ id: 'pool-11',
73
+ timestamp: '2024-01-01T18:00:00Z', // Same day, different time
74
+ sumPrincipalRepaidAmountByPeriod: Balance.fromFloat(0.5, 6), // 0.5
75
+ sumInterestRepaidAmountByPeriod: Balance.fromFloat(0.025, 6), // 0.025
76
+ sumBorrowedAmountByPeriod: Balance.fromFloat(1, 6), // 1.0
77
+ },
78
+ {
79
+ ...mockPoolSnapshots[0],
80
+ id: 'pool-12',
81
+ timestamp: '2024-01-02T12:00:00Z', // Next day
82
+ sumPrincipalRepaidAmountByPeriod: Balance.fromFloat(2, 6), // 2.0
83
+ sumInterestRepaidAmountByPeriod: Balance.fromFloat(0.1, 6), // 0.1
84
+ sumBorrowedAmountByPeriod: Balance.fromFloat(4, 6), // 4.0
85
+ },
86
+ ];
87
+ const mockCashflowFeeSnapshots = {
88
+ '2024-01-01': [
89
+ {
90
+ ...mockPoolFeeSnapshots['2024-01-01']?.[0],
91
+ poolFee: { name: 'serviceFee' },
92
+ sumPaidAmountByPeriod: new Balance(1000000n, 6), // 1.0
93
+ sumAccruedAmountByPeriod: new Balance(500000n, 6), // 0.5
94
+ },
95
+ {
96
+ ...mockPoolFeeSnapshots['2024-01-01']?.[1],
97
+ poolFee: { name: 'adminFee' },
98
+ sumPaidAmountByPeriod: new Balance(2000000n, 6), // 2.0
99
+ sumAccruedAmountByPeriod: new Balance(1000000n, 6), // 1.0
100
+ },
101
+ ],
102
+ '2024-01-02': [
103
+ {
104
+ ...mockPoolFeeSnapshots['2024-01-02']?.[0],
105
+ poolFee: { name: 'serviceFee' },
106
+ sumPaidAmountByPeriod: new Balance(3000000n, 6), // 3.0
107
+ sumAccruedAmountByPeriod: new Balance(1500000n, 6), // 1.5
108
+ },
109
+ {
110
+ ...mockPoolFeeSnapshots['2024-01-02']?.[1],
111
+ poolFee: { name: 'adminFee' },
112
+ sumPaidAmountByPeriod: new Balance(4000000n, 6), // 4.0
113
+ sumAccruedAmountByPeriod: new Balance(2000000n, 6), // 2.0
114
+ },
115
+ ],
116
+ };
117
+ it('should return empty array when no snapshots found', () => {
118
+ expect(processor.cashflow({ poolSnapshots: [], poolFeeSnapshots: {}, metadata: undefined })).to.deep.equal([]);
119
+ });
120
+ it('should throw an error if no metadata is passed', () => {
121
+ let thrown = false;
122
+ try {
123
+ processor.cashflow({
124
+ poolSnapshots: mockPoolSnapshots,
125
+ poolFeeSnapshots: mockPoolFeeSnapshots,
126
+ metadata: undefined,
127
+ });
128
+ }
129
+ catch {
130
+ thrown = true;
131
+ }
132
+ expect(thrown).to.be.true;
133
+ });
134
+ it('should aggregate values correctly when grouping by day', () => {
135
+ const result = processor.cashflow({
136
+ poolSnapshots: mockCashflowPoolSnapshots,
137
+ poolFeeSnapshots: mockCashflowFeeSnapshots,
138
+ metadata: mockPoolMetadata,
139
+ }, { groupBy: 'day' });
140
+ expect(result).to.have.lengthOf(2);
141
+ const jan1 = result[0];
142
+ expect(jan1?.timestamp.slice(0, 10)).to.equal('2024-01-01');
143
+ expect(jan1?.principalPayments.toFloat()).to.equal(1.5); // 1.0 + 0.5
144
+ expect(jan1?.interestPayments.toFloat()).to.equal(0.075); // 0.05 + 0.025
145
+ expect(jan1?.subtype === 'privateCredit' ? jan1?.assetFinancing?.toFloat() : jan1?.assetPurchases?.toFloat()).to.equal(3); // 2.0 + 1.0
146
+ expect(jan1?.fees.length).to.equal(2);
147
+ expect(jan1?.fees[0]?.name).to.equal('serviceFee');
148
+ expect(jan1?.fees[1]?.name).to.equal('adminFee');
149
+ expect(jan1?.fees[0]?.amount.toFloat()).to.equal(1);
150
+ expect(jan1?.fees[1]?.amount.toFloat()).to.equal(2);
151
+ expect(jan1?.fees[0]?.timestamp.slice(0, 10)).to.equal('2024-01-01');
152
+ expect(jan1?.fees[1]?.timestamp.slice(0, 10)).to.equal('2024-01-01');
153
+ const jan2 = result[1];
154
+ expect(jan2?.timestamp.slice(0, 10)).to.equal('2024-01-02');
155
+ expect(jan2?.principalPayments.toFloat()).to.equal(2); // 2.0
156
+ expect(jan2?.interestPayments.toFloat()).to.equal(0.1); // 0.1
157
+ expect(jan2?.subtype === 'privateCredit' ? jan2?.assetFinancing?.toFloat() : jan2?.assetPurchases?.toFloat()).to.equal(4); // 4.0
158
+ expect(jan2?.fees.length).to.equal(2);
159
+ expect(jan2?.fees[0]?.name).to.equal('serviceFee');
160
+ expect(jan2?.fees[1]?.name).to.equal('adminFee');
161
+ expect(jan2?.fees[0]?.amount.toFloat()).to.equal(3);
162
+ expect(jan2?.fees[1]?.amount.toFloat()).to.equal(4);
163
+ expect(jan2?.fees[0]?.timestamp.slice(0, 10)).to.equal('2024-01-02');
164
+ expect(jan2?.fees[1]?.timestamp.slice(0, 10)).to.equal('2024-01-02');
165
+ });
166
+ it('should aggregate values correctly when grouping by month', () => {
167
+ const result = processor.cashflow({
168
+ poolSnapshots: mockCashflowPoolSnapshots,
169
+ poolFeeSnapshots: mockCashflowFeeSnapshots,
170
+ metadata: mockPoolMetadata,
171
+ }, { groupBy: 'month' });
172
+ expect(result).to.have.lengthOf(1);
173
+ const january = result[0];
174
+ expect(january?.timestamp.slice(0, 10)).to.equal('2024-01-02'); // Grouping by month returns the last day of the period
175
+ expect(january?.principalPayments.toFloat()).to.equal(3.5); // 1.0 + 0.5 + 2.0
176
+ expect(january?.interestPayments.toFloat()).to.equal(0.175); // 0.05 + 0.025 + 0.1
177
+ expect(january?.subtype === 'privateCredit' ? january?.assetFinancing?.toFloat() : january?.assetPurchases?.toFloat()).to.equal(7); // 2.0 + 1.0 + 4.0
178
+ expect(january?.fees.length).to.equal(2);
179
+ expect(january?.fees[0]?.name).to.equal('serviceFee');
180
+ expect(january?.fees[1]?.name).to.equal('adminFee');
181
+ // fees are NOT aggregated by period
182
+ expect(january?.fees[0]?.amount.toFloat()).to.equal(3);
183
+ expect(january?.fees[1]?.amount.toFloat()).to.equal(4);
184
+ });
185
+ it('should return realizedPL if pool is public credit', () => {
186
+ const result = processor.cashflow({
187
+ poolSnapshots: mockCashflowPoolSnapshots,
188
+ poolFeeSnapshots: mockCashflowFeeSnapshots,
189
+ metadata: {
190
+ ...mockPoolMetadata,
191
+ pool: { ...mockPoolMetadata.pool, asset: { ...mockPoolMetadata.pool.asset, class: 'Public credit' } },
192
+ },
193
+ }, { groupBy: 'day' });
194
+ expect(result?.[0]).to.have.property('realizedPL');
195
+ });
196
+ });
197
+ describe('profit and loss processor', () => {
198
+ const mockPLPoolSnapshots = [
199
+ {
200
+ ...mockPoolSnapshots[0],
201
+ id: 'pool-10',
202
+ timestamp: '2024-01-01T12:00:00Z',
203
+ sumInterestRepaidAmountByPeriod: Balance.fromFloat(0.05, 6), // 0.05
204
+ sumInterestAccruedByPeriod: Balance.fromFloat(0.1, 6), // 0.1
205
+ sumDebtWrittenOffByPeriod: Balance.fromFloat(0.02, 6), // 0.02
206
+ sumUnscheduledRepaidAmountByPeriod: Balance.fromFloat(0.01, 6), // 0.01
207
+ sumUnrealizedProfitByPeriod: Balance.fromFloat(0.15, 6), // 0.15
208
+ },
209
+ {
210
+ ...mockPoolSnapshots[1],
211
+ id: 'pool-11',
212
+ timestamp: '2024-01-02T12:00:00Z',
213
+ sumInterestRepaidAmountByPeriod: Balance.fromFloat(0.1, 6),
214
+ sumInterestAccruedByPeriod: Balance.fromFloat(0.2, 6),
215
+ sumDebtWrittenOffByPeriod: Balance.fromFloat(0.03, 6),
216
+ sumUnscheduledRepaidAmountByPeriod: Balance.fromFloat(0.02, 6),
217
+ sumUnrealizedProfitByPeriod: Balance.fromFloat(0.25, 6),
218
+ },
219
+ ];
220
+ const mockPLFeeSnapshots = {
221
+ '2024-01-01': [
222
+ {
223
+ poolFee: { name: 'serviceFee' },
224
+ sumAccruedAmountByPeriod: Balance.fromFloat(0.01, 6),
225
+ sumChargedAmountByPeriod: Balance.fromFloat(0.02, 6),
226
+ timestamp: '2024-01-01T12:00:00Z',
227
+ poolFeeId: 'pool-fee-1',
228
+ },
229
+ ],
230
+ '2024-01-02': [
231
+ {
232
+ poolFee: { name: 'serviceFee' },
233
+ sumAccruedAmountByPeriod: Balance.fromFloat(0.02, 6),
234
+ sumChargedAmountByPeriod: Balance.fromFloat(0.03, 6),
235
+ timestamp: '2024-01-02T12:00:00Z',
236
+ poolFeeId: 'pool-fee-2',
237
+ },
238
+ ],
239
+ };
240
+ it('should return empty array when no snapshots found', () => {
241
+ expect(processor.profitAndLoss({ poolSnapshots: [], poolFeeSnapshots: {}, metadata: undefined })).to.deep.equal([]);
242
+ });
243
+ it('should handle undefined metadata', () => {
244
+ let thrown = false;
245
+ try {
246
+ processor.profitAndLoss({
247
+ poolSnapshots: mockPLPoolSnapshots,
248
+ poolFeeSnapshots: mockPLFeeSnapshots,
249
+ metadata: undefined,
250
+ });
251
+ }
252
+ catch {
253
+ thrown = true;
254
+ }
255
+ expect(thrown).to.be.true;
256
+ });
257
+ it('should process private credit pool data correctly', () => {
258
+ const result = processor.profitAndLoss({
259
+ poolSnapshots: mockPLPoolSnapshots,
260
+ poolFeeSnapshots: mockPLFeeSnapshots,
261
+ metadata: mockPoolMetadata, // defaults to private credit
262
+ });
263
+ expect(result).to.have.lengthOf(2);
264
+ const firstDay = result[0];
265
+ expect(firstDay?.subtype).to.equal('privateCredit');
266
+ expect(firstDay).to.have.property('interestAccrued');
267
+ expect(firstDay).to.have.property('assetWriteOffs');
268
+ expect(firstDay?.interestAccrued.toFloat()).to.equal(0.1);
269
+ expect(firstDay?.assetWriteOffs.toFloat()).to.equal(0.02);
270
+ expect(firstDay?.interestPayments.toFloat()).to.equal(0.05);
271
+ expect(firstDay?.otherPayments.toFloat()).to.equal(0.01);
272
+ expect(firstDay?.profitAndLossFromAsset.toFloat()).to.equal(0.16); // 0.05 + 0.1 + 0.02 - 0.01
273
+ });
274
+ it('should process public credit pool correctly', () => {
275
+ const result = processor.profitAndLoss({
276
+ poolSnapshots: mockPLPoolSnapshots,
277
+ poolFeeSnapshots: mockPLFeeSnapshots,
278
+ metadata: {
279
+ ...mockPoolMetadata,
280
+ pool: {
281
+ ...mockPoolMetadata.pool,
282
+ asset: { ...mockPoolMetadata.pool.asset, class: 'Public credit' },
283
+ },
284
+ },
285
+ });
286
+ expect(result).to.have.lengthOf(2);
287
+ const firstDay = result[0];
288
+ expect(firstDay?.subtype).to.equal('publicCredit');
289
+ expect(firstDay?.profitAndLossFromAsset.toFloat()).to.equal(0.15); // unrealized profit
290
+ expect(firstDay?.interestPayments.toFloat()).to.equal(0.05);
291
+ expect(firstDay?.otherPayments.toFloat()).to.equal(0.01);
292
+ expect(firstDay).to.have.property('totalIncome');
293
+ expect(firstDay?.totalIncome.toFloat()).to.equal(0.21); // 0.15 + 0.05 + 0.01
294
+ });
295
+ it('should aggregate values correctly when grouping by month', () => {
296
+ const result = processor.profitAndLoss({
297
+ poolSnapshots: mockPLPoolSnapshots,
298
+ poolFeeSnapshots: mockPLFeeSnapshots,
299
+ metadata: mockPoolMetadata,
300
+ }, { groupBy: 'month' });
301
+ expect(result).to.have.lengthOf(1);
302
+ const january = result[0];
303
+ expect(january?.timestamp.slice(0, 10)).to.equal('2024-01-02');
304
+ expect(january?.interestPayments.toFloat()).to.equal(0.15); // 0.05 + 0.1
305
+ expect(january?.otherPayments.toFloat()).to.equal(0.03); // 0.01 + 0.02
306
+ });
307
+ it('should make sure timestamp for pool state and pool fee match', () => {
308
+ const result = processor.profitAndLoss({
309
+ poolSnapshots: mockPLPoolSnapshots,
310
+ poolFeeSnapshots: mockPLFeeSnapshots,
311
+ metadata: mockPoolMetadata,
312
+ });
313
+ expect(result[0]?.timestamp.slice(0, 10)).to.equal('2024-01-01');
314
+ expect(result[0]?.fees?.[0]?.timestamp.slice(0, 10)).to.equal('2024-01-01');
315
+ });
316
+ });
317
+ describe('investor transactions processor', () => {
318
+ it('should return empty array when no transactions found', () => {
319
+ expect(processor.investorTransactions({ investorTransactions: [] })).to.deep.equal([]);
320
+ });
321
+ it('should process investor transactions correctly without filters', () => {
322
+ const result = processor.investorTransactions({
323
+ investorTransactions: mockInvestorTransactions,
324
+ });
325
+ expect(result).to.have.lengthOf(2);
326
+ const firstTx = result[0];
327
+ expect(firstTx?.timestamp.slice(0, 10)).to.equal('2024-01-01');
328
+ expect(firstTx?.chainId).to.equal(1);
329
+ expect(firstTx?.account).to.equal('0x123a');
330
+ expect(firstTx?.epoch).to.equal('1');
331
+ expect(firstTx?.transactionType).to.equal('INVEST_ORDER_UPDATE');
332
+ expect(firstTx?.currencyAmount.toFloat()).to.equal(1.0);
333
+ expect(firstTx?.trancheTokenAmount.toFloat()).to.equal(0.9);
334
+ expect(firstTx?.price.toString()).to.equal('1100000000000000000');
335
+ expect(firstTx?.transactionHash).to.equal('0xabc');
336
+ });
337
+ it('should filter by tokenId', () => {
338
+ const mockInvestorTransactionsWithJunior = [
339
+ ...mockInvestorTransactions,
340
+ {
341
+ ...mockInvestorTransactions[0],
342
+ trancheId: 'junior',
343
+ },
344
+ ];
345
+ const result = processor.investorTransactions({
346
+ investorTransactions: mockInvestorTransactionsWithJunior,
347
+ }, { tokenId: 'senior' });
348
+ expect(result).to.have.lengthOf(2);
349
+ expect(result[0]?.trancheTokenId).to.equal('senior');
350
+ });
351
+ it('should filter by address', () => {
352
+ const result = processor.investorTransactions({
353
+ investorTransactions: mockInvestorTransactions,
354
+ }, { address: '0x123a' });
355
+ expect(result).to.have.lengthOf(1);
356
+ expect(result[0]?.account).to.equal('0x123a');
357
+ });
358
+ it('should filter by network', () => {
359
+ const mockInvestorTransactionsWithNetwork = [
360
+ ...mockInvestorTransactions,
361
+ {
362
+ ...mockInvestorTransactions[0],
363
+ chainId: 2,
364
+ },
365
+ ];
366
+ const result = processor.investorTransactions({
367
+ investorTransactions: mockInvestorTransactionsWithNetwork,
368
+ }, { network: 2 });
369
+ expect(result).to.have.lengthOf(1);
370
+ expect(result[0]?.chainId).to.equal(2);
371
+ });
372
+ it('should filter by all networks', () => {
373
+ const result = processor.investorTransactions({
374
+ investorTransactions: mockInvestorTransactions,
375
+ }, { network: 'all' });
376
+ expect(result).to.have.lengthOf(2);
377
+ });
378
+ it('should filter by centrifuge network', () => {
379
+ const mockInvestorTransactionsWithCentrifuge = [
380
+ ...mockInvestorTransactions,
381
+ {
382
+ ...mockInvestorTransactions[0],
383
+ chainId: 'centrifuge',
384
+ },
385
+ ];
386
+ const result = processor.investorTransactions({
387
+ investorTransactions: mockInvestorTransactionsWithCentrifuge,
388
+ }, { network: 'centrifuge' });
389
+ expect(result).to.have.lengthOf(1);
390
+ expect(result[0]?.chainId).to.equal('centrifuge');
391
+ });
392
+ it('should filter by transaction type', () => {
393
+ const result = processor.investorTransactions({
394
+ investorTransactions: mockInvestorTransactions,
395
+ }, { transactionType: 'orders' });
396
+ expect(result).to.have.lengthOf(1);
397
+ expect(result[0]?.transactionType).to.equal('INVEST_ORDER_UPDATE');
398
+ });
399
+ it('should filter by network and transaction type', () => {
400
+ const mockInvestorTransactionsWithNetworkAndOrders = [
401
+ ...mockInvestorTransactions,
402
+ {
403
+ ...mockInvestorTransactions[0],
404
+ chainId: 2,
405
+ },
406
+ ];
407
+ const result = processor.investorTransactions({
408
+ investorTransactions: mockInvestorTransactionsWithNetworkAndOrders,
409
+ }, { network: 1, transactionType: 'orders' });
410
+ expect(result).to.have.lengthOf(1);
411
+ expect(result[0]?.chainId).to.equal(1);
412
+ expect(result[0]?.transactionType).to.equal('INVEST_ORDER_UPDATE');
413
+ });
414
+ it('should return an empty array when no filters match', () => {
415
+ const result = processor.investorTransactions({
416
+ investorTransactions: mockInvestorTransactions,
417
+ }, { network: 2, transactionType: 'executions' });
418
+ expect(result).to.deep.equal([]);
419
+ });
420
+ });
421
+ describe('asset transactions processor', () => {
422
+ it('should return empty array when no transactions found', () => {
423
+ expect(processor.assetTransactions({ assetTransactions: [] })).to.deep.equal([]);
424
+ });
425
+ it('should process asset transactions correctly without filters', () => {
426
+ const result = processor.assetTransactions({
427
+ assetTransactions: mockAssetTransactions,
428
+ });
429
+ expect(result).to.have.lengthOf(3);
430
+ });
431
+ it('should filter by assetId', () => {
432
+ const result = processor.assetTransactions({
433
+ assetTransactions: mockAssetTransactions,
434
+ }, { assetId: '1' });
435
+ expect(result).to.have.lengthOf(2);
436
+ });
437
+ it('should filter by transaction type', () => {
438
+ const types = [
439
+ { type: 'created', expected: 0 },
440
+ { type: 'financed', expected: 1 },
441
+ { type: 'repaid', expected: 1 },
442
+ { type: 'priced', expected: 0 },
443
+ { type: 'closed', expected: 0 },
444
+ { type: 'cashTransfer', expected: 1 },
445
+ ];
446
+ for (const { type, expected } of types) {
447
+ const result = processor.assetTransactions({
448
+ assetTransactions: mockAssetTransactions,
449
+ }, { transactionType: type });
450
+ expect(result).to.have.lengthOf(expected);
451
+ }
452
+ });
453
+ it('should make sure all the fields exist', () => {
454
+ const result = processor.assetTransactions({ assetTransactions: mockAssetTransactions });
455
+ expect(result).to.have.lengthOf(3);
456
+ expect(result[0]).to.have.property('type');
457
+ expect(result[0]).to.have.property('timestamp');
458
+ expect(result[0]).to.have.property('assetId');
459
+ expect(result[0]).to.have.property('transactionType');
460
+ expect(result[0]).to.have.property('amount');
461
+ expect(result[0]).to.have.property('epoch');
462
+ expect(result[0]).to.have.property('transactionHash');
463
+ expect(result[0]).to.have.property('fromAsset'); // optional
464
+ expect(result[1]).to.have.property('toAsset'); // optional
465
+ });
466
+ });
467
+ describe('fee transactions processor', () => {
468
+ it('should return empty array when no transactions found', () => {
469
+ expect(processor.feeTransactions({ poolFeeTransactions: [] })).to.deep.equal([]);
470
+ });
471
+ it('should process fee transactions correctly', () => {
472
+ const result = processor.feeTransactions({ poolFeeTransactions: mockFeeTransactions });
473
+ expect(result).to.have.lengthOf(2);
474
+ });
475
+ it('should filter by transaction type all', () => {
476
+ const result = processor.feeTransactions({ poolFeeTransactions: mockFeeTransactions }, { transactionType: 'all' });
477
+ expect(result).to.have.lengthOf(2);
478
+ });
479
+ it('should filter by transaction type accrued', () => {
480
+ const result = processor.feeTransactions({ poolFeeTransactions: mockFeeTransactions }, { transactionType: 'accrued' });
481
+ expect(result).to.have.lengthOf(1);
482
+ });
483
+ it('should filter by transaction type paid', () => {
484
+ const result = processor.feeTransactions({ poolFeeTransactions: mockFeeTransactions }, { transactionType: 'paid' });
485
+ expect(result).to.have.lengthOf(1);
486
+ });
487
+ it('should return an empty array when no filters match', () => {
488
+ const result = processor.feeTransactions({ poolFeeTransactions: mockFeeTransactions }, { transactionType: 'directChargeMade' });
489
+ expect(result).to.deep.equal([]);
490
+ });
491
+ });
492
+ describe('token price processor', () => {
493
+ it('should return empty array when no snapshots found', () => {
494
+ expect(processor.tokenPrice({ trancheSnapshots: {} })).to.deep.equal([]);
495
+ });
496
+ it('should process token price correctly', () => {
497
+ const result = processor.tokenPrice({ trancheSnapshots: mockTrancheSnapshots });
498
+ expect(result).to.have.lengthOf(2);
499
+ expect(result[0]?.tranches[0]?.price?.toDecimal().toString()).to.equal('1');
500
+ expect(result[0]?.tranches[0]?.id).to.equal('senior');
501
+ });
502
+ it('should group by month', () => {
503
+ const result = processor.tokenPrice({ trancheSnapshots: mockTrancheSnapshots }, { groupBy: 'month' });
504
+ expect(result).to.have.lengthOf(1);
505
+ });
506
+ it('should make sure all fields are present', () => {
507
+ const result = processor.tokenPrice({ trancheSnapshots: mockTrancheSnapshots }, { groupBy: 'day' });
508
+ expect(result).to.have.lengthOf(2);
509
+ expect(result[0]).to.have.property('tranches');
510
+ expect(result[0]).to.have.property('timestamp');
511
+ expect(result[0]?.tranches[0]).to.have.property('id');
512
+ expect(result[0]?.tranches[0]).to.have.property('yieldMTD');
513
+ expect(result[0]?.tranches[0]).to.have.property('yieldQTD');
514
+ expect(result[0]?.tranches[0]).to.have.property('yieldYTD');
515
+ expect(result[0]?.tranches[0]).to.have.property('yield7daysAnnualized');
516
+ expect(result[0]?.tranches[0]).to.have.property('yield30daysAnnualized');
517
+ expect(result[0]?.tranches[0]).to.have.property('yield90daysAnnualized');
518
+ expect(result[0]?.tranches[0]).to.have.property('timestamp');
519
+ expect(result[0]?.tranches[0]).to.have.property('supply');
520
+ expect(result[0]?.tranches[0]).to.have.property('price');
521
+ });
522
+ });
523
+ describe('asset list processor', () => {
524
+ it('should return empty array when no snapshots found', () => {
525
+ expect(processor.assetList({ assetSnapshots: [], metadata: undefined })).to.deep.equal([]);
526
+ });
527
+ it('should throw an error if no metadata is passed', () => {
528
+ let thrown = false;
529
+ try {
530
+ processor.assetList({ assetSnapshots: mockAssetSnapshots, metadata: undefined });
531
+ }
532
+ catch {
533
+ thrown = true;
534
+ }
535
+ expect(thrown).to.be.true;
536
+ });
537
+ it('should process asset list correctly', () => {
538
+ const result = processor.assetList({ assetSnapshots: mockAssetSnapshots, metadata: mockPoolMetadata });
539
+ expect(result).to.have.lengthOf(2);
540
+ });
541
+ it('should filter by status ongoing', () => {
542
+ const result = processor.assetList({ assetSnapshots: mockAssetSnapshots, metadata: mockPoolMetadata }, { status: 'ongoing' });
543
+ expect(result).to.have.lengthOf(2);
544
+ });
545
+ it('should filter by status repaid', () => {
546
+ const result = processor.assetList({ assetSnapshots: mockAssetSnapshots, metadata: mockPoolMetadata }, { status: 'repaid' });
547
+ expect(result).to.have.lengthOf(0);
548
+ });
549
+ it('should filter by status overdue', () => {
550
+ const mockAssetSnapshotsOverdue = [
551
+ ...mockAssetSnapshots,
552
+ { ...mockAssetSnapshots[0], actualMaturityDate: '2023-01-01' },
553
+ ];
554
+ const result = processor.assetList({ assetSnapshots: mockAssetSnapshotsOverdue, metadata: mockPoolMetadata }, { status: 'overdue' });
555
+ expect(result).to.have.lengthOf(1);
556
+ });
557
+ it('should return the correct data for private credit pools', () => {
558
+ const result = processor.assetList({ assetSnapshots: mockAssetSnapshots, metadata: mockPoolMetadata }, { status: 'ongoing' });
559
+ expect(result).to.have.lengthOf(2);
560
+ expect(result?.[0]).to.have.property('outstandingPrincipal');
561
+ expect(result?.[0]).to.have.property('outstandingInterest');
562
+ expect(result?.[0]).to.have.property('repaidPrincipal');
563
+ expect(result?.[0]).to.have.property('repaidInterest');
564
+ expect(result?.[0]).to.have.property('repaidUnscheduled');
565
+ expect(result?.[0]).to.have.property('originationDate');
566
+ expect(result?.[0]).to.have.property('maturityDate');
567
+ expect(result?.[0]).to.have.property('valuationMethod');
568
+ expect(result?.[0]).to.have.property('advanceRate');
569
+ expect(result?.[0]).to.have.property('collateralValue');
570
+ expect(result?.[0]).to.have.property('probabilityOfDefault');
571
+ expect(result?.[0]).to.have.property('lossGivenDefault');
572
+ expect(result?.[0]).to.have.property('discountRate');
573
+ expect(result?.[0]).to.have.property('name');
574
+ });
575
+ it('should return the correct data for public credit pools', () => {
576
+ const result = processor.assetList({
577
+ assetSnapshots: mockAssetSnapshots,
578
+ metadata: {
579
+ ...mockPoolMetadata,
580
+ pool: { ...mockPoolMetadata.pool, asset: { ...mockPoolMetadata.pool.asset, class: 'Public credit' } },
581
+ },
582
+ }, { status: 'ongoing' });
583
+ expect(result).to.have.lengthOf(2);
584
+ expect(result?.[0]).to.have.property('faceValue');
585
+ expect(result?.[0]).to.have.property('outstandingQuantity');
586
+ expect(result?.[0]).to.have.property('currentPrice');
587
+ expect(result?.[0]).to.have.property('unrealizedProfit');
588
+ expect(result?.[0]).to.have.property('realizedProfit');
589
+ expect(result?.[0]).to.have.property('name');
590
+ });
591
+ });
592
+ describe('investor list processor', () => {
593
+ it('should return empty array when no balances found', () => {
594
+ expect(processor.investorList({ trancheCurrencyBalance: [] })).to.deep.equal([]);
595
+ });
596
+ it('should filter by network', () => {
597
+ const result = processor.investorList({ trancheCurrencyBalance: mockInvestorCurrencyBalances }, { network: 1 });
598
+ expect(result).to.have.lengthOf(1);
599
+ });
600
+ it('should filter by centrifuge network', () => {
601
+ const result = processor.investorList({ trancheCurrencyBalance: mockInvestorCurrencyBalances }, { network: 'centrifuge' });
602
+ expect(result).to.have.lengthOf(1);
603
+ });
604
+ it('should filter by address', () => {
605
+ const result = processor.investorList({ trancheCurrencyBalance: mockInvestorCurrencyBalances }, { address: '0x123' });
606
+ expect(result).to.have.lengthOf(1);
607
+ });
608
+ it('should filter by trancheId', () => {
609
+ const result = processor.investorList({ trancheCurrencyBalance: mockInvestorCurrencyBalances }, { trancheId: 'tranche-1' });
610
+ expect(result).to.have.lengthOf(2);
611
+ const result2 = processor.investorList({ trancheCurrencyBalance: mockInvestorCurrencyBalances }, { trancheId: 'tranche-2' });
612
+ expect(result2).to.have.lengthOf(0);
613
+ });
614
+ it('should make sure all the fields exist', () => {
615
+ const result = processor.investorList({ trancheCurrencyBalance: mockInvestorCurrencyBalances });
616
+ expect(result).to.have.lengthOf(2);
617
+ expect(result[0]).to.have.property('type');
618
+ expect(result[0]).to.have.property('chainId');
619
+ expect(result[0]).to.have.property('accountId');
620
+ expect(result[0]).to.have.property('evmAddress');
621
+ expect(result[0]).to.have.property('position');
622
+ expect(result[0]).to.have.property('poolPercentage');
623
+ expect(result[0]).to.have.property('pendingInvest');
624
+ expect(result[0]).to.have.property('pendingRedeem');
625
+ expect(result[0]).to.have.property('trancheId');
626
+ });
627
+ });
628
+ describe('orders list processor', () => {
629
+ it('should return empty array when no epochs found', () => {
630
+ expect(processor.ordersList({ poolEpochs: [] })).to.deep.equal([]);
631
+ });
632
+ it('should process orders list correctly', () => {
633
+ const result = processor.ordersList({ poolEpochs: mockEpochs });
634
+ expect(result).to.have.lengthOf(2);
635
+ expect(result[0]?.epoch).to.equal('1');
636
+ expect(result[0]?.netAssetValue.toString()).to.equal(Balance.fromFloat(1000, 6).toString());
637
+ expect(result[0]?.navPerShare.toString()).to.equal(new Price(1000000000000000000n).toString());
638
+ expect(result[0]?.lockedInvestments.toString()).to.equal(Balance.fromFloat(1000, 6).toString());
639
+ expect(result[0]?.lockedRedemptions.toString()).to.equal(Balance.fromFloat(100, 6).toString());
640
+ expect(result[0]?.executedInvestments.toString()).to.equal(Balance.fromFloat(900, 6).toString());
641
+ expect(result[0]?.executedRedemptions.toString()).to.equal(Balance.fromFloat(90, 6).toString());
642
+ expect(result[0]?.paidFees.toString()).to.equal(Balance.fromFloat(100, 6).toString());
643
+ });
644
+ });
645
+ describe('asset time series processor', () => {
646
+ it('should return empty array when no snapshots found', () => {
647
+ expect(processor.assetTimeSeries({ assetSnapshots: [] })).to.deep.equal([]);
648
+ });
649
+ it('should process asset time series correctly', () => {
650
+ const result = processor.assetTimeSeries({ assetSnapshots: mockAssetSnapshots });
651
+ expect(result).to.have.lengthOf(2);
652
+ expect(result[0]?.assetId).to.equal('1');
653
+ expect(result[0]?.currentPrice.toString()).to.equal(Balance.fromFloat(1, 6).toString());
654
+ });
655
+ });
656
+ describe('applyGrouping', () => {
657
+ const applyGrouping = processor['applyGrouping'];
658
+ const mockData = [
659
+ { a: Balance.fromFloat(10, 6), timestamp: '2024-01-01' },
660
+ { a: Balance.fromFloat(20, 6), timestamp: '2024-01-01' },
661
+ ];
662
+ it('should return empty array when no items found', () => {
663
+ expect(applyGrouping([], 'day', 'sum')).to.deep.equal([]);
664
+ });
665
+ it('should return items by day when no grouping is specified', () => {
666
+ const latest = applyGrouping(mockData, undefined, 'latest');
667
+ expect(latest).to.deep.equal([{ a: Balance.fromFloat(20, 6), timestamp: '2024-01-01' }]);
668
+ const summed = applyGrouping(mockData, undefined, 'sum');
669
+ expect(summed).to.deep.equal([{ a: Balance.fromFloat(30, 6), timestamp: '2024-01-01' }]);
670
+ });
671
+ it('should return latest item when strategy is latest', () => {
672
+ const grouped = applyGrouping(mockData, 'day', 'latest');
673
+ expect(grouped).to.deep.equal([{ a: Balance.fromFloat(20, 6), timestamp: '2024-01-01' }]);
674
+ });
675
+ it('should aggregate values when strategy is sum', () => {
676
+ const grouped = applyGrouping(mockData, 'day', 'sum');
677
+ expect(grouped).to.deep.equal([{ a: Balance.fromFloat(30, 6), timestamp: '2024-01-01' }]);
678
+ });
679
+ it('should return latest item when strategy is latest and no grouping is specified', () => {
680
+ const grouped = applyGrouping(mockData, undefined, 'latest');
681
+ expect(grouped).to.deep.equal([{ a: Balance.fromFloat(20, 6), timestamp: '2024-01-01' }]);
682
+ });
683
+ it('should aggregate values when strategy is sum and no grouping is specified', () => {
684
+ const grouped = applyGrouping(mockData, undefined, 'sum');
685
+ expect(grouped).to.deep.equal([{ a: Balance.fromFloat(30, 6), timestamp: '2024-01-01' }]);
686
+ });
687
+ it('should return latest item when strategy is latest and grouping is month', () => {
688
+ const extendedMockData = [...mockData, { a: Balance.fromFloat(30, 6), timestamp: '2024-02-01' }];
689
+ const grouped = applyGrouping(extendedMockData, 'month', 'latest');
690
+ const expected = [
691
+ { a: Balance.fromFloat(20, 6), timestamp: '2024-01-01' },
692
+ { a: Balance.fromFloat(30, 6), timestamp: '2024-02-01' },
693
+ ];
694
+ expect(grouped).to.deep.equal(expected);
695
+ });
696
+ it('should aggregate values when strategy is sum and grouping is month (Token)', () => {
697
+ const extendedMockData = [
698
+ { a: Balance.fromFloat(10, 6), timestamp: '2024-01-01' },
699
+ { a: Balance.fromFloat(20, 6), timestamp: '2024-01-02' },
700
+ { a: Balance.fromFloat(30, 6), timestamp: '2024-02-01' },
701
+ ];
702
+ const grouped = applyGrouping(extendedMockData, 'month', 'sum');
703
+ const expected = [
704
+ { a: Balance.fromFloat(30, 6), timestamp: '2024-01-02' },
705
+ { a: Balance.fromFloat(30, 6), timestamp: '2024-02-01' },
706
+ ];
707
+ expect(grouped).to.deep.equal(expected);
708
+ });
709
+ it('should aggregate values when strategy is sum and grouping is month (Price)', () => {
710
+ const extendedMockData = [
711
+ { a: Price.fromFloat(10), timestamp: '2024-01-01' },
712
+ { a: Price.fromFloat(20), timestamp: '2024-01-02' },
713
+ { a: Price.fromFloat(30), timestamp: '2024-02-01' },
714
+ ];
715
+ const grouped = applyGrouping(extendedMockData, 'month', 'sum');
716
+ const expected = [
717
+ { a: Price.fromFloat(30), timestamp: '2024-01-02' },
718
+ { a: Price.fromFloat(30), timestamp: '2024-02-01' },
719
+ ];
720
+ expect(grouped).to.deep.equal(expected);
721
+ });
722
+ it('should only aggregate top-level Currency values and use last value for nested objects', () => {
723
+ const items = [
724
+ {
725
+ timestamp: '2024-01-01T12:00:00Z',
726
+ topLevelAmount: Balance.fromFloat(1, 6), // should be summed
727
+ nested: {
728
+ amount: Balance.fromFloat(1, 6), // should take last value
729
+ description: 'first',
730
+ },
731
+ fees: [
732
+ {
733
+ amount: Balance.fromFloat(0.5, 6), // should take last value
734
+ name: 'fee1',
735
+ },
736
+ ],
737
+ },
738
+ {
739
+ timestamp: '2024-01-01T18:00:00Z',
740
+ topLevelAmount: Balance.fromFloat(2, 6),
741
+ nested: {
742
+ amount: Balance.fromFloat(3, 6),
743
+ description: 'second',
744
+ },
745
+ fees: [
746
+ {
747
+ amount: Balance.fromFloat(0.7, 6),
748
+ name: 'fee1',
749
+ },
750
+ ],
751
+ },
752
+ ];
753
+ const result = processor['applyGrouping'](items, 'day', 'sum');
754
+ expect(result).to.have.lengthOf(1);
755
+ const aggregated = result[0];
756
+ // Top level Currency should be summed
757
+ expect(aggregated?.topLevelAmount.toFloat()).to.equal(3); // 1 + 2
758
+ // Nested Currency should be from last item
759
+ expect(aggregated?.nested?.amount.toFloat()).to.equal(3); // last value only
760
+ expect(aggregated?.nested?.description).to.equal('second');
761
+ // Array of objects with Currency should be from last item
762
+ expect(aggregated?.fees[0]?.amount.toFloat()).to.equal(0.7);
763
+ expect(aggregated?.fees[0]?.name).to.equal('fee1');
764
+ });
765
+ });
766
+ });
767
+ //# sourceMappingURL=Processor.test.js.map