hookr-sdk 0.2.0 → 1.0.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/CHANGELOG.md +38 -0
- package/LICENSE +21 -0
- package/MIGRATING.md +89 -0
- package/README.md +283 -96
- package/dist/core/abi.d.ts +10930 -0
- package/dist/core/abi.js +455 -0
- package/dist/core/advisories.d.ts +184 -0
- package/dist/core/advisories.js +291 -0
- package/dist/core/client.d.ts +55 -0
- package/dist/core/client.js +107 -0
- package/dist/core/generated.d.ts +14295 -0
- package/dist/core/generated.js +1058 -0
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.js +17 -0
- package/dist/core/launch.d.ts +200 -0
- package/dist/core/launch.js +427 -0
- package/dist/core/pair.d.ts +64 -0
- package/dist/core/pair.js +136 -0
- package/dist/core/params.d.ts +415 -0
- package/dist/core/params.js +1235 -0
- package/dist/core/policies.d.ts +136 -0
- package/dist/core/policies.js +125 -0
- package/dist/core/proofs.d.ts +25 -0
- package/dist/core/proofs.js +118 -0
- package/dist/core/quotes.d.ts +185 -0
- package/dist/core/quotes.js +550 -0
- package/dist/core/referrals.d.ts +32 -0
- package/dist/core/referrals.js +36 -0
- package/dist/core/registry.d.ts +357 -0
- package/dist/core/registry.js +378 -0
- package/dist/core/rules.d.ts +675 -0
- package/dist/core/rules.js +1049 -0
- package/dist/core/schema.d.ts +358 -0
- package/dist/core/schema.js +105 -0
- package/dist/core/stocks.generated.d.ts +11 -0
- package/dist/core/stocks.generated.js +1228 -0
- package/dist/core/vault.d.ts +59 -0
- package/dist/core/vault.js +112 -0
- package/dist/core/wallet.d.ts +142 -0
- package/dist/core/wallet.js +304 -0
- package/dist/deployments.d.ts +8 -0
- package/dist/deployments.js +26 -0
- package/dist/index.d.ts +6 -15
- package/dist/index.js +6 -15
- package/dist/releases.d.ts +172 -0
- package/dist/releases.js +268 -0
- package/package.json +46 -10
- package/provenance.json +31 -0
- package/dist/abi.d.ts +0 -6404
- package/dist/abi.js +0 -8300
- package/dist/chain.d.ts +0 -87
- package/dist/chain.js +0 -86
- package/dist/claims.d.ts +0 -32
- package/dist/claims.js +0 -31
- package/dist/fees.d.ts +0 -59
- package/dist/fees.js +0 -142
- package/dist/links.d.ts +0 -48
- package/dist/links.js +0 -93
- package/dist/market.d.ts +0 -264
- package/dist/market.js +0 -310
- package/dist/reads.d.ts +0 -127
- package/dist/reads.js +0 -207
- package/dist/rules.d.ts +0 -84
- package/dist/rules.js +0 -296
- package/dist/swap.d.ts +0 -96
- package/dist/swap.js +0 -134
|
@@ -0,0 +1,675 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import { type Address } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* HookrTypes.RulesConfig. Integers up to 48 bits are numbers; the uint128 amounts are bigints. Every field is set by
|
|
5
|
+
* the pool's creator at launch and frozen at bind.
|
|
6
|
+
*/
|
|
7
|
+
export interface RulesConfig {
|
|
8
|
+
guardEndBlock: number;
|
|
9
|
+
maxFeePips: number;
|
|
10
|
+
/** Anti-Snipe tax at launch, in pips of the pool input. */
|
|
11
|
+
snipeTaxPips: number;
|
|
12
|
+
/** Tax the decay ends at: below snipeTaxPips, or zero when snipeDecaySeconds is zero. */
|
|
13
|
+
snipeFloorPips: number;
|
|
14
|
+
/** Seconds the tax takes to fall linearly from snipeTaxPips to snipeFloorPips; zero charges snipeTaxPips flat. */
|
|
15
|
+
snipeDecaySeconds: number;
|
|
16
|
+
/** Hookr dynamic fee sensitivity, 1 to 10; zero exactly when maxFeePips equals the base fee. */
|
|
17
|
+
dynamicFeeSens: number;
|
|
18
|
+
burnBps: number;
|
|
19
|
+
lpBps: number;
|
|
20
|
+
potBps: number;
|
|
21
|
+
royaltyBps: number;
|
|
22
|
+
protocolShareBps: number;
|
|
23
|
+
potEveryNBuys: number;
|
|
24
|
+
maxBuyQuoteAmount: bigint;
|
|
25
|
+
potMinBuyQuote: bigint;
|
|
26
|
+
royaltyTo: Address;
|
|
27
|
+
/**
|
|
28
|
+
* The pool's integrator, zero for none. A nonzero integrator must be on the integrator list of the treasury the
|
|
29
|
+
* Rules pay (`HookrTreasury.feeTerms(integrator)` answers a nonzero rate) when the pool binds, or the bind reverts
|
|
30
|
+
* `UnknownIntegrator`; the pool then freezes it with that rate and pays it the rate of every Hookr share of the
|
|
31
|
+
* Snipe, dynamic fee, LP Rewards and Auto Burn (`splitProtocolShare`). Set by the app the launch goes through, not
|
|
32
|
+
* by the creator. The list is on chain: offline, `checkRulesConfig` checks it only against `RulesContext.integrators`.
|
|
33
|
+
*/
|
|
34
|
+
integrator: Address;
|
|
35
|
+
}
|
|
36
|
+
/** HookrTypes.RecaptureConfig: a recapture pool's creator knobs, frozen at bind as the third part of its rules data. */
|
|
37
|
+
export interface RecaptureConfig {
|
|
38
|
+
on: boolean;
|
|
39
|
+
traderBps: number;
|
|
40
|
+
lpBps: number;
|
|
41
|
+
period: number;
|
|
42
|
+
maxPrizeBps: number;
|
|
43
|
+
potReleaseBps: number;
|
|
44
|
+
minBuyQuote: bigint;
|
|
45
|
+
releaseBlocks: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* HookrTypes.RulesKnobs (r31): a pool's Rules knobs beyond RulesConfig, frozen at bind as the second part of its rules
|
|
49
|
+
* data. `minDynamicFeeLiquidity` is a dynamic fee pool's minimum dynamic fee liquidity (1 to 2^96 - 1); the four tempo
|
|
50
|
+
* knobs are its dynamic fee reference windows (RULES_KNOB_BOUNDS); all five are zero on a pool without dynamic fees.
|
|
51
|
+
* `snipeCurve` is a decaying Snipe's shape (SNIPE_CURVE), linear unless the Snipe decays.
|
|
52
|
+
*/
|
|
53
|
+
export interface RulesKnobs {
|
|
54
|
+
minDynamicFeeLiquidity: bigint;
|
|
55
|
+
windowSeconds: number;
|
|
56
|
+
resetSeconds: number;
|
|
57
|
+
carryBps: number;
|
|
58
|
+
moveTicks: number;
|
|
59
|
+
snipeCurve: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* HookrLauncher.MemberKnobs (r31, launchFamily only): a member's supply weight, its minimum dynamic fee liquidity
|
|
63
|
+
* divisor (zero for DYNAMIC_FEE_LIQUIDITY_DIVISOR), its lock end and its Rules knobs, which the Launcher passes to the
|
|
64
|
+
* member's Rules as given (a dynamic fee member whose four tempo knobs are all zero takes the default tempo).
|
|
65
|
+
*/
|
|
66
|
+
export interface MemberKnobs {
|
|
67
|
+
subjectWeightBps: number;
|
|
68
|
+
dynamicFeeLiquidityDivisor: number;
|
|
69
|
+
lockEndBlock: bigint;
|
|
70
|
+
windowSeconds: number;
|
|
71
|
+
resetSeconds: number;
|
|
72
|
+
carryBps: number;
|
|
73
|
+
moveTicks: number;
|
|
74
|
+
snipeCurve: number;
|
|
75
|
+
}
|
|
76
|
+
/** HookrTypes.Caps: aggregate fee ceilings. Pips use 1e6, basis points 1e4. */
|
|
77
|
+
export interface Caps {
|
|
78
|
+
maxLpFeePips: number;
|
|
79
|
+
maxQuoteTakePips: number;
|
|
80
|
+
maxSubjectTakeBps: number;
|
|
81
|
+
}
|
|
82
|
+
/** Gas every Rules admission, and so every pool bound to HookrRules, carries: exactly 2,000,000. */
|
|
83
|
+
export declare const RULES_GAS_LIMIT: 2000000;
|
|
84
|
+
/** Ceiling on any LP fee, in pips. */
|
|
85
|
+
export declare const MAX_LP_FEE_PIPS = 600000;
|
|
86
|
+
/**
|
|
87
|
+
* Highest protocol share a pool binds with, in basis points (HookrRules._validate), and highest minimum a HookrRules
|
|
88
|
+
* can be built with (its constructor): 50%.
|
|
89
|
+
*/
|
|
90
|
+
export declare const MAX_PROTOCOL_SHARE_BPS = 5000;
|
|
91
|
+
/**
|
|
92
|
+
* Rule-fee terms the treasury governs (HookrTreasury, r23): the highest governed floor of a pool's protocolShareBps,
|
|
93
|
+
* the highest integrator rate (in basis points of Hookr's rule-fee share; HookrRules refuses a larger one at bind too)
|
|
94
|
+
* and the rate the app pre-fills, and how long a proposed change waits and then stays acceptable, in seconds.
|
|
95
|
+
*/
|
|
96
|
+
export declare const MAX_RULE_SHARE_FLOOR_BPS: number;
|
|
97
|
+
export declare const MAX_INTEGRATOR_BPS: number;
|
|
98
|
+
export declare const DEFAULT_INTEGRATOR_BPS: number;
|
|
99
|
+
export declare const FEE_TERMS_DELAY_SECONDS: number;
|
|
100
|
+
export declare const FEE_TERMS_GRACE_SECONDS: number;
|
|
101
|
+
/**
|
|
102
|
+
* The Hookr minimum (r25, HookrTreasury): the least Hookr takes of every trader swap on a Hookr token's pool, in pips
|
|
103
|
+
* of the swap, frozen at bind. The treasury holds a rate for pools without arb recapture and one for pools with it,
|
|
104
|
+
* each 0 to MAX_MIN_FEE_PIPS (10,000, 1%) and DEFAULT_MIN_FEE_PIPS (1,000, 0.1%) at deployment, and a per-integrator
|
|
105
|
+
* override (0 to 10,000; NO_MIN_FEE_OVERRIDE, 65,535, reads as none) that reaches only the pool ids that integrator
|
|
106
|
+
* approved (`approveMinFeePool`). HookrRules refuses a minimum above its own MAX_MIN_FEE_PIPS at bind.
|
|
107
|
+
*/
|
|
108
|
+
export declare const MAX_MIN_FEE_PIPS: number;
|
|
109
|
+
export declare const DEFAULT_MIN_FEE_PIPS: number;
|
|
110
|
+
export declare const NO_MIN_FEE_OVERRIDE: number;
|
|
111
|
+
export declare const RULES_MAX_MIN_FEE_PIPS: number;
|
|
112
|
+
/**
|
|
113
|
+
* The runtime keccak256 of HookrToken, the token HookrLauncher creates. It has no immutables, so every HookrToken has
|
|
114
|
+
* this codehash; HookrRules compares a pool's subject's codehash with it at bind and freezes the Hookr minimum only
|
|
115
|
+
* on a match, and then only on a pool without arb recapture whose rules earn Hookr nothing (`bindMinFeePips`). A token
|
|
116
|
+
* of any other code binds none; HookrToken bytecode deployed outside the launcher binds it.
|
|
117
|
+
*/
|
|
118
|
+
export declare const HOOKR_TOKEN_RUNTIME_KECCAK256: Hex;
|
|
119
|
+
/**
|
|
120
|
+
* Hookr's cut of every arb recapture, in basis points of the profit the root reads back from each push at the pool's
|
|
121
|
+
* frozen partner share (HookrRecapture.RECAPTURE_PROTOCOL_BPS): 25% since r31, on every pool, whatever its
|
|
122
|
+
* protocolShareBps or integrator.
|
|
123
|
+
*/
|
|
124
|
+
export declare const RECAPTURE_PROTOCOL_BPS: number;
|
|
125
|
+
/**
|
|
126
|
+
* HookrRegistryChecks.MAX_LANE_PARTNER_BPS: the most a lane partner keeps of each arb recapture's profit, 25% since
|
|
127
|
+
* r31, checked at every lane opening.
|
|
128
|
+
*/
|
|
129
|
+
export declare const MAX_LANE_PARTNER_BPS: number;
|
|
130
|
+
/** HookrRecapture.PRIZE_SHARE_OF_FEE_BPS: a King of the Pool prize reaches at most half the protocol fee it bounds. */
|
|
131
|
+
export declare const PRIZE_SHARE_OF_FEE_BPS: number;
|
|
132
|
+
/**
|
|
133
|
+
* Longest Anti-Snipe decay any guard binds with, in seconds (HookrTypes.MAX_SNIPE_DECAY_SECONDS, an hour); since r31 a
|
|
134
|
+
* longer guard may decay over its whole length (`maxSnipeDecaySeconds`).
|
|
135
|
+
*/
|
|
136
|
+
export declare const MAX_SNIPE_DECAY_SECONDS: number;
|
|
137
|
+
/** HookrLauncher.DYNAMIC_FEE_LIQUIDITY_DIVISOR: a dynamic fee member's launch liquidity over this is its minimum. */
|
|
138
|
+
export declare const DYNAMIC_FEE_LIQUIDITY_DIVISOR: bigint;
|
|
139
|
+
/** Hookr dynamic fee reference windows (HookrRules.dynamicFeeParameters), in seconds, basis points and ticks. */
|
|
140
|
+
export declare const DYNAMIC_FEE_PARAMETERS: {
|
|
141
|
+
readonly window: number;
|
|
142
|
+
readonly reset: number;
|
|
143
|
+
readonly carryBps: number;
|
|
144
|
+
readonly moveTicks: number;
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* RulesKnobs bounds HookrRules enforces at bind (HookrTypes): a dynamic fee pool's window, its reset (a multiple of the
|
|
148
|
+
* reset step from the larger of twice the window and the reset floor), its carry (a multiple of the carry step) and its
|
|
149
|
+
* counted move; the Snipe curves; and the parent block length a guard's wall-clock length is counted in.
|
|
150
|
+
*/
|
|
151
|
+
export declare const RULES_KNOB_BOUNDS: {
|
|
152
|
+
readonly minWindowSeconds: number;
|
|
153
|
+
readonly maxWindowSeconds: number;
|
|
154
|
+
readonly minResetSeconds: number;
|
|
155
|
+
readonly maxResetSeconds: number;
|
|
156
|
+
readonly resetStepSeconds: number;
|
|
157
|
+
readonly maxCarryBps: number;
|
|
158
|
+
readonly carryStepBps: number;
|
|
159
|
+
readonly minMoveTicks: number;
|
|
160
|
+
readonly maxMoveTicks: number;
|
|
161
|
+
};
|
|
162
|
+
/** RulesKnobs.snipeCurve (HookrTypes.SNIPE_CURVE_*): linear (the default), front-loaded and step. */
|
|
163
|
+
export declare const SNIPE_CURVE: {
|
|
164
|
+
readonly linear: number;
|
|
165
|
+
readonly frontLoaded: number;
|
|
166
|
+
readonly step: number;
|
|
167
|
+
};
|
|
168
|
+
/** HookrTypes.PARENT_BLOCK_SECONDS: a guard's length in parent blocks times this bounds a longer Snipe decay. */
|
|
169
|
+
export declare const PARENT_BLOCK_SECONDS: number;
|
|
170
|
+
/** The knobs of a pool bound without any (`abi.encode(RulesConfig)`): every field zero. */
|
|
171
|
+
export declare const NO_RULES_KNOBS: RulesKnobs;
|
|
172
|
+
/**
|
|
173
|
+
* HookrDynamicFee's reach bound (r31, N09): a dynamic fee pool binds only when its span (maxFeePips less the base fee)
|
|
174
|
+
* times its sensitivity squared is at most `maxReach`, and its span times its protocol share times (`reserveScale` less
|
|
175
|
+
* the sensitivity squared) at most `maxReserve` times `reserveScale`.
|
|
176
|
+
*/
|
|
177
|
+
export declare const DYNAMIC_FEE_REACH: {
|
|
178
|
+
readonly maxReach: bigint;
|
|
179
|
+
readonly maxReserve: bigint;
|
|
180
|
+
readonly reserveScale: bigint;
|
|
181
|
+
};
|
|
182
|
+
/** Longest launch guard, in blocks after the binding block. */
|
|
183
|
+
export declare const MAX_GUARD_BLOCKS = 100000;
|
|
184
|
+
/**
|
|
185
|
+
* RulesConfig's type string, `RulesConfig(uint40 guardEndBlock,...,address integrator)`, built from the struct's ABI
|
|
186
|
+
* components in declaration order (16 fields since r23 appended `integrator`).
|
|
187
|
+
*/
|
|
188
|
+
export declare const RULES_CONFIG_TYPE: string;
|
|
189
|
+
/**
|
|
190
|
+
* The Rules' schema id (r26): HookrRules.configSchemaHash() is the keccak256 of RULES_CONFIG_TYPE, and
|
|
191
|
+
* HookrFeeAdvisory.RULES_SCHEMA and HookrSessionAdvisory's RULES_SCHEMA read the same id. A Rules admission carries it
|
|
192
|
+
* as its `schemaHash` (the lane checks the admission against the Rules' own answer), and a reader that gates on it
|
|
193
|
+
* refuses any other layout.
|
|
194
|
+
*/
|
|
195
|
+
export declare const RULES_CONFIG_SCHEMA_HASH: Hex;
|
|
196
|
+
/**
|
|
197
|
+
* The retired schema id of the 15-word layout before r23's `integrator` field, keccak256("hookr.rules.config"): these
|
|
198
|
+
* Rules never answer it, so an advisory or tool still pinned to it fails closed against them.
|
|
199
|
+
*/
|
|
200
|
+
export declare const RETIRED_RULES_CONFIG_SCHEMA_HASH: `0x${string}`;
|
|
201
|
+
/**
|
|
202
|
+
* Words of each form of rules data HookrRules binds (r31): the config alone, the config and its RulesKnobs, and both
|
|
203
|
+
* with a RecaptureConfig too (16, 22 and 30 words).
|
|
204
|
+
*/
|
|
205
|
+
export declare const RULES_DATA_WORDS: {
|
|
206
|
+
readonly config: 16;
|
|
207
|
+
readonly knobs: number;
|
|
208
|
+
readonly recapture: number;
|
|
209
|
+
};
|
|
210
|
+
/** ABI-encodes a RulesConfig alone: `abi.encode(RulesConfig)`, the rules data of a pool without dynamic fees. */
|
|
211
|
+
export declare function encodeRulesConfig(c: RulesConfig): Hex;
|
|
212
|
+
/** Decodes a config-only rules data (`abi.encode(RulesConfig)`), refusing any non-canonical encoding. */
|
|
213
|
+
export declare function decodeRulesConfig(data: Hex): RulesConfig;
|
|
214
|
+
/**
|
|
215
|
+
* Refuses knobs HookrRules._checkKnobs refuses at bind for `c` in the given form (`knobs`: abi.encode(RulesConfig,
|
|
216
|
+
* RulesKnobs); `recapture`: with a RecaptureConfig after them; `config`: the config alone, whose knobs read as zero). A
|
|
217
|
+
* pool without dynamic fees takes none of the five dynamic fee fields; a dynamic fee pool needs the knobbed form, a
|
|
218
|
+
* minimum dynamic fee liquidity of 1 to 2^96 - 1 and its tempo in bounds; a curve other than linear needs a decaying
|
|
219
|
+
* Snipe; and a knobbed pool without arb recapture or dynamic fees must set a knob off its default (the curve).
|
|
220
|
+
* Returns whether the pool stores knobs (`custom`) and whether its tempo is off the default (`tempo`).
|
|
221
|
+
*/
|
|
222
|
+
export declare function checkRulesKnobs(c: Pick<RulesConfig, "dynamicFeeSens" | "snipeDecaySeconds">, knobs: RulesKnobs, form: "config" | "knobs" | "recapture"): {
|
|
223
|
+
custom: boolean;
|
|
224
|
+
tempo: boolean;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* The canonical rules data HookrRules.bind takes for `c` (r31, three forms told apart by length): `abi.encode(RulesConfig)`
|
|
228
|
+
* for a pool without dynamic fees, arb recapture or a knob off its default; `abi.encode(RulesConfig, RulesKnobs)` for
|
|
229
|
+
* every other pool without arb recapture; `abi.encode(RulesConfig, RulesKnobs, RecaptureConfig)` for a recapture pool
|
|
230
|
+
* (`recapture.on`). Refuses knobs bind would refuse (`checkRulesKnobs`); the RecaptureConfig's own bounds are
|
|
231
|
+
* HookrRecapture's, checked at bind.
|
|
232
|
+
*/
|
|
233
|
+
export declare function encodeRulesData(c: RulesConfig, knobs?: RulesKnobs, recapture?: RecaptureConfig): Hex;
|
|
234
|
+
/**
|
|
235
|
+
* Decodes `RulesBound.config` in any form HookrRules.bind accepts (16, 22 or, for a recapture pool, 30 words) and
|
|
236
|
+
* refuses what bind refuses of its shape: a non-canonical encoding, knobs its config cannot take (`checkRulesKnobs`)
|
|
237
|
+
* and recapture data with recapture off. `knobs` is NO_RULES_KNOBS for the config-only form; `minLiquidity` is the
|
|
238
|
+
* knobs' minimum dynamic fee liquidity, zero without dynamic fees.
|
|
239
|
+
*/
|
|
240
|
+
export declare function decodeRulesData(data: Hex): {
|
|
241
|
+
config: RulesConfig;
|
|
242
|
+
knobs: RulesKnobs;
|
|
243
|
+
minLiquidity: bigint;
|
|
244
|
+
recapture?: RecaptureConfig;
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* HookrLauncher's minimum dynamic fee liquidity for a member launched with `liquidity`: liquidity / divisor, in
|
|
248
|
+
* [1, 2^96 - 1]. `divisor` is launchFamily's MemberKnobs.dynamicFeeLiquidityDivisor; zero (and every other launch) is
|
|
249
|
+
* DYNAMIC_FEE_LIQUIDITY_DIVISOR.
|
|
250
|
+
*/
|
|
251
|
+
export declare function dynamicFeeMinLiquidity(liquidity: bigint, divisor?: number): bigint;
|
|
252
|
+
/**
|
|
253
|
+
* The rules data HookrLauncher binds for a member with `rules` and launch `liquidity` (HookrLauncher._rulesData, r31):
|
|
254
|
+
* launchFamily's MemberKnobs pass the member's Rules knobs as given (`knobs`; every other launch passes none); a
|
|
255
|
+
* dynamic fee member's minimum is its liquidity over the divisor, and its tempo the default when all four tempo knobs
|
|
256
|
+
* are zero. A recapture member (`recapture.on`) binds the 30-word form, a member with every knob zero the config alone,
|
|
257
|
+
* any other the 22-word form. Like the Launcher it does not check the knobs; HookrRules refuses bad ones at bind
|
|
258
|
+
* (`checkRulesKnobs`).
|
|
259
|
+
*/
|
|
260
|
+
export declare function launcherRulesData(c: RulesConfig, liquidity: bigint, opts?: {
|
|
261
|
+
recapture?: RecaptureConfig;
|
|
262
|
+
knobs?: Partial<MemberKnobs>;
|
|
263
|
+
}): Hex;
|
|
264
|
+
/**
|
|
265
|
+
* The longest snipeDecaySeconds a pool binds with at `blockNumber` (HookrRules._validate, r31): MAX_SNIPE_DECAY_SECONDS,
|
|
266
|
+
* or the guard's length in seconds when that is longer, (guardEndBlock - blockNumber) x PARENT_BLOCK_SECONDS, at most
|
|
267
|
+
* 65,535. Without a block number only MAX_SNIPE_DECAY_SECONDS is certain.
|
|
268
|
+
*/
|
|
269
|
+
export declare function maxSnipeDecaySeconds(guardEndBlock: number | bigint, blockNumber?: bigint): number;
|
|
270
|
+
/** Whether a dynamic fee of `spanPips` (maxFeePips less the base fee) at `sens` and `shareBps` binds (HookrDynamicFee.withinReach). */
|
|
271
|
+
export declare function withinDynamicFeeReach(spanPips: number | bigint, sens: number, shareBps: number): boolean;
|
|
272
|
+
/**
|
|
273
|
+
* The Anti-Snipe tax, in pips before clipping, of a guarded buy at `timestamp` in a pool bound at `launchedAt`
|
|
274
|
+
* (HookrRules._snipePips and _knobbedSnipe, r31): snipeTaxPips flat without a decay, otherwise falling from snipeTaxPips
|
|
275
|
+
* at launch to snipeFloorPips at snipeDecaySeconds along the pool's Snipe curve, every division rounded down. With
|
|
276
|
+
* d = snipeDecaySeconds, e the launch age, x = snipeTaxPips - snipeFloorPips and n = 8e / d: linear (the default),
|
|
277
|
+
* floor + x(d - e)/d; step, floor + x(8 - n)/8; front-loaded, what is left halves every eighth of the decay in a
|
|
278
|
+
* straight line between the halvings (the last eighth falls the rest of the way). The launch age is taken modulo 2^32
|
|
279
|
+
* and a clock behind the launch reads as the launch. The guard itself is counted in blocks (guardEndBlock).
|
|
280
|
+
*/
|
|
281
|
+
export declare function snipeTaxAt(c: RulesConfig, launchedAt: number | bigint, timestamp: number | bigint, curve?: number): number;
|
|
282
|
+
/**
|
|
283
|
+
* The guarded per-parent-block buy cap at Anti-Snipe tax `snipePips` (HookrRules.settleSwap): maxBuyQuoteAmount
|
|
284
|
+
* without a decay; with one, maxBuyQuoteAmount * snipeTaxPips / snipePips, so a block that fills the cap pays the
|
|
285
|
+
* same tax at every point of the decay. `null` when there is no cap: a zero maxBuyQuoteAmount, or a zero tax.
|
|
286
|
+
*/
|
|
287
|
+
export declare function guardBuyLimit(c: RulesConfig, snipePips: number): bigint | null;
|
|
288
|
+
/**
|
|
289
|
+
* HookrDynamicFee.averageRate: the average of min(1, (d / knee)^2), knee = 1 / (2 * sens), over the distances [a, b]
|
|
290
|
+
* from the reference, as a fraction of the dynamic fee span in WAD. Distances are in WAD; requires b > a.
|
|
291
|
+
*/
|
|
292
|
+
export declare function dynamicFeeAverageRate(a: bigint, b: bigint, sens: number): bigint;
|
|
293
|
+
/**
|
|
294
|
+
* HookrDynamicFee.distance: the signed distance of `sqrtPriceX96` from the reference `sqrtRefX96` in the direction of
|
|
295
|
+
* a swap, in WAD: sqrt(ref) / sqrt(p) - 1 for zeroForOne, sqrt(p) / sqrt(ref) - 1 otherwise.
|
|
296
|
+
*/
|
|
297
|
+
export declare function dynamicFeeDistance(sqrtRefX96: bigint, sqrtPriceX96: bigint, zeroForOne: boolean): bigint;
|
|
298
|
+
/** Dynamic fee pips before clipping for a move over the distances [a, b]: the span times the average rate. */
|
|
299
|
+
export declare function dynamicFeePips(c: RulesConfig, baseLpFeePips: number, a: bigint, b: bigint): number;
|
|
300
|
+
/**
|
|
301
|
+
* The protocol's share of a `bps` slice of a buy, in pips of the gross buyer spend, rounded up
|
|
302
|
+
* (HookrRules._protocolPips): ceil(bps x 100 x shareBps / 10,000). Exact whenever shareBps is a whole percent.
|
|
303
|
+
*/
|
|
304
|
+
export declare function protocolSharePips(bps: number | bigint, shareBps: number | bigint): bigint;
|
|
305
|
+
/**
|
|
306
|
+
* The royalty's part of a buy's quote take, in pips of the gross buyer spend (HookrRules._buyParts): LP Rewards net of
|
|
307
|
+
* the protocol share, times royaltyBps, rounded down. It is the creator's, not Hookr's: the Hookr minimum compares
|
|
308
|
+
* Hookr's rule-fee share alone with the minimum and adds the royalty on top. Sells pay no royalty.
|
|
309
|
+
*/
|
|
310
|
+
export declare function royaltyPips(c: Pick<RulesConfig, "lpBps" | "protocolShareBps" | "royaltyBps">): number;
|
|
311
|
+
/**
|
|
312
|
+
* LP Rewards of a buy, in pips of the pool input: lpBps x 100 less the protocol share (in pips, rounded up), less
|
|
313
|
+
* the royalty (HookrRules._buyParts). A pool binds only when base + this is at most 600,000 pips.
|
|
314
|
+
*/
|
|
315
|
+
export declare function lpRewardPips(c: Pick<RulesConfig, "lpBps" | "protocolShareBps" | "royaltyBps">): number;
|
|
316
|
+
/**
|
|
317
|
+
* The smallest caps HookrRules accepts for `c` at base fee `baseLpFeePips` on a pool that freezes the Hookr minimum
|
|
318
|
+
* `minFeePips` (zero for a pool without one, `bindMinFeePips`): the worst-case total LP fee, quote take and subject
|
|
319
|
+
* burn over every swap (HookrRules._validate). The quote take is at least royalty + minimum, so a Hookr token's pool
|
|
320
|
+
* whose caps do not admit its minimum does not bind. These are the caps the Rules sees, after the Root has reserved the
|
|
321
|
+
* advisory's admitted maximum.
|
|
322
|
+
*/
|
|
323
|
+
export declare function rulesFeeCeilings(c: RulesConfig, baseLpFeePips: number, minFeePips?: number): Caps;
|
|
324
|
+
/**
|
|
325
|
+
* Largest native LP fee (base + Rules surcharge) HookrRules can quote with Anti-Snipe at `snipeTax`
|
|
326
|
+
* (HookrFeeAdvisory._nativeCeiling). The fee advisory's room on a HookrRoot pool is the pool's LP cap minus this.
|
|
327
|
+
*/
|
|
328
|
+
export declare function nativeLpCeiling(c: RulesConfig, baseLpFeePips: number, snipeTax?: number): number;
|
|
329
|
+
/** Pool facts `checkRulesConfig` validates a configuration against. */
|
|
330
|
+
export interface RulesContext {
|
|
331
|
+
baseLpFeePips: number;
|
|
332
|
+
/** HookrRules.minProtocolShareBps of the Rules the pool binds to. */
|
|
333
|
+
minProtocolShareBps: number;
|
|
334
|
+
/**
|
|
335
|
+
* The governed rule-share floor of the treasury the Rules pay (`feeTerms(..).ruleShareFloorBps`, read at the block
|
|
336
|
+
* the launch lands in, `encodeFeeTermsCall`). The pool binds at no less than the larger of it and
|
|
337
|
+
* minProtocolShareBps. Omitted: zero, the treasury's starting value.
|
|
338
|
+
*/
|
|
339
|
+
ruleShareFloorBps?: number;
|
|
340
|
+
/**
|
|
341
|
+
* The treasury's integrator list as read on chain: lowercase address to its rate (`feeTerms(integrator)`). With it a
|
|
342
|
+
* nonzero `integrator` must be listed at 1 to 5,000; without it the list is not checked offline, and the Rules refuse
|
|
343
|
+
* an integrator off the list at bind (`UnknownIntegrator`).
|
|
344
|
+
*/
|
|
345
|
+
integrators?: Readonly<Record<string, number>>;
|
|
346
|
+
/**
|
|
347
|
+
* Accounts HookrRules refuses as integrator whatever the treasury answers (r26, `bindRefusedIntegrators`): the Rules
|
|
348
|
+
* themselves, their trusted root, their protocol recipient, the PoolManager and their HookrRecapture module, none of
|
|
349
|
+
* which ever claims what the Rules credit it. With it such an integrator is refused offline; the bind refuses it
|
|
350
|
+
* either way (`UnknownIntegrator`).
|
|
351
|
+
*/
|
|
352
|
+
refusedIntegrators?: readonly Address[];
|
|
353
|
+
/**
|
|
354
|
+
* Accounts HookrRules refuses as the royalty recipient (r31, `bindRefusedRoyaltyRecipients`): the Rules themselves,
|
|
355
|
+
* their trusted root, the PoolManager and their HookrRecapture module, none of which ever claims what settleSwap
|
|
356
|
+
* credits it. With it such a `royaltyTo` is refused offline; the bind refuses it either way (`InvalidConfig`, which a
|
|
357
|
+
* launch reports as the root's `ModuleCallReverted`).
|
|
358
|
+
*/
|
|
359
|
+
refusedRoyaltyRecipients?: readonly Address[];
|
|
360
|
+
/**
|
|
361
|
+
* The Hookr minimum the pool freezes at bind, in pips (`bindMinFeePips`: the treasury's `feeTerms(..).minFeePips`
|
|
362
|
+
* for a Hookr token's pool without arb recapture whose rules earn Hookr nothing, zero for any other pool). The fee
|
|
363
|
+
* ceilings then admit royalty + minimum. Omitted: zero, a pool without a minimum.
|
|
364
|
+
*/
|
|
365
|
+
minFeePips?: number;
|
|
366
|
+
/** The caps the Rules sees (`rulesBindCaps`). Omitted: the ceilings are returned without a cap check. */
|
|
367
|
+
caps?: Caps;
|
|
368
|
+
/** Current block.number; with it the launch guard window is checked. */
|
|
369
|
+
blockNumber?: bigint;
|
|
370
|
+
liquidityOwner?: Address;
|
|
371
|
+
}
|
|
372
|
+
/** Whether a runtime codehash is HookrToken's (`HOOKR_TOKEN_RUNTIME_KECCAK256`), the test HookrRules applies at bind. */
|
|
373
|
+
export declare function isHookrTokenRuntime(codeHash: Hex): boolean;
|
|
374
|
+
/** The RulesConfig fields that decide whether a pool's rules earn Hookr a share (`earnsHookr`). */
|
|
375
|
+
export type EarningRules = Pick<RulesConfig, "protocolShareBps" | "lpBps" | "burnBps" | "maxFeePips" | "snipeTaxPips">;
|
|
376
|
+
/** What decides a pool's Hookr minimum at bind (`bindMinFeePips`), besides its subject and the treasury's answer. */
|
|
377
|
+
export interface MinimumTerms {
|
|
378
|
+
/** The pool's RulesConfig. */
|
|
379
|
+
rules: EarningRules;
|
|
380
|
+
/** The pool's base LP fee in pips. */
|
|
381
|
+
baseLpFeePips: number;
|
|
382
|
+
/** Whether the pool binds arb recapture (a RecaptureConfig with `on`, which freezes the root's lane executor). */
|
|
383
|
+
recapture: boolean;
|
|
384
|
+
/**
|
|
385
|
+
* The quote cap (`maxQuoteTakePips`) of the pool's advisory admission on its root when that advisory is Tax +
|
|
386
|
+
* Conversion (its `EXCLUSIVE_GROUP()` is keccak256("DIRECTIONAL_QUOTE_TAX")); null or omitted for any other
|
|
387
|
+
* advisory or none.
|
|
388
|
+
*/
|
|
389
|
+
taxConversion?: {
|
|
390
|
+
maxQuoteTakePips: number;
|
|
391
|
+
} | null;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* HookrRules._earnsHookr (r31): whether a rule can pay Hookr at least a pip of some swap at the pool's
|
|
395
|
+
* protocolShareBps. Nothing does at a zero share; LP Rewards and Auto Burn do at any nonzero share (the Rules round
|
|
396
|
+
* their protocol slices up); the dynamic fee does when its whole span (maxFeePips less the base fee) times the share is
|
|
397
|
+
* at least 10,000, and the Anti-Snipe tax when snipeTaxPips times the share is (the Rules round both shares down).
|
|
398
|
+
*/
|
|
399
|
+
export declare function earnsHookr(rules: EarningRules, baseLpFeePips: number): boolean;
|
|
400
|
+
/**
|
|
401
|
+
* The Hookr minimum a pool freezes at bind (HookrRules.bind, r31): the treasury's `feeTerms(integrator, false, id)`
|
|
402
|
+
* minimum (`decodeFeeTerms`) only on a Hookr token's pool that binds no arb recapture, whose rules earn Hookr no share
|
|
403
|
+
* (`earnsHookr`) and whose advisory is not Tax + Conversion at a nonzero share; zero on every other pool. Whatever
|
|
404
|
+
* pays Hookr a share replaces the minimum, never adds to it. `subject` is `"new"` for a launch that creates its token
|
|
405
|
+
* (HookrLauncher deploys a HookrToken, so it always is one) or the existing subject's runtime codehash (`eth_getCode`,
|
|
406
|
+
* then keccak256; a Hookr token exactly when it equals HOOKR_TOKEN_RUNTIME_KECCAK256). A treasury answer above 10,000
|
|
407
|
+
* pips is refused whatever follows, as the Rules refuse it. A Rules paying an address without code reads no terms and
|
|
408
|
+
* binds no minimum: pass 0 as `treasuryMinFeePips` for it.
|
|
409
|
+
*/
|
|
410
|
+
export declare function bindMinFeePips(subject: "new" | Hex, treasuryMinFeePips: number, terms: MinimumTerms): number;
|
|
411
|
+
/**
|
|
412
|
+
* The minimum HookrTreasury.feeTerms answers for a pool (r25): the integrator's override when it has one
|
|
413
|
+
* (`overridePips` other than NO_MIN_FEE_OVERRIDE) and approved the pool's id, else the rate for its kind of pool (with
|
|
414
|
+
* arb recapture on, `recapturePips`; without, `plainPips`). An override never reaches a pool its integrator did not
|
|
415
|
+
* approve, so naming the integrator alone does not bind it. Offline mirror; read `feeTerms` on chain before signing.
|
|
416
|
+
*/
|
|
417
|
+
export declare function treasuryMinFeePips(t: {
|
|
418
|
+
plainPips: number;
|
|
419
|
+
recapturePips: number;
|
|
420
|
+
recapture: boolean;
|
|
421
|
+
overridePips?: number;
|
|
422
|
+
approved?: boolean;
|
|
423
|
+
}): number;
|
|
424
|
+
/**
|
|
425
|
+
* The effective protocolShareBps floor HookrRules binds a pool at (HookrRules._feeTerms): the larger of its immutable
|
|
426
|
+
* minProtocolShareBps and the treasury's governed floor, both 0 to 5,000.
|
|
427
|
+
*/
|
|
428
|
+
export declare function effectiveShareFloor(minProtocolShareBps: number, ruleShareFloorBps?: number): number;
|
|
429
|
+
/**
|
|
430
|
+
* The rate a pool naming `integrator` freezes, from the treasury's list as read (`RulesContext.integrators`): zero for
|
|
431
|
+
* no integrator; refused when the integrator is not listed at 1 to 5,000. Undefined when the list was not given.
|
|
432
|
+
*/
|
|
433
|
+
export declare function listedIntegratorBps(integrator: Address, integrators?: Readonly<Record<string, number>>): number | undefined;
|
|
434
|
+
/**
|
|
435
|
+
* Splits Hookr's share of one swap's rule fees (the Snipe, dynamic fee, LP Rewards and Auto Burn, royalty already
|
|
436
|
+
* out) on a pool with an integrator frozen at `integratorBps` (HookrRules.settleSwap): the integrator gets
|
|
437
|
+
* share x rate / 10,000 rounded down as a Rules claim (`IntegratorPaid`), the protocol recipient the rest, the odd
|
|
438
|
+
* unit included (`FeesAllocated.protocol`). A pool without an integrator (rate 0) pays the protocol all of it.
|
|
439
|
+
*/
|
|
440
|
+
export declare function splitProtocolShare(share: bigint, integratorBps: number): {
|
|
441
|
+
protocol: bigint;
|
|
442
|
+
integrator: bigint;
|
|
443
|
+
};
|
|
444
|
+
/** One swap's HookrRules quote (HookrTypes.FeeQuote) with the parts of its quote take. */
|
|
445
|
+
export interface RulesQuote {
|
|
446
|
+
/** LP fee on top of the base fee: LP Rewards and the LPs' part of the dynamic fee and Snipe. */
|
|
447
|
+
lpFeeSurchargePips: number;
|
|
448
|
+
/** The quote take: royalty + max(ruleSharePips, minimum). */
|
|
449
|
+
quoteTakePips: number;
|
|
450
|
+
subjectBurnBps: number;
|
|
451
|
+
/** The creator's royalty in the take (buys only). */
|
|
452
|
+
royaltyPips: number;
|
|
453
|
+
/** Hookr's rule-fee share: its part of LP Rewards and Auto Burn (rounded up) and of the dynamic fee and Snipe. */
|
|
454
|
+
ruleSharePips: number;
|
|
455
|
+
/** What the Hookr minimum adds: max(0, minimum - ruleSharePips). */
|
|
456
|
+
topUpPips: number;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* A swap's HookrRules quote (HookrRules._quote, r25) on a pool bound with `c` at `baseLpFeePips` that froze the Hookr
|
|
460
|
+
* minimum `minFeePips`. `dynamicFeePips` is the dynamic fee before clipping (zero without one) and `snipePips` the
|
|
461
|
+
* Anti-Snipe tax (`snipeTaxAt`, only on a buy while the guard lasts). The dynamic fee is clipped to the room base and
|
|
462
|
+
* LP Rewards leave under 600,000 pips, the Snipe to what remains. Hookr's rule-fee share is its part of LP Rewards and
|
|
463
|
+
* Auto Burn (buys) and of the dynamic fee and the Snipe; the royalty is the creator's. The minimum is a top-up to the
|
|
464
|
+
* quote take only: `quoteTakePips` = royalty + max(ruleSharePips, minFeePips) and the LP fee surcharge is unchanged, so
|
|
465
|
+
* a pool without rules takes exactly the minimum and a pool whose rules give Hookr at least the minimum pays nothing
|
|
466
|
+
* more. Sells pay no LP Rewards, Auto Burn, royalty or Snipe, so a sell's share is its dynamic fee share alone. Since
|
|
467
|
+
* r31 only a pool whose rules earn Hookr nothing binds a minimum (`bindMinFeePips`), so there the top-up is the whole
|
|
468
|
+
* minimum, and no arb recapture pool binds one.
|
|
469
|
+
*/
|
|
470
|
+
export declare function rulesQuote(c: RulesConfig, s: {
|
|
471
|
+
baseLpFeePips: number;
|
|
472
|
+
isBuy: boolean;
|
|
473
|
+
dynamicFeePips?: number;
|
|
474
|
+
snipePips?: number;
|
|
475
|
+
minFeePips?: number;
|
|
476
|
+
}): RulesQuote;
|
|
477
|
+
/**
|
|
478
|
+
* The quote HookrRules.simulationQuote gives the root for its simulated swap on a dynamic fee pool (r26): the swap's
|
|
479
|
+
* quote (`rulesQuote`) without a dynamic fee, and on an exact-output sell a quote take of the larger of the largest
|
|
480
|
+
* dynamic fee share the sell can pay (the span, clipped to 600,000 pips less the base fee, times protocolShareBps) and
|
|
481
|
+
* that quote's take, which on a sell is the pool's Hookr minimum (zero without one). The real take of such a sell is
|
|
482
|
+
* max(its dynamic fee share, the minimum), so the simulation reaches at least as far as the real swap and no further
|
|
483
|
+
* than that bound; before r26 it reserved their sum and simulated a longer move. Every other shape is quoted without
|
|
484
|
+
* the dynamic fee.
|
|
485
|
+
*/
|
|
486
|
+
export declare function simulationQuote(c: RulesConfig, s: {
|
|
487
|
+
baseLpFeePips: number;
|
|
488
|
+
isBuy: boolean;
|
|
489
|
+
exactInput: boolean;
|
|
490
|
+
snipePips?: number;
|
|
491
|
+
minFeePips?: number;
|
|
492
|
+
}): RulesQuote;
|
|
493
|
+
/** The four swap shapes a pool quotes: buys and sells, each exact input or exact output. */
|
|
494
|
+
export type SwapShape = "exactInputBuy" | "exactOutputBuy" | "exactInputSell" | "exactOutputSell";
|
|
495
|
+
/**
|
|
496
|
+
* What one swap without an advisory pays the Rules, in the pool's quote (HookrRoot's settlement, then
|
|
497
|
+
* HookrRules.settleSwap): `rulesFee`, the royalty inside it (buys: quoteBasis x royalty pips / 1e6, at most the fee),
|
|
498
|
+
* Hookr's part (`hookr`, the rest: its rule-fee share with the minimum's top-up) and Hookr's part split with the
|
|
499
|
+
* pool's integrator (`splitProtocolShare`: the integrator's frozen rate rounded down, the protocol recipient the rest).
|
|
500
|
+
* `actualQuote` is the quote the pool swap took in (buys) or paid out (sells), `requested` the swap's specified
|
|
501
|
+
* amount. Buys are priced on the gross buyer spend, quoteBasis = actualQuote x 1e6 / (1e6 - take) (at most the
|
|
502
|
+
* specified input of an exact-input buy); an exact-input sell on the quote out; an exact-output sell reserves
|
|
503
|
+
* ceil(requested x take / (1e6 - take)) on top of the requested output, all of it the Rules' fee without an advisory.
|
|
504
|
+
*/
|
|
505
|
+
export declare function rulesSwapFees(s: {
|
|
506
|
+
shape: SwapShape;
|
|
507
|
+
quoteTakePips: number;
|
|
508
|
+
royaltyPips: number;
|
|
509
|
+
integratorBps?: number;
|
|
510
|
+
actualQuote: bigint;
|
|
511
|
+
requested: bigint;
|
|
512
|
+
}): {
|
|
513
|
+
quoteBasis: bigint;
|
|
514
|
+
rulesFee: bigint;
|
|
515
|
+
royalty: bigint;
|
|
516
|
+
hookr: bigint;
|
|
517
|
+
protocol: bigint;
|
|
518
|
+
integrator: bigint;
|
|
519
|
+
};
|
|
520
|
+
/**
|
|
521
|
+
* The profit one currency's push stands for (HookrLane._run, r28): the root reads it back from the push at the pool's
|
|
522
|
+
* frozen partner share, pushed x 10,000 / (10,000 - partnerBps) rounded down, and emits it as CorrectionSucceeded's
|
|
523
|
+
* `reportedProfit`. What the executor's call returns is not read. An executor that keeps floor(P x partnerBps /
|
|
524
|
+
* 10,000) of a profit P and pushes the rest is read back as P or P + 1.
|
|
525
|
+
*/
|
|
526
|
+
export declare function recaptureProfit(pushed: bigint, partnerBps: number): bigint;
|
|
527
|
+
/**
|
|
528
|
+
* One arb recapture's split of `amount` pushed in `currency` (HookrRecapture.settleRecapture): the protocol takes
|
|
529
|
+
* RECAPTURE_PROTOCOL_BPS (25% since r31) of the profit the push stands for (`reportedProfit`: the root's read-back,
|
|
530
|
+
* recaptureProfit(amount, partnerBps)), at most the push, on every pool alike and never split with an integrator; on
|
|
531
|
+
* a push in the pool's quote (`inQuote`) the King of the Pool pot takes potBps of the rest and the trader named on the
|
|
532
|
+
* after-phase traderBps of the rest's part its own move accounts for (min(amount, traderBasis) x rest / amount); the
|
|
533
|
+
* LPs take what is left, rounding dust included. A push in any other currency pays no trader or pot; a frame that
|
|
534
|
+
* pushed in several currencies splits each on its own. With WTH keeping 2,500 bps and the default traderBps of 2,500,
|
|
535
|
+
* a profit P splits 25% to the partner, 25% to the protocol, 12.5% to the trader and 37.5% to the LPs.
|
|
536
|
+
*/
|
|
537
|
+
export declare function recaptureSplit(p: {
|
|
538
|
+
amount: bigint;
|
|
539
|
+
reportedProfit: bigint;
|
|
540
|
+
traderBasis: bigint;
|
|
541
|
+
trader: Address;
|
|
542
|
+
traderBps: number;
|
|
543
|
+
potBps: number;
|
|
544
|
+
inQuote: boolean;
|
|
545
|
+
}): {
|
|
546
|
+
protocol: bigint;
|
|
547
|
+
trader: bigint;
|
|
548
|
+
pot: bigint;
|
|
549
|
+
lp: bigint;
|
|
550
|
+
};
|
|
551
|
+
/**
|
|
552
|
+
* The largest King of the Pool maxPrizeBps a recapture pool binds with (HookrRecapture._validate): half of what the
|
|
553
|
+
* protocol keeps of LP Rewards and Auto Burn in basis points of a buy, each rounded down, where the kept share is
|
|
554
|
+
* protocolShareBps x (10,000 - integratorBps) / 10,000 rounded down. It is HookrRecapture.prizeBoundFor(lpBps, burnBps,
|
|
555
|
+
* protocolShareBps, integratorBps) (r26), read on chain with `encodePrizeBoundForCall`; for a pool naming an integrator,
|
|
556
|
+
* take the rate from `integration(id)` or `feeTerms`, never `prizeBound` on the pool's whole share.
|
|
557
|
+
*/
|
|
558
|
+
export declare function kingOfTheHillPrizeBound(lpBps: number, burnBps: number, protocolShareBps: number, integratorBps?: number): bigint;
|
|
559
|
+
/**
|
|
560
|
+
* Refuses a RulesConfig that HookrRules.bind would refuse, and returns its fee ceilings (`rulesFeeCeilings`).
|
|
561
|
+
* Mirrors HookrRules._validate, including the effective protocol share floor (`effectiveShareFloor`), the integrator
|
|
562
|
+
* list when the context carries it (`listedIntegratorBps`), the Anti-Snipe decay bounds and, on a pool that freezes the
|
|
563
|
+
* Hookr minimum (`RulesContext.minFeePips`), caps that admit royalty + minimum. A dynamic fee pool binds at any tick
|
|
564
|
+
* spacing. An integrator changes no fee ceiling: it is paid from Hookr's share after the take.
|
|
565
|
+
*/
|
|
566
|
+
export declare function checkRulesConfig(c: RulesConfig, ctx: RulesContext): Caps;
|
|
567
|
+
/**
|
|
568
|
+
* The pool caps (PoolConfig.caps) of a pool whose Rules needs `rules` and whose advisory is admitted with
|
|
569
|
+
* `advisory` caps: the Rules ceilings plus the advisory's admitted maximum, so the Root's reservation leaves the
|
|
570
|
+
* Rules its full ceilings. Pass the result of `rulesFeeCeilings` (or `checkRulesConfig`) as `rules`.
|
|
571
|
+
*/
|
|
572
|
+
export declare function poolCapsFor(rules: Caps, baseLpFeePips: number, advisory?: Caps): Caps;
|
|
573
|
+
/**
|
|
574
|
+
* The caps HookrRoot.initializePool hands the Rules: min(pool, Rules admission) per field, less the advisory's
|
|
575
|
+
* admitted maximum. Refuses what the Root refuses: pool caps out of range, or an advisory maximum above the room.
|
|
576
|
+
*/
|
|
577
|
+
export declare function rulesBindCaps(pool: Caps, rulesAdmission: Caps, advisoryAdmission?: Caps): Caps;
|
|
578
|
+
/**
|
|
579
|
+
* `feeTerms(integrator, recapture, id)` calldata for the treasury a Rules pays (r25): its governed floor, `integrator`'s
|
|
580
|
+
* listed rate and the Hookr minimum of pool `id` (with arb recapture on when `recapture`; `integrator`'s override only
|
|
581
|
+
* when it approved `id`). It is exactly the read HookrRules makes at bind, with the pool's own id.
|
|
582
|
+
*/
|
|
583
|
+
export declare function encodeFeeTermsCall(integrator?: Address, recapture?: boolean, poolId?: Hex): Hex;
|
|
584
|
+
/**
|
|
585
|
+
* Decodes a `feeTerms(integrator, recapture, id)` result: `ruleShareFloorBps` for `RulesContext.ruleShareFloorBps`,
|
|
586
|
+
* the integrator's rate (zero when it is not listed) for `RulesContext.integrators`, and the minimum the treasury
|
|
587
|
+
* gives the pool (`bindMinFeePips` applies the r31 rule for `RulesContext.minFeePips`). Refuses values no
|
|
588
|
+
* HookrTreasury holds, and a minimum above the 10,000 pips the Rules accept.
|
|
589
|
+
*/
|
|
590
|
+
export declare function decodeFeeTerms(data: Hex): {
|
|
591
|
+
ruleShareFloorBps: number;
|
|
592
|
+
integratorBps: number;
|
|
593
|
+
minFeePips: number;
|
|
594
|
+
};
|
|
595
|
+
/** `minimumFee(poolId)` calldata for a HookrRules (served by its fallback): the Hookr minimum the pool froze. */
|
|
596
|
+
export declare function encodeMinimumFeeCall(poolId: Hex): Hex;
|
|
597
|
+
/** Decodes a `minimumFee(poolId)` result: the pool's frozen minimum in pips, zero for a pool without one. */
|
|
598
|
+
export declare function decodeMinimumFee(data: Hex): number;
|
|
599
|
+
/**
|
|
600
|
+
* `approveMinFeePool(id, approved)` calldata for the treasury, sent by an integrator account itself: it approves (or
|
|
601
|
+
* withdraws) pool `id` binding that account's Hookr minimum override when the pool names it. Only the sender's own
|
|
602
|
+
* approvals change; an approval does nothing while the sender has no override, and it is read once, at bind. How Hookr
|
|
603
|
+
* runs chosen pools at a lower minimum: list an account it controls as an integrator, set that account's override
|
|
604
|
+
* through the treasury timelock, then have the account approve each chosen pool id before its launch (for a new
|
|
605
|
+
* token the id follows from `HookrLauncher.predictToken`, and nobody can initialize it first).
|
|
606
|
+
*/
|
|
607
|
+
export declare function encodeApproveMinFeePoolCall(poolId: Hex, approved: boolean): Hex;
|
|
608
|
+
/** `integration(poolId)` calldata: the integrator and rate a bound pool froze. */
|
|
609
|
+
export declare function encodeIntegrationCall(poolId: Hex): Hex;
|
|
610
|
+
/** Decodes an `integration(poolId)` result; zeros for a pool without an integrator. */
|
|
611
|
+
export declare function decodeIntegration(data: Hex): {
|
|
612
|
+
integrator: Address;
|
|
613
|
+
integratorBps: number;
|
|
614
|
+
};
|
|
615
|
+
/** `minProtocolShareBps()` calldata: the floor a HookrRules applies to every pool's protocol share. */
|
|
616
|
+
export declare function encodeMinProtocolShareCall(): Hex;
|
|
617
|
+
/**
|
|
618
|
+
* Decodes a `minProtocolShareBps()` result, the `ParamContext.minProtocolShareBps` of pools that bind to that Rules.
|
|
619
|
+
* Refuses a value no HookrRules can hold (its constructor caps it at 5,000 bps).
|
|
620
|
+
*/
|
|
621
|
+
export declare function decodeMinProtocolShareBps(data: Hex): number;
|
|
622
|
+
/**
|
|
623
|
+
* `protocolShareFloor()` calldata for a HookrRules (r26, served by its HookrRecapture module through the fallback): the
|
|
624
|
+
* effective floor a pool binding now must meet, the larger of the Rules' minProtocolShareBps and the governed floor of
|
|
625
|
+
* the treasury they pay (zero governed floor for a recipient without code). One read in place of
|
|
626
|
+
* `encodeMinProtocolShareCall` plus `encodeFeeTermsCall`; it moves when the treasury's floor changes.
|
|
627
|
+
*/
|
|
628
|
+
export declare function encodeProtocolShareFloorCall(): Hex;
|
|
629
|
+
/**
|
|
630
|
+
* Decodes a `protocolShareFloor()` result: the least protocolShareBps a pool binds with now, for
|
|
631
|
+
* `ParamContext.minProtocolShareBps` (with `ruleShareFloorBps` left at zero, since it already includes the governed
|
|
632
|
+
* floor). Refuses a value above 5,000 bps, which neither floor can hold.
|
|
633
|
+
*/
|
|
634
|
+
export declare function decodeProtocolShareFloor(data: Hex): number;
|
|
635
|
+
/**
|
|
636
|
+
* `prizeBoundFor(lpBps, burnBps, protocolShareBps, integratorBps)` calldata for a HookrRules (r26, served by its
|
|
637
|
+
* HookrRecapture module): the widest King of the Pool maxPrizeBps the bind admits for a pool naming an integrator at
|
|
638
|
+
* that rate (0 for none). `kingOfTheHillPrizeBound` computes the same offline.
|
|
639
|
+
*/
|
|
640
|
+
export declare function encodePrizeBoundForCall(lpBps: number, burnBps: number, protocolShareBps: number, integratorBps?: number): Hex;
|
|
641
|
+
/** Decodes a `prizeBoundFor(...)` result: the widest maxPrizeBps, in basis points of a buy. */
|
|
642
|
+
export declare function decodePrizeBoundFor(data: Hex): bigint;
|
|
643
|
+
/** `configSchemaHash()` calldata for a HookrRules: its schema id, which must equal RULES_CONFIG_SCHEMA_HASH. */
|
|
644
|
+
export declare function encodeConfigSchemaHashCall(): Hex;
|
|
645
|
+
/**
|
|
646
|
+
* Decodes a `configSchemaHash()` result and refuses any id but RULES_CONFIG_SCHEMA_HASH: a Rules of another layout
|
|
647
|
+
* (the retired keccak256("hookr.rules.config") among them) is not the Rules this SDK encodes for.
|
|
648
|
+
*/
|
|
649
|
+
export declare function decodeConfigSchemaHash(data: Hex): Hex;
|
|
650
|
+
/**
|
|
651
|
+
* The accounts HookrRules refuses as a pool's integrator whatever its treasury answers (r26, HookrRules._feeTerms),
|
|
652
|
+
* lowercase, for `RulesContext.refusedIntegrators` / `ParamContext.refusedIntegrators`: the Rules, their trusted root,
|
|
653
|
+
* their protocol recipient (the treasury), the PoolManager and their HookrRecapture module (`recaptureModule()`).
|
|
654
|
+
* None of them ever claims what the Rules would credit it. The treasury also refuses, at proposal and acceptance, the
|
|
655
|
+
* zero address, itself, the PoolManager and every admitted source.
|
|
656
|
+
*/
|
|
657
|
+
export declare function bindRefusedIntegrators(a: {
|
|
658
|
+
rules: Address;
|
|
659
|
+
trustedRoot: Address;
|
|
660
|
+
protocolRecipient: Address;
|
|
661
|
+
poolManager: Address;
|
|
662
|
+
recaptureModule: Address;
|
|
663
|
+
}): Address[];
|
|
664
|
+
/**
|
|
665
|
+
* The accounts HookrRules refuses as a pool's royalty recipient (r31, HookrRules._validate), lowercase, for
|
|
666
|
+
* `RulesContext.refusedRoyaltyRecipients` / `ParamContext.refusedRoyaltyRecipients`: the Rules, their trusted root, the
|
|
667
|
+
* PoolManager and their HookrRecapture module (`recaptureModule()`), the integrator refusals less the protocol
|
|
668
|
+
* recipient. None of them ever claims what settleSwap credits it.
|
|
669
|
+
*/
|
|
670
|
+
export declare function bindRefusedRoyaltyRecipients(a: {
|
|
671
|
+
rules: Address;
|
|
672
|
+
trustedRoot: Address;
|
|
673
|
+
poolManager: Address;
|
|
674
|
+
recaptureModule: Address;
|
|
675
|
+
}): Address[];
|