@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.
- package/LICENSE +21 -0
- package/README.md +418 -3
- package/dist/abis/agents.d.ts +2418 -0
- package/dist/abis/agents.js +4 -0
- package/dist/abis/any3.d.ts +2123 -0
- package/dist/abis/any3.js +3 -0
- package/dist/abis/anytax.d.ts +1786 -0
- package/dist/abis/anytax.js +3 -0
- package/dist/abis/calls.d.ts +2515 -0
- package/dist/abis/calls.js +4 -0
- package/dist/abis/common.d.ts +449 -0
- package/dist/abis/common.js +91 -0
- package/dist/abis/dips.d.ts +897 -0
- package/dist/abis/dips.js +2 -0
- package/dist/abis/index.d.ts +14 -0
- package/dist/abis/index.js +14 -0
- package/dist/abis/infra.d.ts +701 -0
- package/dist/abis/infra.js +4 -0
- package/dist/abis/lever.d.ts +1710 -0
- package/dist/abis/lever.js +5 -0
- package/dist/abis/lever2.d.ts +2710 -0
- package/dist/abis/lever2.js +5 -0
- package/dist/abis/pools.d.ts +1898 -0
- package/dist/abis/pools.js +4 -0
- package/dist/abis/sticky.d.ts +953 -0
- package/dist/abis/sticky.js +4 -0
- package/dist/abis/sticky2.d.ts +3750 -0
- package/dist/abis/sticky2.js +8 -0
- package/dist/abis/v1.d.ts +1627 -0
- package/dist/abis/v1.js +5 -0
- package/dist/abis/v2.d.ts +3264 -0
- package/dist/abis/v2.js +8 -0
- package/dist/addresses.d.ts +100 -0
- package/dist/addresses.js +71 -0
- 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/any.d.ts +447 -0
- package/dist/any.js +729 -0
- package/dist/api.d.ts +62 -0
- package/dist/api.js +30 -0
- package/dist/blocks.d.ts +107 -0
- package/dist/blocks.js +126 -0
- package/dist/coin-rules-config.d.ts +8 -0
- package/dist/coin-rules-config.js +13 -0
- package/dist/coin-rules.d.ts +383 -0
- package/dist/coin-rules.js +878 -0
- package/dist/coins.d.ts +217 -0
- package/dist/coins.js +520 -0
- package/dist/desks.d.ts +298 -0
- package/dist/desks.js +343 -0
- package/dist/dips.d.ts +133 -0
- package/dist/dips.js +148 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.js +414 -0
- package/dist/index.d.ts +104 -0
- package/dist/index.js +91 -0
- package/dist/infinity.d.ts +63 -0
- package/dist/infinity.js +96 -0
- package/dist/infra.d.ts +112 -0
- package/dist/infra.js +114 -0
- package/dist/lever.d.ts +391 -0
- package/dist/lever.js +419 -0
- package/dist/pools.d.ts +274 -0
- package/dist/pools.js +405 -0
- package/dist/sticky-rules.d.ts +179 -0
- package/dist/sticky-rules.js +580 -0
- package/dist/sticky-sim.d.ts +125 -0
- package/dist/sticky-sim.js +637 -0
- package/dist/sticky.d.ts +286 -0
- package/dist/sticky.js +420 -0
- package/dist/tlock.d.ts +67 -0
- package/dist/tlock.js +185 -0
- package/dist/tx.d.ts +72 -0
- package/dist/tx.js +78 -0
- package/dist/v2.d.ts +106 -0
- package/dist/v2.js +61 -0
- package/dist/v3.d.ts +42 -0
- package/dist/v3.js +98 -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 +67 -4
package/dist/errors.js
ADDED
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { decodeErrorResult, toFunctionSelector } from "viem";
|
|
2
|
+
import { formatAbiItem } from "viem/utils";
|
|
3
|
+
import { agentsDeskAbi, agentsFactoryAbi, agentsHookAbi } from "./abis/agents.js";
|
|
4
|
+
import { any3FactoryAbi, any3HookAbi } from "./abis/any3.js";
|
|
5
|
+
import { anyTaxFactoryAbi, anyTaxHookAbi } from "./abis/anytax.js";
|
|
6
|
+
import { callsDeskAbi, callsFactoryAbi, callsHookAbi } from "./abis/calls.js";
|
|
7
|
+
import { dipDeskAbi } from "./abis/dips.js";
|
|
8
|
+
import { hooksExecutorAbi, hooksFloorAbi, hooksFloorFactoryAbi } from "./abis/infra.js";
|
|
9
|
+
import { leverEngineAbi, leverFactoryAbi, leverHookAbi, leverRouterAbi } from "./abis/lever.js";
|
|
10
|
+
import { lever2EngineAbi, lever2FactoryAbi, lever2HookAbi } from "./abis/lever2.js";
|
|
11
|
+
import { poolsFactoryAbi, poolsHookAbi } from "./abis/pools.js";
|
|
12
|
+
import { stickyFactoryAbi, stickyTokenAbi, stickyValidatorAbi } from "./abis/sticky.js";
|
|
13
|
+
import { coverDeskAbi, darkRoundAbi, launchDeskAbi, ruleAuctionAbi, sticky2FactoryAbi, sticky2TokenAbi, sticky2ValidatorAbi } from "./abis/sticky2.js";
|
|
14
|
+
import { v1FactoryAbi, v1TokenAbi } from "./abis/v1.js";
|
|
15
|
+
import { arenaAbi, floorVaultAbi, payrollBoxAbi, v2FactoryAbi, v2TokenAbi, voteBoxAbi } from "./abis/v2.js";
|
|
16
|
+
/** sticky: what token.check() answers when no row stops a trade but the coins are not unlocked yet */
|
|
17
|
+
const STICKY_LOCKED = 254;
|
|
18
|
+
/** What hook any coin's factory.check() answers, in words. */
|
|
19
|
+
export const CHECK_TEXT = {
|
|
20
|
+
0: "This coin can get a pickhooks pool.",
|
|
21
|
+
1: "There is no contract at this address.",
|
|
22
|
+
2: "BNB and stablecoins are the other side of a pool, not a coin to hook.",
|
|
23
|
+
3: "This coin is still on its launch curve. Once it trades on PancakeSwap it can get a pool.",
|
|
24
|
+
4: "This coin has a transfer tax. A pool here would be a way around it, so it gets none.",
|
|
25
|
+
5: "This coin pays dividends to holders. The pool would count as a holder, so it gets none.",
|
|
26
|
+
6: "No PancakeSwap pool of this coin against BNB holds at least 3 BNB, so there is no fair price to open at.",
|
|
27
|
+
};
|
|
28
|
+
/** hook any coin's factory and sticky's factory and validator: Bad(what) as a sentence */
|
|
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.",
|
|
40
|
+
// hook any coin, open()
|
|
41
|
+
fee: "Pool fee: 0.2 to 1 % (feeBps 20 to 100).",
|
|
42
|
+
holderFee: "The holder fee cannot be higher than the pool fee.",
|
|
43
|
+
chest: "The fire: at most 10 % of a buy (chestBps up to 1000).",
|
|
44
|
+
bonus: "Bonus: at most 10 % (bonusBps up to 1000).",
|
|
45
|
+
bonusLock: "Bonus lock: 1 to 30 days.",
|
|
46
|
+
jackpotShare: "Jackpot share: 1 to 100 % of the pot (jackpotShareBps 100 to 10000).",
|
|
47
|
+
jackpotMinBuy: "Jackpot minimum buy: at most 10 BNB.",
|
|
48
|
+
silence: "Jackpot silence: 1 minute to 7 days.",
|
|
49
|
+
potShare: "Jackpot: potShareBps at most 10000.",
|
|
50
|
+
"no opener side for a pot": "A jackpot needs an opener side to fill it.",
|
|
51
|
+
maxMove: "maxMoveBps: at most 500 (5 %).",
|
|
52
|
+
slot: "That slot is out of range or taken. Check the coin again for a free slot.",
|
|
53
|
+
ticks: "The range is not valid for this slot.",
|
|
54
|
+
liquidity: "Put in coins (and BNB for a range around the price).",
|
|
55
|
+
partner: "That partner is not listed by pickhooks.",
|
|
56
|
+
"no pool": "There is no pool with this id.",
|
|
57
|
+
openerBps: "openerBps out of range.",
|
|
58
|
+
traderBps: "traderBps out of range.",
|
|
59
|
+
// sticky
|
|
60
|
+
seed: "The seed is out of range.",
|
|
61
|
+
creatorBps: "creatorBps out of range.",
|
|
62
|
+
startFdv: "startFdv out of range.",
|
|
63
|
+
"two sided": "The pool would be two sided.",
|
|
64
|
+
rows: "At most eight rows.",
|
|
65
|
+
"not a template": "Only the launcher's templates can launch right now (hook script is off).",
|
|
66
|
+
burn: "Auto burn: at most 10 % in total.",
|
|
67
|
+
release: "The unlock time must be 10 minutes to 30 days.",
|
|
68
|
+
age: "Hold time: at most 7 days.",
|
|
69
|
+
window: "Sell window: open at least a minute, the period at most a day.",
|
|
70
|
+
hour: "Market hours: whole hours from 1 to 23.",
|
|
71
|
+
terms: "The fee terms changed since they were read. Read them again.",
|
|
72
|
+
keep: "keepBps: at most 10000.",
|
|
73
|
+
value: "Send at least the seed.",
|
|
74
|
+
metadata: "The metadata link is too long.",
|
|
75
|
+
name: "Name or ticker too long.",
|
|
76
|
+
"sell deny must end": "A rule that stops sells or sends must let go by itself.",
|
|
77
|
+
windows: "One sell window at most, and not next to rows on hours or weekdays.",
|
|
78
|
+
hours: "The rows on hours close every hour of the day: leave one open.",
|
|
79
|
+
weekdays: "The rows on weekdays close every day: leave one open.",
|
|
80
|
+
take: "Burn and pot: at most 10 % of a buy together.",
|
|
81
|
+
pot: "Pot: 0.01 to 10 % of the buy.",
|
|
82
|
+
drop: "Drop: 0.01 to 100 % of the pot.",
|
|
83
|
+
"pot needs a drop": "A pot needs a drop row that pays it out.",
|
|
84
|
+
every: "Every n-th buy: n from 2 to 1,000,000.",
|
|
85
|
+
idle: "Time since the last buy: at most 30 days.",
|
|
86
|
+
};
|
|
87
|
+
/** every other error of the pickhooks contracts, by name */
|
|
88
|
+
const BY_NAME = {
|
|
89
|
+
// hook any coin, factory
|
|
90
|
+
NotOwner: "Only the factory's owner can do that.",
|
|
91
|
+
NotOpener: "Only the opener of this pool can do that.",
|
|
92
|
+
NoLiquidity: "That is too little to add any liquidity. Put in more.",
|
|
93
|
+
FeeOnTransfer: "This coin takes a fee on transfers, so it cannot go into a pool.",
|
|
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.",
|
|
109
|
+
PriceMoved: "The coin's price moved more than allowed while the pool opened. Check again and open.",
|
|
110
|
+
TooShallow: "Not enough liquidity: the pool must be at least as deep as the coin's main pool.",
|
|
111
|
+
StillLocked: "This position is still locked. Each one stays 30 days after it went in.",
|
|
112
|
+
NoPosition: "That position is already out.",
|
|
113
|
+
TooMany: "A pool holds at most 8 positions.",
|
|
114
|
+
InvalidTick: "The range is not on the pool's tick spacing.",
|
|
115
|
+
// hook any coin, hook
|
|
116
|
+
UnknownPool: "There is no pickhooks pool with this id.",
|
|
117
|
+
NoPot: "This pool has no jackpot.",
|
|
118
|
+
NoBonus: "This pool has no bonus rule.",
|
|
119
|
+
NothingOwed: "Nothing to claim yet.",
|
|
120
|
+
NotBought: "Only coins bought in this pool can be locked, and no more than that.",
|
|
121
|
+
NoBonusLeft: "The bonus pot has nothing left for this wallet: it is empty, or the cap is reached.",
|
|
122
|
+
Locked: "The bonus is still locked.",
|
|
123
|
+
Reentry: "A call came back into the hook while it was busy.",
|
|
124
|
+
Pending: "A router still has a payment open in the vault.",
|
|
125
|
+
// sticky and the coins with rules
|
|
126
|
+
PoolPrice: "Someone opened this coin's pool first. Launch again (a new salt).",
|
|
127
|
+
NotCreator: "Only the coin's creator can do that.",
|
|
128
|
+
Nope: "The coin refused this.",
|
|
129
|
+
// hook any coin, tax line
|
|
130
|
+
PayFirst: "While this coin's anti-farmer tax runs, a sell in this pool must pay its coins in first (the SDK's sell does). Terminals sell it in its main pool.",
|
|
131
|
+
// pools, Lever
|
|
132
|
+
PartialFill: "The trade would not fill completely. Try a smaller amount.",
|
|
133
|
+
SwapNotFilled: "The trade would not fill completely. Try a smaller amount.",
|
|
134
|
+
// lever and Lever
|
|
135
|
+
MarginTooSmall: "The smallest position is 0.01 BNB of margin plus the open fee.",
|
|
136
|
+
InvalidLeverage: "Up to 3x in a coin's first 10 minutes, then up to 5x.",
|
|
137
|
+
TooManyPositions: "All position slots of this coin are taken. A bigger margin takes the smallest one's slot (Lever), or wait until one closes.",
|
|
138
|
+
OpenInterestLimit: "Longs are full for now: all longs together may borrow at most a quarter of the real BNB in the curve.",
|
|
139
|
+
LongsFull: "Longs are full for now: all longs together may borrow at most a quarter of the real BNB in the curve. Try a smaller position or wait for more buys.",
|
|
140
|
+
ShortsFull: "Shorts are full for now: all shorts together may sell coins for at most a quarter of the real BNB in the curve. Try a smaller position or wait for more buys.",
|
|
141
|
+
UnsafePosition: "This position would sit right at its liquidation point. Try a smaller one or a lower leverage.",
|
|
142
|
+
Unsafe: "This trade would leave a position at its liquidation point. Try a smaller margin or a lower leverage.",
|
|
143
|
+
BandFull: "The curve cannot lend that much right now. Try a smaller position.",
|
|
144
|
+
BadDebt: "This position cannot cover what it borrowed at this price. The next trade that reaches it liquidates it.",
|
|
145
|
+
Pushed: "The price was pushed in this second. Try again in a moment.",
|
|
146
|
+
TooSoon: "A position cannot be closed in the second it opened. Try again in a moment.",
|
|
147
|
+
Slippage: "The price moved past the limit while the transaction waited. Try again.",
|
|
148
|
+
Expired: "The transaction waited too long. Try again.",
|
|
149
|
+
InsufficientTokens: "That is more coins than this wallet holds.",
|
|
150
|
+
InsufficientCash: "The curve does not hold that much BNB.",
|
|
151
|
+
ZeroAmount: "That amount is too small to trade.",
|
|
152
|
+
UnsupportedSwap: "That amount is too small to trade.",
|
|
153
|
+
BadAmount: "That amount is too small to trade.",
|
|
154
|
+
ReserveLimit: "That amount is too big for the curve.",
|
|
155
|
+
AmountTooLarge: "That amount is too big for the curve.",
|
|
156
|
+
InactivePosition: "That position is already closed.",
|
|
157
|
+
NotExpired: "This has not run out yet: only its owner can close it now.",
|
|
158
|
+
UnknownMarket: "This is not a lever coin.",
|
|
159
|
+
InvalidMarket: "This is not a lever coin.",
|
|
160
|
+
NoLiquidityPositions: "Only the coin's curve can hold liquidity in this pool.",
|
|
161
|
+
Unauthorized: "This contract only takes that call from its own router or hook.",
|
|
162
|
+
// curve calls
|
|
163
|
+
TooEarly: "Calls open 10 minutes after the launch, and an owner can close a call 10 minutes after it opened.",
|
|
164
|
+
NotAbove: "That step is not fully above the price any more. Pick a step further up.",
|
|
165
|
+
TooFar: "A call can be at most 8 steps above the price.",
|
|
166
|
+
OverCap: "That is more than the step has left to rent: at most 10 % of a step is out at once.",
|
|
167
|
+
SameBlock: "Someone opened a call on this coin in the same block. Try again.",
|
|
168
|
+
PremiumTooHigh: "The premium went up since the quote. Try again.",
|
|
169
|
+
Paused: "PancakeSwap has paused its pools. Calls open again when it resumes.",
|
|
170
|
+
OffAverage: "The price is far from its 10 minute average right now. Anyone can close an ended call once it settles, or an hour after the end.",
|
|
171
|
+
NoCall: "That call is already closed.",
|
|
172
|
+
NothingPending: "Nothing waits for this wallet here.",
|
|
173
|
+
// curve calls and dip bids
|
|
174
|
+
TooSmall: "That is too small: below the smallest call or floor.",
|
|
175
|
+
Duration: "That duration is out of range (calls 10 minutes to 24 hours, floors 10 minutes to 7 days).",
|
|
176
|
+
Value: "The BNB sent does not match. Quote again.",
|
|
177
|
+
PayoutTooLow: "The payout fell below the minimum while the transaction waited. Try again.",
|
|
178
|
+
// dip bids
|
|
179
|
+
NoCoin: "That is not a coin contract.",
|
|
180
|
+
Strike: "Set a price for the bid.",
|
|
181
|
+
Premium: "The premium is between 0.01 % and 50 % of what a floor covers.",
|
|
182
|
+
Until: "The end of the bid has to be in the future.",
|
|
183
|
+
Deposit: "A new bid locks at least 0.01 BNB, and at least its smallest floor.",
|
|
184
|
+
BidOver: "That bid has ended: it takes no new floors.",
|
|
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.",
|
|
218
|
+
Ended: "That floor has run out or was already handed in.",
|
|
219
|
+
NotOver: "Only the owner can end a floor before it runs out.",
|
|
220
|
+
NotYours: "That floor belongs to another wallet.",
|
|
221
|
+
NotMaker: "Only the wallet that posted the bid can do that.",
|
|
222
|
+
Delivery: "The coins could not be handed in: check that this wallet holds them and has approved the desk.",
|
|
223
|
+
NoBid: "There is no bid with this id.",
|
|
224
|
+
NoFloor: "There is no floor with this id.",
|
|
225
|
+
Reentrant: "The desk is busy. Try again.",
|
|
226
|
+
// HOOKS infra: floors and the protected buy
|
|
227
|
+
SupplyGrew: "The coin minted new coins since its floor opened, so the floor takes no more hand ins.",
|
|
228
|
+
Exists: "This coin already has a floor. Feed it instead.",
|
|
229
|
+
Amount: "Hand in more than zero coins.",
|
|
230
|
+
SendFailed: "The BNB could not be sent to that address.",
|
|
231
|
+
TooFewCoins: "The swap brought fewer coins than the minimum. Quote again or allow more slippage.",
|
|
232
|
+
WrongCoin: "The dip bid is for another coin.",
|
|
233
|
+
NothingToProtect: "No coins arrived to protect.",
|
|
234
|
+
Swap: "The swap through PancakeSwap failed.",
|
|
235
|
+
Target: "The executor only calls PancakeSwap's own routers.",
|
|
236
|
+
};
|
|
237
|
+
/** PancakeSwap's own errors that a trade can run into */
|
|
238
|
+
const PANCAKE = [
|
|
239
|
+
["0x5bf6f916", "The trade waited too long and ran out of time (deadline). Try again."],
|
|
240
|
+
[toFunctionSelector("TooLittleReceived(uint256,uint256)"), "The price moved: the trade would get less than the minimum. Quote again or allow more slippage."],
|
|
241
|
+
[toFunctionSelector("V3TooLittleReceived()"), "The price moved: the trade would get less than the minimum. Quote again or allow more slippage."],
|
|
242
|
+
[toFunctionSelector("InsufficientToken()"), "The trade got less than the minimum. Quote again or allow more slippage."],
|
|
243
|
+
["0xd964f528", "The pool could not fill the whole amount. Try a smaller one."],
|
|
244
|
+
];
|
|
245
|
+
/** The pickhooks contracts' ABIs that errors are decoded with. */
|
|
246
|
+
const ABIS = [
|
|
247
|
+
any3FactoryAbi,
|
|
248
|
+
any3HookAbi,
|
|
249
|
+
stickyFactoryAbi,
|
|
250
|
+
stickyValidatorAbi,
|
|
251
|
+
stickyTokenAbi,
|
|
252
|
+
sticky2FactoryAbi,
|
|
253
|
+
sticky2ValidatorAbi,
|
|
254
|
+
sticky2TokenAbi,
|
|
255
|
+
coverDeskAbi,
|
|
256
|
+
ruleAuctionAbi,
|
|
257
|
+
darkRoundAbi,
|
|
258
|
+
launchDeskAbi,
|
|
259
|
+
anyTaxFactoryAbi,
|
|
260
|
+
anyTaxHookAbi,
|
|
261
|
+
v1FactoryAbi,
|
|
262
|
+
v1TokenAbi,
|
|
263
|
+
v2FactoryAbi,
|
|
264
|
+
v2TokenAbi,
|
|
265
|
+
voteBoxAbi,
|
|
266
|
+
arenaAbi,
|
|
267
|
+
floorVaultAbi,
|
|
268
|
+
payrollBoxAbi,
|
|
269
|
+
poolsFactoryAbi,
|
|
270
|
+
poolsHookAbi,
|
|
271
|
+
leverFactoryAbi,
|
|
272
|
+
leverHookAbi,
|
|
273
|
+
leverEngineAbi,
|
|
274
|
+
leverRouterAbi,
|
|
275
|
+
lever2FactoryAbi,
|
|
276
|
+
lever2HookAbi,
|
|
277
|
+
lever2EngineAbi,
|
|
278
|
+
callsFactoryAbi,
|
|
279
|
+
callsHookAbi,
|
|
280
|
+
callsDeskAbi,
|
|
281
|
+
dipDeskAbi,
|
|
282
|
+
hooksExecutorAbi,
|
|
283
|
+
hooksFloorAbi,
|
|
284
|
+
hooksFloorFactoryAbi,
|
|
285
|
+
agentsFactoryAbi,
|
|
286
|
+
agentsHookAbi,
|
|
287
|
+
agentsDeskAbi,
|
|
288
|
+
];
|
|
289
|
+
/** every error selector the pickhooks ABIs know, for errors that PancakeSwap wraps (WrappedError, the quoter's revert) */
|
|
290
|
+
const SELECTORS = ABIS.flatMap((abi) => abi.filter((x) => x.type === "error").map((x) => ({ sel: toFunctionSelector(formatAbiItem(x)).slice(2).toLowerCase(), abi })));
|
|
291
|
+
/** An error of the SDK: `code` is the contract's error name (or "wallet", "reverted", "input"), `text` a sentence. */
|
|
292
|
+
export class PickhooksError extends Error {
|
|
293
|
+
code;
|
|
294
|
+
args;
|
|
295
|
+
hash;
|
|
296
|
+
constructor(text, opts) {
|
|
297
|
+
super(text, { cause: opts.cause });
|
|
298
|
+
this.name = "PickhooksError";
|
|
299
|
+
this.code = opts.code;
|
|
300
|
+
this.args = opts.args;
|
|
301
|
+
this.hash = opts.hash;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/** The revert data inside a viem error (it nests them), or null. */
|
|
305
|
+
export function findRevertData(err) {
|
|
306
|
+
let e = err;
|
|
307
|
+
for (let i = 0; i < 10 && e; i++) {
|
|
308
|
+
if (typeof e.data === "string" && e.data.startsWith("0x") && e.data.length >= 10)
|
|
309
|
+
return e.data;
|
|
310
|
+
if (e.data && typeof e.data.data === "string")
|
|
311
|
+
return e.data.data;
|
|
312
|
+
e = e.cause;
|
|
313
|
+
}
|
|
314
|
+
const m = String(err?.message ?? "").match(/0x[0-9a-f]{8,}/i);
|
|
315
|
+
return m ? m[0] : null;
|
|
316
|
+
}
|
|
317
|
+
/** A decoded contract error, searched at the start of the revert data and, for wrapped errors, anywhere inside it. */
|
|
318
|
+
export function decodeRevert(data) {
|
|
319
|
+
for (const abi of ABIS) {
|
|
320
|
+
try {
|
|
321
|
+
const d = decodeErrorResult({ abi, data });
|
|
322
|
+
return { name: d.errorName, args: (d.args ?? []) };
|
|
323
|
+
}
|
|
324
|
+
catch {
|
|
325
|
+
/* not this contract's error */
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
const hex = data.toLowerCase().slice(2);
|
|
329
|
+
// a wrapped error carries the inner revert as bytes: find a known selector on a byte boundary and decode from there
|
|
330
|
+
for (const { sel, abi } of SELECTORS) {
|
|
331
|
+
let i = hex.indexOf(sel);
|
|
332
|
+
while (i >= 0) {
|
|
333
|
+
if (i % 2 === 0) {
|
|
334
|
+
try {
|
|
335
|
+
const d = decodeErrorResult({ abi, data: `0x${hex.slice(i)}` });
|
|
336
|
+
return { name: d.errorName, args: (d.args ?? []) };
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
/* trailing bytes of the wrapper: try the selector with its own words only */
|
|
340
|
+
try {
|
|
341
|
+
const d = decodeErrorResult({ abi, data: `0x${hex.slice(i, i + 8 + 64 * 8)}` });
|
|
342
|
+
return { name: d.errorName, args: (d.args ?? []) };
|
|
343
|
+
}
|
|
344
|
+
catch {
|
|
345
|
+
/* keep looking */
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
i = hex.indexOf(sel, i + 1);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return null;
|
|
353
|
+
}
|
|
354
|
+
/** require() strings of PancakeSwap's V3 contracts that need a sentence */
|
|
355
|
+
const ERROR_STRING = {
|
|
356
|
+
"Unexpected error": "PancakeSwap's quoter could not run this trade: the coin refused it, and the quoter does not pass the reason on.",
|
|
357
|
+
"Transaction too old": "The trade's deadline passed before it was mined. Send it again.",
|
|
358
|
+
"Too little received": "The price moved more than the slippage allows. Quote again or allow more slippage.",
|
|
359
|
+
SPL: "The trade would move the price past its limit.",
|
|
360
|
+
};
|
|
361
|
+
/** A contract error as a sentence. */
|
|
362
|
+
export function errorText(name, args) {
|
|
363
|
+
if (name === "Error")
|
|
364
|
+
return ERROR_STRING[String(args[0])] ?? `The contract refused: ${String(args[0] ?? "")}`;
|
|
365
|
+
if (name === "Panic")
|
|
366
|
+
return `The contract stopped with panic code ${String(args[0] ?? "")}.`;
|
|
367
|
+
if (name === "Refused")
|
|
368
|
+
return CHECK_TEXT[Number(args[0])] ?? "The factory refused this coin.";
|
|
369
|
+
if (name === "Blocked") {
|
|
370
|
+
const row = Number(args[0]);
|
|
371
|
+
return row === STICKY_LOCKED ? "Those coins are still locked: they unlock over time." : `Refused by rule ${row + 1} of the coin.`;
|
|
372
|
+
}
|
|
373
|
+
if (name === "Bad") {
|
|
374
|
+
const what = String(args[0] ?? "");
|
|
375
|
+
if (!what)
|
|
376
|
+
return "The hook refused these numbers.";
|
|
377
|
+
return BAD[what] ?? `Refused: ${what}.`;
|
|
378
|
+
}
|
|
379
|
+
return BY_NAME[name] ?? `The contract refused (${name}).`;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Any error as a code and a sentence: a wallet refusal, a pickhooks contract's error (wrapped by PancakeSwap or not), one
|
|
383
|
+
* of PancakeSwap's trade errors, or the fallback.
|
|
384
|
+
*/
|
|
385
|
+
export function explain(err, fallback = "The transaction would fail.") {
|
|
386
|
+
if (err instanceof PickhooksError)
|
|
387
|
+
return { code: err.code, text: err.message, args: err.args };
|
|
388
|
+
const msg = String(err?.message ?? "");
|
|
389
|
+
if (/user rejected|denied transaction|rejected the request|\b4001\b/i.test(msg))
|
|
390
|
+
return { code: "wallet", text: "Cancelled in the wallet. Nothing was sent." };
|
|
391
|
+
if (/insufficient funds/i.test(msg))
|
|
392
|
+
return { code: "funds", text: "Not enough BNB in this wallet for the amount plus gas." };
|
|
393
|
+
const data = findRevertData(err);
|
|
394
|
+
if (data) {
|
|
395
|
+
const d = decodeRevert(data);
|
|
396
|
+
if (d)
|
|
397
|
+
return { code: d.name, text: errorText(d.name, d.args), args: d.args };
|
|
398
|
+
const low = data.toLowerCase();
|
|
399
|
+
for (const [sel, text] of PANCAKE)
|
|
400
|
+
if (low.includes(sel.slice(2).toLowerCase()))
|
|
401
|
+
return { code: "pancake", text };
|
|
402
|
+
}
|
|
403
|
+
const reason = msg.match(/reverted with the following reason:\s*\n?\s*(.+)/);
|
|
404
|
+
if (reason)
|
|
405
|
+
return { code: "reverted", text: `The contract refused: ${reason[1].trim()}` };
|
|
406
|
+
return { code: "unknown", text: fallback };
|
|
407
|
+
}
|
|
408
|
+
/** Wraps any error as a PickhooksError (keeps the original as `cause`). */
|
|
409
|
+
export function toPickhooksError(err, fallback, hash) {
|
|
410
|
+
if (err instanceof PickhooksError)
|
|
411
|
+
return err;
|
|
412
|
+
const e = explain(err, fallback);
|
|
413
|
+
return new PickhooksError(e.text, { code: e.code, args: e.args, hash, cause: err });
|
|
414
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { PublicClient } from "viem";
|
|
2
|
+
import type { Addresses } from "./addresses.js";
|
|
3
|
+
import { type AgentsModule } from "./agents.js";
|
|
4
|
+
import { type AnyModule } from "./any.js";
|
|
5
|
+
import { type ApiModule } from "./api.js";
|
|
6
|
+
import { type Block, type BlocksCatalog } from "./blocks.js";
|
|
7
|
+
import { type CoinsModule } from "./coins.js";
|
|
8
|
+
import { type DesksModule } from "./desks.js";
|
|
9
|
+
import { type DipsModule } from "./dips.js";
|
|
10
|
+
import { type InfraModule } from "./infra.js";
|
|
11
|
+
import { type Lever2Module, type LeverModule } from "./lever.js";
|
|
12
|
+
import { type CallsModule, type PoolsModule } from "./pools.js";
|
|
13
|
+
import { type StickyModule } from "./sticky.js";
|
|
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";
|
|
17
|
+
export type Pickhooks = {
|
|
18
|
+
addresses: Addresses;
|
|
19
|
+
publicClient: PublicClient;
|
|
20
|
+
/** hook any coin: pools next to coins that already trade (v3 with recapture, partners, routers; the tax line when set) */
|
|
21
|
+
any: AnyModule;
|
|
22
|
+
/** sticky rules: rules that stick to the coins */
|
|
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"];
|
|
34
|
+
/** coins with their rules in the coin (v1 and v2, also find the dev and CZ mode coins) */
|
|
35
|
+
coins: CoinsModule;
|
|
36
|
+
/** pools: coins with their rules in a PancakeSwap Infinity pool hook */
|
|
37
|
+
pools: PoolsModule;
|
|
38
|
+
/** curve calls: rent a step of a coin's curve */
|
|
39
|
+
calls: CallsModule;
|
|
40
|
+
/** Lever (v2): real liquidity, longs and shorts */
|
|
41
|
+
lever: Lever2Module;
|
|
42
|
+
/** lever (v1): the engine curve with longs */
|
|
43
|
+
leverV1: LeverModule;
|
|
44
|
+
/** dip bids: floors at a strike */
|
|
45
|
+
dips: DipsModule;
|
|
46
|
+
/** HOOKS infra: BNB floors under coins and the protected buy */
|
|
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;
|
|
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) */
|
|
55
|
+
blocks: {
|
|
56
|
+
catalog: () => BlocksCatalog;
|
|
57
|
+
block: (id: string) => Block | null;
|
|
58
|
+
};
|
|
59
|
+
/** pickhooks.com's public JSON API */
|
|
60
|
+
api: ApiModule;
|
|
61
|
+
/** sends any TxRequest the build helpers return (estimate x gasPct + its extraGas) and waits for the receipt */
|
|
62
|
+
send: (tx: TxRequest, o?: SendOptions) => Promise<Sent>;
|
|
63
|
+
sendAll: (txs: TxRequest[], o?: SendOptions) => Promise<Sent[]>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* The pickhooks SDK. One client, a part per product:
|
|
67
|
+
* any hook any coin: quotes, trades with the recapture room, opening a pool with a partner, the payouts
|
|
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
|
|
71
|
+
* coins coins with rules in the coin (v1, v2): rules as sentences, the rule that would refuse a trade, launches
|
|
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
|
|
75
|
+
* api pickhooks.com's public JSON API (launch feed, board, activity)
|
|
76
|
+
*
|
|
77
|
+
* const ph = createPickhooks({ walletClient });
|
|
78
|
+
* const [pool] = await ph.any.pools({ limit: 1 });
|
|
79
|
+
* const r = await ph.any.buy({ pool, bnbIn: parseEther("0.05") });
|
|
80
|
+
*/
|
|
81
|
+
export declare function createPickhooks(options?: PickhooksOptions): Pickhooks;
|
|
82
|
+
export { BSC_MAINNET, LIMITS, NATIVE, ZERO_ADDRESS, type Addresses } from "./addresses.js";
|
|
83
|
+
export { CHECK_TEXT, PickhooksError, decodeRevert, errorText, explain, findRevertData } from "./errors.js";
|
|
84
|
+
export { DEFAULT_RPC, deadlineIn, minusBps, type PickhooksOptions, type SendOptions, type Sent, type TxRequest } from "./tx.js";
|
|
85
|
+
export { blockedKind, buildInfiSwap, infiPriceBnb, infiQuote, infiSwapInput, permit2Approvals, poolIdOf, toKey, type PoolKey } from "./infinity.js";
|
|
86
|
+
export { approvalFor, buildV3Buy, buildV3Sell, receivedOf, v3PriceBnb, v3Quote } from "./v3.js";
|
|
87
|
+
export { type Venue, bestVenue, buildV2Buy, buildV2Sell, v2Quote, v2RouterAbi } from "./v2.js";
|
|
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";
|
|
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";
|
|
91
|
+
export { ruleText, type CoinRule, type CoinsModule, type RuleCheck, type RuleCoin, type RuleCoinVersion, type RuleLaunch } from "./coins.js";
|
|
92
|
+
export { type CallRow, type CallStep, type CallsModule, type HookCoin, type HookLaunch, type PoolsModule } from "./pools.js";
|
|
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";
|
|
94
|
+
export { coinsFor, coverOf, strikeFromPrice, type DipBid, type DipFloor, type DipPost, type DipsModule } from "./dips.js";
|
|
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";
|
|
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";
|
|
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";
|
|
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";
|
|
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
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { agentsModule } from "./agents.js";
|
|
2
|
+
import { anyModule } from "./any.js";
|
|
3
|
+
import { apiModule } from "./api.js";
|
|
4
|
+
import { blocksCatalog } from "./blocks.js";
|
|
5
|
+
import { coinsModule } from "./coins.js";
|
|
6
|
+
import { desksModule } from "./desks.js";
|
|
7
|
+
import { dipsModule } from "./dips.js";
|
|
8
|
+
import { infraModule } from "./infra.js";
|
|
9
|
+
import { lever2Module, leverModule } from "./lever.js";
|
|
10
|
+
import { callsModule, poolsModule } from "./pools.js";
|
|
11
|
+
import { stickyModule } from "./sticky.js";
|
|
12
|
+
import { makeCtx, sendAll, sendTx } from "./tx.js";
|
|
13
|
+
import { walletModule } from "./wallet.js";
|
|
14
|
+
import { watchModule } from "./watch.js";
|
|
15
|
+
/**
|
|
16
|
+
* The pickhooks SDK. One client, a part per product:
|
|
17
|
+
* any hook any coin: quotes, trades with the recapture room, opening a pool with a partner, the payouts
|
|
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
|
|
21
|
+
* coins coins with rules in the coin (v1, v2): rules as sentences, the rule that would refuse a trade, launches
|
|
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
|
|
25
|
+
* api pickhooks.com's public JSON API (launch feed, board, activity)
|
|
26
|
+
*
|
|
27
|
+
* const ph = createPickhooks({ walletClient });
|
|
28
|
+
* const [pool] = await ph.any.pools({ limit: 1 });
|
|
29
|
+
* const r = await ph.any.buy({ pool, bnbIn: parseEther("0.05") });
|
|
30
|
+
*/
|
|
31
|
+
export function createPickhooks(options = {}) {
|
|
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);
|
|
43
|
+
return {
|
|
44
|
+
addresses: ctx.a,
|
|
45
|
+
publicClient: ctx.pub,
|
|
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,
|
|
57
|
+
leverV1: leverModule(ctx),
|
|
58
|
+
dips,
|
|
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 }),
|
|
63
|
+
blocks: { catalog: blocksCatalog, block: (id) => blocksCatalog().sticky.blocks.find((b) => b.id === id) ?? null },
|
|
64
|
+
api: apiModule(ctx),
|
|
65
|
+
send: (tx, o) => sendTx(ctx, tx, o),
|
|
66
|
+
sendAll: (txs, o) => sendAll(ctx, txs, o),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export { BSC_MAINNET, LIMITS, NATIVE, ZERO_ADDRESS } from "./addresses.js";
|
|
70
|
+
export { CHECK_TEXT, PickhooksError, decodeRevert, errorText, explain, findRevertData } from "./errors.js";
|
|
71
|
+
export { DEFAULT_RPC, deadlineIn, minusBps } from "./tx.js";
|
|
72
|
+
export { blockedKind, buildInfiSwap, infiPriceBnb, infiQuote, infiSwapInput, permit2Approvals, poolIdOf, toKey } from "./infinity.js";
|
|
73
|
+
export { approvalFor, buildV3Buy, buildV3Sell, receivedOf, v3PriceBnb, v3Quote } from "./v3.js";
|
|
74
|
+
export { bestVenue, buildV2Buy, buildV2Sell, v2Quote, v2RouterAbi } from "./v2.js";
|
|
75
|
+
export { MAX_TICK, MIN_TICK, TAX_QUOTE_MARK, afterTax, depthNeeds, fitLadder, partnerLink, rangeFor, tickOf, } from "./any.js";
|
|
76
|
+
export { describeRows, stickyTable, stickyTestRun, testRunText, } from "./sticky.js";
|
|
77
|
+
export { CURVE, SUPPLY, simulate } from "./sticky-sim.js";
|
|
78
|
+
export { ruleText } from "./coins.js";
|
|
79
|
+
export {} from "./pools.js";
|
|
80
|
+
export { LEVER2_REASON, } from "./lever.js";
|
|
81
|
+
export { coinsFor, coverOf, strikeFromPrice } from "./dips.js";
|
|
82
|
+
export {} from "./api.js";
|
|
83
|
+
export {} from "./desks.js";
|
|
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";
|
|
89
|
+
export { BLOCKS_VERSION, BLOCK_ACTIONS, BLOCK_CHECKS, BLOCK_MARKS, BLOCK_OPERATORS, BLOCK_TRIGGERS, blockLineVars, blocksCatalog, } from "./blocks.js";
|
|
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";
|
|
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";
|