@pickhooks/sdk 0.0.0-stage → 0.2.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 +309 -3
- 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 +12 -0
- package/dist/abis/index.js +12 -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/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 +87 -0
- package/dist/addresses.js +62 -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/dips.d.ts +133 -0
- package/dist/dips.js +148 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.js +347 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +58 -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.d.ts +216 -0
- package/dist/sticky.js +292 -0
- package/dist/tx.d.ts +70 -0
- package/dist/tx.js +69 -0
- package/dist/v3.d.ts +42 -0
- package/dist/v3.js +98 -0
- package/package.json +58 -4
package/dist/lever.d.ts
ADDED
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { type Address } from "viem";
|
|
2
|
+
import { type PoolKey } from "./infinity.js";
|
|
3
|
+
import { type Ctx, type SendOptions, type Sent, type TxRequest } from "./tx.js";
|
|
4
|
+
export type LeverMarket = {
|
|
5
|
+
/** free coins and the curve's BNB with its virtual part */
|
|
6
|
+
q: bigint;
|
|
7
|
+
r: bigint;
|
|
8
|
+
v: bigint;
|
|
9
|
+
/** BNB the open longs borrowed */
|
|
10
|
+
debt: bigint;
|
|
11
|
+
locked: bigint;
|
|
12
|
+
supply: bigint;
|
|
13
|
+
creatorOwed: bigint;
|
|
14
|
+
platformOwed: bigint;
|
|
15
|
+
refunds: bigint;
|
|
16
|
+
start: number;
|
|
17
|
+
creator: Address;
|
|
18
|
+
creatorBps: number;
|
|
19
|
+
};
|
|
20
|
+
export type LeverCoin = {
|
|
21
|
+
token: Address;
|
|
22
|
+
name: string;
|
|
23
|
+
symbol: string;
|
|
24
|
+
metadata: string;
|
|
25
|
+
market: LeverMarket;
|
|
26
|
+
priceBnb: number;
|
|
27
|
+
mcapBnb: number;
|
|
28
|
+
positions: number;
|
|
29
|
+
};
|
|
30
|
+
export type LeverPosition = {
|
|
31
|
+
id: bigint;
|
|
32
|
+
owner: Address;
|
|
33
|
+
tokens: bigint;
|
|
34
|
+
debt: bigint;
|
|
35
|
+
margin: bigint;
|
|
36
|
+
opened: number;
|
|
37
|
+
trigger: bigint;
|
|
38
|
+
closeQuote: bigint | null;
|
|
39
|
+
};
|
|
40
|
+
/** lever v1 */
|
|
41
|
+
export declare function leverModule(ctx: Ctx): {
|
|
42
|
+
factory: `0x${string}`;
|
|
43
|
+
contracts: () => Promise<{
|
|
44
|
+
hook: Address;
|
|
45
|
+
router: Address;
|
|
46
|
+
engine: Address;
|
|
47
|
+
}>;
|
|
48
|
+
count: () => Promise<number>;
|
|
49
|
+
coins: (o?: {
|
|
50
|
+
limit?: number;
|
|
51
|
+
offset?: number;
|
|
52
|
+
}) => Promise<LeverCoin[]>;
|
|
53
|
+
coin: (token: Address) => Promise<LeverCoin | null>;
|
|
54
|
+
isCoin: (token: Address) => Promise<boolean>;
|
|
55
|
+
positions: (token: Address) => Promise<LeverPosition[]>;
|
|
56
|
+
quoteBuy: (token: Address, bnbIn: bigint) => Promise<bigint>;
|
|
57
|
+
quoteSell: (token: Address, amount: bigint) => Promise<{
|
|
58
|
+
out: bigint;
|
|
59
|
+
liquidations: number;
|
|
60
|
+
}>;
|
|
61
|
+
quoteOpen: (token: Address, gross: bigint, leverage: number) => Promise<{
|
|
62
|
+
tokens: bigint;
|
|
63
|
+
debt: bigint;
|
|
64
|
+
fee: bigint;
|
|
65
|
+
trigger: bigint;
|
|
66
|
+
}>;
|
|
67
|
+
refundOwed: (token: Address, who: Address) => Promise<bigint>;
|
|
68
|
+
poolKey: (token: Address) => Promise<PoolKey>;
|
|
69
|
+
build: {
|
|
70
|
+
buy: (token: Address, bnbIn: bigint, minOut: bigint) => Promise<TxRequest>;
|
|
71
|
+
/** needs the coin approved to the lever router */
|
|
72
|
+
sell: (token: Address, amount: bigint, minOut: bigint) => Promise<TxRequest>;
|
|
73
|
+
openLong: (token: Address, gross: bigint, leverage: number, minTokens: bigint) => Promise<TxRequest>;
|
|
74
|
+
closeLong: (token: Address, id: bigint, minBnb: bigint) => Promise<TxRequest>;
|
|
75
|
+
/** anyone, after 24 hours: the payout waits for the owner as a refund */
|
|
76
|
+
closeExpired: (token: Address, id: bigint) => Promise<TxRequest>;
|
|
77
|
+
claimRefund: (token: Address) => Promise<TxRequest>;
|
|
78
|
+
claimCreator: (token: Address) => Promise<TxRequest>;
|
|
79
|
+
};
|
|
80
|
+
buy: (b: {
|
|
81
|
+
token: Address;
|
|
82
|
+
bnbIn: bigint;
|
|
83
|
+
slippageBps?: number;
|
|
84
|
+
}, s?: SendOptions) => Promise<{
|
|
85
|
+
quoted: bigint;
|
|
86
|
+
hash: import("viem").Hex;
|
|
87
|
+
receipt: import("viem").TransactionReceipt;
|
|
88
|
+
}>;
|
|
89
|
+
sell: (x: {
|
|
90
|
+
token: Address;
|
|
91
|
+
amount: bigint;
|
|
92
|
+
slippageBps?: number;
|
|
93
|
+
}, s?: SendOptions) => Promise<{
|
|
94
|
+
quoted: bigint;
|
|
95
|
+
liquidations: number;
|
|
96
|
+
hash: import("viem").Hex;
|
|
97
|
+
receipt: import("viem").TransactionReceipt;
|
|
98
|
+
}>;
|
|
99
|
+
/** gross = margin plus the open fee; the long gets at least the quote less roomBps (default 100) coins */
|
|
100
|
+
openLong: (o: {
|
|
101
|
+
token: Address;
|
|
102
|
+
gross: bigint;
|
|
103
|
+
leverage: number;
|
|
104
|
+
roomBps?: number;
|
|
105
|
+
}, s?: SendOptions) => Promise<Sent & {
|
|
106
|
+
id: bigint;
|
|
107
|
+
tokens: bigint;
|
|
108
|
+
}>;
|
|
109
|
+
closeLong: (o: {
|
|
110
|
+
token: Address;
|
|
111
|
+
id: bigint;
|
|
112
|
+
roomBps?: number;
|
|
113
|
+
}, s?: SendOptions) => Promise<{
|
|
114
|
+
quoted: bigint;
|
|
115
|
+
hash: import("viem").Hex;
|
|
116
|
+
receipt: import("viem").TransactionReceipt;
|
|
117
|
+
}>;
|
|
118
|
+
closeExpired: (token: Address, id: bigint, s?: SendOptions) => Promise<Sent>;
|
|
119
|
+
claimRefund: (token: Address, s?: SendOptions) => Promise<Sent>;
|
|
120
|
+
claimCreator: (token: Address, s?: SendOptions) => Promise<Sent>;
|
|
121
|
+
/** one transaction: the coin and the creator's first buy; returns the coin */
|
|
122
|
+
launch: (l: {
|
|
123
|
+
name: string;
|
|
124
|
+
symbol: string;
|
|
125
|
+
metadata: string;
|
|
126
|
+
firstBuy?: bigint;
|
|
127
|
+
minSeedTokens?: bigint;
|
|
128
|
+
}, s?: SendOptions) => Promise<Sent & {
|
|
129
|
+
token: Address;
|
|
130
|
+
}>;
|
|
131
|
+
};
|
|
132
|
+
export type Lever2State = {
|
|
133
|
+
q: bigint;
|
|
134
|
+
r: bigint;
|
|
135
|
+
/** BNB per coin times 1e18 */
|
|
136
|
+
price: bigint;
|
|
137
|
+
curveBnb: bigint;
|
|
138
|
+
longRoom: bigint;
|
|
139
|
+
shortRoom: bigint;
|
|
140
|
+
debt: bigint;
|
|
141
|
+
locked: bigint;
|
|
142
|
+
lent: bigint;
|
|
143
|
+
notional: bigint;
|
|
144
|
+
longs: bigint;
|
|
145
|
+
shorts: bigint;
|
|
146
|
+
tS: number;
|
|
147
|
+
tB: number;
|
|
148
|
+
/** coins a sale may take before the curve's start (the longs' coins already off) */
|
|
149
|
+
sellRoom: bigint;
|
|
150
|
+
};
|
|
151
|
+
export type Lever2Row = {
|
|
152
|
+
id: bigint;
|
|
153
|
+
owner: Address;
|
|
154
|
+
opened: number;
|
|
155
|
+
margin: bigint;
|
|
156
|
+
borrowed: bigint;
|
|
157
|
+
amount: bigint;
|
|
158
|
+
trigger: bigint;
|
|
159
|
+
triggerPrice: bigint;
|
|
160
|
+
closeNet: bigint;
|
|
161
|
+
expired: boolean;
|
|
162
|
+
};
|
|
163
|
+
/** Lens OpenQuote; reason 0 ok, 1 leverage, 2 margin, 3 no slot, 4 side full, 5 unsafe self, 6 unsafe other, 7 unknown, 8 pushed */
|
|
164
|
+
export type Lever2OpenQuote = {
|
|
165
|
+
reason: number;
|
|
166
|
+
margin: bigint;
|
|
167
|
+
/** long: BNB debt; short: notional (what its coins sell for) */
|
|
168
|
+
borrowed: bigint;
|
|
169
|
+
fee: bigint;
|
|
170
|
+
/** long: coins bought; short: coins borrowed and sold */
|
|
171
|
+
amount: bigint;
|
|
172
|
+
trigger: bigint;
|
|
173
|
+
triggerPrice: bigint;
|
|
174
|
+
entryPrice: bigint;
|
|
175
|
+
curveBnb: bigint;
|
|
176
|
+
room: bigint;
|
|
177
|
+
liquidations: bigint;
|
|
178
|
+
/** a full side: the position of this side the open closes first to take its slot (0: none) */
|
|
179
|
+
bump: bigint;
|
|
180
|
+
/** reason 3: the margin from which a new position takes the smallest one's slot */
|
|
181
|
+
bumpFrom: bigint;
|
|
182
|
+
};
|
|
183
|
+
export type Lever2CloseQuote = {
|
|
184
|
+
net: bigint;
|
|
185
|
+
gross: bigint;
|
|
186
|
+
fundingFee: bigint;
|
|
187
|
+
closeFee: bigint;
|
|
188
|
+
liquidations: bigint;
|
|
189
|
+
pushed: boolean;
|
|
190
|
+
};
|
|
191
|
+
/** Lens reasons as sentences */
|
|
192
|
+
export declare const LEVER2_REASON: Record<number, string>;
|
|
193
|
+
declare const KIND: {
|
|
194
|
+
readonly creator: 3;
|
|
195
|
+
readonly refund: 4;
|
|
196
|
+
readonly platform: 5;
|
|
197
|
+
};
|
|
198
|
+
export declare function lever2Module(ctx: Ctx): {
|
|
199
|
+
factory: `0x${string}`;
|
|
200
|
+
contracts: () => Promise<{
|
|
201
|
+
hook: Address;
|
|
202
|
+
engine: Address;
|
|
203
|
+
lens: Address;
|
|
204
|
+
}>;
|
|
205
|
+
count: () => Promise<number>;
|
|
206
|
+
coins: (o?: {
|
|
207
|
+
limit?: number;
|
|
208
|
+
offset?: number;
|
|
209
|
+
}) => Promise<{
|
|
210
|
+
token: `0x${string}`;
|
|
211
|
+
name: string;
|
|
212
|
+
symbol: string;
|
|
213
|
+
metadata: string;
|
|
214
|
+
supply: bigint;
|
|
215
|
+
state: {
|
|
216
|
+
tS: number;
|
|
217
|
+
tB: number;
|
|
218
|
+
q: bigint;
|
|
219
|
+
r: bigint;
|
|
220
|
+
/** BNB per coin times 1e18 */
|
|
221
|
+
price: bigint;
|
|
222
|
+
curveBnb: bigint;
|
|
223
|
+
longRoom: bigint;
|
|
224
|
+
shortRoom: bigint;
|
|
225
|
+
debt: bigint;
|
|
226
|
+
locked: bigint;
|
|
227
|
+
lent: bigint;
|
|
228
|
+
notional: bigint;
|
|
229
|
+
longs: bigint;
|
|
230
|
+
shorts: bigint;
|
|
231
|
+
/** coins a sale may take before the curve's start (the longs' coins already off) */
|
|
232
|
+
sellRoom: bigint;
|
|
233
|
+
};
|
|
234
|
+
market: {
|
|
235
|
+
start: number;
|
|
236
|
+
creatorBps: number;
|
|
237
|
+
creator: Address;
|
|
238
|
+
liquidity: bigint;
|
|
239
|
+
v: bigint;
|
|
240
|
+
debt: bigint;
|
|
241
|
+
creatorOwed: bigint;
|
|
242
|
+
platformOwed: bigint;
|
|
243
|
+
refunds: bigint;
|
|
244
|
+
};
|
|
245
|
+
key: PoolKey;
|
|
246
|
+
id: `0x${string}`;
|
|
247
|
+
priceBnb: number;
|
|
248
|
+
mcapBnb: number;
|
|
249
|
+
}[]>;
|
|
250
|
+
coin: (token: Address) => Promise<{
|
|
251
|
+
token: `0x${string}`;
|
|
252
|
+
name: string;
|
|
253
|
+
symbol: string;
|
|
254
|
+
metadata: string;
|
|
255
|
+
supply: bigint;
|
|
256
|
+
state: {
|
|
257
|
+
tS: number;
|
|
258
|
+
tB: number;
|
|
259
|
+
q: bigint;
|
|
260
|
+
r: bigint;
|
|
261
|
+
/** BNB per coin times 1e18 */
|
|
262
|
+
price: bigint;
|
|
263
|
+
curveBnb: bigint;
|
|
264
|
+
longRoom: bigint;
|
|
265
|
+
shortRoom: bigint;
|
|
266
|
+
debt: bigint;
|
|
267
|
+
locked: bigint;
|
|
268
|
+
lent: bigint;
|
|
269
|
+
notional: bigint;
|
|
270
|
+
longs: bigint;
|
|
271
|
+
shorts: bigint;
|
|
272
|
+
/** coins a sale may take before the curve's start (the longs' coins already off) */
|
|
273
|
+
sellRoom: bigint;
|
|
274
|
+
};
|
|
275
|
+
market: {
|
|
276
|
+
start: number;
|
|
277
|
+
creatorBps: number;
|
|
278
|
+
creator: Address;
|
|
279
|
+
liquidity: bigint;
|
|
280
|
+
v: bigint;
|
|
281
|
+
debt: bigint;
|
|
282
|
+
creatorOwed: bigint;
|
|
283
|
+
platformOwed: bigint;
|
|
284
|
+
refunds: bigint;
|
|
285
|
+
};
|
|
286
|
+
key: PoolKey;
|
|
287
|
+
id: `0x${string}`;
|
|
288
|
+
priceBnb: number;
|
|
289
|
+
mcapBnb: number;
|
|
290
|
+
} | null>;
|
|
291
|
+
isCoin: (token: Address) => Promise<boolean>;
|
|
292
|
+
poolKey: (token: Address) => Promise<PoolKey>;
|
|
293
|
+
positions: (token: Address) => Promise<{
|
|
294
|
+
longs: Lever2Row[];
|
|
295
|
+
shorts: Lever2Row[];
|
|
296
|
+
}>;
|
|
297
|
+
quoteOpen: (token: Address, side: "long" | "short", gross: bigint, leverage: number) => Promise<Lever2OpenQuote & {
|
|
298
|
+
text: string;
|
|
299
|
+
}>;
|
|
300
|
+
quoteClose: (token: Address, side: "long" | "short", id: bigint) => Promise<Lever2CloseQuote>;
|
|
301
|
+
quote: (q: {
|
|
302
|
+
token: Address;
|
|
303
|
+
side: "buy" | "sell";
|
|
304
|
+
amount: bigint;
|
|
305
|
+
from?: Address;
|
|
306
|
+
}) => Promise<{
|
|
307
|
+
amountOut: bigint;
|
|
308
|
+
}>;
|
|
309
|
+
sellPlan: (token: Address, amount: bigint) => Promise<{
|
|
310
|
+
legs: bigint[];
|
|
311
|
+
closes: number;
|
|
312
|
+
fits: boolean;
|
|
313
|
+
sellRoom: bigint;
|
|
314
|
+
}>;
|
|
315
|
+
refundOwed: (token: Address, who: Address) => Promise<bigint>;
|
|
316
|
+
/** the gross (margin plus the open fee) for at least `margin` at `leverage`, rounded up to a millionth of a BNB */
|
|
317
|
+
grossForMargin: (margin: bigint, leverage: number) => bigint;
|
|
318
|
+
build: {
|
|
319
|
+
buy: (key: PoolKey, bnbIn: bigint, minOut: bigint) => TxRequest;
|
|
320
|
+
/** legs from sellPlan(); the router pulls the coins with Permit2 */
|
|
321
|
+
sell: (key: PoolKey, legs: readonly bigint[], minOut: bigint) => TxRequest;
|
|
322
|
+
openLong: (token: Address, gross: bigint, leverage: number, minTokens: bigint) => Promise<TxRequest>;
|
|
323
|
+
openShort: (token: Address, gross: bigint, leverage: number, maxCoins: bigint) => Promise<TxRequest>;
|
|
324
|
+
close: (token: Address, side: "long" | "short", id: bigint, minBnb: bigint) => Promise<TxRequest>;
|
|
325
|
+
/** the pad's keeper after 24 hours, anyone 24 hours later; the payout waits for the owner as a refund */
|
|
326
|
+
closeExpired: (token: Address, side: "long" | "short", id: bigint, minBnb: bigint) => Promise<TxRequest>;
|
|
327
|
+
/** refund: the caller's refunds; creator: the creator's fees; platform: the pad's share (anyone may send it) */
|
|
328
|
+
claim: (token: Address, kind: keyof typeof KIND) => Promise<TxRequest>;
|
|
329
|
+
};
|
|
330
|
+
buy: (b: {
|
|
331
|
+
token: Address;
|
|
332
|
+
bnbIn: bigint;
|
|
333
|
+
slippageBps?: number;
|
|
334
|
+
}, s?: SendOptions) => Promise<{
|
|
335
|
+
quoted: bigint;
|
|
336
|
+
hash: import("viem").Hex;
|
|
337
|
+
receipt: import("viem").TransactionReceipt;
|
|
338
|
+
}>;
|
|
339
|
+
/** sells in one or two legs (sellPlan); the minimum is the pool's quote of the first leg plus the rest, less slippage */
|
|
340
|
+
sell: (x: {
|
|
341
|
+
token: Address;
|
|
342
|
+
amount: bigint;
|
|
343
|
+
slippageBps?: number;
|
|
344
|
+
minOut?: bigint;
|
|
345
|
+
}, s?: SendOptions) => Promise<{
|
|
346
|
+
quoted: bigint;
|
|
347
|
+
plan: {
|
|
348
|
+
legs: bigint[];
|
|
349
|
+
closes: number;
|
|
350
|
+
fits: boolean;
|
|
351
|
+
sellRoom: bigint;
|
|
352
|
+
};
|
|
353
|
+
hash: import("viem").Hex;
|
|
354
|
+
receipt: import("viem").TransactionReceipt;
|
|
355
|
+
}>;
|
|
356
|
+
/** opens a long or short at the Lens quote with roomBps (default 100) on its bound; a refusing reason throws its sentence */
|
|
357
|
+
open: (o: {
|
|
358
|
+
token: Address;
|
|
359
|
+
side: "long" | "short";
|
|
360
|
+
gross: bigint;
|
|
361
|
+
leverage: number;
|
|
362
|
+
roomBps?: number;
|
|
363
|
+
}, s?: SendOptions) => Promise<Sent & {
|
|
364
|
+
id: bigint;
|
|
365
|
+
quote: Lever2OpenQuote;
|
|
366
|
+
}>;
|
|
367
|
+
close: (o: {
|
|
368
|
+
token: Address;
|
|
369
|
+
side: "long" | "short";
|
|
370
|
+
id: bigint;
|
|
371
|
+
roomBps?: number;
|
|
372
|
+
}, s?: SendOptions) => Promise<{
|
|
373
|
+
quoted: bigint;
|
|
374
|
+
hash: import("viem").Hex;
|
|
375
|
+
receipt: import("viem").TransactionReceipt;
|
|
376
|
+
}>;
|
|
377
|
+
claim: (token: Address, kind: keyof typeof KIND, s?: SendOptions) => Promise<Sent>;
|
|
378
|
+
/** one transaction: the hook's launch dust plus the creator's first buy; returns the coin */
|
|
379
|
+
launch: (l: {
|
|
380
|
+
name: string;
|
|
381
|
+
symbol: string;
|
|
382
|
+
metadata: string;
|
|
383
|
+
firstBuy?: bigint;
|
|
384
|
+
minSeedTokens?: bigint;
|
|
385
|
+
}, s?: SendOptions) => Promise<Sent & {
|
|
386
|
+
token: Address;
|
|
387
|
+
}>;
|
|
388
|
+
};
|
|
389
|
+
export type LeverModule = ReturnType<typeof leverModule>;
|
|
390
|
+
export type Lever2Module = ReturnType<typeof lever2Module>;
|
|
391
|
+
export {};
|