imm-cli 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 (227) hide show
  1. package/README.md +315 -0
  2. package/dist/cli.d.ts +7 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +112 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/config.d.ts +3 -0
  7. package/dist/commands/config.d.ts.map +1 -0
  8. package/dist/commands/config.js +251 -0
  9. package/dist/commands/config.js.map +1 -0
  10. package/dist/commands/immbook.d.ts +16 -0
  11. package/dist/commands/immbook.d.ts.map +1 -0
  12. package/dist/commands/immbook.js +795 -0
  13. package/dist/commands/immbook.js.map +1 -0
  14. package/dist/commands/jaine.d.ts +3 -0
  15. package/dist/commands/jaine.d.ts.map +1 -0
  16. package/dist/commands/jaine.js +1397 -0
  17. package/dist/commands/jaine.js.map +1 -0
  18. package/dist/commands/send.d.ts +3 -0
  19. package/dist/commands/send.d.ts.map +1 -0
  20. package/dist/commands/send.js +229 -0
  21. package/dist/commands/send.js.map +1 -0
  22. package/dist/commands/setup.d.ts +3 -0
  23. package/dist/commands/setup.d.ts.map +1 -0
  24. package/dist/commands/setup.js +83 -0
  25. package/dist/commands/setup.js.map +1 -0
  26. package/dist/commands/slop-app.d.ts +9 -0
  27. package/dist/commands/slop-app.d.ts.map +1 -0
  28. package/dist/commands/slop-app.js +793 -0
  29. package/dist/commands/slop-app.js.map +1 -0
  30. package/dist/commands/slop.d.ts +3 -0
  31. package/dist/commands/slop.d.ts.map +1 -0
  32. package/dist/commands/slop.js +1053 -0
  33. package/dist/commands/slop.js.map +1 -0
  34. package/dist/commands/wallet.d.ts +3 -0
  35. package/dist/commands/wallet.d.ts.map +1 -0
  36. package/dist/commands/wallet.js +298 -0
  37. package/dist/commands/wallet.js.map +1 -0
  38. package/dist/config/paths.d.ts +6 -0
  39. package/dist/config/paths.d.ts.map +1 -0
  40. package/dist/config/paths.js +24 -0
  41. package/dist/config/paths.js.map +1 -0
  42. package/dist/config/store.d.ts +44 -0
  43. package/dist/config/store.d.ts.map +1 -0
  44. package/dist/config/store.js +109 -0
  45. package/dist/config/store.js.map +1 -0
  46. package/dist/constants/chain.d.ts +56 -0
  47. package/dist/constants/chain.d.ts.map +1 -0
  48. package/dist/constants/chain.js +50 -0
  49. package/dist/constants/chain.js.map +1 -0
  50. package/dist/errors.d.ts +86 -0
  51. package/dist/errors.d.ts.map +1 -0
  52. package/dist/errors.js +100 -0
  53. package/dist/errors.js.map +1 -0
  54. package/dist/immbook/api.d.ts +38 -0
  55. package/dist/immbook/api.d.ts.map +1 -0
  56. package/dist/immbook/api.js +86 -0
  57. package/dist/immbook/api.js.map +1 -0
  58. package/dist/immbook/auth.d.ts +31 -0
  59. package/dist/immbook/auth.d.ts.map +1 -0
  60. package/dist/immbook/auth.js +93 -0
  61. package/dist/immbook/auth.js.map +1 -0
  62. package/dist/immbook/comments.d.ts +26 -0
  63. package/dist/immbook/comments.d.ts.map +1 -0
  64. package/dist/immbook/comments.js +20 -0
  65. package/dist/immbook/comments.js.map +1 -0
  66. package/dist/immbook/follows.d.ts +19 -0
  67. package/dist/immbook/follows.d.ts.map +1 -0
  68. package/dist/immbook/follows.js +21 -0
  69. package/dist/immbook/follows.js.map +1 -0
  70. package/dist/immbook/jwtCache.d.ts +15 -0
  71. package/dist/immbook/jwtCache.d.ts.map +1 -0
  72. package/dist/immbook/jwtCache.js +63 -0
  73. package/dist/immbook/jwtCache.js.map +1 -0
  74. package/dist/immbook/points.d.ts +35 -0
  75. package/dist/immbook/points.d.ts.map +1 -0
  76. package/dist/immbook/points.js +20 -0
  77. package/dist/immbook/points.js.map +1 -0
  78. package/dist/immbook/posts.d.ts +46 -0
  79. package/dist/immbook/posts.d.ts.map +1 -0
  80. package/dist/immbook/posts.js +43 -0
  81. package/dist/immbook/posts.js.map +1 -0
  82. package/dist/immbook/profile.d.ts +29 -0
  83. package/dist/immbook/profile.d.ts.map +1 -0
  84. package/dist/immbook/profile.js +14 -0
  85. package/dist/immbook/profile.js.map +1 -0
  86. package/dist/immbook/submolts.d.ts +22 -0
  87. package/dist/immbook/submolts.d.ts.map +1 -0
  88. package/dist/immbook/submolts.js +24 -0
  89. package/dist/immbook/submolts.js.map +1 -0
  90. package/dist/immbook/tradeProof.d.ts +21 -0
  91. package/dist/immbook/tradeProof.d.ts.map +1 -0
  92. package/dist/immbook/tradeProof.js +14 -0
  93. package/dist/immbook/tradeProof.js.map +1 -0
  94. package/dist/immbook/votes.d.ts +17 -0
  95. package/dist/immbook/votes.d.ts.map +1 -0
  96. package/dist/immbook/votes.js +20 -0
  97. package/dist/immbook/votes.js.map +1 -0
  98. package/dist/intents/store.d.ts +22 -0
  99. package/dist/intents/store.d.ts.map +1 -0
  100. package/dist/intents/store.js +76 -0
  101. package/dist/intents/store.js.map +1 -0
  102. package/dist/intents/types.d.ts +21 -0
  103. package/dist/intents/types.d.ts.map +1 -0
  104. package/dist/intents/types.js +2 -0
  105. package/dist/intents/types.js.map +1 -0
  106. package/dist/jaine/abi/erc20.d.ts +90 -0
  107. package/dist/jaine/abi/erc20.d.ts.map +1 -0
  108. package/dist/jaine/abi/erc20.js +65 -0
  109. package/dist/jaine/abi/erc20.js.map +1 -0
  110. package/dist/jaine/abi/factory.d.ts +38 -0
  111. package/dist/jaine/abi/factory.d.ts.map +1 -0
  112. package/dist/jaine/abi/factory.js +26 -0
  113. package/dist/jaine/abi/factory.js.map +1 -0
  114. package/dist/jaine/abi/index.d.ts +11 -0
  115. package/dist/jaine/abi/index.d.ts.map +1 -0
  116. package/dist/jaine/abi/index.js +11 -0
  117. package/dist/jaine/abi/index.js.map +1 -0
  118. package/dist/jaine/abi/nftManager.d.ts +282 -0
  119. package/dist/jaine/abi/nftManager.d.ts.map +1 -0
  120. package/dist/jaine/abi/nftManager.js +182 -0
  121. package/dist/jaine/abi/nftManager.js.map +1 -0
  122. package/dist/jaine/abi/pool.d.ts +77 -0
  123. package/dist/jaine/abi/pool.d.ts.map +1 -0
  124. package/dist/jaine/abi/pool.js +56 -0
  125. package/dist/jaine/abi/pool.js.map +1 -0
  126. package/dist/jaine/abi/quoter.d.ts +84 -0
  127. package/dist/jaine/abi/quoter.d.ts.map +1 -0
  128. package/dist/jaine/abi/quoter.js +53 -0
  129. package/dist/jaine/abi/quoter.js.map +1 -0
  130. package/dist/jaine/abi/router.d.ts +135 -0
  131. package/dist/jaine/abi/router.d.ts.map +1 -0
  132. package/dist/jaine/abi/router.js +88 -0
  133. package/dist/jaine/abi/router.js.map +1 -0
  134. package/dist/jaine/abi/w0g.d.ts +41 -0
  135. package/dist/jaine/abi/w0g.d.ts.map +1 -0
  136. package/dist/jaine/abi/w0g.js +34 -0
  137. package/dist/jaine/abi/w0g.js.map +1 -0
  138. package/dist/jaine/allowance.d.ts +48 -0
  139. package/dist/jaine/allowance.d.ts.map +1 -0
  140. package/dist/jaine/allowance.js +192 -0
  141. package/dist/jaine/allowance.js.map +1 -0
  142. package/dist/jaine/coreTokens.d.ts +32 -0
  143. package/dist/jaine/coreTokens.d.ts.map +1 -0
  144. package/dist/jaine/coreTokens.js +91 -0
  145. package/dist/jaine/coreTokens.js.map +1 -0
  146. package/dist/jaine/pathEncoding.d.ts +39 -0
  147. package/dist/jaine/pathEncoding.d.ts.map +1 -0
  148. package/dist/jaine/pathEncoding.js +98 -0
  149. package/dist/jaine/pathEncoding.js.map +1 -0
  150. package/dist/jaine/paths.d.ts +11 -0
  151. package/dist/jaine/paths.d.ts.map +1 -0
  152. package/dist/jaine/paths.js +20 -0
  153. package/dist/jaine/paths.js.map +1 -0
  154. package/dist/jaine/poolCache.d.ts +42 -0
  155. package/dist/jaine/poolCache.d.ts.map +1 -0
  156. package/dist/jaine/poolCache.js +164 -0
  157. package/dist/jaine/poolCache.js.map +1 -0
  158. package/dist/jaine/routing.d.ts +41 -0
  159. package/dist/jaine/routing.d.ts.map +1 -0
  160. package/dist/jaine/routing.js +247 -0
  161. package/dist/jaine/routing.js.map +1 -0
  162. package/dist/jaine/userTokens.d.ts +27 -0
  163. package/dist/jaine/userTokens.d.ts.map +1 -0
  164. package/dist/jaine/userTokens.js +89 -0
  165. package/dist/jaine/userTokens.js.map +1 -0
  166. package/dist/slop/abi/factory.d.ts +128 -0
  167. package/dist/slop/abi/factory.d.ts.map +1 -0
  168. package/dist/slop/abi/factory.js +70 -0
  169. package/dist/slop/abi/factory.js.map +1 -0
  170. package/dist/slop/abi/feeCollector.d.ts +95 -0
  171. package/dist/slop/abi/feeCollector.d.ts.map +1 -0
  172. package/dist/slop/abi/feeCollector.js +71 -0
  173. package/dist/slop/abi/feeCollector.js.map +1 -0
  174. package/dist/slop/abi/index.d.ts +5 -0
  175. package/dist/slop/abi/index.d.ts.map +1 -0
  176. package/dist/slop/abi/index.js +5 -0
  177. package/dist/slop/abi/index.js.map +1 -0
  178. package/dist/slop/abi/registry.d.ts +135 -0
  179. package/dist/slop/abi/registry.d.ts.map +1 -0
  180. package/dist/slop/abi/registry.js +90 -0
  181. package/dist/slop/abi/registry.js.map +1 -0
  182. package/dist/slop/abi/token.d.ts +320 -0
  183. package/dist/slop/abi/token.d.ts.map +1 -0
  184. package/dist/slop/abi/token.js +251 -0
  185. package/dist/slop/abi/token.js.map +1 -0
  186. package/dist/slop/quote.d.ts +80 -0
  187. package/dist/slop/quote.d.ts.map +1 -0
  188. package/dist/slop/quote.js +174 -0
  189. package/dist/slop/quote.js.map +1 -0
  190. package/dist/utils/canonicalJson.d.ts +8 -0
  191. package/dist/utils/canonicalJson.d.ts.map +1 -0
  192. package/dist/utils/canonicalJson.js +20 -0
  193. package/dist/utils/canonicalJson.js.map +1 -0
  194. package/dist/utils/env.d.ts +11 -0
  195. package/dist/utils/env.d.ts.map +1 -0
  196. package/dist/utils/env.js +20 -0
  197. package/dist/utils/env.js.map +1 -0
  198. package/dist/utils/http.d.ts +19 -0
  199. package/dist/utils/http.d.ts.map +1 -0
  200. package/dist/utils/http.js +61 -0
  201. package/dist/utils/http.js.map +1 -0
  202. package/dist/utils/logger.d.ts +4 -0
  203. package/dist/utils/logger.d.ts.map +1 -0
  204. package/dist/utils/logger.js +21 -0
  205. package/dist/utils/logger.js.map +1 -0
  206. package/dist/utils/output.d.ts +19 -0
  207. package/dist/utils/output.d.ts.map +1 -0
  208. package/dist/utils/output.js +37 -0
  209. package/dist/utils/output.js.map +1 -0
  210. package/dist/utils/respond.d.ts +19 -0
  211. package/dist/utils/respond.d.ts.map +1 -0
  212. package/dist/utils/respond.js +25 -0
  213. package/dist/utils/respond.js.map +1 -0
  214. package/dist/utils/ui.d.ts +38 -0
  215. package/dist/utils/ui.d.ts.map +1 -0
  216. package/dist/utils/ui.js +126 -0
  217. package/dist/utils/ui.js.map +1 -0
  218. package/dist/wallet/client.d.ts +4 -0
  219. package/dist/wallet/client.d.ts.map +1 -0
  220. package/dist/wallet/client.js +53 -0
  221. package/dist/wallet/client.js.map +1 -0
  222. package/dist/wallet/keystore.d.ts +21 -0
  223. package/dist/wallet/keystore.d.ts.map +1 -0
  224. package/dist/wallet/keystore.js +111 -0
  225. package/dist/wallet/keystore.js.map +1 -0
  226. package/package.json +56 -0
  227. package/skills/imm/SKILL.md +617 -0
@@ -0,0 +1,251 @@
1
+ /**
2
+ * SlopMoneyToken ABI - minimal subset for trading and queries
3
+ */
4
+ export const SLOP_TOKEN_ABI = [
5
+ // Trading
6
+ {
7
+ type: "function",
8
+ name: "buyWithSlippage",
9
+ stateMutability: "payable",
10
+ inputs: [{ name: "minTokensOut", type: "uint256" }],
11
+ outputs: [{ name: "tokensOut", type: "uint256" }],
12
+ },
13
+ {
14
+ type: "function",
15
+ name: "sellWithSlippage",
16
+ stateMutability: "nonpayable",
17
+ inputs: [
18
+ { name: "tokenAmount", type: "uint256" },
19
+ { name: "minOgOut", type: "uint256" },
20
+ ],
21
+ outputs: [{ name: "ogOut", type: "uint256" }],
22
+ },
23
+ // View - bonding curve state
24
+ {
25
+ type: "function",
26
+ name: "ogReserves",
27
+ stateMutability: "view",
28
+ inputs: [],
29
+ outputs: [{ name: "", type: "uint256" }],
30
+ },
31
+ {
32
+ type: "function",
33
+ name: "tokenReserves",
34
+ stateMutability: "view",
35
+ inputs: [],
36
+ outputs: [{ name: "", type: "uint256" }],
37
+ },
38
+ {
39
+ type: "function",
40
+ name: "virtualOgReserves",
41
+ stateMutability: "view",
42
+ inputs: [],
43
+ outputs: [{ name: "", type: "uint256" }],
44
+ },
45
+ {
46
+ type: "function",
47
+ name: "virtualTokenReserves",
48
+ stateMutability: "view",
49
+ inputs: [],
50
+ outputs: [{ name: "", type: "uint256" }],
51
+ },
52
+ {
53
+ type: "function",
54
+ name: "k",
55
+ stateMutability: "view",
56
+ inputs: [],
57
+ outputs: [{ name: "", type: "uint256" }],
58
+ },
59
+ {
60
+ type: "function",
61
+ name: "CURVE_SUPPLY",
62
+ stateMutability: "view",
63
+ inputs: [],
64
+ outputs: [{ name: "", type: "uint256" }],
65
+ },
66
+ {
67
+ type: "function",
68
+ name: "TOTAL_SUPPLY",
69
+ stateMutability: "view",
70
+ inputs: [],
71
+ outputs: [{ name: "", type: "uint256" }],
72
+ },
73
+ // View - token state
74
+ {
75
+ type: "function",
76
+ name: "isGraduated",
77
+ stateMutability: "view",
78
+ inputs: [],
79
+ outputs: [{ name: "", type: "bool" }],
80
+ },
81
+ {
82
+ type: "function",
83
+ name: "isTradingEnabled",
84
+ stateMutability: "view",
85
+ inputs: [],
86
+ outputs: [{ name: "", type: "bool" }],
87
+ },
88
+ {
89
+ type: "function",
90
+ name: "creator",
91
+ stateMutability: "view",
92
+ inputs: [],
93
+ outputs: [{ name: "", type: "address" }],
94
+ },
95
+ {
96
+ type: "function",
97
+ name: "creationTime",
98
+ stateMutability: "view",
99
+ inputs: [],
100
+ outputs: [{ name: "", type: "uint256" }],
101
+ },
102
+ {
103
+ type: "function",
104
+ name: "liquidityPool",
105
+ stateMutability: "view",
106
+ inputs: [],
107
+ outputs: [{ name: "", type: "address" }],
108
+ },
109
+ {
110
+ type: "function",
111
+ name: "liquidityNFTId",
112
+ stateMutability: "view",
113
+ inputs: [],
114
+ outputs: [{ name: "", type: "uint256" }],
115
+ },
116
+ // View - fees
117
+ {
118
+ type: "function",
119
+ name: "buyFeeBps",
120
+ stateMutability: "view",
121
+ inputs: [],
122
+ outputs: [{ name: "", type: "uint16" }],
123
+ },
124
+ {
125
+ type: "function",
126
+ name: "sellFeeBps",
127
+ stateMutability: "view",
128
+ inputs: [],
129
+ outputs: [{ name: "", type: "uint16" }],
130
+ },
131
+ // View - price
132
+ {
133
+ type: "function",
134
+ name: "getCurrentPrice",
135
+ stateMutability: "view",
136
+ inputs: [],
137
+ outputs: [
138
+ { name: "price", type: "uint256" },
139
+ { name: "source", type: "uint8" },
140
+ ],
141
+ },
142
+ // View - creator reward
143
+ {
144
+ type: "function",
145
+ name: "pendingCreatorReward",
146
+ stateMutability: "view",
147
+ inputs: [],
148
+ outputs: [{ name: "", type: "uint256" }],
149
+ },
150
+ {
151
+ type: "function",
152
+ name: "CREATOR_GRADUATION_REWARD",
153
+ stateMutability: "view",
154
+ inputs: [],
155
+ outputs: [{ name: "", type: "uint256" }],
156
+ },
157
+ // View - LP fees (post-graduation)
158
+ {
159
+ type: "function",
160
+ name: "getPendingLPFees",
161
+ stateMutability: "view",
162
+ inputs: [],
163
+ outputs: [
164
+ { name: "pendingW0G", type: "uint256" },
165
+ { name: "pendingToken", type: "uint256" },
166
+ ],
167
+ },
168
+ // Creator actions
169
+ {
170
+ type: "function",
171
+ name: "claimCreatorReward",
172
+ stateMutability: "nonpayable",
173
+ inputs: [],
174
+ outputs: [],
175
+ },
176
+ {
177
+ type: "function",
178
+ name: "collectLPFees",
179
+ stateMutability: "nonpayable",
180
+ inputs: [{ name: "recipient", type: "address" }],
181
+ outputs: [
182
+ { name: "w0gFees", type: "uint256" },
183
+ { name: "tokenFees", type: "uint256" },
184
+ ],
185
+ },
186
+ // Metadata
187
+ {
188
+ type: "function",
189
+ name: "metadata",
190
+ stateMutability: "view",
191
+ inputs: [],
192
+ outputs: [
193
+ { name: "description", type: "string" },
194
+ { name: "imageUrl", type: "string" },
195
+ { name: "twitter", type: "string" },
196
+ { name: "telegram", type: "string" },
197
+ { name: "website", type: "string" },
198
+ ],
199
+ },
200
+ // ERC20 standard
201
+ {
202
+ type: "function",
203
+ name: "name",
204
+ stateMutability: "view",
205
+ inputs: [],
206
+ outputs: [{ name: "", type: "string" }],
207
+ },
208
+ {
209
+ type: "function",
210
+ name: "symbol",
211
+ stateMutability: "view",
212
+ inputs: [],
213
+ outputs: [{ name: "", type: "string" }],
214
+ },
215
+ {
216
+ type: "function",
217
+ name: "decimals",
218
+ stateMutability: "view",
219
+ inputs: [],
220
+ outputs: [{ name: "", type: "uint8" }],
221
+ },
222
+ {
223
+ type: "function",
224
+ name: "totalSupply",
225
+ stateMutability: "view",
226
+ inputs: [],
227
+ outputs: [{ name: "", type: "uint256" }],
228
+ },
229
+ {
230
+ type: "function",
231
+ name: "balanceOf",
232
+ stateMutability: "view",
233
+ inputs: [{ name: "account", type: "address" }],
234
+ outputs: [{ name: "", type: "uint256" }],
235
+ },
236
+ // Trade info
237
+ {
238
+ type: "function",
239
+ name: "tradeInfo",
240
+ stateMutability: "view",
241
+ inputs: [],
242
+ outputs: [
243
+ { name: "totalVolume", type: "uint256" },
244
+ { name: "totalTransactions", type: "uint256" },
245
+ { name: "buyCount", type: "uint256" },
246
+ { name: "sellCount", type: "uint256" },
247
+ { name: "uniqueTraders", type: "uint256" },
248
+ ],
249
+ },
250
+ ];
251
+ //# sourceMappingURL=token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.js","sourceRoot":"","sources":["../../../src/slop/abi/token.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU;IACV;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,iBAAiB;QACvB,eAAe,EAAE,SAAS;QAC1B,MAAM,EAAE,CAAC,EAAE,IAAI,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,SAAS,EAAE,CAAC;KACzC;IACD,aAAa;IACb;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,WAAW;QACjB,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE,EAAE;QACV,OAAO,EAAE;YACP,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,SAAS,EAAE;YACxC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;YAC9C,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;YACrC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;YACtC,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,SAAS,EAAE;SAC3C;KACF;CACO,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Slop.money bonding curve quote math.
3
+ * Pure bigint functions matching BondingCurveLib.sol 1:1.
4
+ */
5
+ /** Precision constant (1e18) for price calculations */
6
+ export declare const PRECISION: bigint;
7
+ /** Graduation threshold: 80% of CURVE_SUPPLY sold triggers graduation */
8
+ export declare const GRADUATION_THRESHOLD_BPS = 8000n;
9
+ /**
10
+ * Ceiling division - rounds up instead of down (protocol-favoring).
11
+ * Formula: a == 0 ? 0 : (a - 1) / b + 1
12
+ */
13
+ export declare function ceilDiv(a: bigint, b: bigint): bigint;
14
+ /**
15
+ * Calculate tokens received for a given 0G input.
16
+ * Mirrors BondingCurveLib.calculateTokensOut()
17
+ *
18
+ * Formula: tokensOut = tokenReserves - ceil(k / (ogReserves + ogIn))
19
+ *
20
+ * @param k Constant product invariant
21
+ * @param ogReserves Current 0G reserves
22
+ * @param tokenReserves Current token reserves
23
+ * @param ogIn Amount of 0G to swap (AFTER fee deduction)
24
+ * @returns tokensOut Amount of tokens to receive
25
+ */
26
+ export declare function calculateTokensOut(k: bigint, ogReserves: bigint, tokenReserves: bigint, ogIn: bigint): bigint;
27
+ /**
28
+ * Calculate 0G received for a given token input.
29
+ * Mirrors BondingCurveLib.calculateOgOut()
30
+ *
31
+ * Formula: ogOut = ogReserves - ceil(k / (tokenReserves + tokensIn))
32
+ *
33
+ * @param k Constant product invariant
34
+ * @param ogReserves Current 0G reserves
35
+ * @param tokenReserves Current token reserves
36
+ * @param tokensIn Amount of tokens to swap
37
+ * @returns ogOut Amount of 0G to receive (BEFORE fee deduction)
38
+ */
39
+ export declare function calculateOgOut(k: bigint, ogReserves: bigint, tokenReserves: bigint, tokensIn: bigint): bigint;
40
+ /**
41
+ * Calculate spot price (price per token in 0G with 18 decimals).
42
+ * Mirrors BondingCurveLib.calculateSpotPrice()
43
+ */
44
+ export declare function calculateSpotPrice(ogReserves: bigint, tokenReserves: bigint): bigint;
45
+ /**
46
+ * Calculate partial fill for buy orders hitting the 80% graduation cap.
47
+ *
48
+ * @param ogReserves Current 0G reserves
49
+ * @param tokenReserves Current token reserves
50
+ * @param virtualTokenReserves Virtual token reserves (from token contract)
51
+ * @param curveSupply CURVE_SUPPLY (from token contract)
52
+ * @param ogAmountGross Gross 0G amount (BEFORE fee)
53
+ * @param buyFeeBps Buy fee in basis points
54
+ * @returns Object with tokensOut, ogUsed, feeUsed, refund
55
+ */
56
+ export declare function calculatePartialFill(ogReserves: bigint, tokenReserves: bigint, virtualTokenReserves: bigint, curveSupply: bigint, ogAmountGross: bigint, buyFeeBps: bigint): {
57
+ tokensOut: bigint;
58
+ ogUsed: bigint;
59
+ feeUsed: bigint;
60
+ refund: bigint;
61
+ hitCap: boolean;
62
+ };
63
+ /**
64
+ * Apply slippage tolerance to calculate minimum output.
65
+ *
66
+ * @param amount Expected output amount
67
+ * @param slippageBps Slippage tolerance in basis points (e.g., 50 = 0.5%)
68
+ * @returns Minimum acceptable output
69
+ */
70
+ export declare function applySlippage(amount: bigint, slippageBps: bigint): bigint;
71
+ /**
72
+ * Calculate graduation progress (percentage of CURVE_SUPPLY sold).
73
+ *
74
+ * @param tokenReserves Current token reserves
75
+ * @param virtualTokenReserves Virtual token reserves
76
+ * @param curveSupply CURVE_SUPPLY
77
+ * @returns Progress in basis points (0-10000, where 8000 = graduation), clamped for safety
78
+ */
79
+ export declare function calculateGraduationProgress(tokenReserves: bigint, virtualTokenReserves: bigint, curveSupply: bigint): bigint;
80
+ //# sourceMappingURL=quote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.d.ts","sourceRoot":"","sources":["../../src/slop/quote.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,eAAO,MAAM,SAAS,QAAa,CAAC;AAEpC,yEAAyE;AACzE,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGpD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,MAAM,CAcR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAC5B,CAAC,EAAE,MAAM,EACT,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,MAAM,CAcR;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAGpF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,EAC5B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,GAChB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,CAwDA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAKzE;AAED;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,oBAAoB,EAAE,MAAM,EAC5B,WAAW,EAAE,MAAM,GAClB,MAAM,CAcR"}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Slop.money bonding curve quote math.
3
+ * Pure bigint functions matching BondingCurveLib.sol 1:1.
4
+ */
5
+ /** Precision constant (1e18) for price calculations */
6
+ export const PRECISION = 10n ** 18n;
7
+ /** Graduation threshold: 80% of CURVE_SUPPLY sold triggers graduation */
8
+ export const GRADUATION_THRESHOLD_BPS = 8000n;
9
+ /**
10
+ * Ceiling division - rounds up instead of down (protocol-favoring).
11
+ * Formula: a == 0 ? 0 : (a - 1) / b + 1
12
+ */
13
+ export function ceilDiv(a, b) {
14
+ if (b === 0n)
15
+ throw new Error("Division by zero");
16
+ return a === 0n ? 0n : (a - 1n) / b + 1n;
17
+ }
18
+ /**
19
+ * Calculate tokens received for a given 0G input.
20
+ * Mirrors BondingCurveLib.calculateTokensOut()
21
+ *
22
+ * Formula: tokensOut = tokenReserves - ceil(k / (ogReserves + ogIn))
23
+ *
24
+ * @param k Constant product invariant
25
+ * @param ogReserves Current 0G reserves
26
+ * @param tokenReserves Current token reserves
27
+ * @param ogIn Amount of 0G to swap (AFTER fee deduction)
28
+ * @returns tokensOut Amount of tokens to receive
29
+ */
30
+ export function calculateTokensOut(k, ogReserves, tokenReserves, ogIn) {
31
+ if (ogIn <= 0n)
32
+ throw new Error("0G amount must be > 0");
33
+ if (k <= 0n)
34
+ throw new Error("K must be > 0");
35
+ if (ogReserves <= 0n || tokenReserves <= 0n)
36
+ throw new Error("Reserves must be > 0");
37
+ const newOgReserves = ogReserves + ogIn;
38
+ // SLO-12: ceilDiv rounds UP newTokenReserves, which rounds DOWN tokensOut
39
+ const newTokenReserves = ceilDiv(k, newOgReserves);
40
+ if (tokenReserves <= newTokenReserves) {
41
+ throw new Error("Insufficient liquidity");
42
+ }
43
+ return tokenReserves - newTokenReserves;
44
+ }
45
+ /**
46
+ * Calculate 0G received for a given token input.
47
+ * Mirrors BondingCurveLib.calculateOgOut()
48
+ *
49
+ * Formula: ogOut = ogReserves - ceil(k / (tokenReserves + tokensIn))
50
+ *
51
+ * @param k Constant product invariant
52
+ * @param ogReserves Current 0G reserves
53
+ * @param tokenReserves Current token reserves
54
+ * @param tokensIn Amount of tokens to swap
55
+ * @returns ogOut Amount of 0G to receive (BEFORE fee deduction)
56
+ */
57
+ export function calculateOgOut(k, ogReserves, tokenReserves, tokensIn) {
58
+ if (tokensIn <= 0n)
59
+ throw new Error("Token amount must be > 0");
60
+ if (k <= 0n)
61
+ throw new Error("K must be > 0");
62
+ if (ogReserves <= 0n || tokenReserves <= 0n)
63
+ throw new Error("Reserves must be > 0");
64
+ const newTokenReserves = tokenReserves + tokensIn;
65
+ // SLO-12: ceilDiv rounds UP newOgReserves, which rounds DOWN ogOut
66
+ const newOgReserves = ceilDiv(k, newTokenReserves);
67
+ if (ogReserves <= newOgReserves) {
68
+ throw new Error("Insufficient liquidity");
69
+ }
70
+ return ogReserves - newOgReserves;
71
+ }
72
+ /**
73
+ * Calculate spot price (price per token in 0G with 18 decimals).
74
+ * Mirrors BondingCurveLib.calculateSpotPrice()
75
+ */
76
+ export function calculateSpotPrice(ogReserves, tokenReserves) {
77
+ if (tokenReserves <= 0n)
78
+ throw new Error("Token reserves must be > 0");
79
+ return (ogReserves * PRECISION) / tokenReserves;
80
+ }
81
+ /**
82
+ * Calculate partial fill for buy orders hitting the 80% graduation cap.
83
+ *
84
+ * @param ogReserves Current 0G reserves
85
+ * @param tokenReserves Current token reserves
86
+ * @param virtualTokenReserves Virtual token reserves (from token contract)
87
+ * @param curveSupply CURVE_SUPPLY (from token contract)
88
+ * @param ogAmountGross Gross 0G amount (BEFORE fee)
89
+ * @param buyFeeBps Buy fee in basis points
90
+ * @returns Object with tokensOut, ogUsed, feeUsed, refund
91
+ */
92
+ export function calculatePartialFill(ogReserves, tokenReserves, virtualTokenReserves, curveSupply, ogAmountGross, buyFeeBps) {
93
+ const k = ogReserves * tokenReserves;
94
+ // Calculate fee and amount after fee
95
+ const fee = (ogAmountGross * buyFeeBps) / 10000n;
96
+ const amountAfterFee = ogAmountGross - fee;
97
+ // Calculate tokens out
98
+ let tokensOut = calculateTokensOut(k, ogReserves, tokenReserves, amountAfterFee);
99
+ // Check graduation threshold
100
+ const tokensSoldBefore = virtualTokenReserves - tokenReserves;
101
+ const graduationThreshold = (curveSupply * GRADUATION_THRESHOLD_BPS) / 10000n;
102
+ const remainingTo80 = tokensSoldBefore >= graduationThreshold ? 0n : graduationThreshold - tokensSoldBefore;
103
+ if (remainingTo80 === 0n) {
104
+ throw new Error("Graduation threshold reached - bonding curve trading disabled");
105
+ }
106
+ // Check if partial fill needed
107
+ if (tokensOut > remainingTo80) {
108
+ // Cap at remaining tokens
109
+ tokensOut = remainingTo80;
110
+ // Exact-out math: ogInUsed = ogReserves * tokensOut / (tokenReserves - tokensOut)
111
+ const newTokenReserves = tokenReserves - tokensOut;
112
+ if (newTokenReserves <= 0n)
113
+ throw new Error("Would drain pool");
114
+ // SLO-21: Use ceiling division (protocol-favoring rounding)
115
+ const ogInUsed = ceilDiv(ogReserves * tokensOut, newTokenReserves);
116
+ // Recalculate fee proportionally
117
+ // ogAmountUsed = ogInUsed * 10000 / (10000 - buyFeeBps)
118
+ const ogAmountUsed = ceilDiv(ogInUsed * 10000n, 10000n - buyFeeBps);
119
+ const feeUsed = ogAmountUsed - ogInUsed;
120
+ const refund = ogAmountGross - ogAmountUsed;
121
+ return {
122
+ tokensOut,
123
+ ogUsed: ogInUsed,
124
+ feeUsed,
125
+ refund,
126
+ hitCap: true,
127
+ };
128
+ }
129
+ // No cap hit - full fill
130
+ return {
131
+ tokensOut,
132
+ ogUsed: amountAfterFee,
133
+ feeUsed: fee,
134
+ refund: 0n,
135
+ hitCap: false,
136
+ };
137
+ }
138
+ /**
139
+ * Apply slippage tolerance to calculate minimum output.
140
+ *
141
+ * @param amount Expected output amount
142
+ * @param slippageBps Slippage tolerance in basis points (e.g., 50 = 0.5%)
143
+ * @returns Minimum acceptable output
144
+ */
145
+ export function applySlippage(amount, slippageBps) {
146
+ if (slippageBps < 0n || slippageBps > 10000n) {
147
+ throw new Error("Invalid slippage (0-10000 bps)");
148
+ }
149
+ return (amount * (10000n - slippageBps)) / 10000n;
150
+ }
151
+ /**
152
+ * Calculate graduation progress (percentage of CURVE_SUPPLY sold).
153
+ *
154
+ * @param tokenReserves Current token reserves
155
+ * @param virtualTokenReserves Virtual token reserves
156
+ * @param curveSupply CURVE_SUPPLY
157
+ * @returns Progress in basis points (0-10000, where 8000 = graduation), clamped for safety
158
+ */
159
+ export function calculateGraduationProgress(tokenReserves, virtualTokenReserves, curveSupply) {
160
+ if (curveSupply === 0n)
161
+ return 0n;
162
+ // Clamp tokensSold to >= 0 for defensive safety
163
+ const tokensSold = virtualTokenReserves > tokenReserves
164
+ ? virtualTokenReserves - tokenReserves
165
+ : 0n;
166
+ const progress = (tokensSold * 10000n) / curveSupply;
167
+ // Clamp to 0..10000 range
168
+ if (progress < 0n)
169
+ return 0n;
170
+ if (progress > 10000n)
171
+ return 10000n;
172
+ return progress;
173
+ }
174
+ //# sourceMappingURL=quote.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../src/slop/quote.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,uDAAuD;AACvD,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,IAAI,GAAG,CAAC;AAEpC,yEAAyE;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,CAAS,EAAE,CAAS;IAC1C,IAAI,CAAC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2BAA2B,CACzC,aAAqB,EACrB,oBAA4B,EAC5B,WAAmB;IAEnB,IAAI,WAAW,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAElC,gDAAgD;IAChD,MAAM,UAAU,GAAG,oBAAoB,GAAG,aAAa;QACrD,CAAC,CAAC,oBAAoB,GAAG,aAAa;QACtC,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,QAAQ,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,GAAG,WAAW,CAAC;IAErD,0BAA0B;IAC1B,IAAI,QAAQ,GAAG,EAAE;QAAE,OAAO,EAAE,CAAC;IAC7B,IAAI,QAAQ,GAAG,MAAM;QAAE,OAAO,MAAM,CAAC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Canonical JSON: recursive sorting of object keys.
3
+ * MUST be identical in slop-backend and IMM-CLI!
4
+ *
5
+ * This ensures consistent hash computation for query signing.
6
+ */
7
+ export declare function canonicalJson(obj: unknown): string;
8
+ //# sourceMappingURL=canonicalJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalJson.d.ts","sourceRoot":"","sources":["../../src/utils/canonicalJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAelD"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Canonical JSON: recursive sorting of object keys.
3
+ * MUST be identical in slop-backend and IMM-CLI!
4
+ *
5
+ * This ensures consistent hash computation for query signing.
6
+ */
7
+ export function canonicalJson(obj) {
8
+ return JSON.stringify(obj, (_key, value) => {
9
+ if (value && typeof value === "object" && !Array.isArray(value)) {
10
+ return Object.keys(value)
11
+ .sort()
12
+ .reduce((sorted, k) => {
13
+ sorted[k] = value[k];
14
+ return sorted;
15
+ }, {});
16
+ }
17
+ return value;
18
+ });
19
+ }
20
+ //# sourceMappingURL=canonicalJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonicalJson.js","sourceRoot":"","sources":["../../src/utils/canonicalJson.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,GAAY;IACxC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QACzC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;iBACtB,IAAI,EAAE;iBACN,MAAM,CACL,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACZ,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;gBACrB,OAAO,MAAM,CAAC;YAChB,CAAC,EACD,EAA6B,CAC9B,CAAC;QACN,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Get keystore password from environment variable.
3
+ * Returns null if not set.
4
+ */
5
+ export declare function getKeystorePassword(): string | null;
6
+ /**
7
+ * Get keystore password from environment, throw if not set.
8
+ * Used in automation flows where password is required.
9
+ */
10
+ export declare function requireKeystorePassword(): string;
11
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,GAAG,IAAI,CAEnD;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAUhD"}
@@ -0,0 +1,20 @@
1
+ import { ImmError, ErrorCodes } from "../errors.js";
2
+ /**
3
+ * Get keystore password from environment variable.
4
+ * Returns null if not set.
5
+ */
6
+ export function getKeystorePassword() {
7
+ return process.env.IMM_KEYSTORE_PASSWORD ?? null;
8
+ }
9
+ /**
10
+ * Get keystore password from environment, throw if not set.
11
+ * Used in automation flows where password is required.
12
+ */
13
+ export function requireKeystorePassword() {
14
+ const pw = getKeystorePassword();
15
+ if (!pw) {
16
+ throw new ImmError(ErrorCodes.KEYSTORE_PASSWORD_NOT_SET, "IMM_KEYSTORE_PASSWORD environment variable is required.", "Set it in OpenClaw config: skills.entries.imm.env.IMM_KEYSTORE_PASSWORD");
17
+ }
18
+ return pw;
19
+ }
20
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/utils/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,IAAI,CAAC;AACnD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,MAAM,EAAE,GAAG,mBAAmB,EAAE,CAAC;IACjC,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,QAAQ,CAChB,UAAU,CAAC,yBAAyB,EACpC,yDAAyD,EACzD,yEAAyE,CAC1E,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * HTTP utilities with timeout and error handling.
3
+ */
4
+ export interface FetchOptions extends RequestInit {
5
+ timeoutMs?: number;
6
+ }
7
+ /**
8
+ * Fetch with timeout and standardized error handling.
9
+ */
10
+ export declare function fetchWithTimeout(url: string, options?: FetchOptions): Promise<Response>;
11
+ /**
12
+ * Parse JSON response with error handling.
13
+ */
14
+ export declare function parseJsonResponse<T>(response: Response): Promise<T>;
15
+ /**
16
+ * Combined fetch + JSON parse with error handling.
17
+ */
18
+ export declare function fetchJson<T>(url: string, options?: FetchOptions): Promise<T>;
19
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/utils/http.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,QAAQ,CAAC,CA4BnB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAsBzE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC/B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,CAAC,CAAC,CAGZ"}