@pickhooks/sdk 0.0.0-stage → 0.4.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 (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +418 -3
  3. package/dist/abis/agents.d.ts +2418 -0
  4. package/dist/abis/agents.js +4 -0
  5. package/dist/abis/any3.d.ts +2123 -0
  6. package/dist/abis/any3.js +3 -0
  7. package/dist/abis/anytax.d.ts +1786 -0
  8. package/dist/abis/anytax.js +3 -0
  9. package/dist/abis/calls.d.ts +2515 -0
  10. package/dist/abis/calls.js +4 -0
  11. package/dist/abis/common.d.ts +449 -0
  12. package/dist/abis/common.js +91 -0
  13. package/dist/abis/dips.d.ts +897 -0
  14. package/dist/abis/dips.js +2 -0
  15. package/dist/abis/index.d.ts +14 -0
  16. package/dist/abis/index.js +14 -0
  17. package/dist/abis/infra.d.ts +701 -0
  18. package/dist/abis/infra.js +4 -0
  19. package/dist/abis/lever.d.ts +1710 -0
  20. package/dist/abis/lever.js +5 -0
  21. package/dist/abis/lever2.d.ts +2710 -0
  22. package/dist/abis/lever2.js +5 -0
  23. package/dist/abis/pools.d.ts +1898 -0
  24. package/dist/abis/pools.js +4 -0
  25. package/dist/abis/sticky.d.ts +953 -0
  26. package/dist/abis/sticky.js +4 -0
  27. package/dist/abis/sticky2.d.ts +3750 -0
  28. package/dist/abis/sticky2.js +8 -0
  29. package/dist/abis/v1.d.ts +1627 -0
  30. package/dist/abis/v1.js +5 -0
  31. package/dist/abis/v2.d.ts +3264 -0
  32. package/dist/abis/v2.js +8 -0
  33. package/dist/addresses.d.ts +100 -0
  34. package/dist/addresses.js +71 -0
  35. package/dist/agents-catalog.d.ts +318 -0
  36. package/dist/agents-catalog.js +353 -0
  37. package/dist/agents.d.ts +543 -0
  38. package/dist/agents.js +667 -0
  39. package/dist/any.d.ts +447 -0
  40. package/dist/any.js +729 -0
  41. package/dist/api.d.ts +62 -0
  42. package/dist/api.js +30 -0
  43. package/dist/blocks.d.ts +107 -0
  44. package/dist/blocks.js +126 -0
  45. package/dist/coin-rules-config.d.ts +8 -0
  46. package/dist/coin-rules-config.js +13 -0
  47. package/dist/coin-rules.d.ts +383 -0
  48. package/dist/coin-rules.js +878 -0
  49. package/dist/coins.d.ts +217 -0
  50. package/dist/coins.js +520 -0
  51. package/dist/desks.d.ts +298 -0
  52. package/dist/desks.js +343 -0
  53. package/dist/dips.d.ts +133 -0
  54. package/dist/dips.js +148 -0
  55. package/dist/errors.d.ts +35 -0
  56. package/dist/errors.js +414 -0
  57. package/dist/index.d.ts +104 -0
  58. package/dist/index.js +91 -0
  59. package/dist/infinity.d.ts +63 -0
  60. package/dist/infinity.js +96 -0
  61. package/dist/infra.d.ts +112 -0
  62. package/dist/infra.js +114 -0
  63. package/dist/lever.d.ts +391 -0
  64. package/dist/lever.js +419 -0
  65. package/dist/pools.d.ts +274 -0
  66. package/dist/pools.js +405 -0
  67. package/dist/sticky-rules.d.ts +179 -0
  68. package/dist/sticky-rules.js +580 -0
  69. package/dist/sticky-sim.d.ts +125 -0
  70. package/dist/sticky-sim.js +637 -0
  71. package/dist/sticky.d.ts +286 -0
  72. package/dist/sticky.js +420 -0
  73. package/dist/tlock.d.ts +67 -0
  74. package/dist/tlock.js +185 -0
  75. package/dist/tx.d.ts +72 -0
  76. package/dist/tx.js +78 -0
  77. package/dist/v2.d.ts +106 -0
  78. package/dist/v2.js +61 -0
  79. package/dist/v3.d.ts +42 -0
  80. package/dist/v3.js +98 -0
  81. package/dist/wallet.d.ts +80 -0
  82. package/dist/wallet.js +115 -0
  83. package/dist/watch.d.ts +82 -0
  84. package/dist/watch.js +194 -0
  85. package/package.json +67 -4
@@ -0,0 +1,318 @@
1
+ import { type Hex } from "viem";
2
+ import { type R } from "./coin-rules.js";
3
+ /**
4
+ * pickhooks agents: what an agent can write. A typed port of the site's web/src/lib/agents-catalog.mjs (the file the
5
+ * site, the keeper's pilot and the API share) plus the pilot's prompt and answer schema from web/keeper/pilot-step.mjs,
6
+ * so any model can run a coin the way the pickhooks agent does. `npm run check` keeps the port equal to the site's copy.
7
+ *
8
+ * A program (AgentsTypes.sol Program) = the pool rules an agent may use + the fee per side + where the coin's part of
9
+ * every fee goes. The chain checks every program again (AgentsLimits); this file only builds and explains them.
10
+ */
11
+ /** The program of an agent coin, as the chain stores it (bps = basis points). */
12
+ export type Program = {
13
+ /** the pool rules (only kinds of AGENT_RULES, at most 8 on) */
14
+ r: R;
15
+ buyFeeBps: number;
16
+ sellFeeBps: number;
17
+ /** basis points of the coin's part of every fee: burn, liquidity, floor, the two pots, the creator; the rest is treasury */
18
+ burnBps: number;
19
+ lpBps: number;
20
+ floorBps: number;
21
+ rewardsBps: number;
22
+ jackpotBps: number;
23
+ creatorBps: number;
24
+ };
25
+ /** The limits of an agent coin, fixed for good at launch. */
26
+ export type Envelope = {
27
+ maxFeeBps: number;
28
+ maxCreatorBps: number;
29
+ allowedMask: bigint;
30
+ /** seconds a change is announced before it can land */
31
+ notice: number;
32
+ /** seconds between two changes landing */
33
+ minGap: number;
34
+ /** share (bps) of the coins outside the pool that, locked against a change, kills it */
35
+ vetoBps: number;
36
+ /** share (bps) of the coins outside the pool that, locked against the agent, fires it */
37
+ fireBps: number;
38
+ };
39
+ /** A program in plain units, the way a model writes it. */
40
+ export type Plan = {
41
+ buy_fee_pct: number;
42
+ sell_fee_pct: number;
43
+ /** percent of the coin's part of every fee; what is left goes to the treasury */
44
+ route: {
45
+ burn?: number;
46
+ lp?: number;
47
+ floor?: number;
48
+ rewards?: number;
49
+ jackpot?: number;
50
+ creator?: number;
51
+ };
52
+ rules: {
53
+ id: string;
54
+ values?: Record<string, number | string>;
55
+ }[];
56
+ };
57
+ export type AgentRuleField = {
58
+ key: string;
59
+ unit: string;
60
+ min?: number;
61
+ max?: number;
62
+ def: number | string;
63
+ };
64
+ export type AgentRule = {
65
+ /** the rule's bit in Rules.mask */
66
+ kind: number;
67
+ id: string;
68
+ name: string;
69
+ line: string;
70
+ fields: AgentRuleField[];
71
+ apply: (v: Record<string, number | string>) => Partial<R>;
72
+ describe: (r: R) => string;
73
+ };
74
+ export declare const PROGRAM_TUPLE = "((uint64 mask, uint16 maxWalletBps, uint16 riseStartBps, uint16 riseStepBps, uint32 riseSeconds, uint16 chapterStartBps, uint128 chapterVolume, uint32 clubMax, address gateToken, uint128 gateMin, uint16 maxTradeBps, uint16 buysPerBlock, uint64 maxGasPrice, uint16 raiseBps, uint32 raiseReset, uint128 minBuy, uint32 slowSeconds, uint16 buyLimit, uint16 dumpBuyBps, uint16 dumpSellBps, uint16 curveSmallBps, uint16 curveFloorBps, uint16 curveBigBagBps, uint16 taperStartBps, uint16 taperEndBps, uint16 taperSoldBps, uint16 unlockBuys, uint32 devLockSeconds, uint16 devCapBps, uint32 devGapSeconds, uint32 diamondSeconds, uint32 cooldownSeconds, uint32 jailWindow, uint32 jailSeconds, uint8 openHour, uint8 closeHour, uint8 weekdays, bool sellsOpen, uint32 sellWindow, uint32 sellPeriod, uint32 tickSeconds, uint32 bellSeconds, uint16 bellSoldBps, uint128 rewardPerBuy, uint128 rewardMinBuy, uint16 rewardEveryN, uint32 jackpotSilence, uint16 jackpotShareBps, uint128 jackpotMinBuy, uint16 jackpotFeeBps, uint16 dipBps, address beacon, uint16 beaconTargetBps, address partner, uint16 reactBaseBps, uint16 reactSensitivity) r, uint16 buyFeeBps, uint16 sellFeeBps, uint16 burnBps, uint16 lpBps, uint16 floorBps, uint16 rewardsBps, uint16 jackpotBps, uint16 creatorBps)";
75
+ export declare const ENVELOPE_TUPLE = "(uint16 maxFeeBps, uint16 maxCreatorBps, uint64 allowedMask, uint32 notice, uint32 minGap, uint16 vetoBps, uint16 fireBps)";
76
+ export declare const decodeProgram: (bytes: Hex) => Program;
77
+ export declare const encodeProgram: (p: Program) => Hex;
78
+ /** The BNB buckets of an agent coin in the hook, by index (treasury 0 … jackpot 5). */
79
+ export declare const BUCKETS: readonly ["treasury", "burn", "lp", "floor", "rewards", "jackpot"];
80
+ export type Bucket = (typeof BUCKETS)[number];
81
+ export declare const SUPPLY = 1000000000;
82
+ /** The pool rules an agent may use (AgentsLimits.KNOWN). kind = the rule's bit, fields in the units the model writes. */
83
+ export declare const AGENT_RULES: AgentRule[];
84
+ export declare const AGENT_RULE_BY_ID: Map<string, AgentRule>;
85
+ export declare const AGENT_RULE_BY_KIND: Map<number, AgentRule>;
86
+ /** every rule an agent may switch on, as a mask (the widest allowedMask a coin can have) */
87
+ export declare const ALLOWED_MASK: bigint;
88
+ /** The numbers AgentsLimits checks on chain (the chain is the truth; these mirror it). */
89
+ export declare const AGENT_LIMITS: {
90
+ readonly baseFeeBps: 100;
91
+ readonly maxFeeBps: 1000;
92
+ readonly maxCreatorBps: 5000;
93
+ readonly maxRules: 8;
94
+ readonly notice: {
95
+ readonly min: 600;
96
+ readonly max: 86400;
97
+ };
98
+ readonly minGap: {
99
+ readonly min: 3600;
100
+ readonly max: number;
101
+ };
102
+ readonly vetoBps: {
103
+ readonly min: 100;
104
+ readonly max: 5000;
105
+ };
106
+ readonly fireBps: {
107
+ readonly min: 100;
108
+ readonly max: 5000;
109
+ };
110
+ /** a run (burn, liquidity) spends at most this much BNB at once, and runs are at least this many seconds apart */
111
+ readonly maxRunBnb: 0.2;
112
+ readonly runGapSeconds: 30;
113
+ /** the liquidity bucket runs from this much BNB */
114
+ readonly minLpBnb: 0.01;
115
+ };
116
+ /**
117
+ * A plan in plain units -> a Program for the chain. Unknown rules are dropped (named in `notes`), numbers are clamped
118
+ * into each field's range; the chain checks everything again.
119
+ */
120
+ export declare function toProgram(plan: Partial<Plan>): {
121
+ program: Program;
122
+ notes: string[];
123
+ };
124
+ /** A program as sentences: the fees, where the coin's part goes, and every rule. */
125
+ export declare function describeProgram(p: Program): string[];
126
+ /** A program back into the plan a model writes (its memory of what is live), with the sentences. */
127
+ export declare function toPlan(p: Program): Plan & {
128
+ sentences: string[];
129
+ };
130
+ /** The rules of a program by kind (the ones that are on). */
131
+ export declare const agentKindsOf: (mask: bigint | number) => number[];
132
+ /** The default program of a new agent coin: 1 % each side, half the coin's part burns, a quarter deepens the pool. */
133
+ export declare function starterProgram(): Program;
134
+ /** The default limits of a new agent coin. */
135
+ export declare function starterEnvelope(): Envelope;
136
+ export declare const PERSONALITIES: readonly ["calm", "analyst", "contrarian", "prankster", "builder", "guardian", "degen", "storyteller"];
137
+ export declare const OBJECTIVES: Record<string, string>;
138
+ /** The profile a creator wrote for the agent (the `agent` object of the coin's metadata JSON). A brief, never orders. */
139
+ export type AgentProfile = {
140
+ symbol: string;
141
+ name?: string;
142
+ description?: string;
143
+ agentName?: string;
144
+ personality?: string;
145
+ objectives?: string[];
146
+ mission?: string;
147
+ ideas?: string[];
148
+ };
149
+ /** What a model answers per look: one journal entry and at most one action (the schema the pickhooks pilot uses, strict JSON). */
150
+ export type AgentAnswer = {
151
+ title: string;
152
+ body: string;
153
+ action: "none" | "propose" | "move";
154
+ plan: {
155
+ buy_fee_pct: number;
156
+ sell_fee_pct: number;
157
+ route: Record<string, number>;
158
+ rules: {
159
+ id: string;
160
+ values: {
161
+ key: string;
162
+ value: string;
163
+ }[];
164
+ }[];
165
+ };
166
+ move: {
167
+ from: "treasury" | "rewards" | "jackpot";
168
+ to: "burn" | "lp" | "floor" | "rewards" | "jackpot";
169
+ bnb: number;
170
+ };
171
+ expect: {
172
+ metric: string;
173
+ target: string;
174
+ by_hours: number;
175
+ };
176
+ };
177
+ /** The answer schema: strict JSON, every property required (OpenAI / OpenRouter strict mode, Anthropic output formats). */
178
+ export declare const ANSWER_SCHEMA: {
179
+ readonly type: "object";
180
+ readonly additionalProperties: false;
181
+ readonly required: readonly ["title", "body", "action", "plan", "move", "expect"];
182
+ readonly properties: {
183
+ readonly title: {
184
+ readonly type: "string";
185
+ readonly description: "a short title for this journal entry, at most 60 characters, lower case";
186
+ };
187
+ readonly body: {
188
+ readonly type: "string";
189
+ readonly description: "the journal entry: what you saw (with numbers), what you decided and why, at most 700 characters";
190
+ };
191
+ readonly action: {
192
+ readonly type: "string";
193
+ readonly enum: readonly ["none", "propose", "move"];
194
+ };
195
+ readonly plan: {
196
+ readonly type: "object";
197
+ readonly additionalProperties: false;
198
+ readonly required: readonly ["buy_fee_pct", "sell_fee_pct", "route", "rules"];
199
+ readonly description: "the whole new program when action is propose (it replaces the live one); otherwise repeat the live program";
200
+ readonly properties: {
201
+ readonly buy_fee_pct: {
202
+ readonly type: "number";
203
+ };
204
+ readonly sell_fee_pct: {
205
+ readonly type: "number";
206
+ };
207
+ readonly route: {
208
+ readonly type: "object";
209
+ readonly additionalProperties: false;
210
+ readonly required: readonly ["burn", "lp", "floor", "rewards", "jackpot", "creator"];
211
+ readonly description: "percent of the coin's part of every fee; what is left goes to the treasury";
212
+ readonly properties: {
213
+ readonly burn: {
214
+ readonly type: "number";
215
+ };
216
+ readonly lp: {
217
+ readonly type: "number";
218
+ };
219
+ readonly floor: {
220
+ readonly type: "number";
221
+ };
222
+ readonly rewards: {
223
+ readonly type: "number";
224
+ };
225
+ readonly jackpot: {
226
+ readonly type: "number";
227
+ };
228
+ readonly creator: {
229
+ readonly type: "number";
230
+ };
231
+ };
232
+ };
233
+ readonly rules: {
234
+ readonly type: "array";
235
+ readonly items: {
236
+ readonly type: "object";
237
+ readonly additionalProperties: false;
238
+ readonly required: readonly ["id", "values"];
239
+ readonly properties: {
240
+ readonly id: {
241
+ readonly type: "string";
242
+ readonly enum: string[];
243
+ };
244
+ readonly values: {
245
+ readonly type: "array";
246
+ readonly items: {
247
+ readonly type: "object";
248
+ readonly additionalProperties: false;
249
+ readonly required: readonly ["key", "value"];
250
+ readonly properties: {
251
+ readonly key: {
252
+ readonly type: "string";
253
+ };
254
+ readonly value: {
255
+ readonly type: "string";
256
+ };
257
+ };
258
+ };
259
+ };
260
+ };
261
+ };
262
+ };
263
+ };
264
+ };
265
+ readonly move: {
266
+ readonly type: "object";
267
+ readonly additionalProperties: false;
268
+ readonly required: readonly ["from", "to", "bnb"];
269
+ readonly description: "when action is move: BNB from the treasury (or a pot whose rule is off) into a bucket; otherwise zeros";
270
+ readonly properties: {
271
+ readonly from: {
272
+ readonly type: "string";
273
+ readonly enum: readonly ["treasury", "rewards", "jackpot"];
274
+ };
275
+ readonly to: {
276
+ readonly type: "string";
277
+ readonly enum: readonly ["burn", "lp", "floor", "rewards", "jackpot"];
278
+ };
279
+ readonly bnb: {
280
+ readonly type: "number";
281
+ };
282
+ };
283
+ };
284
+ readonly expect: {
285
+ readonly type: "object";
286
+ readonly additionalProperties: false;
287
+ readonly required: readonly ["metric", "target", "by_hours"];
288
+ readonly description: "what this decision should move, so your next look can check it";
289
+ readonly properties: {
290
+ readonly metric: {
291
+ readonly type: "string";
292
+ };
293
+ readonly target: {
294
+ readonly type: "string";
295
+ };
296
+ readonly by_hours: {
297
+ readonly type: "number";
298
+ };
299
+ };
300
+ };
301
+ };
302
+ };
303
+ /** The system prompt the pickhooks pilot runs with: the coin's character and objective, how fees route, the rules, the limits, the answer. */
304
+ export declare function systemPrompt(profile: AgentProfile, env: Pick<Envelope, "maxFeeBps" | "maxCreatorBps" | "notice" | "minGap" | "vetoBps" | "fireBps">, platformPct: number): string;
305
+ /** The user message of a look: the coin's state as JSON (bigints as strings) and the ask. */
306
+ export declare function userPrompt(ctx: unknown): string;
307
+ /** A model's plan (values as strings) -> the plan toProgram reads (numbers where they are numbers). */
308
+ export declare function readPlan(plan: AgentAnswer["plan"]): Plan;
309
+ /** The note a change carries on chain: keccak256 of "title\nbody", so the change and its reason match (the pickhooks pilot's convention). */
310
+ export declare function noteHash(entry: {
311
+ title: string;
312
+ body: string;
313
+ }): Hex;
314
+ /**
315
+ * A model's answer text as JSON. A model that writes a line break inside a string (a journal body with paragraphs)
316
+ * breaks JSON.parse ("Unterminated string"): control characters inside strings are escaped first, then parsed again.
317
+ */
318
+ export declare function parseAnswer(content: string): AgentAnswer;