fourmm 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +147 -0
  2. package/dist/bin.d.ts +9 -0
  3. package/dist/bin.d.ts.map +1 -0
  4. package/dist/bin.js +14 -0
  5. package/dist/bin.js.map +1 -0
  6. package/dist/cli.d.ts +319 -0
  7. package/dist/cli.d.ts.map +1 -0
  8. package/dist/cli.js +25 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/commands/config.d.ts +35 -0
  11. package/dist/commands/config.d.ts.map +1 -0
  12. package/dist/commands/config.js +145 -0
  13. package/dist/commands/config.js.map +1 -0
  14. package/dist/commands/query.d.ts +51 -0
  15. package/dist/commands/query.d.ts.map +1 -0
  16. package/dist/commands/query.js +364 -0
  17. package/dist/commands/query.js.map +1 -0
  18. package/dist/commands/token.d.ts +55 -0
  19. package/dist/commands/token.d.ts.map +1 -0
  20. package/dist/commands/token.js +650 -0
  21. package/dist/commands/token.js.map +1 -0
  22. package/dist/commands/tools.d.ts +54 -0
  23. package/dist/commands/tools.d.ts.map +1 -0
  24. package/dist/commands/tools.js +499 -0
  25. package/dist/commands/tools.js.map +1 -0
  26. package/dist/commands/trade.d.ts +63 -0
  27. package/dist/commands/trade.d.ts.map +1 -0
  28. package/dist/commands/trade.js +933 -0
  29. package/dist/commands/trade.js.map +1 -0
  30. package/dist/commands/transfer.d.ts +51 -0
  31. package/dist/commands/transfer.d.ts.map +1 -0
  32. package/dist/commands/transfer.js +728 -0
  33. package/dist/commands/transfer.js.map +1 -0
  34. package/dist/commands/wallet.d.ts +111 -0
  35. package/dist/commands/wallet.d.ts.map +1 -0
  36. package/dist/commands/wallet.js +716 -0
  37. package/dist/commands/wallet.js.map +1 -0
  38. package/dist/contracts/erc20.d.ts +72 -0
  39. package/dist/contracts/erc20.d.ts.map +1 -0
  40. package/dist/contracts/erc20.js +55 -0
  41. package/dist/contracts/erc20.js.map +1 -0
  42. package/dist/contracts/fourmemeMmRouter.d.ts +68 -0
  43. package/dist/contracts/fourmemeMmRouter.d.ts.map +1 -0
  44. package/dist/contracts/fourmemeMmRouter.js +48 -0
  45. package/dist/contracts/fourmemeMmRouter.js.map +1 -0
  46. package/dist/contracts/pancakeRouter.d.ts +73 -0
  47. package/dist/contracts/pancakeRouter.d.ts.map +1 -0
  48. package/dist/contracts/pancakeRouter.js +50 -0
  49. package/dist/contracts/pancakeRouter.js.map +1 -0
  50. package/dist/contracts/tokenManager2.d.ts +193 -0
  51. package/dist/contracts/tokenManager2.d.ts.map +1 -0
  52. package/dist/contracts/tokenManager2.js +108 -0
  53. package/dist/contracts/tokenManager2.js.map +1 -0
  54. package/dist/contracts/tokenManagerHelper3.d.ts +118 -0
  55. package/dist/contracts/tokenManagerHelper3.d.ts.map +1 -0
  56. package/dist/contracts/tokenManagerHelper3.js +66 -0
  57. package/dist/contracts/tokenManagerHelper3.js.map +1 -0
  58. package/dist/datastore/cache.d.ts +20 -0
  59. package/dist/datastore/cache.d.ts.map +1 -0
  60. package/dist/datastore/cache.js +45 -0
  61. package/dist/datastore/cache.js.map +1 -0
  62. package/dist/datastore/index.d.ts +85 -0
  63. package/dist/datastore/index.d.ts.map +1 -0
  64. package/dist/datastore/index.js +341 -0
  65. package/dist/datastore/index.js.map +1 -0
  66. package/dist/datastore/paths.d.ts +17 -0
  67. package/dist/datastore/paths.d.ts.map +1 -0
  68. package/dist/datastore/paths.js +39 -0
  69. package/dist/datastore/paths.js.map +1 -0
  70. package/dist/datastore/types.d.ts +105 -0
  71. package/dist/datastore/types.d.ts.map +1 -0
  72. package/dist/datastore/types.js +8 -0
  73. package/dist/datastore/types.js.map +1 -0
  74. package/dist/fourmeme/auth.d.ts +22 -0
  75. package/dist/fourmeme/auth.d.ts.map +1 -0
  76. package/dist/fourmeme/auth.js +78 -0
  77. package/dist/fourmeme/auth.js.map +1 -0
  78. package/dist/fourmeme/create.d.ts +31 -0
  79. package/dist/fourmeme/create.d.ts.map +1 -0
  80. package/dist/fourmeme/create.js +111 -0
  81. package/dist/fourmeme/create.js.map +1 -0
  82. package/dist/fourmeme/upload.d.ts +16 -0
  83. package/dist/fourmeme/upload.d.ts.map +1 -0
  84. package/dist/fourmeme/upload.js +52 -0
  85. package/dist/fourmeme/upload.js.map +1 -0
  86. package/dist/lib/bundle.d.ts +51 -0
  87. package/dist/lib/bundle.d.ts.map +1 -0
  88. package/dist/lib/bundle.js +95 -0
  89. package/dist/lib/bundle.js.map +1 -0
  90. package/dist/lib/config.d.ts +58 -0
  91. package/dist/lib/config.d.ts.map +1 -0
  92. package/dist/lib/config.js +183 -0
  93. package/dist/lib/config.js.map +1 -0
  94. package/dist/lib/const.d.ts +165 -0
  95. package/dist/lib/const.d.ts.map +1 -0
  96. package/dist/lib/const.js +98 -0
  97. package/dist/lib/const.js.map +1 -0
  98. package/dist/lib/env.d.ts +14 -0
  99. package/dist/lib/env.d.ts.map +1 -0
  100. package/dist/lib/env.js +18 -0
  101. package/dist/lib/env.js.map +1 -0
  102. package/dist/lib/guards.d.ts +44 -0
  103. package/dist/lib/guards.d.ts.map +1 -0
  104. package/dist/lib/guards.js +65 -0
  105. package/dist/lib/guards.js.map +1 -0
  106. package/dist/lib/identify.d.ts +85 -0
  107. package/dist/lib/identify.d.ts.map +1 -0
  108. package/dist/lib/identify.js +88 -0
  109. package/dist/lib/identify.js.map +1 -0
  110. package/dist/lib/pricing.d.ts +62 -0
  111. package/dist/lib/pricing.d.ts.map +1 -0
  112. package/dist/lib/pricing.js +302 -0
  113. package/dist/lib/pricing.js.map +1 -0
  114. package/dist/lib/routing.d.ts +57 -0
  115. package/dist/lib/routing.d.ts.map +1 -0
  116. package/dist/lib/routing.js +67 -0
  117. package/dist/lib/routing.js.map +1 -0
  118. package/dist/lib/slippage.d.ts +29 -0
  119. package/dist/lib/slippage.d.ts.map +1 -0
  120. package/dist/lib/slippage.js +110 -0
  121. package/dist/lib/slippage.js.map +1 -0
  122. package/dist/lib/tracker.d.ts +68 -0
  123. package/dist/lib/tracker.d.ts.map +1 -0
  124. package/dist/lib/tracker.js +155 -0
  125. package/dist/lib/tracker.js.map +1 -0
  126. package/dist/lib/viem.d.ts +12 -0
  127. package/dist/lib/viem.d.ts.map +1 -0
  128. package/dist/lib/viem.js +44 -0
  129. package/dist/lib/viem.js.map +1 -0
  130. package/dist/lib/wallet-rows.d.ts +30 -0
  131. package/dist/lib/wallet-rows.d.ts.map +1 -0
  132. package/dist/lib/wallet-rows.js +9 -0
  133. package/dist/lib/wallet-rows.js.map +1 -0
  134. package/dist/lib/walletClient.d.ts +16 -0
  135. package/dist/lib/walletClient.d.ts.map +1 -0
  136. package/dist/lib/walletClient.js +26 -0
  137. package/dist/lib/walletClient.js.map +1 -0
  138. package/dist/wallets/groups/encrypt.d.ts +26 -0
  139. package/dist/wallets/groups/encrypt.d.ts.map +1 -0
  140. package/dist/wallets/groups/encrypt.js +52 -0
  141. package/dist/wallets/groups/encrypt.js.map +1 -0
  142. package/dist/wallets/groups/generate.d.ts +19 -0
  143. package/dist/wallets/groups/generate.d.ts.map +1 -0
  144. package/dist/wallets/groups/generate.js +36 -0
  145. package/dist/wallets/groups/generate.js.map +1 -0
  146. package/dist/wallets/groups/store.d.ts +107 -0
  147. package/dist/wallets/groups/store.d.ts.map +1 -0
  148. package/dist/wallets/groups/store.js +254 -0
  149. package/dist/wallets/groups/store.js.map +1 -0
  150. package/package.json +50 -0
  151. package/skills/SKILL.md +187 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * viem ABI binding for TokenManager2.
3
+ *
4
+ * Only the methods fourMM trade commands need: buyTokenAMAP, sellToken, createToken.
5
+ * Address is resolved at runtime via Helper3.getTokenInfo().tokenManager.
6
+ */
7
+ export const tokenManager2Abi = [
8
+ // ---- Buy ----
9
+ {
10
+ type: 'function',
11
+ name: 'buyTokenAMAP',
12
+ stateMutability: 'payable',
13
+ inputs: [
14
+ { name: 'token', type: 'address' },
15
+ { name: 'funds', type: 'uint256' },
16
+ { name: 'minAmount', type: 'uint256' },
17
+ ],
18
+ outputs: [],
19
+ },
20
+ {
21
+ type: 'function',
22
+ name: 'buyTokenAMAP',
23
+ stateMutability: 'payable',
24
+ inputs: [
25
+ { name: 'token', type: 'address' },
26
+ { name: 'to', type: 'address' },
27
+ { name: 'funds', type: 'uint256' },
28
+ { name: 'minAmount', type: 'uint256' },
29
+ ],
30
+ outputs: [],
31
+ },
32
+ // ---- Sell ----
33
+ {
34
+ type: 'function',
35
+ name: 'sellToken',
36
+ stateMutability: 'nonpayable',
37
+ inputs: [
38
+ { name: 'token', type: 'address' },
39
+ { name: 'amount', type: 'uint256' },
40
+ ],
41
+ outputs: [],
42
+ },
43
+ // ---- Create ----
44
+ {
45
+ type: 'function',
46
+ name: 'createToken',
47
+ stateMutability: 'payable',
48
+ inputs: [
49
+ { name: 'createArg', type: 'bytes' },
50
+ { name: 'signature', type: 'bytes' },
51
+ ],
52
+ outputs: [],
53
+ },
54
+ // ---- Events (for TxTracker / receipt parsing) ----
55
+ {
56
+ type: 'event',
57
+ name: 'TokenCreate',
58
+ inputs: [
59
+ { name: 'creator', type: 'address', indexed: false },
60
+ { name: 'token', type: 'address', indexed: false },
61
+ { name: 'requestId', type: 'uint256', indexed: false },
62
+ { name: 'name', type: 'string', indexed: false },
63
+ { name: 'symbol', type: 'string', indexed: false },
64
+ { name: 'totalSupply', type: 'uint256', indexed: false },
65
+ { name: 'launchTime', type: 'uint256', indexed: false },
66
+ { name: 'launchFee', type: 'uint256', indexed: false },
67
+ ],
68
+ },
69
+ {
70
+ type: 'event',
71
+ name: 'TokenPurchase',
72
+ inputs: [
73
+ { name: 'token', type: 'address', indexed: false },
74
+ { name: 'account', type: 'address', indexed: false },
75
+ { name: 'price', type: 'uint256', indexed: false },
76
+ { name: 'amount', type: 'uint256', indexed: false },
77
+ { name: 'cost', type: 'uint256', indexed: false },
78
+ { name: 'fee', type: 'uint256', indexed: false },
79
+ { name: 'offers', type: 'uint256', indexed: false },
80
+ { name: 'funds', type: 'uint256', indexed: false },
81
+ ],
82
+ },
83
+ {
84
+ type: 'event',
85
+ name: 'TokenSale',
86
+ inputs: [
87
+ { name: 'token', type: 'address', indexed: false },
88
+ { name: 'account', type: 'address', indexed: false },
89
+ { name: 'price', type: 'uint256', indexed: false },
90
+ { name: 'amount', type: 'uint256', indexed: false },
91
+ { name: 'cost', type: 'uint256', indexed: false },
92
+ { name: 'fee', type: 'uint256', indexed: false },
93
+ { name: 'offers', type: 'uint256', indexed: false },
94
+ { name: 'funds', type: 'uint256', indexed: false },
95
+ ],
96
+ },
97
+ {
98
+ type: 'event',
99
+ name: 'LiquidityAdded',
100
+ inputs: [
101
+ { name: 'base', type: 'address', indexed: false },
102
+ { name: 'offers', type: 'uint256', indexed: false },
103
+ { name: 'quote', type: 'address', indexed: false },
104
+ { name: 'funds', type: 'uint256', indexed: false },
105
+ ],
106
+ },
107
+ ];
108
+ //# sourceMappingURL=tokenManager2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenManager2.js","sourceRoot":"","sources":["../../src/contracts/tokenManager2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB;IAChB;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,cAAc;QACpB,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;SACvC;QACD,OAAO,EAAE,EAAE;KACZ;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,cAAc;QACpB,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;Y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AE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACpD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YAClD,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACnD,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACjD,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YAChD,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACnD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;SACnD;KACF;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACjD,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YACnD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;YAClD,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE;SACnD;KACF;CACO,CAAA"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * viem ABI binding for TokenManagerHelper3.
3
+ *
4
+ * Only the methods fourMM uses are declared here — we don't need the full ABI.
5
+ *
6
+ * Source: docs/API-Documents.03-03-2026.md §TokenManagerHelper3 (V3)
7
+ * Address: 0xF251F83e40a78868FcfA3FA4599Dad6494E46034 (BSC mainnet)
8
+ */
9
+ export declare const tokenManagerHelper3Abi: readonly [{
10
+ readonly type: "function";
11
+ readonly name: "getTokenInfo";
12
+ readonly stateMutability: "view";
13
+ readonly inputs: readonly [{
14
+ readonly name: "token";
15
+ readonly type: "address";
16
+ }];
17
+ readonly outputs: readonly [{
18
+ readonly name: "version";
19
+ readonly type: "uint256";
20
+ }, {
21
+ readonly name: "tokenManager";
22
+ readonly type: "address";
23
+ }, {
24
+ readonly name: "quote";
25
+ readonly type: "address";
26
+ }, {
27
+ readonly name: "lastPrice";
28
+ readonly type: "uint256";
29
+ }, {
30
+ readonly name: "tradingFeeRate";
31
+ readonly type: "uint256";
32
+ }, {
33
+ readonly name: "minTradingFee";
34
+ readonly type: "uint256";
35
+ }, {
36
+ readonly name: "launchTime";
37
+ readonly type: "uint256";
38
+ }, {
39
+ readonly name: "offers";
40
+ readonly type: "uint256";
41
+ }, {
42
+ readonly name: "maxOffers";
43
+ readonly type: "uint256";
44
+ }, {
45
+ readonly name: "funds";
46
+ readonly type: "uint256";
47
+ }, {
48
+ readonly name: "maxFunds";
49
+ readonly type: "uint256";
50
+ }, {
51
+ readonly name: "liquidityAdded";
52
+ readonly type: "bool";
53
+ }];
54
+ }, {
55
+ readonly type: "function";
56
+ readonly name: "tryBuy";
57
+ readonly stateMutability: "view";
58
+ readonly inputs: readonly [{
59
+ readonly name: "token";
60
+ readonly type: "address";
61
+ }, {
62
+ readonly name: "amount";
63
+ readonly type: "uint256";
64
+ }, {
65
+ readonly name: "funds";
66
+ readonly type: "uint256";
67
+ }];
68
+ readonly outputs: readonly [{
69
+ readonly name: "tokenManager";
70
+ readonly type: "address";
71
+ }, {
72
+ readonly name: "quote";
73
+ readonly type: "address";
74
+ }, {
75
+ readonly name: "estimatedAmount";
76
+ readonly type: "uint256";
77
+ }, {
78
+ readonly name: "estimatedCost";
79
+ readonly type: "uint256";
80
+ }, {
81
+ readonly name: "estimatedFee";
82
+ readonly type: "uint256";
83
+ }, {
84
+ readonly name: "amountMsgValue";
85
+ readonly type: "uint256";
86
+ }, {
87
+ readonly name: "amountApproval";
88
+ readonly type: "uint256";
89
+ }, {
90
+ readonly name: "amountFunds";
91
+ readonly type: "uint256";
92
+ }];
93
+ }, {
94
+ readonly type: "function";
95
+ readonly name: "trySell";
96
+ readonly stateMutability: "view";
97
+ readonly inputs: readonly [{
98
+ readonly name: "token";
99
+ readonly type: "address";
100
+ }, {
101
+ readonly name: "amount";
102
+ readonly type: "uint256";
103
+ }];
104
+ readonly outputs: readonly [{
105
+ readonly name: "tokenManager";
106
+ readonly type: "address";
107
+ }, {
108
+ readonly name: "quote";
109
+ readonly type: "address";
110
+ }, {
111
+ readonly name: "funds";
112
+ readonly type: "uint256";
113
+ }, {
114
+ readonly name: "fee";
115
+ readonly type: "uint256";
116
+ }];
117
+ }];
118
+ //# sourceMappingURL=tokenManagerHelper3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenManagerHelper3.d.ts","sourceRoot":"","sources":["../../src/contracts/tokenManagerHelper3.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwDzB,CAAA"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * viem ABI binding for TokenManagerHelper3.
3
+ *
4
+ * Only the methods fourMM uses are declared here — we don't need the full ABI.
5
+ *
6
+ * Source: docs/API-Documents.03-03-2026.md §TokenManagerHelper3 (V3)
7
+ * Address: 0xF251F83e40a78868FcfA3FA4599Dad6494E46034 (BSC mainnet)
8
+ */
9
+ export const tokenManagerHelper3Abi = [
10
+ {
11
+ type: 'function',
12
+ name: 'getTokenInfo',
13
+ stateMutability: 'view',
14
+ inputs: [{ name: 'token', type: 'address' }],
15
+ outputs: [
16
+ { name: 'version', type: 'uint256' },
17
+ { name: 'tokenManager', type: 'address' },
18
+ { name: 'quote', type: 'address' },
19
+ { name: 'lastPrice', type: 'uint256' },
20
+ { name: 'tradingFeeRate', type: 'uint256' },
21
+ { name: 'minTradingFee', type: 'uint256' },
22
+ { name: 'launchTime', type: 'uint256' },
23
+ { name: 'offers', type: 'uint256' },
24
+ { name: 'maxOffers', type: 'uint256' },
25
+ { name: 'funds', type: 'uint256' },
26
+ { name: 'maxFunds', type: 'uint256' },
27
+ { name: 'liquidityAdded', type: 'bool' },
28
+ ],
29
+ },
30
+ {
31
+ type: 'function',
32
+ name: 'tryBuy',
33
+ stateMutability: 'view',
34
+ inputs: [
35
+ { name: 'token', type: 'address' },
36
+ { name: 'amount', type: 'uint256' },
37
+ { name: 'funds', type: 'uint256' },
38
+ ],
39
+ outputs: [
40
+ { name: 'tokenManager', type: 'address' },
41
+ { name: 'quote', type: 'address' },
42
+ { name: 'estimatedAmount', type: 'uint256' },
43
+ { name: 'estimatedCost', type: 'uint256' },
44
+ { name: 'estimatedFee', type: 'uint256' },
45
+ { name: 'amountMsgValue', type: 'uint256' },
46
+ { name: 'amountApproval', type: 'uint256' },
47
+ { name: 'amountFunds', type: 'uint256' },
48
+ ],
49
+ },
50
+ {
51
+ type: 'function',
52
+ name: 'trySell',
53
+ stateMutability: 'view',
54
+ inputs: [
55
+ { name: 'token', type: 'address' },
56
+ { name: 'amount', type: 'uint256' },
57
+ ],
58
+ outputs: [
59
+ { name: 'tokenManager', type: 'address' },
60
+ { name: 'quote', type: 'address' },
61
+ { name: 'funds', type: 'uint256' },
62
+ { name: 'fee', type: 'uint256' },
63
+ ],
64
+ },
65
+ ];
66
+ //# sourceMappingURL=tokenManagerHelper3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenManagerHelper3.js","sourceRoot":"","sources":["../../src/contracts/tokenManagerHelper3.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE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ACzC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,SAAS,EAAE;YAC5C,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE;YAC1C,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE;YACzC,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;YAC3C,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,SAAS,EAAE;YAC3C,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;SACzC;KACF;IACD;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;SACpC;QACD,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,SAAS,EAAE;YACzC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE;SACjC;KACF;CACO,CAAA"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * In-process memory cache with TTL.
3
+ *
4
+ * Used by DataStore to avoid re-reading JSON from disk on every call.
5
+ * Entry is invalidated on write and expires after `ttlMs`.
6
+ */
7
+ export declare class MemoryCache {
8
+ private readonly ttlMs;
9
+ private store;
10
+ constructor(ttlMs?: number);
11
+ get<T>(key: string): T | undefined;
12
+ set<T>(key: string, value: T, ttlMs?: number): void;
13
+ invalidate(key: string): void;
14
+ /** Drop all entries whose key starts with prefix (e.g. "token:<ca>:") */
15
+ invalidatePrefix(prefix: string): void;
16
+ clear(): void;
17
+ /** Test helper: number of live (not yet expired) entries */
18
+ size(): number;
19
+ }
20
+ //# sourceMappingURL=cache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../src/datastore/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,qBAAa,WAAW;IAEV,OAAO,CAAC,QAAQ,CAAC,KAAK;IADlC,OAAO,CAAC,KAAK,CAAoC;gBACpB,KAAK,GAAE,MAAe;IAEnD,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAUlC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IAKnD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI7B,yEAAyE;IACzE,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAMtC,KAAK,IAAI,IAAI;IAIb,4DAA4D;IAC5D,IAAI,IAAI,MAAM;CAGf"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * In-process memory cache with TTL.
3
+ *
4
+ * Used by DataStore to avoid re-reading JSON from disk on every call.
5
+ * Entry is invalidated on write and expires after `ttlMs`.
6
+ */
7
+ export class MemoryCache {
8
+ ttlMs;
9
+ store = new Map();
10
+ constructor(ttlMs = 30_000) {
11
+ this.ttlMs = ttlMs;
12
+ }
13
+ get(key) {
14
+ const e = this.store.get(key);
15
+ if (!e)
16
+ return undefined;
17
+ if (Date.now() >= e.expiresAt) {
18
+ this.store.delete(key);
19
+ return undefined;
20
+ }
21
+ return e.value;
22
+ }
23
+ set(key, value, ttlMs) {
24
+ const ttl = ttlMs ?? this.ttlMs;
25
+ this.store.set(key, { value, expiresAt: Date.now() + ttl });
26
+ }
27
+ invalidate(key) {
28
+ this.store.delete(key);
29
+ }
30
+ /** Drop all entries whose key starts with prefix (e.g. "token:<ca>:") */
31
+ invalidatePrefix(prefix) {
32
+ for (const k of this.store.keys()) {
33
+ if (k.startsWith(prefix))
34
+ this.store.delete(k);
35
+ }
36
+ }
37
+ clear() {
38
+ this.store.clear();
39
+ }
40
+ /** Test helper: number of live (not yet expired) entries */
41
+ size() {
42
+ return this.store.size;
43
+ }
44
+ }
45
+ //# sourceMappingURL=cache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/datastore/cache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,OAAO,WAAW;IAEO;IADrB,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAA;IACjD,YAA6B,QAAgB,MAAM;QAAtB,UAAK,GAAL,KAAK,CAAiB;IAAG,CAAC;IAEvD,GAAG,CAAI,GAAW;QAChB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAC7B,IAAI,CAAC,CAAC;YAAE,OAAO,SAAS,CAAA;QACxB,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACtB,OAAO,SAAS,CAAA;QAClB,CAAC;QACD,OAAO,CAAC,CAAC,KAAU,CAAA;IACrB,CAAC;IAED,GAAG,CAAI,GAAW,EAAE,KAAQ,EAAE,KAAc;QAC1C,MAAM,GAAG,GAAG,KAAK,IAAI,IAAI,CAAC,KAAK,CAAA;QAC/B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAED,yEAAyE;IACzE,gBAAgB,CAAC,MAAc;QAC7B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YAClC,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC;gBAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,4DAA4D;IAC5D,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAA;IACxB,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * DataStore — local JSON store at ~/.fourmm/data/.
3
+ *
4
+ * Responsibilities:
5
+ * - Persist token metadata, pool info, transaction history, holdings, balances
6
+ * - Atomic writes (write .tmp, rename) to avoid half-written files
7
+ * - Memory cache per key with TTL (default 30s)
8
+ *
9
+ * What it does NOT do:
10
+ * - Cross-process locking. CLI is single-process; parallel invocations
11
+ * can race on writes. If Week 3 Router daemons need parallel writes we
12
+ * add a lockfile then.
13
+ * - Pretty printing control / schema migration (we'll version if needed).
14
+ *
15
+ * Public surface is a class with a singleton accessor so tests can inject
16
+ * a fresh instance. Paths come from datastore/paths.ts which reads HOME
17
+ * lazily, so redirecting HOME per test works.
18
+ */
19
+ import { MemoryCache } from './cache.js';
20
+ import type { BalancesFile, BnbPriceFile, HoldingsFile, PoolInfoFile, TokenInfoFile, TransactionRecord, TransactionsFile, WalletBalance, WalletHolding } from './types.js';
21
+ import type { Address } from 'viem';
22
+ export * from './types.js';
23
+ export { MemoryCache } from './cache.js';
24
+ export declare class DataStore {
25
+ readonly cache: MemoryCache;
26
+ constructor(ttlMs?: number);
27
+ getTokenInfo(ca: Address): TokenInfoFile | null;
28
+ saveTokenInfo(info: TokenInfoFile): void;
29
+ getPoolInfo(ca: Address): PoolInfoFile | null;
30
+ savePoolInfo(info: PoolInfoFile): void;
31
+ getTransactions(ca: Address, groupId: number): TransactionsFile | null;
32
+ /**
33
+ * Append a transaction to the group's history, deduped by txHash.
34
+ * Always reads fresh from disk (no cache) to avoid losing a concurrent append.
35
+ */
36
+ appendTransaction(ca: Address, groupId: number, tx: TransactionRecord): void;
37
+ getHoldings(ca: Address, groupId: number): HoldingsFile | null;
38
+ /**
39
+ * Upsert a single wallet's holding.
40
+ * Merges with existing (by walletAddress); creates the file if missing.
41
+ */
42
+ updateHolding(ca: Address, groupId: number, wallet: Address, patch: Partial<WalletHolding>): void;
43
+ getBalances(ca: Address, groupId: number): BalancesFile | null;
44
+ /**
45
+ * Partial upsert of a single wallet's balance.
46
+ *
47
+ * IMPORTANT: patch semantics — any field you DON'T pass keeps its previous
48
+ * value. This avoids the bug where a BNB-only refresh would clobber a
49
+ * stored tokenBalance. `updatedAt` is always bumped to now.
50
+ *
51
+ * If the wallet has no existing row, missing fields default to 0.
52
+ */
53
+ updateBalance(ca: Address, groupId: number, walletAddress: Address, patch: Partial<Omit<WalletBalance, 'walletAddress' | 'updatedAt'>>): void;
54
+ /**
55
+ * Batch variant: apply a list of patches in one file write.
56
+ * Each patch must include `walletAddress` so we know which row to merge.
57
+ */
58
+ updateBalancesBatch(ca: Address, groupId: number, patches: Array<{
59
+ walletAddress: Address;
60
+ } & Partial<Omit<WalletBalance, 'walletAddress' | 'updatedAt'>>>): void;
61
+ getBnbPrice(): BnbPriceFile | null;
62
+ saveBnbPrice(priceUsd: number): void;
63
+ /**
64
+ * List all token CA directories we have data for.
65
+ *
66
+ * Excludes `NATIVE_BNB` (the sentinel CA used for BNB transfer history) so
67
+ * callers iterating "for each known token" don't hit version=0 reverts on
68
+ * the zero address.
69
+ */
70
+ listTokens(): Address[];
71
+ /**
72
+ * List the groups that have native BNB transfer history.
73
+ * Separate from `listTokens` so downstream monitor/PnL code can treat
74
+ * BNB history distinctly from token holdings.
75
+ */
76
+ listNativeBnbGroups(): number[];
77
+ listGroups(ca: Address): number[];
78
+ /** Ensure the group directory exists (useful before running a session) */
79
+ ensureGroupDir(ca: Address, groupId: number): void;
80
+ }
81
+ /** Get the global DataStore. Tests that need isolation should use `new DataStore()`. */
82
+ export declare function getDataStore(): DataStore;
83
+ /** Reset the singleton (test helper) */
84
+ export declare function resetDataStore(): void;
85
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/datastore/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAaxC,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAGnC,cAAc,YAAY,CAAA;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAwCxC,qBAAa,SAAS;IACpB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;gBAEf,KAAK,SAAS;IAM1B,YAAY,CAAC,EAAE,EAAE,OAAO,GAAG,aAAa,GAAG,IAAI;IAU/C,aAAa,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;IAQxC,WAAW,CAAC,EAAE,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI;IAU7C,YAAY,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI;IAQtC,eAAe,CAAC,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAKtE;;;OAGG;IACH,iBAAiB,CACf,EAAE,EAAE,OAAO,EACX,OAAO,EAAE,MAAM,EACf,EAAE,EAAE,iBAAiB,GACpB,IAAI;IAuBP,WAA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