@sentio/sdk 2.57.12-rc.j → 2.57.13-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 (250) hide show
  1. package/lib/core/template.d.ts +1 -5
  2. package/lib/core/template.d.ts.map +1 -1
  3. package/lib/core/template.js +1 -4
  4. package/lib/core/template.js.map +1 -1
  5. package/lib/store/store.d.ts +2 -2
  6. package/lib/store/store.d.ts.map +1 -1
  7. package/lib/store/store.js.map +1 -1
  8. package/package.json +3 -3
  9. package/src/core/template.ts +1 -6
  10. package/src/store/store.ts +2 -3
  11. package/lib/chunk-2F2KNF4Z.js +0 -71905
  12. package/lib/chunk-2F2KNF4Z.js.map +0 -1
  13. package/lib/chunk-43HP4DQZ.js +0 -47
  14. package/lib/chunk-43HP4DQZ.js.map +0 -1
  15. package/lib/chunk-4HPFNKDX.js +0 -6763
  16. package/lib/chunk-4HPFNKDX.js.map +0 -1
  17. package/lib/chunk-4OCWUYSJ.js +0 -898
  18. package/lib/chunk-4OCWUYSJ.js.map +0 -1
  19. package/lib/chunk-6UVWNOIX.js +0 -4207
  20. package/lib/chunk-6UVWNOIX.js.map +0 -1
  21. package/lib/chunk-73SHERGU.js +0 -23970
  22. package/lib/chunk-73SHERGU.js.map +0 -1
  23. package/lib/chunk-742S42NO.js +0 -1323
  24. package/lib/chunk-742S42NO.js.map +0 -1
  25. package/lib/chunk-7ECRTQD7.js +0 -26757
  26. package/lib/chunk-7ECRTQD7.js.map +0 -1
  27. package/lib/chunk-7IDGS56O.js +0 -5058
  28. package/lib/chunk-7IDGS56O.js.map +0 -1
  29. package/lib/chunk-7S6WQ4RL.js +0 -1069
  30. package/lib/chunk-7S6WQ4RL.js.map +0 -1
  31. package/lib/chunk-AZFMPZRN.js +0 -3613
  32. package/lib/chunk-AZFMPZRN.js.map +0 -1
  33. package/lib/chunk-BZCXYTDE.js +0 -1333
  34. package/lib/chunk-BZCXYTDE.js.map +0 -1
  35. package/lib/chunk-E2DS6WZF.js +0 -1690
  36. package/lib/chunk-E2DS6WZF.js.map +0 -1
  37. package/lib/chunk-GE6BRIGS.js +0 -1721
  38. package/lib/chunk-GE6BRIGS.js.map +0 -1
  39. package/lib/chunk-J3I3VNTV.js +0 -767
  40. package/lib/chunk-J3I3VNTV.js.map +0 -1
  41. package/lib/chunk-J3QOJ2RV.js +0 -661
  42. package/lib/chunk-J3QOJ2RV.js.map +0 -1
  43. package/lib/chunk-J5UEW4B7.js +0 -1351
  44. package/lib/chunk-J5UEW4B7.js.map +0 -1
  45. package/lib/chunk-LPSNAS2G.js +0 -460
  46. package/lib/chunk-LPSNAS2G.js.map +0 -1
  47. package/lib/chunk-LR232ZJV.js +0 -2593
  48. package/lib/chunk-LR232ZJV.js.map +0 -1
  49. package/lib/chunk-N36N7RXJ.js +0 -653
  50. package/lib/chunk-N36N7RXJ.js.map +0 -1
  51. package/lib/chunk-OJG2VJ5T.js +0 -7063
  52. package/lib/chunk-OJG2VJ5T.js.map +0 -1
  53. package/lib/chunk-ONBEMKI5.js +0 -323
  54. package/lib/chunk-ONBEMKI5.js.map +0 -1
  55. package/lib/chunk-PVX2LIM5.js +0 -205
  56. package/lib/chunk-PVX2LIM5.js.map +0 -1
  57. package/lib/chunk-R7PMHHKJ.js +0 -52
  58. package/lib/chunk-R7PMHHKJ.js.map +0 -1
  59. package/lib/chunk-RMT2JEWA.js +0 -7740
  60. package/lib/chunk-RMT2JEWA.js.map +0 -1
  61. package/lib/chunk-S6MJ3KIL.js +0 -27798
  62. package/lib/chunk-S6MJ3KIL.js.map +0 -1
  63. package/lib/chunk-UEFVZL4I.js +0 -199
  64. package/lib/chunk-UEFVZL4I.js.map +0 -1
  65. package/lib/chunk-UIBPOKNT.js +0 -945
  66. package/lib/chunk-UIBPOKNT.js.map +0 -1
  67. package/lib/chunk-ZR7UHHH2.js +0 -5
  68. package/lib/chunk-ZR7UHHH2.js.map +0 -1
  69. package/lib/multipart-parser-SQIYSR67.js +0 -368
  70. package/lib/multipart-parser-SQIYSR67.js.map +0 -1
  71. package/src/aptos/builtin/0x1.d.ts +0 -6451
  72. package/src/aptos/builtin/0x1.d.ts.map +0 -1
  73. package/src/aptos/builtin/0x1.js +0 -7138
  74. package/src/aptos/builtin/0x1.js.map +0 -1
  75. package/src/aptos/builtin/0x3.d.ts +0 -1122
  76. package/src/aptos/builtin/0x3.d.ts.map +0 -1
  77. package/src/aptos/builtin/0x3.js +0 -937
  78. package/src/aptos/builtin/0x3.js.map +0 -1
  79. package/src/aptos/builtin/0x4.d.ts +0 -551
  80. package/src/aptos/builtin/0x4.d.ts.map +0 -1
  81. package/src/aptos/builtin/0x4.js +0 -529
  82. package/src/aptos/builtin/0x4.js.map +0 -1
  83. package/src/aptos/builtin/index.d.ts +0 -4
  84. package/src/aptos/builtin/index.d.ts.map +0 -1
  85. package/src/aptos/builtin/index.js +0 -7
  86. package/src/aptos/builtin/index.js.map +0 -1
  87. package/src/eth/builtin/eacaggregatorproxy.d.ts +0 -5
  88. package/src/eth/builtin/eacaggregatorproxy.d.ts.map +0 -1
  89. package/src/eth/builtin/eacaggregatorproxy.js +0 -8
  90. package/src/eth/builtin/eacaggregatorproxy.js.map +0 -1
  91. package/src/eth/builtin/erc1155.d.ts +0 -5
  92. package/src/eth/builtin/erc1155.d.ts.map +0 -1
  93. package/src/eth/builtin/erc1155.js +0 -8
  94. package/src/eth/builtin/erc1155.js.map +0 -1
  95. package/src/eth/builtin/erc20.d.ts +0 -5
  96. package/src/eth/builtin/erc20.d.ts.map +0 -1
  97. package/src/eth/builtin/erc20.js +0 -8
  98. package/src/eth/builtin/erc20.js.map +0 -1
  99. package/src/eth/builtin/erc20bytes.d.ts +0 -5
  100. package/src/eth/builtin/erc20bytes.d.ts.map +0 -1
  101. package/src/eth/builtin/erc20bytes.js +0 -8
  102. package/src/eth/builtin/erc20bytes.js.map +0 -1
  103. package/src/eth/builtin/erc721.d.ts +0 -5
  104. package/src/eth/builtin/erc721.d.ts.map +0 -1
  105. package/src/eth/builtin/erc721.js +0 -8
  106. package/src/eth/builtin/erc721.js.map +0 -1
  107. package/src/eth/builtin/index.d.ts +0 -13
  108. package/src/eth/builtin/index.d.ts.map +0 -1
  109. package/src/eth/builtin/index.js +0 -16
  110. package/src/eth/builtin/index.js.map +0 -1
  111. package/src/eth/builtin/internal/EACAggregatorProxy.d.ts +0 -50
  112. package/src/eth/builtin/internal/EACAggregatorProxy.d.ts.map +0 -1
  113. package/src/eth/builtin/internal/EACAggregatorProxy.js +0 -2
  114. package/src/eth/builtin/internal/EACAggregatorProxy.js.map +0 -1
  115. package/src/eth/builtin/internal/ERC1155.d.ts +0 -57
  116. package/src/eth/builtin/internal/ERC1155.d.ts.map +0 -1
  117. package/src/eth/builtin/internal/ERC1155.js +0 -2
  118. package/src/eth/builtin/internal/ERC1155.js.map +0 -1
  119. package/src/eth/builtin/internal/ERC20.d.ts +0 -41
  120. package/src/eth/builtin/internal/ERC20.d.ts.map +0 -1
  121. package/src/eth/builtin/internal/ERC20.js +0 -2
  122. package/src/eth/builtin/internal/ERC20.js.map +0 -1
  123. package/src/eth/builtin/internal/ERC20Bytes.d.ts +0 -32
  124. package/src/eth/builtin/internal/ERC20Bytes.d.ts.map +0 -1
  125. package/src/eth/builtin/internal/ERC20Bytes.js +0 -2
  126. package/src/eth/builtin/internal/ERC20Bytes.js.map +0 -1
  127. package/src/eth/builtin/internal/ERC721.d.ts +0 -43
  128. package/src/eth/builtin/internal/ERC721.d.ts.map +0 -1
  129. package/src/eth/builtin/internal/ERC721.js +0 -2
  130. package/src/eth/builtin/internal/ERC721.js.map +0 -1
  131. package/src/eth/builtin/internal/WETH9.d.ts +0 -47
  132. package/src/eth/builtin/internal/WETH9.d.ts.map +0 -1
  133. package/src/eth/builtin/internal/WETH9.js +0 -2
  134. package/src/eth/builtin/internal/WETH9.js.map +0 -1
  135. package/src/eth/builtin/internal/common.d.ts +0 -3
  136. package/src/eth/builtin/internal/common.d.ts.map +0 -1
  137. package/src/eth/builtin/internal/common.js +0 -8
  138. package/src/eth/builtin/internal/common.js.map +0 -1
  139. package/src/eth/builtin/internal/eacaggregatorproxy-processor.d.ts +0 -373
  140. package/src/eth/builtin/internal/eacaggregatorproxy-processor.d.ts.map +0 -1
  141. package/src/eth/builtin/internal/eacaggregatorproxy-processor.js +0 -1355
  142. package/src/eth/builtin/internal/eacaggregatorproxy-processor.js.map +0 -1
  143. package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.d.ts +0 -7
  144. package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.d.ts.map +0 -1
  145. package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.js +0 -55
  146. package/src/eth/builtin/internal/eacaggregatorproxy-test-utils.js.map +0 -1
  147. package/src/eth/builtin/internal/erc1155-processor.d.ts +0 -173
  148. package/src/eth/builtin/internal/erc1155-processor.d.ts.map +0 -1
  149. package/src/eth/builtin/internal/erc1155-processor.js +0 -596
  150. package/src/eth/builtin/internal/erc1155-processor.js.map +0 -1
  151. package/src/eth/builtin/internal/erc1155-test-utils.d.ts +0 -7
  152. package/src/eth/builtin/internal/erc1155-test-utils.d.ts.map +0 -1
  153. package/src/eth/builtin/internal/erc1155-test-utils.js +0 -55
  154. package/src/eth/builtin/internal/erc1155-test-utils.js.map +0 -1
  155. package/src/eth/builtin/internal/erc20-processor.d.ts +0 -244
  156. package/src/eth/builtin/internal/erc20-processor.d.ts.map +0 -1
  157. package/src/eth/builtin/internal/erc20-processor.js +0 -1109
  158. package/src/eth/builtin/internal/erc20-processor.js.map +0 -1
  159. package/src/eth/builtin/internal/erc20-test-utils.d.ts +0 -6
  160. package/src/eth/builtin/internal/erc20-test-utils.d.ts.map +0 -1
  161. package/src/eth/builtin/internal/erc20-test-utils.js +0 -44
  162. package/src/eth/builtin/internal/erc20-test-utils.js.map +0 -1
  163. package/src/eth/builtin/internal/erc20bytes-processor.d.ts +0 -144
  164. package/src/eth/builtin/internal/erc20bytes-processor.d.ts.map +0 -1
  165. package/src/eth/builtin/internal/erc20bytes-processor.js +0 -594
  166. package/src/eth/builtin/internal/erc20bytes-processor.js.map +0 -1
  167. package/src/eth/builtin/internal/erc20bytes-test-utils.d.ts +0 -5
  168. package/src/eth/builtin/internal/erc20bytes-test-utils.d.ts.map +0 -1
  169. package/src/eth/builtin/internal/erc20bytes-test-utils.js +0 -33
  170. package/src/eth/builtin/internal/erc20bytes-test-utils.js.map +0 -1
  171. package/src/eth/builtin/internal/erc721-processor.d.ts +0 -215
  172. package/src/eth/builtin/internal/erc721-processor.d.ts.map +0 -1
  173. package/src/eth/builtin/internal/erc721-processor.js +0 -895
  174. package/src/eth/builtin/internal/erc721-processor.js.map +0 -1
  175. package/src/eth/builtin/internal/erc721-test-utils.d.ts +0 -6
  176. package/src/eth/builtin/internal/erc721-test-utils.d.ts.map +0 -1
  177. package/src/eth/builtin/internal/erc721-test-utils.js +0 -44
  178. package/src/eth/builtin/internal/erc721-test-utils.js.map +0 -1
  179. package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.d.ts +0 -400
  180. package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.d.ts.map +0 -1
  181. package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.js +0 -524
  182. package/src/eth/builtin/internal/factories/EACAggregatorProxy__factory.js.map +0 -1
  183. package/src/eth/builtin/internal/factories/ERC1155__factory.d.ts +0 -251
  184. package/src/eth/builtin/internal/factories/ERC1155__factory.d.ts.map +0 -1
  185. package/src/eth/builtin/internal/factories/ERC1155__factory.js +0 -329
  186. package/src/eth/builtin/internal/factories/ERC1155__factory.js.map +0 -1
  187. package/src/eth/builtin/internal/factories/ERC20Bytes__factory.d.ts +0 -185
  188. package/src/eth/builtin/internal/factories/ERC20Bytes__factory.d.ts.map +0 -1
  189. package/src/eth/builtin/internal/factories/ERC20Bytes__factory.js +0 -251
  190. package/src/eth/builtin/internal/factories/ERC20Bytes__factory.js.map +0 -1
  191. package/src/eth/builtin/internal/factories/ERC20__factory.d.ts +0 -303
  192. package/src/eth/builtin/internal/factories/ERC20__factory.d.ts.map +0 -1
  193. package/src/eth/builtin/internal/factories/ERC20__factory.js +0 -401
  194. package/src/eth/builtin/internal/factories/ERC20__factory.js.map +0 -1
  195. package/src/eth/builtin/internal/factories/ERC721__factory.d.ts +0 -273
  196. package/src/eth/builtin/internal/factories/ERC721__factory.d.ts.map +0 -1
  197. package/src/eth/builtin/internal/factories/ERC721__factory.js +0 -361
  198. package/src/eth/builtin/internal/factories/ERC721__factory.js.map +0 -1
  199. package/src/eth/builtin/internal/factories/WETH9__factory.d.ts +0 -220
  200. package/src/eth/builtin/internal/factories/WETH9__factory.d.ts.map +0 -1
  201. package/src/eth/builtin/internal/factories/WETH9__factory.js +0 -294
  202. package/src/eth/builtin/internal/factories/WETH9__factory.js.map +0 -1
  203. package/src/eth/builtin/internal/factories/index.d.ts +0 -7
  204. package/src/eth/builtin/internal/factories/index.d.ts.map +0 -1
  205. package/src/eth/builtin/internal/factories/index.js +0 -10
  206. package/src/eth/builtin/internal/factories/index.js.map +0 -1
  207. package/src/eth/builtin/internal/index.d.ts +0 -14
  208. package/src/eth/builtin/internal/index.d.ts.map +0 -1
  209. package/src/eth/builtin/internal/index.js +0 -8
  210. package/src/eth/builtin/internal/index.js.map +0 -1
  211. package/src/eth/builtin/internal/weth9-processor.d.ts +0 -172
  212. package/src/eth/builtin/internal/weth9-processor.d.ts.map +0 -1
  213. package/src/eth/builtin/internal/weth9-processor.js +0 -729
  214. package/src/eth/builtin/internal/weth9-processor.js.map +0 -1
  215. package/src/eth/builtin/internal/weth9-test-utils.d.ts +0 -7
  216. package/src/eth/builtin/internal/weth9-test-utils.d.ts.map +0 -1
  217. package/src/eth/builtin/internal/weth9-test-utils.js +0 -55
  218. package/src/eth/builtin/internal/weth9-test-utils.js.map +0 -1
  219. package/src/eth/builtin/weth9.d.ts +0 -5
  220. package/src/eth/builtin/weth9.d.ts.map +0 -1
  221. package/src/eth/builtin/weth9.js +0 -8
  222. package/src/eth/builtin/weth9.js.map +0 -1
  223. package/src/solana/builtin/index.d.ts +0 -2
  224. package/src/solana/builtin/index.d.ts.map +0 -1
  225. package/src/solana/builtin/index.js +0 -2
  226. package/src/solana/builtin/index.js.map +0 -1
  227. package/src/solana/builtin/spl-token-processor.d.ts +0 -40
  228. package/src/solana/builtin/spl-token-processor.d.ts.map +0 -1
  229. package/src/solana/builtin/spl-token-processor.js +0 -254
  230. package/src/solana/builtin/spl-token-processor.js.map +0 -1
  231. package/src/solana/builtin/types.d.ts +0 -428
  232. package/src/solana/builtin/types.d.ts.map +0 -1
  233. package/src/solana/builtin/types.js +0 -201
  234. package/src/solana/builtin/types.js.map +0 -1
  235. package/src/sui/builtin/0x1.d.ts +0 -114
  236. package/src/sui/builtin/0x1.d.ts.map +0 -1
  237. package/src/sui/builtin/0x1.js +0 -159
  238. package/src/sui/builtin/0x1.js.map +0 -1
  239. package/src/sui/builtin/0x2.d.ts +0 -1250
  240. package/src/sui/builtin/0x2.d.ts.map +0 -1
  241. package/src/sui/builtin/0x2.js +0 -1511
  242. package/src/sui/builtin/0x2.js.map +0 -1
  243. package/src/sui/builtin/0x3.d.ts +0 -774
  244. package/src/sui/builtin/0x3.d.ts.map +0 -1
  245. package/src/sui/builtin/0x3.js +0 -720
  246. package/src/sui/builtin/0x3.js.map +0 -1
  247. package/src/sui/builtin/index.d.ts +0 -4
  248. package/src/sui/builtin/index.d.ts.map +0 -1
  249. package/src/sui/builtin/index.js +0 -7
  250. package/src/sui/builtin/index.js.map +0 -1
@@ -1,199 +0,0 @@
1
- import { createRequire as createRequireSdkShim } from 'module'; const require = createRequireSdkShim(import.meta.url);
2
- import {
3
- BigDecimal
4
- } from "./chunk-J5UEW4B7.js";
5
- import {
6
- __name
7
- } from "./chunk-R7PMHHKJ.js";
8
-
9
- // src/move/ext/coin.ts
10
- import("node:process").then((p) => p.stdout.write(""));
11
-
12
- // src/move/ext/move-dex.ts
13
- var MoveDex = class {
14
- static {
15
- __name(this, "MoveDex");
16
- }
17
- coinList;
18
- poolAdaptor;
19
- volume;
20
- volumeByCoin;
21
- tvlAll;
22
- tvlByPool;
23
- tvlByCoin;
24
- constructor(volume, volumeByCoin, tvlAll, tvlByCoin, tvlByPool, poolAdaptor) {
25
- this.volume = volume;
26
- this.volumeByCoin = volumeByCoin;
27
- this.tvlAll = tvlAll;
28
- this.tvlByPool = tvlByPool;
29
- this.tvlByCoin = tvlByCoin;
30
- this.poolAdaptor = poolAdaptor;
31
- }
32
- async recordTradingVolume(ctx, coinx, coiny, coinXAmount, coinYAmount, extraLabels) {
33
- let result = BigDecimal(0);
34
- const whitelistx = this.coinList.whiteListed(coinx);
35
- const whitelisty = this.coinList.whiteListed(coiny);
36
- if (!whitelistx && !whitelisty) {
37
- return result;
38
- }
39
- const coinXInfo = await this.coinList.getCoinInfo(coinx);
40
- const coinYInfo = await this.coinList.getCoinInfo(coiny);
41
- const timestamp = ctx.getTimestamp();
42
- let resultX = BigDecimal(0);
43
- let resultY = BigDecimal(0);
44
- const pair = await this.getPair(coinx, coiny);
45
- const baseLabels = extraLabels ? { ...extraLabels, pair } : { pair };
46
- if (whitelistx) {
47
- resultX = await this.coinList.calculateValueInUsd(coinXAmount, coinXInfo, timestamp, ctx.network);
48
- }
49
- if (whitelisty) {
50
- resultY = await this.coinList.calculateValueInUsd(coinYAmount, coinYInfo, timestamp, ctx.network);
51
- }
52
- if (resultX.eq(0)) {
53
- resultX = BigDecimal(resultY);
54
- }
55
- if (resultY.eq(0)) {
56
- resultY = BigDecimal(resultX);
57
- }
58
- const total = resultX.plus(resultY);
59
- if (total.gt(0)) {
60
- this.volume.record(ctx, total, {
61
- ...baseLabels,
62
- bridge: coinXInfo.bridge
63
- });
64
- }
65
- if (resultX.gt(0)) {
66
- this.volumeByCoin.record(ctx, resultX, {
67
- coin: coinXInfo.symbol,
68
- bridge: coinXInfo.bridge,
69
- type: coinXInfo.type
70
- });
71
- }
72
- if (resultY.gt(0)) {
73
- this.volumeByCoin.record(ctx, resultY, {
74
- coin: coinYInfo.symbol,
75
- bridge: coinYInfo.bridge,
76
- type: coinYInfo.type
77
- });
78
- }
79
- result = resultX.plus(resultY).div(2);
80
- return result;
81
- }
82
- async syncPools(resources, ctx, poolsHandler) {
83
- const pools = await ctx.coder.filterAndDecodeStruct(this.poolAdaptor.poolType, resources);
84
- const volumeByCoin = /* @__PURE__ */ new Map();
85
- const timestamp = ctx.getTimestamp();
86
- console.log("num of pools: ", pools.length, timestamp);
87
- let tvlAllValue = BigDecimal(0);
88
- for (const pool of pools) {
89
- const coinx = pool.type_arguments[0];
90
- const coiny = pool.type_arguments[1];
91
- const whitelistx = this.coinList.whiteListed(coinx);
92
- const whitelisty = this.coinList.whiteListed(coiny);
93
- if (!whitelistx && !whitelisty) {
94
- continue;
95
- }
96
- const pair = await this.getPair(coinx, coiny);
97
- const extraLabels = this.poolAdaptor.getExtraPoolTags(pool);
98
- const baseLabels = { ...extraLabels, pair };
99
- const coinXInfo = await this.coinList.getCoinInfo(coinx);
100
- const coinYInfo = await this.coinList.getCoinInfo(coiny);
101
- const coinx_amount = this.poolAdaptor.getXReserve(pool.data_decoded);
102
- const coiny_amount = this.poolAdaptor.getYReserve(pool.data_decoded);
103
- let resultX = BigDecimal(0);
104
- let resultY = BigDecimal(0);
105
- if (whitelistx) {
106
- resultX = await this.coinList.calculateValueInUsd(coinx_amount, coinXInfo, timestamp, ctx.network);
107
- let coinXTotal = volumeByCoin.get(coinXInfo.type);
108
- if (!coinXTotal) {
109
- coinXTotal = resultX;
110
- } else {
111
- coinXTotal = coinXTotal.plus(resultX);
112
- }
113
- volumeByCoin.set(coinXInfo.type, coinXTotal);
114
- }
115
- if (whitelisty) {
116
- resultY = await this.coinList.calculateValueInUsd(coiny_amount, coinYInfo, timestamp, ctx.network);
117
- let coinYTotal = volumeByCoin.get(coinYInfo.type);
118
- if (!coinYTotal) {
119
- coinYTotal = resultY;
120
- } else {
121
- coinYTotal = coinYTotal.plus(resultY);
122
- }
123
- volumeByCoin.set(coinYInfo.type, coinYTotal);
124
- }
125
- if (resultX.eq(0)) {
126
- resultX = BigDecimal(resultY);
127
- }
128
- if (resultY.eq(0)) {
129
- resultY = BigDecimal(resultX);
130
- }
131
- const poolValue = resultX.plus(resultY);
132
- if (poolValue.isGreaterThan(0)) {
133
- this.tvlByPool.record(ctx, poolValue, baseLabels);
134
- }
135
- tvlAllValue = tvlAllValue.plus(poolValue);
136
- }
137
- this.tvlAll.record(ctx, tvlAllValue);
138
- if (poolsHandler) {
139
- poolsHandler(pools);
140
- }
141
- for (const [k, v] of volumeByCoin) {
142
- const coinInfo = this.coinList.whitelistCoins().get(k);
143
- if (!coinInfo) {
144
- throw Error("unexpected coin " + k);
145
- }
146
- if (v.isGreaterThan(0)) {
147
- this.tvlByCoin.record(ctx, v, {
148
- coin: coinInfo.symbol,
149
- bridge: coinInfo.bridge,
150
- type: coinInfo.type
151
- });
152
- }
153
- }
154
- }
155
- async getPair(coinx, coiny) {
156
- const coinXInfo = await this.coinList.getCoinInfo(coinx);
157
- const coinYInfo = await this.coinList.getCoinInfo(coiny);
158
- if (coinXInfo.symbol.localeCompare(coinYInfo.symbol) > 0) {
159
- return `${coinYInfo.symbol}-${coinXInfo.symbol}`;
160
- }
161
- return `${coinXInfo.symbol}-${coinYInfo.symbol}`;
162
- }
163
- };
164
- async function moveGetPairValue(coinList, ctx, coinx, coiny, coinXAmount, coinYAmount) {
165
- const whitelistx = coinList.whiteListed(coinx);
166
- const whitelisty = coinList.whiteListed(coiny);
167
- const coinXInfo = await coinList.getCoinInfo(coinx);
168
- const coinYInfo = await coinList.getCoinInfo(coiny);
169
- const timestamp = ctx.getTimestamp();
170
- let result = BigDecimal(0);
171
- if (!whitelistx || !whitelisty) {
172
- return result;
173
- }
174
- if (whitelistx) {
175
- const value = await coinList.calculateValueInUsd(coinXAmount, coinXInfo, timestamp, ctx.network);
176
- result = value;
177
- if (!whitelisty) {
178
- result = result.plus(value);
179
- }
180
- }
181
- if (whitelisty) {
182
- const value = await coinList.calculateValueInUsd(coinYAmount, coinYInfo, timestamp, ctx.network);
183
- if (!whitelistx) {
184
- result = result.plus(value);
185
- }
186
- }
187
- return result;
188
- }
189
- __name(moveGetPairValue, "moveGetPairValue");
190
- import("node:process").then((p) => p.stdout.write(""));
191
-
192
- // src/move/ext/index.ts
193
- import("node:process").then((p) => p.stdout.write(""));
194
-
195
- export {
196
- MoveDex,
197
- moveGetPairValue
198
- };
199
- //# sourceMappingURL=chunk-UEFVZL4I.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/move/ext/coin.ts","../src/move/ext/move-dex.ts","../src/move/ext/index.ts"],"sourcesContent":["import { BigDecimal } from '@sentio/bigdecimal'\n\nexport interface BaseCoinInfo {\n // token_type: { type: string; account_address: string }\n type: string\n symbol: string\n hippo_symbol?: string\n decimals: number\n bridge: string\n}\n\nexport interface MoveCoinList<TokenType extends BaseCoinInfo, Network> {\n whiteListed(type: string): boolean\n whitelistCoins(): Map<string, TokenType>\n getCoinInfo(type: string): Promise<TokenType>\n calculateValueInUsd(amount: bigint, coinInfo: TokenType, timestamp: number, network: Network): Promise<BigDecimal>\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","import { DecodedStruct, TypeDescriptor } from '@typemove/move'\nimport { BigDecimal } from '@sentio/bigdecimal'\nimport { Gauge } from '../../core/index.js'\nimport { MoveAccountContext, MoveContext } from '../move-context.js'\nimport { MoveCoinList, BaseCoinInfo } from './coin.js'\n\nexport interface MovePoolAdaptor<StructType, T> {\n getXReserve(pool: T): bigint\n\n getYReserve(pool: T): bigint\n\n getExtraPoolTags(pool: DecodedStruct<StructType, T>): any\n\n poolType: TypeDescriptor<T>\n}\n\nexport class MoveDex<\n TokenType extends BaseCoinInfo,\n Network,\n ModuleType,\n StructType,\n EventType,\n ContextType extends MoveContext<Network, ModuleType, StructType | EventType>,\n AccountContextType extends MoveAccountContext<Network, ModuleType, StructType | EventType>,\n T\n> {\n coinList: MoveCoinList<TokenType, Network>\n poolAdaptor: MovePoolAdaptor<StructType, T>\n volume: Gauge\n volumeByCoin: Gauge\n tvlAll: Gauge\n tvlByPool: Gauge\n tvlByCoin: Gauge\n\n constructor(\n volume: Gauge,\n volumeByCoin: Gauge,\n tvlAll: Gauge,\n tvlByCoin: Gauge,\n tvlByPool: Gauge,\n poolAdaptor: MovePoolAdaptor<StructType, T>\n ) {\n this.volume = volume\n this.volumeByCoin = volumeByCoin\n this.tvlAll = tvlAll\n this.tvlByPool = tvlByPool\n this.tvlByCoin = tvlByCoin\n this.poolAdaptor = poolAdaptor\n }\n\n async recordTradingVolume(\n ctx: ContextType,\n coinx: string,\n coiny: string,\n coinXAmount: bigint,\n coinYAmount: bigint,\n extraLabels?: any\n ): Promise<BigDecimal> {\n let result = BigDecimal(0)\n\n const whitelistx = this.coinList.whiteListed(coinx)\n const whitelisty = this.coinList.whiteListed(coiny)\n if (!whitelistx && !whitelisty) {\n return result\n }\n const coinXInfo = await this.coinList.getCoinInfo(coinx)\n const coinYInfo = await this.coinList.getCoinInfo(coiny)\n const timestamp = ctx.getTimestamp()\n let resultX = BigDecimal(0)\n let resultY = BigDecimal(0)\n const pair = await this.getPair(coinx, coiny)\n const baseLabels: Record<string, string> = extraLabels ? { ...extraLabels, pair } : { pair }\n if (whitelistx) {\n resultX = await this.coinList.calculateValueInUsd(coinXAmount, coinXInfo, timestamp, ctx.network)\n }\n if (whitelisty) {\n resultY = await this.coinList.calculateValueInUsd(coinYAmount, coinYInfo, timestamp, ctx.network)\n }\n if (resultX.eq(0)) {\n resultX = BigDecimal(resultY)\n }\n if (resultY.eq(0)) {\n resultY = BigDecimal(resultX)\n }\n const total = resultX.plus(resultY)\n if (total.gt(0)) {\n this.volume.record(ctx, total, {\n ...baseLabels,\n bridge: coinXInfo.bridge\n })\n }\n if (resultX.gt(0)) {\n this.volumeByCoin.record(ctx, resultX, {\n coin: coinXInfo.symbol,\n bridge: coinXInfo.bridge,\n type: coinXInfo.type\n })\n }\n if (resultY.gt(0)) {\n this.volumeByCoin.record(ctx, resultY, {\n coin: coinYInfo.symbol,\n bridge: coinYInfo.bridge,\n type: coinYInfo.type\n })\n }\n result = resultX.plus(resultY).div(2)\n return result\n }\n\n async syncPools(\n resources: StructType[],\n ctx: AccountContextType,\n poolsHandler?: (pools: DecodedStruct<StructType, T>[]) => Promise<void> | void\n ) {\n const pools = await ctx.coder.filterAndDecodeStruct(this.poolAdaptor.poolType, resources)\n\n const volumeByCoin = new Map<string, BigDecimal>()\n const timestamp = ctx.getTimestamp()\n\n console.log('num of pools: ', pools.length, timestamp)\n\n let tvlAllValue = BigDecimal(0)\n for (const pool of pools) {\n // savePool(ctx.version, pool.type_arguments)\n const coinx = pool.type_arguments[0]\n const coiny = pool.type_arguments[1]\n const whitelistx = this.coinList.whiteListed(coinx)\n const whitelisty = this.coinList.whiteListed(coiny)\n if (!whitelistx && !whitelisty) {\n continue\n }\n\n const pair = await this.getPair(coinx, coiny)\n const extraLabels = this.poolAdaptor.getExtraPoolTags(pool)\n const baseLabels: Record<string, string> = { ...extraLabels, pair }\n\n const coinXInfo = await this.coinList.getCoinInfo(coinx)\n const coinYInfo = await this.coinList.getCoinInfo(coiny)\n\n const coinx_amount = this.poolAdaptor.getXReserve(pool.data_decoded)\n const coiny_amount = this.poolAdaptor.getYReserve(pool.data_decoded)\n\n let resultX = BigDecimal(0)\n let resultY = BigDecimal(0)\n\n if (whitelistx) {\n resultX = await this.coinList.calculateValueInUsd(coinx_amount, coinXInfo, timestamp, ctx.network)\n let coinXTotal = volumeByCoin.get(coinXInfo.type)\n if (!coinXTotal) {\n coinXTotal = resultX\n } else {\n coinXTotal = coinXTotal.plus(resultX)\n }\n volumeByCoin.set(coinXInfo.type, coinXTotal)\n }\n if (whitelisty) {\n resultY = await this.coinList.calculateValueInUsd(coiny_amount, coinYInfo, timestamp, ctx.network)\n let coinYTotal = volumeByCoin.get(coinYInfo.type)\n if (!coinYTotal) {\n coinYTotal = resultY\n } else {\n coinYTotal = coinYTotal.plus(resultY)\n }\n volumeByCoin.set(coinYInfo.type, coinYTotal)\n }\n\n if (resultX.eq(0)) {\n resultX = BigDecimal(resultY)\n }\n if (resultY.eq(0)) {\n resultY = BigDecimal(resultX)\n }\n\n const poolValue = resultX.plus(resultY)\n\n if (poolValue.isGreaterThan(0)) {\n this.tvlByPool.record(ctx, poolValue, baseLabels)\n }\n tvlAllValue = tvlAllValue.plus(poolValue)\n }\n this.tvlAll.record(ctx, tvlAllValue)\n\n if (poolsHandler) {\n poolsHandler(pools)\n }\n\n for (const [k, v] of volumeByCoin) {\n const coinInfo = this.coinList.whitelistCoins().get(k)\n if (!coinInfo) {\n throw Error('unexpected coin ' + k)\n }\n // const price = await getPrice(coinInfo, timestamp)\n // priceGauge.record(ctx, price, { coin: coinInfo.symbol })\n if (v.isGreaterThan(0)) {\n this.tvlByCoin.record(ctx, v, {\n coin: coinInfo.symbol,\n bridge: coinInfo.bridge,\n type: coinInfo.type\n })\n }\n }\n }\n\n async getPair(coinx: string, coiny: string): Promise<string> {\n const coinXInfo = await this.coinList.getCoinInfo(coinx)\n const coinYInfo = await this.coinList.getCoinInfo(coiny)\n if (coinXInfo.symbol.localeCompare(coinYInfo.symbol) > 0) {\n return `${coinYInfo.symbol}-${coinXInfo.symbol}`\n }\n return `${coinXInfo.symbol}-${coinYInfo.symbol}`\n }\n}\n\nexport async function moveGetPairValue<\n TokenType extends BaseCoinInfo,\n Network,\n ContextType extends MoveAccountContext<Network, any, any>\n>(\n coinList: MoveCoinList<TokenType, Network>,\n ctx: ContextType,\n coinx: string,\n coiny: string,\n coinXAmount: bigint,\n coinYAmount: bigint\n): Promise<BigDecimal> {\n const whitelistx = coinList.whiteListed(coinx)\n const whitelisty = coinList.whiteListed(coiny)\n const coinXInfo = await coinList.getCoinInfo(coinx)\n const coinYInfo = await coinList.getCoinInfo(coiny)\n const timestamp = ctx.getTimestamp()\n let result = BigDecimal(0.0)\n\n if (!whitelistx || !whitelisty) {\n return result\n }\n\n if (whitelistx) {\n const value = await coinList.calculateValueInUsd(coinXAmount, coinXInfo, timestamp, ctx.network)\n result = value\n\n if (!whitelisty) {\n result = result.plus(value)\n }\n }\n if (whitelisty) {\n const value = await coinList.calculateValueInUsd(coinYAmount, coinYInfo, timestamp, ctx.network)\n\n if (!whitelistx) {\n result = result.plus(value)\n }\n }\n\n return result\n}\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));","export * from './coin.js'\nexport * from './move-dex.js'\n;import(\"node:process\").then((p) => p.stdout.write(\"\"));"],"mappings":";;;;;;;;;AAiBC,OAAO,cAAc,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,MAAM,EAAE,CAAC;;;ACD/C,IAAM,UAAN,MASL;AAAA,EAzBF,OAyBE;AAAA;AAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA,YACE,QACA,cACA,QACA,WACA,WACA,aACA;AACA,SAAK,SAAS;AACd,SAAK,eAAe;AACpB,SAAK,SAAS;AACd,SAAK,YAAY;AACjB,SAAK,YAAY;AACjB,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,MAAM,oBACJ,KACA,OACA,OACA,aACA,aACA,aACqB;AACrB,QAAI,SAAS,WAAW,CAAC;AAEzB,UAAM,aAAa,KAAK,SAAS,YAAY,KAAK;AAClD,UAAM,aAAa,KAAK,SAAS,YAAY,KAAK;AAClD,QAAI,CAAC,cAAc,CAAC,YAAY;AAC9B,aAAO;AAAA,IACT;AACA,UAAM,YAAY,MAAM,KAAK,SAAS,YAAY,KAAK;AACvD,UAAM,YAAY,MAAM,KAAK,SAAS,YAAY,KAAK;AACvD,UAAM,YAAY,IAAI,aAAa;AACnC,QAAI,UAAU,WAAW,CAAC;AAC1B,QAAI,UAAU,WAAW,CAAC;AAC1B,UAAM,OAAO,MAAM,KAAK,QAAQ,OAAO,KAAK;AAC5C,UAAM,aAAqC,cAAc,EAAE,GAAG,aAAa,KAAK,IAAI,EAAE,KAAK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