@pickhooks/sdk 0.2.0 → 0.5.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/README.md +143 -4
- package/dist/abis/agents.d.ts +2418 -0
- package/dist/abis/agents.js +4 -0
- package/dist/abis/index.d.ts +3 -0
- package/dist/abis/index.js +3 -0
- package/dist/abis/sticky2.d.ts +3750 -0
- package/dist/abis/sticky2.js +8 -0
- package/dist/abis/sticky3.d.ts +2292 -0
- package/dist/abis/sticky3.js +8 -0
- package/dist/addresses.d.ts +25 -1
- package/dist/addresses.js +23 -2
- package/dist/agents-catalog.d.ts +318 -0
- package/dist/agents-catalog.js +353 -0
- package/dist/agents.d.ts +543 -0
- package/dist/agents.js +667 -0
- package/dist/desks.d.ts +298 -0
- package/dist/desks.js +343 -0
- package/dist/errors.js +97 -2
- package/dist/index.d.ts +59 -4
- package/dist/index.js +86 -9
- package/dist/modes-catalog.d.ts +59 -0
- package/dist/modes-catalog.js +77 -0
- package/dist/modes.d.ts +71 -0
- package/dist/modes.js +86 -0
- package/dist/simulate.d.ts +75 -0
- package/dist/simulate.js +225 -0
- package/dist/sticky-sim.d.ts +125 -0
- package/dist/sticky-sim.js +637 -0
- package/dist/sticky.d.ts +93 -4
- package/dist/sticky.js +281 -43
- package/dist/text-launch.d.ts +52 -0
- package/dist/text-launch.js +178 -0
- package/dist/tlock.d.ts +77 -0
- package/dist/tlock.js +201 -0
- package/dist/tx.d.ts +2 -0
- package/dist/tx.js +9 -0
- package/dist/v2.d.ts +106 -0
- package/dist/v2.js +61 -0
- package/dist/wallet.d.ts +80 -0
- package/dist/wallet.js +115 -0
- package/dist/watch.d.ts +82 -0
- package/dist/watch.js +194 -0
- package/package.json +12 -2
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,8 @@ 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";
|
|
14
|
+
import { comboModeAbi, drandBeaconAbi, forwardModeAbi, sticky3FactoryAbi, sticky3TokenAbi, sticky3ValidatorAbi, } from "./abis/sticky3.js";
|
|
12
15
|
import { v1FactoryAbi, v1TokenAbi } from "./abis/v1.js";
|
|
13
16
|
import { arenaAbi, floorVaultAbi, payrollBoxAbi, v2FactoryAbi, v2TokenAbi, voteBoxAbi } from "./abis/v2.js";
|
|
14
17
|
/** sticky: what token.check() answers when no row stops a trade but the coins are not unlocked yet */
|
|
@@ -25,6 +28,16 @@ export const CHECK_TEXT = {
|
|
|
25
28
|
};
|
|
26
29
|
/** hook any coin's factory and sticky's factory and validator: Bad(what) as a sentence */
|
|
27
30
|
const BAD = {
|
|
31
|
+
// sticky 2 factory and dark round
|
|
32
|
+
tick: "The start price is not on the price ladder.",
|
|
33
|
+
drip: "The drip is at most an hour.",
|
|
34
|
+
ciphertext: "The sealed bid has the wrong shape.",
|
|
35
|
+
creator: "The creator address is empty.",
|
|
36
|
+
switcher: "The coin's switcher is not listed, or it has switch rows without one.",
|
|
37
|
+
round: "A round runs 2 to 60 minutes.",
|
|
38
|
+
allocation: "The round sells 10 to 30 % of the supply.",
|
|
39
|
+
raise: "The minimum raise is at least 0.05 BNB.",
|
|
40
|
+
step: "The step is 0 to 23.",
|
|
28
41
|
// hook any coin, open()
|
|
29
42
|
fee: "Pool fee: 0.2 to 1 % (feeBps 20 to 100).",
|
|
30
43
|
holderFee: "The holder fee cannot be higher than the pool fee.",
|
|
@@ -71,6 +84,21 @@ const BAD = {
|
|
|
71
84
|
"pot needs a drop": "A pot needs a drop row that pays it out.",
|
|
72
85
|
every: "Every n-th buy: n from 2 to 1,000,000.",
|
|
73
86
|
idle: "Time since the last buy: at most 30 days.",
|
|
87
|
+
// sticky 3: the factory, the validator, the modes
|
|
88
|
+
mode: "That mode is not open for launches (or it launches another way).",
|
|
89
|
+
"mode data": "Settings for a mode, but no mode.",
|
|
90
|
+
"game take": "The rows' burns and pots and the mode's share are over 10 % of a buy together.",
|
|
91
|
+
bps: "The mode's share of buys is outside its bounds.",
|
|
92
|
+
min: "The mode's minimum size is outside its bounds (0.001 to 0.1 % of the supply).",
|
|
93
|
+
registered: "This coin is registered with the mode already.",
|
|
94
|
+
"no play": "This mode has nothing to play.",
|
|
95
|
+
"no poke": "This mode has nothing to nudge.",
|
|
96
|
+
"no action": "Say what to do (the action first).",
|
|
97
|
+
action: "This mode does not know that action.",
|
|
98
|
+
player: "The creator (and the coin's pools) cannot play this.",
|
|
99
|
+
"too small": "Too small: below the mode's minimum.",
|
|
100
|
+
size: "A size is out of its bounds.",
|
|
101
|
+
"not yet": "Not yet: the reveal round is not out.",
|
|
74
102
|
};
|
|
75
103
|
/** every other error of the pickhooks contracts, by name */
|
|
76
104
|
const BY_NAME = {
|
|
@@ -80,6 +108,20 @@ const BY_NAME = {
|
|
|
80
108
|
NoLiquidity: "That is too little to add any liquidity. Put in more.",
|
|
81
109
|
FeeOnTransfer: "This coin takes a fee on transfers, so it cannot go into a pool.",
|
|
82
110
|
Transfer: "The coin refused the transfer. Check the balance and the allowance.",
|
|
111
|
+
// agents: the desk and the hook
|
|
112
|
+
NotPilot: "Only the coin's pilot (its agent's wallet) can do that.",
|
|
113
|
+
NoPilot: "This coin has no pilot any more: the holders fired it.",
|
|
114
|
+
NoPending: "This coin has no pending change.",
|
|
115
|
+
NoLock: "This wallet has no coins locked at the desk for this coin.",
|
|
116
|
+
Closed: "That vote is over: the change landed or was cancelled, or the pilot is gone.",
|
|
117
|
+
Unsteady: "The pool's price moved in this block already. The run waits for the next block.",
|
|
118
|
+
BadBucket: "That bucket does not exist, or BNB cannot move there.",
|
|
119
|
+
Empty: "That bucket is empty.",
|
|
120
|
+
DeskSet: "The desk is set once.",
|
|
121
|
+
NotDesk: "Only the desk can do that.",
|
|
122
|
+
NotReady: "The factory is not initialised yet.",
|
|
123
|
+
Liquidity: "The launch could not place the curve.",
|
|
124
|
+
AlreadyRegistered: "This coin is registered already.",
|
|
83
125
|
PriceMoved: "The coin's price moved more than allowed while the pool opened. Check again and open.",
|
|
84
126
|
TooShallow: "Not enough liquidity: the pool must be at least as deep as the coin's main pool.",
|
|
85
127
|
StillLocked: "This position is still locked. Each one stays 30 days after it went in.",
|
|
@@ -155,9 +197,40 @@ const BY_NAME = {
|
|
|
155
197
|
Premium: "The premium is between 0.01 % and 50 % of what a floor covers.",
|
|
156
198
|
Until: "The end of the bid has to be in the future.",
|
|
157
199
|
Deposit: "A new bid locks at least 0.01 BNB, and at least its smallest floor.",
|
|
158
|
-
IsClosed: "That bid is closed.",
|
|
159
200
|
BidOver: "That bid has ended: it takes no new floors.",
|
|
160
|
-
TooBig: "
|
|
201
|
+
TooBig: "That is more than this bid or offer has free. Ask for less or pick another one.",
|
|
202
|
+
// sticky 2 desks (dev cover, dark launch, rule auction, launch desk); TooBig and IsClosed above are shared with dip bids
|
|
203
|
+
IsClosed: "That bid or offer is closed.",
|
|
204
|
+
NotWriter: "Only the wallet that posted the offer can do that.",
|
|
205
|
+
NoOffer: "There is no cover offer with this id.",
|
|
206
|
+
NoPolicy: "There is no policy with this id.",
|
|
207
|
+
Mark: "The mark is 10, 25, 50 or 100 % of the creator's coins sold.",
|
|
208
|
+
Stop: "The stop share has to be at most the mark.",
|
|
209
|
+
OfferOver: "This offer has ended: it takes no new policies.",
|
|
210
|
+
MarkHit: "The creator already sold past this mark: no new policies on it.",
|
|
211
|
+
StopHit: "The creator already sold past this offer's stop share: no new policies.",
|
|
212
|
+
Creator: "The creator cannot cover its own coin.",
|
|
213
|
+
OverBag: "A policy can only cover what this wallet's coins are worth right now. Ask for less.",
|
|
214
|
+
NotTriggered: "The creator has not sold past the mark yet (or it happened inside the 10 minute warm up).",
|
|
215
|
+
NoRound: "There is no dark round with this id.",
|
|
216
|
+
NotOpen: "Not every bid is open yet and the opening window is still running.",
|
|
217
|
+
Over: "This round takes no more bids.",
|
|
218
|
+
Opened: "That bid is open already.",
|
|
219
|
+
Nothing: "Nothing left to claim for this bid.",
|
|
220
|
+
NotSwitcher: "Only the coin's switcher can turn a game on.",
|
|
221
|
+
AlreadyStarted: "The auction of this coin has started already.",
|
|
222
|
+
Length: "The coin has no switch rows for the auction.",
|
|
223
|
+
NotAGame: "That rule is not one of the coin's games.",
|
|
224
|
+
Zero: "Burn more than nothing.",
|
|
225
|
+
Burn: "The burn failed: check the balance and the approval to the auction.",
|
|
226
|
+
NothingToSettle: "There is no auction round to settle for this coin.",
|
|
227
|
+
NotOperator: "Only the pad's reply bot may launch from a launch desk balance.",
|
|
228
|
+
NotAllowed: "This wallet has not allowed the bot to launch for it.",
|
|
229
|
+
Limit: "Over this wallet's limit per launch or per day.",
|
|
230
|
+
Balance: "Not enough BNB on the launch desk for this.",
|
|
231
|
+
GasFee: "The gas refund asked for is over the cap of 0.002 BNB.",
|
|
232
|
+
FeeTooHigh: "That fee is over the contract's cap.",
|
|
233
|
+
ZeroAddress: "That address is empty.",
|
|
161
234
|
Ended: "That floor has run out or was already handed in.",
|
|
162
235
|
NotOver: "Only the owner can end a floor before it runs out.",
|
|
163
236
|
NotYours: "That floor belongs to another wallet.",
|
|
@@ -176,6 +249,12 @@ const BY_NAME = {
|
|
|
176
249
|
NothingToProtect: "No coins arrived to protect.",
|
|
177
250
|
Swap: "The swap through PancakeSwap failed.",
|
|
178
251
|
Target: "The executor only calls PancakeSwap's own routers.",
|
|
252
|
+
// sticky 3: the coin
|
|
253
|
+
Busy: "The coin is busy with its mode. Try again.",
|
|
254
|
+
NoMode: "This coin has no mode.",
|
|
255
|
+
LowGas: "Too little gas for the coin's mode: send it with more gas (estimate again).",
|
|
256
|
+
BadOrder: "The mode answered with an order the coin refuses.",
|
|
257
|
+
BadSignature: "That is not drand's signature on this round.",
|
|
179
258
|
};
|
|
180
259
|
/** PancakeSwap's own errors that a trade can run into */
|
|
181
260
|
const PANCAKE = [
|
|
@@ -192,6 +271,13 @@ const ABIS = [
|
|
|
192
271
|
stickyFactoryAbi,
|
|
193
272
|
stickyValidatorAbi,
|
|
194
273
|
stickyTokenAbi,
|
|
274
|
+
sticky2FactoryAbi,
|
|
275
|
+
sticky2ValidatorAbi,
|
|
276
|
+
sticky2TokenAbi,
|
|
277
|
+
coverDeskAbi,
|
|
278
|
+
ruleAuctionAbi,
|
|
279
|
+
darkRoundAbi,
|
|
280
|
+
launchDeskAbi,
|
|
195
281
|
anyTaxFactoryAbi,
|
|
196
282
|
anyTaxHookAbi,
|
|
197
283
|
v1FactoryAbi,
|
|
@@ -218,6 +304,15 @@ const ABIS = [
|
|
|
218
304
|
hooksExecutorAbi,
|
|
219
305
|
hooksFloorAbi,
|
|
220
306
|
hooksFloorFactoryAbi,
|
|
307
|
+
agentsFactoryAbi,
|
|
308
|
+
agentsHookAbi,
|
|
309
|
+
agentsDeskAbi,
|
|
310
|
+
sticky3FactoryAbi,
|
|
311
|
+
sticky3ValidatorAbi,
|
|
312
|
+
sticky3TokenAbi,
|
|
313
|
+
drandBeaconAbi,
|
|
314
|
+
comboModeAbi,
|
|
315
|
+
forwardModeAbi,
|
|
221
316
|
];
|
|
222
317
|
/** every error selector the pickhooks ABIs know, for errors that PancakeSwap wraps (WrappedError, the quoter's revert) */
|
|
223
318
|
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,22 @@
|
|
|
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
|
-
import { type StickyModule } from "./sticky.js";
|
|
13
|
+
import { type StickyModule, type StickyLaunch } from "./sticky.js";
|
|
14
|
+
import { type ModesModule } from "./modes.js";
|
|
15
|
+
import { type SimulateModule } from "./simulate.js";
|
|
16
|
+
import { type TextRead, understandLaunch } from "./text-launch.js";
|
|
12
17
|
import { type PickhooksOptions, type SendOptions, type Sent, type TxRequest } from "./tx.js";
|
|
18
|
+
import { type WalletModule } from "./wallet.js";
|
|
19
|
+
import { type WatchModule } from "./watch.js";
|
|
13
20
|
export type Pickhooks = {
|
|
14
21
|
addresses: Addresses;
|
|
15
22
|
publicClient: PublicClient;
|
|
@@ -17,6 +24,33 @@ export type Pickhooks = {
|
|
|
17
24
|
any: AnyModule;
|
|
18
25
|
/** sticky rules: rules that stick to the coins */
|
|
19
26
|
sticky: StickyModule;
|
|
27
|
+
/** sticky 2: the same coins from the second factory, plus what the creator sold and the switch rows (off until it is on mainnet) */
|
|
28
|
+
sticky2: StickyModule & Pick<DesksModule, "devCounters" | "switches">;
|
|
29
|
+
/**
|
|
30
|
+
* sticky 3: the sticky 2 coin with a mode (a game, like combo), fixed at launch: launch with `mode` and
|
|
31
|
+
* `modeSettings`; fromText reads a sentence into a launch. Off until the factory is on mainnet (the zero address).
|
|
32
|
+
*/
|
|
33
|
+
sticky3: StickyModule & {
|
|
34
|
+
fromText: (text: string, o?: {
|
|
35
|
+
reader?: Parameters<typeof understandLaunch>[1];
|
|
36
|
+
metadata?: string;
|
|
37
|
+
}) => Promise<TextRead & {
|
|
38
|
+
by: "parser" | "reader" | null;
|
|
39
|
+
launch: StickyLaunch | null;
|
|
40
|
+
}>;
|
|
41
|
+
};
|
|
42
|
+
/** the games of sticky 3 coins: each mode's state and actions, custody, the catalog */
|
|
43
|
+
modes: ModesModule;
|
|
44
|
+
/** every buy, sell, send or play tried first against the chain as it is (eth_simulateV1): what arrives, burns, pays, or which rule stops it */
|
|
45
|
+
simulate: SimulateModule;
|
|
46
|
+
/** dev cover and dev bond: cover against the creator selling, paid out of the desk when the creator's sold share reaches the mark */
|
|
47
|
+
cover: DesksModule["cover"];
|
|
48
|
+
/** the rule auction: holders burn coins to pick the game of the next round */
|
|
49
|
+
auction: DesksModule["auction"];
|
|
50
|
+
/** the dark launch: sealed bids before the coin exists, one price for everyone, born with BNB on both sides */
|
|
51
|
+
dark: DesksModule["dark"];
|
|
52
|
+
/** the launch desk of launch per reply: a wallet's balance the pad's bot may launch with, for that wallet only */
|
|
53
|
+
launchDesk: DesksModule["desk"];
|
|
20
54
|
/** coins with their rules in the coin (v1 and v2, also find the dev and CZ mode coins) */
|
|
21
55
|
coins: CoinsModule;
|
|
22
56
|
/** pools: coins with their rules in a PancakeSwap Infinity pool hook */
|
|
@@ -29,8 +63,14 @@ export type Pickhooks = {
|
|
|
29
63
|
leverV1: LeverModule;
|
|
30
64
|
/** dip bids: floors at a strike */
|
|
31
65
|
dips: DipsModule;
|
|
32
|
-
/** HOOKS infra: BNB floors under coins and the protected buy
|
|
66
|
+
/** HOOKS infra: BNB floors under coins and the protected buy */
|
|
33
67
|
infra: InfraModule;
|
|
68
|
+
/** agents: coins run by an agent that rewrites their rules live, inside limits the chain checks; be the agent yourself (brief, act) */
|
|
69
|
+
agents: AgentsModule;
|
|
70
|
+
/** live events: every launch on the pad, every trade of a coin, everything that happens to an agent coin */
|
|
71
|
+
watch: WatchModule;
|
|
72
|
+
/** one address: everything it holds on pickhooks, what it can sell now, what it can claim */
|
|
73
|
+
wallet: WalletModule;
|
|
34
74
|
/** 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
75
|
blocks: {
|
|
36
76
|
catalog: () => BlocksCatalog;
|
|
@@ -46,8 +86,12 @@ export type Pickhooks = {
|
|
|
46
86
|
* The pickhooks SDK. One client, a part per product:
|
|
47
87
|
* any hook any coin: quotes, trades with the recapture room, opening a pool with a partner, the payouts
|
|
48
88
|
* sticky sticky rules: launching from templates, checking a trade against the coin's table, trading, lifting
|
|
89
|
+
* sticky2 sticky 2 (the same, plus what the creator sold); cover: dev cover and dev bond; auction: the rule auction;
|
|
90
|
+
* dark: the dark launch (sealed bids, @pickhooks/sdk/tlock seals them); launchDesk: launch per reply's balance
|
|
49
91
|
* coins coins with rules in the coin (v1, v2): rules as sentences, the rule that would refuse a trade, launches
|
|
50
92
|
* pools rules in the pool; calls: curve calls; lever: Lever longs and shorts (leverV1 the first lever); dips: dip bids
|
|
93
|
+
* agents coins run by an agent: read the program, brief any model, act as the pilot, veto and fire as a holder
|
|
94
|
+
* watch live events (launches, trades, agent changes); wallet: one address, everything it holds and can claim
|
|
51
95
|
* api pickhooks.com's public JSON API (launch feed, board, activity)
|
|
52
96
|
*
|
|
53
97
|
* const ph = createPickhooks({ walletClient });
|
|
@@ -55,19 +99,30 @@ export type Pickhooks = {
|
|
|
55
99
|
* const r = await ph.any.buy({ pool, bnbIn: parseEther("0.05") });
|
|
56
100
|
*/
|
|
57
101
|
export declare function createPickhooks(options?: PickhooksOptions): Pickhooks;
|
|
58
|
-
export { BSC_MAINNET, LIMITS, NATIVE, ZERO_ADDRESS, type Addresses } from "./addresses.js";
|
|
102
|
+
export { BSC_MAINNET, LIMITS, MODE_NAMES, NATIVE, ZERO_ADDRESS, type Addresses, type ModeName } from "./addresses.js";
|
|
59
103
|
export { CHECK_TEXT, PickhooksError, decodeRevert, errorText, explain, findRevertData } from "./errors.js";
|
|
60
104
|
export { DEFAULT_RPC, deadlineIn, minusBps, type PickhooksOptions, type SendOptions, type Sent, type TxRequest } from "./tx.js";
|
|
61
105
|
export { blockedKind, buildInfiSwap, infiPriceBnb, infiQuote, infiSwapInput, permit2Approvals, poolIdOf, toKey, type PoolKey } from "./infinity.js";
|
|
62
106
|
export { approvalFor, buildV3Buy, buildV3Sell, receivedOf, v3PriceBnb, v3Quote } from "./v3.js";
|
|
107
|
+
export { type Venue, bestVenue, buildV2Buy, buildV2Sell, v2Quote, v2RouterAbi } from "./v2.js";
|
|
63
108
|
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";
|
|
109
|
+
export { describeRows, stickyTable, stickyTestRun, testRunText, type StickyTestRun, type StickyCheck, type StickyCoin, type StickyLaunch, type StickyLot, type StickyModule, type StickyRow, type StickyTerms, } from "./sticky.js";
|
|
110
|
+
export { CURVE, SUPPLY, simulate, type SimReport } from "./sticky-sim.js";
|
|
111
|
+
export { MODES, MODE_LIST, encodeModeData, modeBps, type ModeAction, type ModeInfo, type ModeSettings } from "./modes-catalog.js";
|
|
112
|
+
export { type Custody, type ModesModule } from "./modes.js";
|
|
113
|
+
export { eventText, shadowOf, type SimResult, type SimulateModule } from "./simulate.js";
|
|
114
|
+
export { NOT_POSSIBLE, readLaunch, understandLaunch, type TextDraft, type TextPick, type TextRead } from "./text-launch.js";
|
|
65
115
|
export { ruleText, type CoinRule, type CoinsModule, type RuleCheck, type RuleCoin, type RuleCoinVersion, type RuleLaunch } from "./coins.js";
|
|
66
116
|
export { type CallRow, type CallStep, type CallsModule, type HookCoin, type HookLaunch, type PoolsModule } from "./pools.js";
|
|
67
117
|
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
118
|
export { coinsFor, coverOf, strikeFromPrice, type DipBid, type DipFloor, type DipPost, type DipsModule } from "./dips.js";
|
|
69
119
|
export { type ApiModule, type Launch, type LaunchFeed } from "./api.js";
|
|
120
|
+
export { type AuctionState, type CoverOffer, type CoverPolicy, type CoverPost, type DarkBid, type DarkRoundState, type DesksModule, type DevCounters, } from "./desks.js";
|
|
70
121
|
export { type FloorState, type InfraModule, type ProtectOffer } from "./infra.js";
|
|
122
|
+
export { type AgentCoin, type AgentLaunch, type AgentLock, type AgentLook, type AgentPending, type AgentsModule, type JournalEntry } from "./agents.js";
|
|
123
|
+
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";
|
|
124
|
+
export { type AgentEvent, type WatchMode, type WatchOptions, type WatchModule, type WatchedLaunch, type WatchedTrade } from "./watch.js";
|
|
125
|
+
export { type WalletCoin, type WalletModule, type WalletView } from "./wallet.js";
|
|
71
126
|
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
127
|
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
128
|
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,31 @@
|
|
|
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";
|
|
12
|
+
import { modesModule } from "./modes.js";
|
|
13
|
+
import { simulateModule } from "./simulate.js";
|
|
14
|
+
import { understandLaunch } from "./text-launch.js";
|
|
15
|
+
import { PickhooksError } from "./errors.js";
|
|
10
16
|
import { makeCtx, sendAll, sendTx } from "./tx.js";
|
|
17
|
+
import { walletModule } from "./wallet.js";
|
|
18
|
+
import { watchModule } from "./watch.js";
|
|
11
19
|
/**
|
|
12
20
|
* The pickhooks SDK. One client, a part per product:
|
|
13
21
|
* any hook any coin: quotes, trades with the recapture room, opening a pool with a partner, the payouts
|
|
14
22
|
* sticky sticky rules: launching from templates, checking a trade against the coin's table, trading, lifting
|
|
23
|
+
* sticky2 sticky 2 (the same, plus what the creator sold); cover: dev cover and dev bond; auction: the rule auction;
|
|
24
|
+
* dark: the dark launch (sealed bids, @pickhooks/sdk/tlock seals them); launchDesk: launch per reply's balance
|
|
15
25
|
* coins coins with rules in the coin (v1, v2): rules as sentences, the rule that would refuse a trade, launches
|
|
16
26
|
* pools rules in the pool; calls: curve calls; lever: Lever longs and shorts (leverV1 the first lever); dips: dip bids
|
|
27
|
+
* agents coins run by an agent: read the program, brief any model, act as the pilot, veto and fire as a holder
|
|
28
|
+
* watch live events (launches, trades, agent changes); wallet: one address, everything it holds and can claim
|
|
17
29
|
* api pickhooks.com's public JSON API (launch feed, board, activity)
|
|
18
30
|
*
|
|
19
31
|
* const ph = createPickhooks({ walletClient });
|
|
@@ -22,37 +34,102 @@ import { makeCtx, sendAll, sendTx } from "./tx.js";
|
|
|
22
34
|
*/
|
|
23
35
|
export function createPickhooks(options = {}) {
|
|
24
36
|
const ctx = makeCtx(options);
|
|
37
|
+
const d = desksModule(ctx);
|
|
38
|
+
const sticky = stickyModule(ctx);
|
|
39
|
+
const sticky2 = stickyModule(ctx, true);
|
|
40
|
+
const sticky3 = stickyModule(ctx, 3);
|
|
41
|
+
const coins = coinsModule(ctx);
|
|
42
|
+
const pools = poolsModule(ctx);
|
|
43
|
+
const calls = callsModule(ctx);
|
|
44
|
+
const lever = lever2Module(ctx);
|
|
45
|
+
const dips = dipsModule(ctx);
|
|
46
|
+
const any = anyModule(ctx);
|
|
47
|
+
const agents = agentsModule(ctx);
|
|
25
48
|
return {
|
|
26
49
|
addresses: ctx.a,
|
|
27
50
|
publicClient: ctx.pub,
|
|
28
|
-
any
|
|
29
|
-
sticky
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
any,
|
|
52
|
+
sticky,
|
|
53
|
+
sticky2: { ...sticky2, devCounters: d.devCounters, switches: d.switches },
|
|
54
|
+
sticky3: {
|
|
55
|
+
...sticky3,
|
|
56
|
+
/**
|
|
57
|
+
* A sentence ("CAT Cat, combo, dev lock 7 days, sniper jail, dev buy 0.05") read into a sticky 3 launch. `launch` is
|
|
58
|
+
* ready for ph.sticky3.launch once there are no unknown clauses (add `metadata`); the factory and the mode check it
|
|
59
|
+
* again on chain. Pass a reader (your model, your key) for what the parser does not understand.
|
|
60
|
+
*/
|
|
61
|
+
fromText: async (text, o = {}) => {
|
|
62
|
+
const r = await understandLaunch(text, o.reader);
|
|
63
|
+
const d = r.draft;
|
|
64
|
+
if (!d || r.unknown.length || r.refusals.length)
|
|
65
|
+
return { ...r, launch: null };
|
|
66
|
+
const launch = {
|
|
67
|
+
name: d.name,
|
|
68
|
+
symbol: d.symbol,
|
|
69
|
+
metadata: o.metadata ?? "",
|
|
70
|
+
picks: d.picks,
|
|
71
|
+
devBuy: BigInt(Math.round(d.devBuyBnb * 1e6)) * 10n ** 12n,
|
|
72
|
+
...(d.mode ? { mode: d.mode, modeSettings: d.modeSettings } : {}),
|
|
73
|
+
};
|
|
74
|
+
const table = (() => {
|
|
75
|
+
try {
|
|
76
|
+
return sticky3.table(launch);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
return e instanceof PickhooksError ? e.message : String(e);
|
|
80
|
+
}
|
|
81
|
+
})();
|
|
82
|
+
if (typeof table === "string")
|
|
83
|
+
return { ...r, notes: [...r.notes, table], launch: null };
|
|
84
|
+
return { ...r, launch };
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
modes: modesModule(ctx),
|
|
88
|
+
simulate: simulateModule(ctx),
|
|
89
|
+
cover: d.cover,
|
|
90
|
+
auction: d.auction,
|
|
91
|
+
dark: d.dark,
|
|
92
|
+
launchDesk: d.desk,
|
|
93
|
+
coins,
|
|
94
|
+
pools,
|
|
95
|
+
calls,
|
|
96
|
+
lever,
|
|
34
97
|
leverV1: leverModule(ctx),
|
|
35
|
-
dips
|
|
98
|
+
dips,
|
|
36
99
|
infra: infraModule(ctx),
|
|
100
|
+
agents,
|
|
101
|
+
watch: watchModule(ctx, { sticky, sticky2, coins, pools, calls, agents, any }),
|
|
102
|
+
wallet: walletModule(ctx, { sticky, sticky2, coins, pools, calls, lever, agents, any, dips }),
|
|
37
103
|
blocks: { catalog: blocksCatalog, block: (id) => blocksCatalog().sticky.blocks.find((b) => b.id === id) ?? null },
|
|
38
104
|
api: apiModule(ctx),
|
|
39
105
|
send: (tx, o) => sendTx(ctx, tx, o),
|
|
40
106
|
sendAll: (txs, o) => sendAll(ctx, txs, o),
|
|
41
107
|
};
|
|
42
108
|
}
|
|
43
|
-
export { BSC_MAINNET, LIMITS, NATIVE, ZERO_ADDRESS } from "./addresses.js";
|
|
109
|
+
export { BSC_MAINNET, LIMITS, MODE_NAMES, NATIVE, ZERO_ADDRESS } from "./addresses.js";
|
|
44
110
|
export { CHECK_TEXT, PickhooksError, decodeRevert, errorText, explain, findRevertData } from "./errors.js";
|
|
45
111
|
export { DEFAULT_RPC, deadlineIn, minusBps } from "./tx.js";
|
|
46
112
|
export { blockedKind, buildInfiSwap, infiPriceBnb, infiQuote, infiSwapInput, permit2Approvals, poolIdOf, toKey } from "./infinity.js";
|
|
47
113
|
export { approvalFor, buildV3Buy, buildV3Sell, receivedOf, v3PriceBnb, v3Quote } from "./v3.js";
|
|
114
|
+
export { bestVenue, buildV2Buy, buildV2Sell, v2Quote, v2RouterAbi } from "./v2.js";
|
|
48
115
|
export { MAX_TICK, MIN_TICK, TAX_QUOTE_MARK, afterTax, depthNeeds, fitLadder, partnerLink, rangeFor, tickOf, } from "./any.js";
|
|
49
|
-
export { describeRows, } from "./sticky.js";
|
|
116
|
+
export { describeRows, stickyTable, stickyTestRun, testRunText, } from "./sticky.js";
|
|
117
|
+
export { CURVE, SUPPLY, simulate } from "./sticky-sim.js";
|
|
118
|
+
export { MODES, MODE_LIST, encodeModeData, modeBps } from "./modes-catalog.js";
|
|
119
|
+
export {} from "./modes.js";
|
|
120
|
+
export { eventText, shadowOf } from "./simulate.js";
|
|
121
|
+
export { NOT_POSSIBLE, readLaunch, understandLaunch } from "./text-launch.js";
|
|
50
122
|
export { ruleText } from "./coins.js";
|
|
51
123
|
export {} from "./pools.js";
|
|
52
124
|
export { LEVER2_REASON, } from "./lever.js";
|
|
53
125
|
export { coinsFor, coverOf, strikeFromPrice } from "./dips.js";
|
|
54
126
|
export {} from "./api.js";
|
|
127
|
+
export {} from "./desks.js";
|
|
55
128
|
export {} from "./infra.js";
|
|
129
|
+
export {} from "./agents.js";
|
|
130
|
+
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";
|
|
131
|
+
export {} from "./watch.js";
|
|
132
|
+
export {} from "./wallet.js";
|
|
56
133
|
export { BLOCKS_VERSION, BLOCK_ACTIONS, BLOCK_CHECKS, BLOCK_MARKS, BLOCK_OPERATORS, BLOCK_TRIGGERS, blockLineVars, blocksCatalog, } from "./blocks.js";
|
|
57
134
|
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
135
|
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,59 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import type { ModeName } from "./addresses.js";
|
|
3
|
+
/**
|
|
4
|
+
* The modes of sticky 3, offline: what each one is, its line, its share of buys and the bounds of its settings, the
|
|
5
|
+
* actions holders play, and whether it draws with drand. The chain is the truth: a mode's own quote() refuses settings
|
|
6
|
+
* outside its bounds, and the coin's guardrails hold whatever a mode does.
|
|
7
|
+
*/
|
|
8
|
+
export type ModeSettings = {
|
|
9
|
+
/** the mode's share of every buy into the game pot, basis points */
|
|
10
|
+
bps?: number;
|
|
11
|
+
/** the smallest trade (or bid, try, join) that counts, millionths of the supply */
|
|
12
|
+
minPpm?: number;
|
|
13
|
+
};
|
|
14
|
+
export type ModeAction = {
|
|
15
|
+
name: string;
|
|
16
|
+
who: "holder" | "creator" | "anyone" | "dev";
|
|
17
|
+
text: string;
|
|
18
|
+
};
|
|
19
|
+
export type ModeInfo = {
|
|
20
|
+
name: ModeName;
|
|
21
|
+
title: string;
|
|
22
|
+
/** the line as the launcher and the posts say it */
|
|
23
|
+
line: string;
|
|
24
|
+
/** how it plays, sentence by sentence */
|
|
25
|
+
how: string[];
|
|
26
|
+
/** the share of every buy into the game pot, basis points: default and bounds (0: the mode takes nothing) */
|
|
27
|
+
bps: {
|
|
28
|
+
default: number;
|
|
29
|
+
min: number;
|
|
30
|
+
max: number;
|
|
31
|
+
};
|
|
32
|
+
/** the smallest trade that counts, millionths of the supply (null: the mode has no minimum setting) */
|
|
33
|
+
minPpm: {
|
|
34
|
+
default: number;
|
|
35
|
+
min: number;
|
|
36
|
+
max: number;
|
|
37
|
+
} | null;
|
|
38
|
+
/** the settings the launcher offers */
|
|
39
|
+
settings: (keyof ModeSettings)[];
|
|
40
|
+
actions: ModeAction[];
|
|
41
|
+
/** it waits for drand rounds (the keeper hands them in) */
|
|
42
|
+
drand: boolean;
|
|
43
|
+
/** coins can sit in custody in this mode (never more than 7 days; 14 for a dev bag locked at the launch) */
|
|
44
|
+
custody: boolean;
|
|
45
|
+
/** the keeper's part: what it settles, opens or drops */
|
|
46
|
+
keeper: string | null;
|
|
47
|
+
/** said plainly: what can look odd or be gamed, and the cap that holds it */
|
|
48
|
+
notes: string[];
|
|
49
|
+
};
|
|
50
|
+
export declare const MODES: Record<ModeName, ModeInfo>;
|
|
51
|
+
/** The modes in the launcher's order. */
|
|
52
|
+
export declare const MODE_LIST: ModeInfo[];
|
|
53
|
+
/**
|
|
54
|
+
* A mode's settings as the factory passes them on (abi encoded; zeros mean the defaults, empty means all defaults). Throws
|
|
55
|
+
* for settings the mode does not have, or outside its bounds.
|
|
56
|
+
*/
|
|
57
|
+
export declare function encodeModeData(name: ModeName, s?: ModeSettings): Hex;
|
|
58
|
+
/** The share of buys a mode takes with these settings (offline; the mode's quote() on chain is the truth). */
|
|
59
|
+
export declare function modeBps(name: ModeName, s?: ModeSettings): number;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { encodeAbiParameters } from "viem";
|
|
2
|
+
import { PickhooksError } from "./errors.js";
|
|
3
|
+
const MIN = { default: 100, min: 10, max: 1000 };
|
|
4
|
+
export const MODES = {
|
|
5
|
+
combo: {
|
|
6
|
+
name: "combo",
|
|
7
|
+
title: "combo",
|
|
8
|
+
line: "Buys build the combo. One sell breaks it.",
|
|
9
|
+
how: [
|
|
10
|
+
"Every buy of at least the minimum size adds one to the combo; every sell of that size breaks it to zero.",
|
|
11
|
+
"The buy that brings the combo to 10, 25 or 50 wins 10, 25 or 50 % of the pot, then every 25 more win 25 %.",
|
|
12
|
+
"A win is never more coins than the winning buy itself brings, and never goes to the creator.",
|
|
13
|
+
],
|
|
14
|
+
bps: { default: 200, min: 100, max: 300 },
|
|
15
|
+
minPpm: MIN,
|
|
16
|
+
settings: ["bps", "minPpm"],
|
|
17
|
+
actions: [],
|
|
18
|
+
drand: false,
|
|
19
|
+
custody: false,
|
|
20
|
+
keeper: null,
|
|
21
|
+
notes: ["A bot can aim for the 10th buy: it buys, and the win stops at its own buy."],
|
|
22
|
+
},
|
|
23
|
+
forward: {
|
|
24
|
+
name: "forward",
|
|
25
|
+
title: "pay it forward",
|
|
26
|
+
line: "Your buy pays the last buyer. The next buy pays you.",
|
|
27
|
+
how: [
|
|
28
|
+
"A share of every buy (3 % by default) goes straight to the wallet that bought before, as fresh coins.",
|
|
29
|
+
"Never the same wallet twice in a row, never the creator, never more than that wallet's own buy brought.",
|
|
30
|
+
"What is not forwarded is burned: the mode keeps no pot.",
|
|
31
|
+
],
|
|
32
|
+
bps: { default: 300, min: 100, max: 500 },
|
|
33
|
+
minPpm: MIN,
|
|
34
|
+
settings: ["bps", "minPpm"],
|
|
35
|
+
actions: [],
|
|
36
|
+
drand: false,
|
|
37
|
+
custody: false,
|
|
38
|
+
keeper: null,
|
|
39
|
+
notes: ["A game with a fixed share, not a return: two own wallets pay each other and lose the price and the fees."],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/** The modes in the launcher's order. */
|
|
43
|
+
export const MODE_LIST = [
|
|
44
|
+
MODES.combo,
|
|
45
|
+
MODES.forward,
|
|
46
|
+
];
|
|
47
|
+
const u = (x) => BigInt(typeof x === "boolean" ? (x ? 1 : 0) : Math.round(x ?? 0));
|
|
48
|
+
/**
|
|
49
|
+
* A mode's settings as the factory passes them on (abi encoded; zeros mean the defaults, empty means all defaults). Throws
|
|
50
|
+
* for settings the mode does not have, or outside its bounds.
|
|
51
|
+
*/
|
|
52
|
+
export function encodeModeData(name, s) {
|
|
53
|
+
const info = MODES[name];
|
|
54
|
+
if (!info)
|
|
55
|
+
throw new PickhooksError(`There is no mode "${name}".`, { code: "input" });
|
|
56
|
+
if (!s || Object.values(s).every((x) => x === undefined))
|
|
57
|
+
return "0x";
|
|
58
|
+
for (const k of Object.keys(s)) {
|
|
59
|
+
if (s[k] !== undefined && !info.settings.includes(k))
|
|
60
|
+
throw new PickhooksError(`${info.title} has no setting "${k}".`, { code: "input" });
|
|
61
|
+
}
|
|
62
|
+
if (s.bps !== undefined && (s.bps < info.bps.min || s.bps > info.bps.max)) {
|
|
63
|
+
throw new PickhooksError(`${info.title}: the share of buys is ${info.bps.min / 100} to ${info.bps.max / 100} %.`, { code: "input" });
|
|
64
|
+
}
|
|
65
|
+
if (s.minPpm !== undefined && info.minPpm && (s.minPpm < info.minPpm.min || s.minPpm > info.minPpm.max)) {
|
|
66
|
+
throw new PickhooksError(`${info.title}: the minimum size is ${info.minPpm.min / 1e4} to ${info.minPpm.max / 1e4} % of the supply.`, { code: "input" });
|
|
67
|
+
}
|
|
68
|
+
const two = [{ type: "uint256" }, { type: "uint256" }];
|
|
69
|
+
switch (name) {
|
|
70
|
+
default:
|
|
71
|
+
return encodeAbiParameters(two, [u(s.bps), u(s.minPpm)]);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** The share of buys a mode takes with these settings (offline; the mode's quote() on chain is the truth). */
|
|
75
|
+
export function modeBps(name, s) {
|
|
76
|
+
return s?.bps ?? MODES[name].bps.default;
|
|
77
|
+
}
|
package/dist/modes.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type Address, type Hex } from "viem";
|
|
2
|
+
import { type ModeName } from "./addresses.js";
|
|
3
|
+
import { type ModeInfo, encodeModeData, modeBps } from "./modes-catalog.js";
|
|
4
|
+
import { type Ctx, type SendOptions, type TxRequest } from "./tx.js";
|
|
5
|
+
/**
|
|
6
|
+
* ph.modes: the games of sticky 3 coins. Every coin has one mode, fixed at launch; holders play it through the coin
|
|
7
|
+
* (`coin.play`), anyone nudges it (`coin.poke`), and the coin carries out what the mode answers inside its guardrails.
|
|
8
|
+
* Each mode here has its state (what the page shows) and its actions (build: the TxRequest; the plain name sends it).
|
|
9
|
+
* The modes that draw fetch drand's signature themselves (@pickhooks/sdk/tlock is loaded only then).
|
|
10
|
+
*/
|
|
11
|
+
export type Custody = {
|
|
12
|
+
amount: bigint;
|
|
13
|
+
dev: bigint;
|
|
14
|
+
until: number;
|
|
15
|
+
since: number;
|
|
16
|
+
shadow: Address;
|
|
17
|
+
releasable: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function modesModule(ctx: Ctx): {
|
|
20
|
+
/** the modes: line, how they play, share of buys and bounds, actions (offline) */
|
|
21
|
+
catalog: Record<ModeName, ModeInfo>;
|
|
22
|
+
list: ModeInfo[];
|
|
23
|
+
info: (n: ModeName) => ModeInfo;
|
|
24
|
+
/** a mode's settings encoded for the launch (zeros: defaults) */
|
|
25
|
+
encode: typeof encodeModeData;
|
|
26
|
+
/** the share of buys a mode takes with these settings */
|
|
27
|
+
bps: typeof modeBps;
|
|
28
|
+
/** is the mode open for launches on the factory now */
|
|
29
|
+
listed: (n: ModeName) => Promise<boolean>;
|
|
30
|
+
of: (coin: Address) => Promise<{
|
|
31
|
+
name: ModeName | "other" | null;
|
|
32
|
+
address: Address;
|
|
33
|
+
gameBps: number;
|
|
34
|
+
gamePot: bigint;
|
|
35
|
+
info: ModeInfo | null;
|
|
36
|
+
}>;
|
|
37
|
+
custody: (coin: Address, who: Address) => Promise<Custody>;
|
|
38
|
+
build: {
|
|
39
|
+
release: (coin: Address, who: Address) => TxRequest;
|
|
40
|
+
play: (coin: Address, data: Hex, label: string) => TxRequest;
|
|
41
|
+
poke: (coin: Address, data: Hex, label: string) => TxRequest;
|
|
42
|
+
};
|
|
43
|
+
/** anyone: a holder's custody back to the wallet once its time is up */
|
|
44
|
+
release: (coin: Address, who: Address, s?: SendOptions) => Promise<import("./tx.js").Sent>;
|
|
45
|
+
/** a raw play or poke (data: abi.encode(action, ...)) for modes the SDK does not know */
|
|
46
|
+
play: (coin: Address, data: Hex, s?: SendOptions) => Promise<import("./tx.js").Sent>;
|
|
47
|
+
poke: (coin: Address, data: Hex, s?: SendOptions) => Promise<import("./tx.js").Sent>;
|
|
48
|
+
combo: {
|
|
49
|
+
state(coin: Address): Promise<{
|
|
50
|
+
combo: number;
|
|
51
|
+
best: number;
|
|
52
|
+
hits: number;
|
|
53
|
+
bps: number;
|
|
54
|
+
minPpm: number;
|
|
55
|
+
breaker: `0x${string}`;
|
|
56
|
+
brokeAt: number;
|
|
57
|
+
next: number;
|
|
58
|
+
nextSharePct: number;
|
|
59
|
+
}>;
|
|
60
|
+
};
|
|
61
|
+
forward: {
|
|
62
|
+
state(coin: Address): Promise<{
|
|
63
|
+
last: `0x${string}`;
|
|
64
|
+
lastGot: bigint;
|
|
65
|
+
bps: number;
|
|
66
|
+
minPpm: number;
|
|
67
|
+
forwards: number;
|
|
68
|
+
}>;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export type ModesModule = ReturnType<typeof modesModule>;
|