@pickhooks/sdk 0.2.0 → 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.
package/dist/errors.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { decodeErrorResult, toFunctionSelector } from "viem";
2
2
  import { formatAbiItem } from "viem/utils";
3
+ import { agentsDeskAbi, agentsFactoryAbi, agentsHookAbi } from "./abis/agents.js";
3
4
  import { any3FactoryAbi, any3HookAbi } from "./abis/any3.js";
4
5
  import { anyTaxFactoryAbi, anyTaxHookAbi } from "./abis/anytax.js";
5
6
  import { callsDeskAbi, callsFactoryAbi, callsHookAbi } from "./abis/calls.js";
@@ -9,6 +10,7 @@ import { leverEngineAbi, leverFactoryAbi, leverHookAbi, leverRouterAbi } from ".
9
10
  import { lever2EngineAbi, lever2FactoryAbi, lever2HookAbi } from "./abis/lever2.js";
10
11
  import { poolsFactoryAbi, poolsHookAbi } from "./abis/pools.js";
11
12
  import { stickyFactoryAbi, stickyTokenAbi, stickyValidatorAbi } from "./abis/sticky.js";
13
+ import { coverDeskAbi, darkRoundAbi, launchDeskAbi, ruleAuctionAbi, sticky2FactoryAbi, sticky2TokenAbi, sticky2ValidatorAbi } from "./abis/sticky2.js";
12
14
  import { v1FactoryAbi, v1TokenAbi } from "./abis/v1.js";
13
15
  import { arenaAbi, floorVaultAbi, payrollBoxAbi, v2FactoryAbi, v2TokenAbi, voteBoxAbi } from "./abis/v2.js";
14
16
  /** sticky: what token.check() answers when no row stops a trade but the coins are not unlocked yet */
@@ -25,6 +27,16 @@ export const CHECK_TEXT = {
25
27
  };
26
28
  /** hook any coin's factory and sticky's factory and validator: Bad(what) as a sentence */
27
29
  const BAD = {
30
+ // sticky 2 factory and dark round
31
+ tick: "The start price is not on the price ladder.",
32
+ drip: "The drip is at most an hour.",
33
+ ciphertext: "The sealed bid has the wrong shape.",
34
+ creator: "The creator address is empty.",
35
+ switcher: "The coin's switcher is not listed, or it has switch rows without one.",
36
+ round: "A round runs 2 to 60 minutes.",
37
+ allocation: "The round sells 10 to 30 % of the supply.",
38
+ raise: "The minimum raise is at least 0.05 BNB.",
39
+ step: "The step is 0 to 23.",
28
40
  // hook any coin, open()
29
41
  fee: "Pool fee: 0.2 to 1 % (feeBps 20 to 100).",
30
42
  holderFee: "The holder fee cannot be higher than the pool fee.",
@@ -80,6 +92,20 @@ const BY_NAME = {
80
92
  NoLiquidity: "That is too little to add any liquidity. Put in more.",
81
93
  FeeOnTransfer: "This coin takes a fee on transfers, so it cannot go into a pool.",
82
94
  Transfer: "The coin refused the transfer. Check the balance and the allowance.",
95
+ // agents: the desk and the hook
96
+ NotPilot: "Only the coin's pilot (its agent's wallet) can do that.",
97
+ NoPilot: "This coin has no pilot any more: the holders fired it.",
98
+ NoPending: "This coin has no pending change.",
99
+ NoLock: "This wallet has no coins locked at the desk for this coin.",
100
+ Closed: "That vote is over: the change landed or was cancelled, or the pilot is gone.",
101
+ Unsteady: "The pool's price moved in this block already. The run waits for the next block.",
102
+ BadBucket: "That bucket does not exist, or BNB cannot move there.",
103
+ Empty: "That bucket is empty.",
104
+ DeskSet: "The desk is set once.",
105
+ NotDesk: "Only the desk can do that.",
106
+ NotReady: "The factory is not initialised yet.",
107
+ Liquidity: "The launch could not place the curve.",
108
+ AlreadyRegistered: "This coin is registered already.",
83
109
  PriceMoved: "The coin's price moved more than allowed while the pool opened. Check again and open.",
84
110
  TooShallow: "Not enough liquidity: the pool must be at least as deep as the coin's main pool.",
85
111
  StillLocked: "This position is still locked. Each one stays 30 days after it went in.",
@@ -155,9 +181,40 @@ const BY_NAME = {
155
181
  Premium: "The premium is between 0.01 % and 50 % of what a floor covers.",
156
182
  Until: "The end of the bid has to be in the future.",
157
183
  Deposit: "A new bid locks at least 0.01 BNB, and at least its smallest floor.",
158
- IsClosed: "That bid is closed.",
159
184
  BidOver: "That bid has ended: it takes no new floors.",
160
- TooBig: "The bid has less BNB free than this floor covers. Protect fewer coins or pick another bid.",
185
+ TooBig: "That is more than this bid or offer has free. Ask for less or pick another one.",
186
+ // sticky 2 desks (dev cover, dark launch, rule auction, launch desk); TooBig and IsClosed above are shared with dip bids
187
+ IsClosed: "That bid or offer is closed.",
188
+ NotWriter: "Only the wallet that posted the offer can do that.",
189
+ NoOffer: "There is no cover offer with this id.",
190
+ NoPolicy: "There is no policy with this id.",
191
+ Mark: "The mark is 10, 25, 50 or 100 % of the creator's coins sold.",
192
+ Stop: "The stop share has to be at most the mark.",
193
+ OfferOver: "This offer has ended: it takes no new policies.",
194
+ MarkHit: "The creator already sold past this mark: no new policies on it.",
195
+ StopHit: "The creator already sold past this offer's stop share: no new policies.",
196
+ Creator: "The creator cannot cover its own coin.",
197
+ OverBag: "A policy can only cover what this wallet's coins are worth right now. Ask for less.",
198
+ NotTriggered: "The creator has not sold past the mark yet (or it happened inside the 10 minute warm up).",
199
+ NoRound: "There is no dark round with this id.",
200
+ NotOpen: "Not every bid is open yet and the opening window is still running.",
201
+ Over: "This round takes no more bids.",
202
+ Opened: "That bid is open already.",
203
+ Nothing: "Nothing left to claim for this bid.",
204
+ NotSwitcher: "Only the coin's switcher can turn a game on.",
205
+ AlreadyStarted: "The auction of this coin has started already.",
206
+ Length: "The coin has no switch rows for the auction.",
207
+ NotAGame: "That rule is not one of the coin's games.",
208
+ Zero: "Burn more than nothing.",
209
+ Burn: "The burn failed: check the balance and the approval to the auction.",
210
+ NothingToSettle: "There is no auction round to settle for this coin.",
211
+ NotOperator: "Only the pad's reply bot may launch from a launch desk balance.",
212
+ NotAllowed: "This wallet has not allowed the bot to launch for it.",
213
+ Limit: "Over this wallet's limit per launch or per day.",
214
+ Balance: "Not enough BNB on the launch desk for this.",
215
+ GasFee: "The gas refund asked for is over the cap of 0.002 BNB.",
216
+ FeeTooHigh: "That fee is over the contract's cap.",
217
+ ZeroAddress: "That address is empty.",
161
218
  Ended: "That floor has run out or was already handed in.",
162
219
  NotOver: "Only the owner can end a floor before it runs out.",
163
220
  NotYours: "That floor belongs to another wallet.",
@@ -192,6 +249,13 @@ const ABIS = [
192
249
  stickyFactoryAbi,
193
250
  stickyValidatorAbi,
194
251
  stickyTokenAbi,
252
+ sticky2FactoryAbi,
253
+ sticky2ValidatorAbi,
254
+ sticky2TokenAbi,
255
+ coverDeskAbi,
256
+ ruleAuctionAbi,
257
+ darkRoundAbi,
258
+ launchDeskAbi,
195
259
  anyTaxFactoryAbi,
196
260
  anyTaxHookAbi,
197
261
  v1FactoryAbi,
@@ -218,6 +282,9 @@ const ABIS = [
218
282
  hooksExecutorAbi,
219
283
  hooksFloorAbi,
220
284
  hooksFloorFactoryAbi,
285
+ agentsFactoryAbi,
286
+ agentsHookAbi,
287
+ agentsDeskAbi,
221
288
  ];
222
289
  /** every error selector the pickhooks ABIs know, for errors that PancakeSwap wraps (WrappedError, the quoter's revert) */
223
290
  const SELECTORS = ABIS.flatMap((abi) => abi.filter((x) => x.type === "error").map((x) => ({ sel: toFunctionSelector(formatAbiItem(x)).slice(2).toLowerCase(), abi })));
package/dist/index.d.ts CHANGED
@@ -1,15 +1,19 @@
1
1
  import type { PublicClient } from "viem";
2
2
  import type { Addresses } from "./addresses.js";
3
+ import { type AgentsModule } from "./agents.js";
3
4
  import { type AnyModule } from "./any.js";
4
5
  import { type ApiModule } from "./api.js";
5
6
  import { type Block, type BlocksCatalog } from "./blocks.js";
6
7
  import { type CoinsModule } from "./coins.js";
8
+ import { type DesksModule } from "./desks.js";
7
9
  import { type DipsModule } from "./dips.js";
8
10
  import { type InfraModule } from "./infra.js";
9
11
  import { type Lever2Module, type LeverModule } from "./lever.js";
10
12
  import { type CallsModule, type PoolsModule } from "./pools.js";
11
13
  import { type StickyModule } from "./sticky.js";
12
14
  import { type PickhooksOptions, type SendOptions, type Sent, type TxRequest } from "./tx.js";
15
+ import { type WalletModule } from "./wallet.js";
16
+ import { type WatchModule } from "./watch.js";
13
17
  export type Pickhooks = {
14
18
  addresses: Addresses;
15
19
  publicClient: PublicClient;
@@ -17,6 +21,16 @@ export type Pickhooks = {
17
21
  any: AnyModule;
18
22
  /** sticky rules: rules that stick to the coins */
19
23
  sticky: StickyModule;
24
+ /** sticky 2: the same coins from the second factory, plus what the creator sold and the switch rows (off until it is on mainnet) */
25
+ sticky2: StickyModule & Pick<DesksModule, "devCounters" | "switches">;
26
+ /** dev cover and dev bond: cover against the creator selling, paid out of the desk when the creator's sold share reaches the mark */
27
+ cover: DesksModule["cover"];
28
+ /** the rule auction: holders burn coins to pick the game of the next round */
29
+ auction: DesksModule["auction"];
30
+ /** the dark launch: sealed bids before the coin exists, one price for everyone, born with BNB on both sides */
31
+ dark: DesksModule["dark"];
32
+ /** the launch desk of launch per reply: a wallet's balance the pad's bot may launch with, for that wallet only */
33
+ launchDesk: DesksModule["desk"];
20
34
  /** coins with their rules in the coin (v1 and v2, also find the dev and CZ mode coins) */
21
35
  coins: CoinsModule;
22
36
  /** pools: coins with their rules in a PancakeSwap Infinity pool hook */
@@ -29,8 +43,14 @@ export type Pickhooks = {
29
43
  leverV1: LeverModule;
30
44
  /** dip bids: floors at a strike */
31
45
  dips: DipsModule;
32
- /** HOOKS infra: BNB floors under coins and the protected buy (off while their addresses are zero) */
46
+ /** HOOKS infra: BNB floors under coins and the protected buy */
33
47
  infra: InfraModule;
48
+ /** agents: coins run by an agent that rewrites their rules live, inside limits the chain checks; be the agent yourself (brief, act) */
49
+ agents: AgentsModule;
50
+ /** live events: every launch on the pad, every trade of a coin, everything that happens to an agent coin */
51
+ watch: WatchModule;
52
+ /** one address: everything it holds on pickhooks, what it can sell now, what it can claim */
53
+ wallet: WalletModule;
34
54
  /** the building blocks: sticky rules' ready blocks with their numbers and rows, the hook script grammar, the rule book (offline; ph.api.blocks() asks the site) */
35
55
  blocks: {
36
56
  catalog: () => BlocksCatalog;
@@ -46,8 +66,12 @@ export type Pickhooks = {
46
66
  * The pickhooks SDK. One client, a part per product:
47
67
  * any hook any coin: quotes, trades with the recapture room, opening a pool with a partner, the payouts
48
68
  * sticky sticky rules: launching from templates, checking a trade against the coin's table, trading, lifting
69
+ * sticky2 sticky 2 (the same, plus what the creator sold); cover: dev cover and dev bond; auction: the rule auction;
70
+ * dark: the dark launch (sealed bids, @pickhooks/sdk/tlock seals them); launchDesk: launch per reply's balance
49
71
  * coins coins with rules in the coin (v1, v2): rules as sentences, the rule that would refuse a trade, launches
50
72
  * pools rules in the pool; calls: curve calls; lever: Lever longs and shorts (leverV1 the first lever); dips: dip bids
73
+ * agents coins run by an agent: read the program, brief any model, act as the pilot, veto and fire as a holder
74
+ * watch live events (launches, trades, agent changes); wallet: one address, everything it holds and can claim
51
75
  * api pickhooks.com's public JSON API (launch feed, board, activity)
52
76
  *
53
77
  * const ph = createPickhooks({ walletClient });
@@ -60,14 +84,21 @@ export { CHECK_TEXT, PickhooksError, decodeRevert, errorText, explain, findRever
60
84
  export { DEFAULT_RPC, deadlineIn, minusBps, type PickhooksOptions, type SendOptions, type Sent, type TxRequest } from "./tx.js";
61
85
  export { blockedKind, buildInfiSwap, infiPriceBnb, infiQuote, infiSwapInput, permit2Approvals, poolIdOf, toKey, type PoolKey } from "./infinity.js";
62
86
  export { approvalFor, buildV3Buy, buildV3Sell, receivedOf, v3PriceBnb, v3Quote } from "./v3.js";
87
+ export { type Venue, bestVenue, buildV2Buy, buildV2Sell, v2Quote, v2RouterAbi } from "./v2.js";
63
88
  export { MAX_TICK, MIN_TICK, TAX_QUOTE_MARK, afterTax, depthNeeds, fitLadder, partnerLink, rangeFor, tickOf, type AnyLine, type AnyModule, type AnyPool, type AnyQuote, type CoinCheck, type Earnings, type OpenOptions, type OpenParams, type PoolConfig, type PoolPosition, type PoolRef, type RangeKind, type Recapture, type TaxLive, type TradeResult, } from "./any.js";
64
- export { describeRows, type StickyCheck, type StickyCoin, type StickyLaunch, type StickyLot, type StickyModule, type StickyRow, type StickyTerms, } from "./sticky.js";
89
+ export { describeRows, stickyTable, stickyTestRun, testRunText, type StickyTestRun, type StickyCheck, type StickyCoin, type StickyLaunch, type StickyLot, type StickyModule, type StickyRow, type StickyTerms, } from "./sticky.js";
90
+ export { CURVE, SUPPLY, simulate, type SimReport } from "./sticky-sim.js";
65
91
  export { ruleText, type CoinRule, type CoinsModule, type RuleCheck, type RuleCoin, type RuleCoinVersion, type RuleLaunch } from "./coins.js";
66
92
  export { type CallRow, type CallStep, type CallsModule, type HookCoin, type HookLaunch, type PoolsModule } from "./pools.js";
67
93
  export { LEVER2_REASON, type Lever2CloseQuote, type Lever2Module, type Lever2OpenQuote, type Lever2Row, type Lever2State, type LeverCoin, type LeverMarket, type LeverModule, type LeverPosition, } from "./lever.js";
68
94
  export { coinsFor, coverOf, strikeFromPrice, type DipBid, type DipFloor, type DipPost, type DipsModule } from "./dips.js";
69
95
  export { type ApiModule, type Launch, type LaunchFeed } from "./api.js";
96
+ export { type AuctionState, type CoverOffer, type CoverPolicy, type CoverPost, type DarkBid, type DarkRoundState, type DesksModule, type DevCounters, } from "./desks.js";
70
97
  export { type FloorState, type InfraModule, type ProtectOffer } from "./infra.js";
98
+ export { type AgentCoin, type AgentLaunch, type AgentLock, type AgentLook, type AgentPending, type AgentsModule, type JournalEntry } from "./agents.js";
99
+ export { AGENT_LIMITS, AGENT_RULES, AGENT_RULE_BY_ID, AGENT_RULE_BY_KIND, ALLOWED_MASK, ANSWER_SCHEMA, BUCKETS, ENVELOPE_TUPLE, OBJECTIVES, PERSONALITIES, PROGRAM_TUPLE, agentKindsOf, decodeProgram, describeProgram, encodeProgram, noteHash, parseAnswer, readPlan, starterEnvelope, starterProgram, systemPrompt, toPlan, toProgram, userPrompt, type AgentAnswer, type AgentProfile, type AgentRule, type AgentRuleField, type Bucket, type Envelope, type Plan, type Program, } from "./agents-catalog.js";
100
+ export { type AgentEvent, type WatchMode, type WatchOptions, type WatchModule, type WatchedLaunch, type WatchedTrade } from "./watch.js";
101
+ export { type WalletCoin, type WalletModule, type WalletView } from "./wallet.js";
71
102
  export { BLOCKS_VERSION, BLOCK_ACTIONS, BLOCK_CHECKS, BLOCK_MARKS, BLOCK_OPERATORS, BLOCK_TRIGGERS, blockLineVars, blocksCatalog, type Block, type BlockAction, type BlockParam, type BlockVariable, type BlocksCatalog, type CoinRuleBlock, type CoinRuleField, type GrammarItem, } from "./blocks.js";
72
103
  export { ACT, FLAG, LOCKED, NONE, ON, OP, STICKY_LIMITS, TEMPLATES, TEMPLATE_BY_ID, VAR, VARS, VAR_BY_ID, compile, decodeRow, defaults, editToRow, emptyEditRow, encodeRow, paramProblems, rowProblems, rowText, scannerOf, tableProblems, templateOf, type Cond, type EditCond, type EditRow, type Pick, type Row, type Template, type TemplateId, } from "./sticky-rules.js";
73
104
  export { GROUPS, RULES, RULE_BY_ID, RULE_BY_KIND, buildRules, emptyExtras, emptyRules, fieldProblem, kindsOf, refusal, selectionProblem, v2Costs, worstScanner, defaults as ruleDefaults, type Picked, type R as CoinRules, type RuleDef, type X as CoinExtras, } from "./coin-rules.js";
package/dist/index.js CHANGED
@@ -1,19 +1,27 @@
1
+ import { agentsModule } from "./agents.js";
1
2
  import { anyModule } from "./any.js";
2
3
  import { apiModule } from "./api.js";
3
4
  import { blocksCatalog } from "./blocks.js";
4
5
  import { coinsModule } from "./coins.js";
6
+ import { desksModule } from "./desks.js";
5
7
  import { dipsModule } from "./dips.js";
6
8
  import { infraModule } from "./infra.js";
7
9
  import { lever2Module, leverModule } from "./lever.js";
8
10
  import { callsModule, poolsModule } from "./pools.js";
9
11
  import { stickyModule } from "./sticky.js";
10
12
  import { makeCtx, sendAll, sendTx } from "./tx.js";
13
+ import { walletModule } from "./wallet.js";
14
+ import { watchModule } from "./watch.js";
11
15
  /**
12
16
  * The pickhooks SDK. One client, a part per product:
13
17
  * any hook any coin: quotes, trades with the recapture room, opening a pool with a partner, the payouts
14
18
  * sticky sticky rules: launching from templates, checking a trade against the coin's table, trading, lifting
19
+ * sticky2 sticky 2 (the same, plus what the creator sold); cover: dev cover and dev bond; auction: the rule auction;
20
+ * dark: the dark launch (sealed bids, @pickhooks/sdk/tlock seals them); launchDesk: launch per reply's balance
15
21
  * coins coins with rules in the coin (v1, v2): rules as sentences, the rule that would refuse a trade, launches
16
22
  * pools rules in the pool; calls: curve calls; lever: Lever longs and shorts (leverV1 the first lever); dips: dip bids
23
+ * agents coins run by an agent: read the program, brief any model, act as the pilot, veto and fire as a holder
24
+ * watch live events (launches, trades, agent changes); wallet: one address, everything it holds and can claim
17
25
  * api pickhooks.com's public JSON API (launch feed, board, activity)
18
26
  *
19
27
  * const ph = createPickhooks({ walletClient });
@@ -22,18 +30,36 @@ import { makeCtx, sendAll, sendTx } from "./tx.js";
22
30
  */
23
31
  export function createPickhooks(options = {}) {
24
32
  const ctx = makeCtx(options);
33
+ const d = desksModule(ctx);
34
+ const sticky = stickyModule(ctx);
35
+ const sticky2 = stickyModule(ctx, true);
36
+ const coins = coinsModule(ctx);
37
+ const pools = poolsModule(ctx);
38
+ const calls = callsModule(ctx);
39
+ const lever = lever2Module(ctx);
40
+ const dips = dipsModule(ctx);
41
+ const any = anyModule(ctx);
42
+ const agents = agentsModule(ctx);
25
43
  return {
26
44
  addresses: ctx.a,
27
45
  publicClient: ctx.pub,
28
- any: anyModule(ctx),
29
- sticky: stickyModule(ctx),
30
- coins: coinsModule(ctx),
31
- pools: poolsModule(ctx),
32
- calls: callsModule(ctx),
33
- lever: lever2Module(ctx),
46
+ any,
47
+ sticky,
48
+ sticky2: { ...sticky2, devCounters: d.devCounters, switches: d.switches },
49
+ cover: d.cover,
50
+ auction: d.auction,
51
+ dark: d.dark,
52
+ launchDesk: d.desk,
53
+ coins,
54
+ pools,
55
+ calls,
56
+ lever,
34
57
  leverV1: leverModule(ctx),
35
- dips: dipsModule(ctx),
58
+ dips,
36
59
  infra: infraModule(ctx),
60
+ agents,
61
+ watch: watchModule(ctx, { sticky, sticky2, coins, pools, calls, agents, any }),
62
+ wallet: walletModule(ctx, { sticky, sticky2, coins, pools, calls, lever, agents, any, dips }),
37
63
  blocks: { catalog: blocksCatalog, block: (id) => blocksCatalog().sticky.blocks.find((b) => b.id === id) ?? null },
38
64
  api: apiModule(ctx),
39
65
  send: (tx, o) => sendTx(ctx, tx, o),
@@ -45,14 +71,21 @@ export { CHECK_TEXT, PickhooksError, decodeRevert, errorText, explain, findRever
45
71
  export { DEFAULT_RPC, deadlineIn, minusBps } from "./tx.js";
46
72
  export { blockedKind, buildInfiSwap, infiPriceBnb, infiQuote, infiSwapInput, permit2Approvals, poolIdOf, toKey } from "./infinity.js";
47
73
  export { approvalFor, buildV3Buy, buildV3Sell, receivedOf, v3PriceBnb, v3Quote } from "./v3.js";
74
+ export { bestVenue, buildV2Buy, buildV2Sell, v2Quote, v2RouterAbi } from "./v2.js";
48
75
  export { MAX_TICK, MIN_TICK, TAX_QUOTE_MARK, afterTax, depthNeeds, fitLadder, partnerLink, rangeFor, tickOf, } from "./any.js";
49
- export { describeRows, } from "./sticky.js";
76
+ export { describeRows, stickyTable, stickyTestRun, testRunText, } from "./sticky.js";
77
+ export { CURVE, SUPPLY, simulate } from "./sticky-sim.js";
50
78
  export { ruleText } from "./coins.js";
51
79
  export {} from "./pools.js";
52
80
  export { LEVER2_REASON, } from "./lever.js";
53
81
  export { coinsFor, coverOf, strikeFromPrice } from "./dips.js";
54
82
  export {} from "./api.js";
83
+ export {} from "./desks.js";
55
84
  export {} from "./infra.js";
85
+ export {} from "./agents.js";
86
+ export { AGENT_LIMITS, AGENT_RULES, AGENT_RULE_BY_ID, AGENT_RULE_BY_KIND, ALLOWED_MASK, ANSWER_SCHEMA, BUCKETS, ENVELOPE_TUPLE, OBJECTIVES, PERSONALITIES, PROGRAM_TUPLE, agentKindsOf, decodeProgram, describeProgram, encodeProgram, noteHash, parseAnswer, readPlan, starterEnvelope, starterProgram, systemPrompt, toPlan, toProgram, userPrompt, } from "./agents-catalog.js";
87
+ export {} from "./watch.js";
88
+ export {} from "./wallet.js";
56
89
  export { BLOCKS_VERSION, BLOCK_ACTIONS, BLOCK_CHECKS, BLOCK_MARKS, BLOCK_OPERATORS, BLOCK_TRIGGERS, blockLineVars, blocksCatalog, } from "./blocks.js";
57
90
  export { ACT, FLAG, LOCKED, NONE, ON, OP, STICKY_LIMITS, TEMPLATES, TEMPLATE_BY_ID, VAR, VARS, VAR_BY_ID, compile, decodeRow, defaults, editToRow, emptyEditRow, encodeRow, paramProblems, rowProblems, rowText, scannerOf, tableProblems, templateOf, } from "./sticky-rules.js";
58
91
  export { GROUPS, RULES, RULE_BY_ID, RULE_BY_KIND, buildRules, emptyExtras, emptyRules, fieldProblem, kindsOf, refusal, selectionProblem, v2Costs, worstScanner, defaults as ruleDefaults, } from "./coin-rules.js";
@@ -0,0 +1,125 @@
1
+ /**
2
+ * sticky rules in the browser: the coin's rule engine (src/sticky/StickyToken.sol) line for line, on bigints, and a test
3
+ * run of random trades on top. The engine is checked against the contract trade by trade (test/sticky/StickyTrace.t.sol
4
+ * writes a run, scripts/dev/sticky-sim-diff.mjs replays it here), so what the launcher shows is what the coin would do.
5
+ * The chain stays the truth: this only shows a creator what a table does before the launch.
6
+ */
7
+ import { type Row } from "./sticky-rules.js";
8
+ export declare const SUPPLY: bigint;
9
+ /** The addresses the coin does not keep lots for. */
10
+ export declare const POOL = "pool";
11
+ export declare const POT = "pot";
12
+ export declare const DEAD = "dead";
13
+ export type Lot = {
14
+ amount: bigint;
15
+ lk: bigint;
16
+ since: number;
17
+ flags: number;
18
+ };
19
+ export type Stats = {
20
+ holders: number;
21
+ buys: number;
22
+ sells: number;
23
+ highAt: number;
24
+ lastBuy: number;
25
+ volume: bigint;
26
+ net: bigint;
27
+ peak: bigint;
28
+ high: bigint;
29
+ };
30
+ export type Now = {
31
+ t: number;
32
+ b: number;
33
+ };
34
+ export type CoinState = {
35
+ rows: Row[];
36
+ release: number;
37
+ off: number;
38
+ creator: string;
39
+ start: number;
40
+ startBlock: number;
41
+ curveSupply: bigint;
42
+ stats: Stats;
43
+ bal: Map<string, bigint>;
44
+ lots: Map<string, Lot[]>;
45
+ };
46
+ export type Result = {
47
+ ok: true;
48
+ burn: bigint;
49
+ toPot: bigint;
50
+ drop: bigint;
51
+ } | {
52
+ ok: false;
53
+ why: number | "nope";
54
+ };
55
+ export declare function newCoin(rows: (bigint | Row)[], release: number, creator: string, curveSupply: bigint, start?: number, startBlock?: number): CoinState;
56
+ /** A transfer as the coin runs it: out of POOL is a buy, into POOL a sell, anything else a send. */
57
+ export declare function transfer(s: CoinState, from: string, to: string, amount: bigint, now: Now): Result;
58
+ /** What `a` could sell right now (size rows left out, like the coin's view). */
59
+ export declare function sellable(s: CoinState, a: string, now: Now): bigint;
60
+ export declare function balanceOf(s: CoinState, a: string): bigint;
61
+ export declare function lots(s: CoinState, a: string): Lot[];
62
+ /** The curve as the coin prices it: x * y = k from the start price, so price / start = (supply / coins left)². */
63
+ export declare const CURVE: {
64
+ supply: bigint;
65
+ startFdvBnb: number;
66
+ };
67
+ export type SimReport = {
68
+ trades: number;
69
+ hours: number;
70
+ buys: {
71
+ ok: number;
72
+ refused: number;
73
+ };
74
+ sells: {
75
+ ok: number;
76
+ refused: number;
77
+ };
78
+ sends: {
79
+ ok: number;
80
+ refused: number;
81
+ };
82
+ /** refusals by row (0 based) and LOCKED (254) */
83
+ refusals: {
84
+ row: number;
85
+ count: number;
86
+ }[];
87
+ /** longest a wallet that wanted to sell had to wait until a sell went through (seconds) */
88
+ longestWait: number;
89
+ /** wallets still unable to sell when the run ended */
90
+ stillWaiting: number;
91
+ /** after the run: seconds until every wallet can sell everything (null: longer than 31 days) */
92
+ allFreeAfter: number | null;
93
+ burnedPct: number;
94
+ pot: {
95
+ inPct: number;
96
+ drops: number;
97
+ paidPct: number;
98
+ biggestX: number;
99
+ leftPct: number;
100
+ };
101
+ snipers: {
102
+ count: number;
103
+ firstSellAfter: number | null;
104
+ };
105
+ splits: {
106
+ count: number;
107
+ refusedAfter: number;
108
+ };
109
+ /** a scanner's test: a tiny buy and an instant sell an hour after launch */
110
+ scanner: {
111
+ buy: number | null;
112
+ sell: number | null;
113
+ };
114
+ };
115
+ /**
116
+ * Random trades on a fresh coin with this table: the creator's first buy, three snipers in the first blocks, wallets
117
+ * that come, buy, hold for a while and sell (and try again when refused), some bags split to fresh wallets that then
118
+ * try to sell. The same seed gives the same run.
119
+ */
120
+ export declare function simulate(rows: bigint[], release: number, opts?: {
121
+ seed?: number;
122
+ trades?: number;
123
+ devBuyBnb?: number;
124
+ start?: number;
125
+ }): SimReport;