hookr-sdk 0.2.1 → 1.1.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 +70 -0
- package/LICENSE +21 -0
- package/MIGRATING.md +89 -0
- package/README.md +308 -105
- 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 +42 -15
- package/dist/index.js +40 -15
- package/dist/releases.d.ts +219 -0
- package/dist/releases.js +365 -0
- package/dist/wallet-cap.d.ts +159 -0
- package/dist/wallet-cap.js +234 -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 -136
- package/dist/reads.js +0 -219
- package/dist/rules.d.ts +0 -84
- package/dist/rules.js +0 -296
- package/dist/swap.d.ts +0 -108
- package/dist/swap.js +0 -144
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import { type Address, type Call, type DeploymentManifest, type Hash } from "./schema.js";
|
|
3
|
+
import { type PoolKey } from "./wallet.js";
|
|
4
|
+
/** IHookrPairRoot.Params: every value is immutable for the life of the pool. */
|
|
5
|
+
export interface PairRootParams {
|
|
6
|
+
currency0: Address;
|
|
7
|
+
currency1: Address;
|
|
8
|
+
tickSpacing: number;
|
|
9
|
+
baseLpFeePips: number;
|
|
10
|
+
/** Ceiling on every fee the root returns; at least base plus advisory cap. */
|
|
11
|
+
maxLpFeePips: number;
|
|
12
|
+
/** Zero for a fixed-fee pool. */
|
|
13
|
+
advisory: Address;
|
|
14
|
+
advisoryCapPips: number;
|
|
15
|
+
advisoryGasLimit: number;
|
|
16
|
+
/** On advisory failure, true charges the cap and false reverts the swap. */
|
|
17
|
+
advisoryFailOpen: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Low 14 address bits of every pair root: BEFORE_INITIALIZE | BEFORE_SWAP. */
|
|
20
|
+
export declare const PAIR_ROOT_FLAGS: 8320;
|
|
21
|
+
/** Leading address byte the salt miner refuses: the prefix that opts a hook out of Uniswap routing. */
|
|
22
|
+
export declare const PAIR_ROOT_REFUSED_PREFIX: 145;
|
|
23
|
+
/** Refuses Params the HookrPairRoot constructor would refuse (the checks that do not read chain state). */
|
|
24
|
+
export declare function checkPairRootParams(p: PairRootParams): PairRootParams;
|
|
25
|
+
/** The one pool a pair root at `root` serves. */
|
|
26
|
+
export declare function pairRootPoolKey(root: Address, p: PairRootParams): PoolKey;
|
|
27
|
+
/** HookrRootFactory.deploySalt: keccak256(abi.encode(deployer, salt)). The CREATE2 salt binds the caller. */
|
|
28
|
+
export declare function pairRootDeploySalt(deployer: Address, salt: Hash): Hash;
|
|
29
|
+
/**
|
|
30
|
+
* CREATE2 init code of a pair root: HookrPairRoot creation code followed by abi.encode(poolManager, registry,
|
|
31
|
+
* params). `creationCode` must be the reviewed build the factory was deployed with; compare
|
|
32
|
+
* keccak256(creationCode) with the factory's `pairRootCreationCodeHash()`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function pairRootInitCode(creationCode: Hex, poolManager: Address, registry: Address, p: PairRootParams): Hex;
|
|
35
|
+
/** keccak256 of `pairRootInitCode`: the value HookrRootFactory.initCodeHash(params) returns. */
|
|
36
|
+
export declare function pairRootInitCodeHash(creationCode: Hex, poolManager: Address, registry: Address, p: PairRootParams): Hash;
|
|
37
|
+
/** HookrRootFactory.computeAddress for a known init code hash. */
|
|
38
|
+
export declare function pairRootAddress(factory: Address, deployer: Address, salt: Hash, initCodeHash: Hash): Address;
|
|
39
|
+
/** Whether a root address carries exactly the pair root flags and does not start with the refused prefix. */
|
|
40
|
+
export declare function isPairRootAddress(root: Address): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Lowest salt at or above `start` for which `factory` deploys `deployer`'s root at an address carrying exactly
|
|
43
|
+
* the pair root flags (0x2080) and not starting with the refused prefix (0x91). Salts are uint256 counters as
|
|
44
|
+
* bytes32, so the result matches script/HookrPairRootSalt.s.sol. Runs locally; `limit` bounds the search (about
|
|
45
|
+
* 16,500 tries are expected per hit).
|
|
46
|
+
*/
|
|
47
|
+
export declare function minePairRootSalt(p: {
|
|
48
|
+
factory: Address;
|
|
49
|
+
deployer: Address;
|
|
50
|
+
initCodeHash: Hash;
|
|
51
|
+
start?: bigint;
|
|
52
|
+
limit?: bigint;
|
|
53
|
+
}): {
|
|
54
|
+
salt: Hash;
|
|
55
|
+
root: Address;
|
|
56
|
+
tries: bigint;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* HookrRootFactory.deploy: deploys the pair root under `salt` (mined for the caller, `minePairRootSalt`),
|
|
60
|
+
* registers it, binds its pool in the advisory with `advisoryData` and initializes the pool at `sqrtPriceX96`.
|
|
61
|
+
* The advisory, when set, must be a pinned HookrFeeAdvisory or HookrSessionAdvisory; build `advisoryData` with
|
|
62
|
+
* `encodeBindPairData`. Without an advisory `advisoryData` must be "0x".
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildPairRootDeploy(m: DeploymentManifest, salt: Hash, p: PairRootParams, sqrtPriceX96: bigint, advisoryData?: Hex): Call;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { concat, encodeAbiParameters, hexToBytes, keccak256, bytesToHex } from "viem";
|
|
2
|
+
import { ARTIFACT_ABIS, RELEASE_CONSTANTS } from "./generated.js";
|
|
3
|
+
import { address, assert, hash, uint, ZERO, } from "./schema.js";
|
|
4
|
+
import { buildCall } from "./wallet.js";
|
|
5
|
+
const factoryAbi = ARTIFACT_ABIS.HookrRootFactory;
|
|
6
|
+
/** Low 14 address bits of every pair root: BEFORE_INITIALIZE | BEFORE_SWAP. */
|
|
7
|
+
export const PAIR_ROOT_FLAGS = RELEASE_CONSTANTS.PAIR_ROOT_PERMISSION_FLAGS;
|
|
8
|
+
/** Leading address byte the salt miner refuses: the prefix that opts a hook out of Uniswap routing. */
|
|
9
|
+
export const PAIR_ROOT_REFUSED_PREFIX = RELEASE_CONSTANTS.PAIR_ROOT_REFUSED_PREFIX;
|
|
10
|
+
const FLAG_MASK = 0x3fff;
|
|
11
|
+
const DYNAMIC_FEE = 0x800000;
|
|
12
|
+
const MIN_SQRT_PRICE = 4295128739n;
|
|
13
|
+
const MAX_SQRT_PRICE = 1461446703485210103287273052203988822378723970342n;
|
|
14
|
+
/** The Params tuple, as the factory ABI declares it. */
|
|
15
|
+
function paramsParameter() {
|
|
16
|
+
const deploy = factoryAbi.find((e) => e.type === "function" && e.name === "deploy");
|
|
17
|
+
assert(deploy && deploy.type === "function", "HookrRootFactory ABI lacks deploy");
|
|
18
|
+
const p = deploy.inputs.find((i) => i.name === "params");
|
|
19
|
+
assert(p, "HookrRootFactory.deploy lacks params");
|
|
20
|
+
return p;
|
|
21
|
+
}
|
|
22
|
+
/** Refuses Params the HookrPairRoot constructor would refuse (the checks that do not read chain state). */
|
|
23
|
+
export function checkPairRootParams(p) {
|
|
24
|
+
const c0 = address(p.currency0, true);
|
|
25
|
+
const c1 = address(p.currency1);
|
|
26
|
+
assert(BigInt(c0) < BigInt(c1), "Unsorted pool currencies");
|
|
27
|
+
assert(Number.isInteger(p.tickSpacing) && p.tickSpacing >= 1 && p.tickSpacing <= 32767, "Invalid tick spacing");
|
|
28
|
+
for (const [v, label] of [
|
|
29
|
+
[p.baseLpFeePips, "base fee"],
|
|
30
|
+
[p.maxLpFeePips, "max fee"],
|
|
31
|
+
[p.advisoryCapPips, "advisory cap"],
|
|
32
|
+
])
|
|
33
|
+
assert(Number.isInteger(v) && v >= 0 && v < 2 ** 24, `Invalid ${label}`);
|
|
34
|
+
assert(p.maxLpFeePips <= RELEASE_CONSTANTS.PAIR_ROOT_MAX_LP_FEE_PIPS, "Max fee above 600000 pips");
|
|
35
|
+
assert(p.baseLpFeePips + p.advisoryCapPips <= p.maxLpFeePips, "Base fee plus advisory cap above max fee");
|
|
36
|
+
assert(Number.isInteger(p.advisoryGasLimit) && p.advisoryGasLimit >= 0, "Invalid advisory gas");
|
|
37
|
+
const advisory = address(p.advisory, true);
|
|
38
|
+
if (advisory === ZERO) {
|
|
39
|
+
assert(p.advisoryCapPips === 0 && p.advisoryGasLimit === 0 && !p.advisoryFailOpen, "Advisory terms without an advisory");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
assert(p.advisoryCapPips > 0, "Advisory needs a cap");
|
|
43
|
+
assert(p.advisoryGasLimit > 0 && p.advisoryGasLimit <= RELEASE_CONSTANTS.PAIR_ROOT_MAX_ADVISORY_GAS, "Advisory gas outside (0, 500000]");
|
|
44
|
+
}
|
|
45
|
+
return { ...p, currency0: c0, currency1: c1, advisory };
|
|
46
|
+
}
|
|
47
|
+
/** The one pool a pair root at `root` serves. */
|
|
48
|
+
export function pairRootPoolKey(root, p) {
|
|
49
|
+
return {
|
|
50
|
+
currency0: address(p.currency0, true),
|
|
51
|
+
currency1: address(p.currency1),
|
|
52
|
+
fee: DYNAMIC_FEE,
|
|
53
|
+
tickSpacing: p.tickSpacing,
|
|
54
|
+
hooks: address(root),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/** HookrRootFactory.deploySalt: keccak256(abi.encode(deployer, salt)). The CREATE2 salt binds the caller. */
|
|
58
|
+
export function pairRootDeploySalt(deployer, salt) {
|
|
59
|
+
return keccak256(encodeAbiParameters([{ type: "address" }, { type: "bytes32" }], [address(deployer), hash(salt)]));
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* CREATE2 init code of a pair root: HookrPairRoot creation code followed by abi.encode(poolManager, registry,
|
|
63
|
+
* params). `creationCode` must be the reviewed build the factory was deployed with; compare
|
|
64
|
+
* keccak256(creationCode) with the factory's `pairRootCreationCodeHash()`.
|
|
65
|
+
*/
|
|
66
|
+
export function pairRootInitCode(creationCode, poolManager, registry, p) {
|
|
67
|
+
const params = checkPairRootParams(p);
|
|
68
|
+
return concat([
|
|
69
|
+
creationCode,
|
|
70
|
+
encodeAbiParameters([{ type: "address" }, { type: "address" }, paramsParameter()], [address(poolManager), address(registry), params]),
|
|
71
|
+
]);
|
|
72
|
+
}
|
|
73
|
+
/** keccak256 of `pairRootInitCode`: the value HookrRootFactory.initCodeHash(params) returns. */
|
|
74
|
+
export function pairRootInitCodeHash(creationCode, poolManager, registry, p) {
|
|
75
|
+
return keccak256(pairRootInitCode(creationCode, poolManager, registry, p));
|
|
76
|
+
}
|
|
77
|
+
/** HookrRootFactory.computeAddress for a known init code hash. */
|
|
78
|
+
export function pairRootAddress(factory, deployer, salt, initCodeHash) {
|
|
79
|
+
const digest = keccak256(concat(["0xff", address(factory), pairRootDeploySalt(deployer, salt), hash(initCodeHash)]));
|
|
80
|
+
return `0x${digest.slice(26)}`;
|
|
81
|
+
}
|
|
82
|
+
/** Whether a root address carries exactly the pair root flags and does not start with the refused prefix. */
|
|
83
|
+
export function isPairRootAddress(root) {
|
|
84
|
+
const a = address(root);
|
|
85
|
+
return (Number(BigInt(a) & BigInt(FLAG_MASK)) === PAIR_ROOT_FLAGS &&
|
|
86
|
+
parseInt(a.slice(2, 4), 16) !== PAIR_ROOT_REFUSED_PREFIX);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Lowest salt at or above `start` for which `factory` deploys `deployer`'s root at an address carrying exactly
|
|
90
|
+
* the pair root flags (0x2080) and not starting with the refused prefix (0x91). Salts are uint256 counters as
|
|
91
|
+
* bytes32, so the result matches script/HookrPairRootSalt.s.sol. Runs locally; `limit` bounds the search (about
|
|
92
|
+
* 16,500 tries are expected per hit).
|
|
93
|
+
*/
|
|
94
|
+
export function minePairRootSalt(p) {
|
|
95
|
+
const start = uint(p.start ?? 0n);
|
|
96
|
+
const limit = uint(p.limit ?? 10000000n);
|
|
97
|
+
const inner = new Uint8Array(64);
|
|
98
|
+
inner.set(hexToBytes(address(p.deployer)), 12);
|
|
99
|
+
const outer = new Uint8Array(85);
|
|
100
|
+
outer[0] = 0xff;
|
|
101
|
+
outer.set(hexToBytes(address(p.factory)), 1);
|
|
102
|
+
outer.set(hexToBytes(hash(p.initCodeHash)), 53);
|
|
103
|
+
const saltBytes = inner.subarray(32);
|
|
104
|
+
for (let tries = 0n; tries < limit; tries++) {
|
|
105
|
+
let i = start + tries;
|
|
106
|
+
assert(i < 1n << 256n, "Salt space exhausted");
|
|
107
|
+
for (let b = 31; b >= 0; b--) {
|
|
108
|
+
saltBytes[b] = Number(i & 0xffn);
|
|
109
|
+
i >>= 8n;
|
|
110
|
+
}
|
|
111
|
+
outer.set(keccak256(inner, "bytes"), 21);
|
|
112
|
+
const h = keccak256(outer, "bytes");
|
|
113
|
+
if ((((h[30] << 8) | h[31]) & FLAG_MASK) === PAIR_ROOT_FLAGS && h[12] !== PAIR_ROOT_REFUSED_PREFIX) {
|
|
114
|
+
return { salt: bytesToHex(saltBytes), root: bytesToHex(h.subarray(12)), tries: tries + 1n };
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
throw new Error("No pair root salt within the search limit");
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* HookrRootFactory.deploy: deploys the pair root under `salt` (mined for the caller, `minePairRootSalt`),
|
|
121
|
+
* registers it, binds its pool in the advisory with `advisoryData` and initializes the pool at `sqrtPriceX96`.
|
|
122
|
+
* The advisory, when set, must be a pinned HookrFeeAdvisory or HookrSessionAdvisory; build `advisoryData` with
|
|
123
|
+
* `encodeBindPairData`. Without an advisory `advisoryData` must be "0x".
|
|
124
|
+
*/
|
|
125
|
+
export function buildPairRootDeploy(m, salt, p, sqrtPriceX96, advisoryData = "0x") {
|
|
126
|
+
const params = checkPairRootParams(p);
|
|
127
|
+
hash(salt);
|
|
128
|
+
const price = uint(sqrtPriceX96, 160);
|
|
129
|
+
assert(price >= MIN_SQRT_PRICE && price < MAX_SQRT_PRICE, "sqrtPriceX96 out of range");
|
|
130
|
+
assert(/^0x([\da-fA-F]{2})*$/.test(advisoryData), "Invalid advisory data");
|
|
131
|
+
if (params.advisory === ZERO)
|
|
132
|
+
assert(advisoryData === "0x", "Advisory data without an advisory");
|
|
133
|
+
else
|
|
134
|
+
assert(m.contracts.some((c) => (c.role === "feeAdvisory" || c.role === "sessionAdvisory") && c.address === params.advisory), "Unqualified advisory");
|
|
135
|
+
return buildCall(m, "rootFactory", factoryAbi, "deploy", [salt, params, price, advisoryData]);
|
|
136
|
+
}
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import { type Hex } from "viem";
|
|
2
|
+
import { type FeeAdvisoryConfig, type FeeAdvisoryRoot, type SessionSchedule, type SessionTiers } from "./advisories.js";
|
|
3
|
+
import { type PairRootParams } from "./pair.js";
|
|
4
|
+
import { type Admission } from "./registry.js";
|
|
5
|
+
import { type Caps, type RulesConfig, type RulesKnobs } from "./rules.js";
|
|
6
|
+
import { type Address, type Hash } from "./schema.js";
|
|
7
|
+
/**
|
|
8
|
+
* Creator knobs of every Hookr rule, one manifest per rule. The launch wizard draws its inputs from `RULE_PARAMS` and
|
|
9
|
+
* the checked encoders below refuse any value outside the same bounds, so the bounds a creator sees are the ones the
|
|
10
|
+
* contracts enforce at bind. Bounds that depend on other knobs are functions of the whole configuration.
|
|
11
|
+
*/
|
|
12
|
+
/** Unit of a knob's raw value. Pips are 1e-6 and basis points 1e-4; `raw` is an integer in the asset's own units. */
|
|
13
|
+
export type ParamUnit = "pips" | "bps" | "blocks" | "seconds" | "raw" | "ticks" | "gas" | "bool" | "mask" | "address" | "bytes32";
|
|
14
|
+
/** Where a knob lands: the launch or deploy call, the Rules bind data, an advisory's bind data, or a KOTH config. */
|
|
15
|
+
export type ParamWhere = "launch" | "bind" | "advisoryData" | "kothConfig";
|
|
16
|
+
/** A knob value. Booleans read as 0 and 1, addresses and bytes32 values as unsigned integers. */
|
|
17
|
+
export type ParamValue = number | bigint | boolean | string;
|
|
18
|
+
/** A configuration under edit: knob name to value. */
|
|
19
|
+
export type ParamConfig = Readonly<Record<string, ParamValue>>;
|
|
20
|
+
/** Chain and pool facts the bounds and defaults read. Every field is optional; a knob that needs one says so. */
|
|
21
|
+
export interface ParamContext {
|
|
22
|
+
/** Current block.number. Without it the Anti-Snipe window is bounded only by its type. */
|
|
23
|
+
blockNumber?: bigint;
|
|
24
|
+
/** Measured parent block time in seconds, used to convert the default guard length. Default 12. */
|
|
25
|
+
blockTimeSeconds?: number;
|
|
26
|
+
/**
|
|
27
|
+
* HookrRules.minProtocolShareBps of the Rules the pool binds to: read it from the deployed Rules
|
|
28
|
+
* (`encodeMinProtocolShareCall`, `decodeMinProtocolShareBps`) or take the release's reviewed value (its deployment
|
|
29
|
+
* configuration's `rulesMinProtocolShareBps`, read back from the Rules at bootstrap). An integer from 0 to 5,000;
|
|
30
|
+
* default 0.
|
|
31
|
+
*/
|
|
32
|
+
minProtocolShareBps?: number;
|
|
33
|
+
/**
|
|
34
|
+
* The governed rule-share floor of the treasury the Rules pay, read at the launch block (`encodeFeeTermsCall`,
|
|
35
|
+
* `decodeFeeTerms`): the protocol share binds at no less than the larger of it and minProtocolShareBps. 0 to 5,000;
|
|
36
|
+
* default 0, the treasury's starting value.
|
|
37
|
+
*/
|
|
38
|
+
ruleShareFloorBps?: number;
|
|
39
|
+
/**
|
|
40
|
+
* The integrator the launch goes through, pre-filled as the `integrator` knob (default zero, none). It must be on
|
|
41
|
+
* the treasury's integrator list when the pool binds (`integrators`).
|
|
42
|
+
*/
|
|
43
|
+
integrator?: Address;
|
|
44
|
+
/**
|
|
45
|
+
* The treasury's integrator list as read on chain: lowercase address to rate (`feeTerms(integrator)`). With it a
|
|
46
|
+
* nonzero integrator knob must be listed at 1 to 5,000. Without it the SDK cannot see the list offline and accepts
|
|
47
|
+
* any address; HookrRules then refuses one off the list at bind (`UnknownIntegrator`), so read it before signing.
|
|
48
|
+
*/
|
|
49
|
+
integrators?: Readonly<Record<string, number>>;
|
|
50
|
+
/**
|
|
51
|
+
* The accounts HookrRules refuses as integrator whatever the treasury answers (r26, `bindRefusedIntegrators`: the
|
|
52
|
+
* Rules, their root, their protocol recipient, the PoolManager and their HookrRecapture module). With it the checked
|
|
53
|
+
* encoder refuses such an integrator knob offline; HookrRules refuses it at bind either way.
|
|
54
|
+
*/
|
|
55
|
+
refusedIntegrators?: readonly Address[];
|
|
56
|
+
/**
|
|
57
|
+
* The accounts HookrRules refuses as the royalty recipient (r31, `bindRefusedRoyaltyRecipients`: the Rules, their
|
|
58
|
+
* root, the PoolManager and their HookrRecapture module). With it the checked encoder refuses such a `royaltyTo`
|
|
59
|
+
* offline; HookrRules refuses it at bind either way.
|
|
60
|
+
*/
|
|
61
|
+
refusedRoyaltyRecipients?: readonly Address[];
|
|
62
|
+
/**
|
|
63
|
+
* The Hookr minimum the member binds, in pips: `bindMinFeePips(subject, feeTerms(..).minFeePips, terms)`, the
|
|
64
|
+
* treasury's minimum for this pool (read at the launch block with `encodeFeeTermsCall(integrator, false, poolId)`)
|
|
65
|
+
* when the subject is a Hookr token (a new token always is one), the member binds no arb recapture and its rules earn
|
|
66
|
+
* Hookr no share (r31), zero for any other pool or a Rules paying an address without code. The derived caps
|
|
67
|
+
* (`rulesPoolTerms`) then admit royalty + minimum, which HookrRules requires at bind: a launch whose caps do not
|
|
68
|
+
* admit it reverts. 0 to 10,000; default 0.
|
|
69
|
+
*/
|
|
70
|
+
minFeePips?: number;
|
|
71
|
+
/**
|
|
72
|
+
* The member's quote-side seed in raw quote units. The default buy cap is 0.5% of the launch's quote depth: the
|
|
73
|
+
* virtual quote reserve at the opening price when `launchLiquidity`, `launchSqrtPriceX96` and `quoteIsCurrency0` are
|
|
74
|
+
* all given, otherwise 0.5% of this seed (zero without either).
|
|
75
|
+
*/
|
|
76
|
+
quoteSeed?: bigint;
|
|
77
|
+
/**
|
|
78
|
+
* The member's launch liquidity (`HookrLauncher.Member.liquidity`). The Launcher binds a dynamic fee member with
|
|
79
|
+
* minLiquidity = liquidity / DYNAMIC_FEE_LIQUIDITY_DIVISOR (100), at least 1 and at most 2^96 - 1; with it the
|
|
80
|
+
* minLiquidity knob is pinned to that value. Without it the knob takes any value HookrRules binds.
|
|
81
|
+
*/
|
|
82
|
+
launchLiquidity?: bigint;
|
|
83
|
+
/** The member's opening price (`HookrLauncher.Member.sqrtPriceX96`), for the default buy cap's quote depth. */
|
|
84
|
+
launchSqrtPriceX96?: bigint;
|
|
85
|
+
/**
|
|
86
|
+
* Whether the member's quote is the pool's currency0. A new token's address, and so the side, is known only when the
|
|
87
|
+
* launch is signed: derive the default again then.
|
|
88
|
+
*/
|
|
89
|
+
quoteIsCurrency0?: boolean;
|
|
90
|
+
/** Royalty recipient offered when a creator turns royalty on. */
|
|
91
|
+
creator?: Address;
|
|
92
|
+
/** Fee advisory: the largest cap its Config may take (`feeAdvisoryLimit`, or a pair root's advisoryCapPips). */
|
|
93
|
+
advisoryLimit?: number;
|
|
94
|
+
/** Session tiers: the fee Config cap. Session advisory: its admitted cap, or a pair root's advisoryCapPips. */
|
|
95
|
+
tierCap?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Pair root: the chosen advisory's factory admission (`admission(factory, advisory)`). Its `failOpen`, `feeOnly`
|
|
98
|
+
* and `maxQuoteTakePips` bound the root's fail-open flag (HookrRootFactory); omitted, they read as fail closed,
|
|
99
|
+
* not fee-only and no quote take.
|
|
100
|
+
*/
|
|
101
|
+
pairAdmission?: {
|
|
102
|
+
maxLpFeePips: number;
|
|
103
|
+
gasLimit: number;
|
|
104
|
+
failOpen?: boolean;
|
|
105
|
+
feeOnly?: boolean;
|
|
106
|
+
maxQuoteTakePips?: number;
|
|
107
|
+
};
|
|
108
|
+
/** Pair root: which advisory the root names, for its gas floor. */
|
|
109
|
+
pairAdvisoryKind?: "fee" | "feeTiered" | "session";
|
|
110
|
+
/** Compliance guard: the pool's caps.maxSubjectTakeBps (RESTRICTED_SUBJECT needs zero). */
|
|
111
|
+
subjectTakeBps?: number;
|
|
112
|
+
/** Compliance guard: whether `listId` exists in HookrCompliance. Omitted: not checked. */
|
|
113
|
+
listExists?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Dev buy: the Anti-Snipe terms of every family member, in member order (`HookrLauncher.Member.rules`). An unguarded
|
|
116
|
+
* member (guardEndBlock zero) takes a dev buy with no Snipe and no cap (r31); a guarded one must be guarded past
|
|
117
|
+
* `blockNumber`, charge a Snipe and cap guarded buys at `quoteIn` or more. Omitted: no member can take a dev buy.
|
|
118
|
+
*/
|
|
119
|
+
launchMembers?: readonly DevBuyMemberTerms[];
|
|
120
|
+
/** Dev buy: whether the launch creates its token (`Token.existing` zero). A dev buy needs a new token. */
|
|
121
|
+
newToken?: boolean;
|
|
122
|
+
}
|
|
123
|
+
/** The Anti-Snipe terms of a launch member that decide whether it can take the dev buy. */
|
|
124
|
+
export type DevBuyMemberTerms = Pick<RulesConfig, "guardEndBlock" | "snipeTaxPips" | "maxBuyQuoteAmount">;
|
|
125
|
+
/** A bound: fixed, or computed from the configuration under edit and the context. */
|
|
126
|
+
export type ParamBound = number | bigint | ((cfg: ParamConfig, ctx: ParamContext) => number | bigint);
|
|
127
|
+
/** One bit of a `mask` knob, shown as a named checkbox. */
|
|
128
|
+
export interface ParamOption {
|
|
129
|
+
bit: number;
|
|
130
|
+
name: string;
|
|
131
|
+
/** Not a free toggle: derived by the SDK from other facts. */
|
|
132
|
+
hidden?: boolean;
|
|
133
|
+
disclose?: string;
|
|
134
|
+
}
|
|
135
|
+
/** One creator knob. */
|
|
136
|
+
export interface RuleParam {
|
|
137
|
+
/** Field name in the bind struct, launch params or pool config. */
|
|
138
|
+
name: string;
|
|
139
|
+
/** Solidity type of the field. */
|
|
140
|
+
type: string;
|
|
141
|
+
unit: ParamUnit;
|
|
142
|
+
min: ParamBound;
|
|
143
|
+
max: ParamBound;
|
|
144
|
+
default: ParamValue | ((ctx: ParamContext, cfg: ParamConfig) => ParamValue);
|
|
145
|
+
where: ParamWhere;
|
|
146
|
+
/** Knobs whose value moves this knob's bounds. */
|
|
147
|
+
dependsOn?: readonly string[];
|
|
148
|
+
/** Step between accepted values, counted from zero. Default 1. */
|
|
149
|
+
grid?: number;
|
|
150
|
+
/** Zero is accepted outside [min, max]: the rule is off. */
|
|
151
|
+
zeroIsOff?: boolean;
|
|
152
|
+
/** Set by the SDK, not shown to creators. */
|
|
153
|
+
hidden?: boolean;
|
|
154
|
+
/** What the wizard must tell the creator next to this knob. */
|
|
155
|
+
disclose?: string;
|
|
156
|
+
/** Tighter input limits for the wizard where the contract has no bound of its own. Never used to refuse. */
|
|
157
|
+
ui?: {
|
|
158
|
+
min: number;
|
|
159
|
+
max: number;
|
|
160
|
+
};
|
|
161
|
+
/** Named bits of a `mask` knob. */
|
|
162
|
+
options?: readonly ParamOption[];
|
|
163
|
+
}
|
|
164
|
+
/** Resolved bounds of one knob for one configuration. */
|
|
165
|
+
export interface ParamBounds {
|
|
166
|
+
min: bigint;
|
|
167
|
+
max: bigint;
|
|
168
|
+
grid: bigint;
|
|
169
|
+
zeroIsOff: boolean;
|
|
170
|
+
}
|
|
171
|
+
/** A knob value as an unsigned integer. Refuses fractions, negatives and malformed hex. */
|
|
172
|
+
export declare function paramValue(v: ParamValue | undefined): bigint;
|
|
173
|
+
/** The default per-block guarded buy cap, in basis points of the launch's quote depth (`quoteDepth`). */
|
|
174
|
+
export declare const DEFAULT_MAX_BUY_DEPTH_BPS = 50n;
|
|
175
|
+
/**
|
|
176
|
+
* A launch member's quote depth in raw quote units: the virtual quote reserve of its liquidity at the opening price,
|
|
177
|
+
* L x 2^96 / sqrtPriceX96 when the quote is currency0 and L x sqrtPriceX96 / 2^96 when it is currency1. A buy of
|
|
178
|
+
* 0.5% of it moves the opening price about 1% while the price stays in the band. Single-sided launches seed no quote,
|
|
179
|
+
* so the seed is no measure of their depth; for a two-sided full-range seed the two are equal. Without the opening
|
|
180
|
+
* state it is the quote seed, and undefined without either.
|
|
181
|
+
*/
|
|
182
|
+
export declare function quoteDepth(ctx: Pick<ParamContext, "quoteSeed" | "launchLiquidity" | "launchSqrtPriceX96" | "quoteIsCurrency0">): bigint | undefined;
|
|
183
|
+
/** The protocol share a launch starts with: 2,000 bps (20%), or the Rules minimum when that is higher. */
|
|
184
|
+
export declare const DEFAULT_PROTOCOL_SHARE_BPS = 2000;
|
|
185
|
+
/** HookrComplianceGuard flag: also check the recipient. */
|
|
186
|
+
export declare const COMPLIANCE_CHECK_BENEFICIARY = 1;
|
|
187
|
+
/** HookrComplianceGuard flag: sellers need a credential too. */
|
|
188
|
+
export declare const COMPLIANCE_KYC_ON_SELL = 2;
|
|
189
|
+
/** HookrComplianceGuard flag: sells stop too while the sanctions source is down. */
|
|
190
|
+
export declare const COMPLIANCE_HALT_SELLS_WHEN_SOURCE_DOWN = 4;
|
|
191
|
+
/** HookrComplianceGuard flag: the subject enforces transfer restrictions; needs a zero subject take. */
|
|
192
|
+
export declare const COMPLIANCE_RESTRICTED_SUBJECT = 8;
|
|
193
|
+
/** HookrComplianceGuard flag: accept curated-router swaps; needs RESTRICTED_SUBJECT or no list. */
|
|
194
|
+
export declare const COMPLIANCE_ACCEPT_CURATED = 16;
|
|
195
|
+
/** HookrComplianceGuard flag: permitted senders other than the launcher may add liquidity. */
|
|
196
|
+
export declare const COMPLIANCE_DIRECT_LP_IF_PERMITTED = 32;
|
|
197
|
+
/** Every HookrComplianceGuard flag. */
|
|
198
|
+
export declare const COMPLIANCE_ALL_FLAGS = 63;
|
|
199
|
+
/** HookrComplianceGuard.MIN_ADVISORY_GAS. */
|
|
200
|
+
export declare const COMPLIANCE_MIN_ADVISORY_GAS = 150000;
|
|
201
|
+
/** HookrLauncher.MAX_DEV_BUY_BPS: the most of the supply, in basis points, a creator holds when a dev-buy launch returns. */
|
|
202
|
+
export declare const MAX_DEV_BUY_BPS: number;
|
|
203
|
+
/** HookrLauncher.MAX_DEV_BUY_LOCK_BLOCKS: the longest DevBuy.lockBlocks, 365 days of 12-second parent blocks. */
|
|
204
|
+
export declare const MAX_DEV_BUY_LOCK_BLOCKS: number;
|
|
205
|
+
/** Largest DevBuy.quoteIn the Launcher swaps: it negates it into an int256 amountSpecified bounded by int128. */
|
|
206
|
+
export declare const MAX_DEV_BUY_QUOTE_IN: bigint;
|
|
207
|
+
/**
|
|
208
|
+
* The lock a launch with a dev buy starts with, in seconds: 7 days, the owner's default. The `lockBlocks` knob takes it
|
|
209
|
+
* in parent blocks at the chain's clock, the measured block time the Anti-Snipe guard default also uses
|
|
210
|
+
* (`ParamContext.blockTimeSeconds`, default 12): 50,400 blocks at 12 seconds.
|
|
211
|
+
*/
|
|
212
|
+
export declare const DEFAULT_DEV_BUY_LOCK_SECONDS: number;
|
|
213
|
+
/** Parent blocks covering a dev-buy lock of `seconds` at the measured block time, rounded up (`guardBlocksFor`) and at
|
|
214
|
+
* most MAX_DEV_BUY_LOCK_BLOCKS. */
|
|
215
|
+
export declare function devBuyLockBlocksFor(seconds: number, blockTimeSeconds?: number): number;
|
|
216
|
+
/**
|
|
217
|
+
* Why the member a dev buy names cannot take it, or null when it can: HookrLauncher._checkBuy's InvalidDevBuy checks on
|
|
218
|
+
* the member (r31, T39). An unguarded member (guardEndBlock zero) takes a dev buy with no Snipe and no cap; a guarded
|
|
219
|
+
* one needs its guard past `blockNumber`, a Snipe and a per-block cap of at least `quoteIn`.
|
|
220
|
+
*/
|
|
221
|
+
export declare function devBuyMemberRefusal(r: DevBuyMemberTerms | undefined, quoteIn: bigint, blockNumber?: bigint): string | null;
|
|
222
|
+
/**
|
|
223
|
+
* Knob manifest per rule, for the release in this package. `pool` is the PoolKey and PoolConfig of a HookrRoot
|
|
224
|
+
* launch member; `antiSnipe`, `dynamicFee`, `autoBurn`, `lpRewards`, `royalty` and `protocolShare` together are one
|
|
225
|
+
* `RulesConfig` and its `RulesKnobs` (r31: with dynamic fees the minimum liquidity and the tempo, and the Snipe curve;
|
|
226
|
+
* `dynamicFeeLiquidityDivisor` is the member's launchFamily divisor); `feeAdvisory` and `sessionTiers` are
|
|
227
|
+
* fee-advisory bind data; `sessionAdvisory` is a session Schedule; `pairRoot` the HookrPairRoot params; `compliance`
|
|
228
|
+
* the HookrComplianceGuard terms; `devBuy` the launch's optional HookrLauncher.DevBuy (`buildLaunchWithBuy`,
|
|
229
|
+
* `quoteDevBuy`, and each of launchFamily's dev buys); `family` launchFamily's family-wide terms (`buildLaunchFamily`).
|
|
230
|
+
*/
|
|
231
|
+
export declare const RULE_PARAMS: {
|
|
232
|
+
readonly pool: readonly RuleParam[];
|
|
233
|
+
readonly antiSnipe: readonly RuleParam[];
|
|
234
|
+
readonly dynamicFee: readonly RuleParam[];
|
|
235
|
+
readonly autoBurn: readonly RuleParam[];
|
|
236
|
+
readonly lpRewards: readonly RuleParam[];
|
|
237
|
+
readonly royalty: readonly RuleParam[];
|
|
238
|
+
readonly protocolShare: readonly RuleParam[];
|
|
239
|
+
readonly feeAdvisory: readonly RuleParam[];
|
|
240
|
+
readonly sessionTiers: RuleParam[];
|
|
241
|
+
readonly sessionAdvisory: RuleParam[];
|
|
242
|
+
readonly pairRoot: readonly RuleParam[];
|
|
243
|
+
readonly compliance: readonly RuleParam[];
|
|
244
|
+
readonly devBuy: readonly RuleParam[];
|
|
245
|
+
readonly family: readonly RuleParam[];
|
|
246
|
+
};
|
|
247
|
+
export type RuleName = keyof typeof RULE_PARAMS;
|
|
248
|
+
/** The rules whose knobs make up a HookrRoot launch member: its pool knobs and one RulesConfig. */
|
|
249
|
+
export declare const RULES_MEMBER_RULES: readonly ["pool", "antiSnipe", "dynamicFee", "autoBurn", "lpRewards", "royalty", "protocolShare"];
|
|
250
|
+
/** Resolves one knob's bounds for `cfg`. */
|
|
251
|
+
export declare function paramBounds(p: RuleParam, cfg: ParamConfig, ctx?: ParamContext): ParamBounds;
|
|
252
|
+
/** Refuses a knob value outside its bounds or off its grid. */
|
|
253
|
+
export declare function checkParam(rule: string, p: RuleParam, cfg: ParamConfig, ctx?: ParamContext): void;
|
|
254
|
+
/** Every knob of `rule` outside its bounds in `cfg`, one message each; empty when all are inside. */
|
|
255
|
+
export declare function ruleParamErrors(rule: RuleName, cfg: ParamConfig, ctx?: ParamContext): string[];
|
|
256
|
+
/** Refuses a configuration with any knob of `rule` outside its bounds, naming every such knob. */
|
|
257
|
+
export declare function checkRuleParams(rule: RuleName, cfg: ParamConfig, ctx?: ParamContext): void;
|
|
258
|
+
/** The default configuration of `rule`, knob by knob in manifest order; `base` fixes knobs already chosen. */
|
|
259
|
+
export declare function defaultRuleParams(rule: RuleName, ctx?: ParamContext, base?: ParamConfig): Record<string, ParamValue>;
|
|
260
|
+
/** Parent blocks covering `seconds` at the measured block time, rounded up. */
|
|
261
|
+
export declare function guardBlocksFor(seconds: number, blockTimeSeconds?: number): bigint;
|
|
262
|
+
/**
|
|
263
|
+
* A HookrRoot launch member's creator knobs: its pool terms, its Rules configuration and its Rules knobs (r31): with
|
|
264
|
+
* dynamic fees the minLiquidity and the tempo bound after the configuration, and the Snipe curve (all zero without
|
|
265
|
+
* them). `dynamicFeeLiquidityDivisor` is launchFamily's MemberKnobs divisor (zero: DYNAMIC_FEE_LIQUIDITY_DIVISOR).
|
|
266
|
+
*/
|
|
267
|
+
export interface RulesLaunch {
|
|
268
|
+
baseLpFeePips: number;
|
|
269
|
+
tickSpacing: number;
|
|
270
|
+
rules: RulesConfig;
|
|
271
|
+
minLiquidity: bigint;
|
|
272
|
+
windowSeconds: number;
|
|
273
|
+
resetSeconds: number;
|
|
274
|
+
carryBps: number;
|
|
275
|
+
moveTicks: number;
|
|
276
|
+
snipeCurve: number;
|
|
277
|
+
dynamicFeeLiquidityDivisor: number;
|
|
278
|
+
}
|
|
279
|
+
/** The RulesKnobs a launch member binds: its minLiquidity, its tempo and its Snipe curve. */
|
|
280
|
+
export declare function rulesKnobsOf(l: RulesLaunch): RulesKnobs;
|
|
281
|
+
/** Every knob of a HookrRoot launch member at its default. */
|
|
282
|
+
export declare function defaultRulesLaunch(ctx?: ParamContext): RulesLaunch;
|
|
283
|
+
/**
|
|
284
|
+
* Builds a RulesLaunch from a flat knob configuration. The retired pot fields are zero. A Rules knob the configuration
|
|
285
|
+
* lacks (one written before r31) takes what the Launcher binds without it: the default tempo on a dynamic fee member,
|
|
286
|
+
* zero otherwise, the linear Snipe curve and the default divisor.
|
|
287
|
+
*/
|
|
288
|
+
export declare function rulesLaunchOf(cfg: ParamConfig): RulesLaunch;
|
|
289
|
+
/**
|
|
290
|
+
* Checks every knob of a launch member against the manifest, HookrRules._validate and _checkKnobs, and returns its
|
|
291
|
+
* `rulesData`: the bytes HookrRules binds (`encodeRulesData`, r31): `abi.encode(RulesConfig)` without dynamic fees or
|
|
292
|
+
* a knob off its default, `abi.encode(RulesConfig, RulesKnobs)` otherwise. `ctx.blockNumber` should be the block the
|
|
293
|
+
* launch lands in; the guard is then checked against the 100,000-block window. A guarded pool needs
|
|
294
|
+
* `liquidityOwner`, the Launcher. For a Launcher member pass `ctx.launchLiquidity`: the Launcher derives minLiquidity
|
|
295
|
+
* from it (and the member's divisor) and the manifest pins the knob to that value, so the returned bytes are the ones
|
|
296
|
+
* launchFamily binds with these MemberKnobs (`launcherRulesData`); launch, launchAdvised and launchWithBuy bind the
|
|
297
|
+
* default tempo and the linear curve.
|
|
298
|
+
*/
|
|
299
|
+
export declare function encodeRulesBind(l: RulesLaunch, ctx?: ParamContext & {
|
|
300
|
+
liquidityOwner?: Address;
|
|
301
|
+
}): Hex;
|
|
302
|
+
/** Which advisory a HookrRoot member binds, for its gas floor and phases. */
|
|
303
|
+
export type RootAdvisoryKind = "fee" | "feeTiered" | "session" | "compliance";
|
|
304
|
+
/**
|
|
305
|
+
* Smallest advisory gas each advisory binds with on a HookrRoot member: the fee advisory's bind floor
|
|
306
|
+
* (`feeAdvisoryMinGas`), HookrSessionAdvisory.MIN_ADVISORY_GAS and HookrComplianceGuard.MIN_ADVISORY_GAS.
|
|
307
|
+
*/
|
|
308
|
+
export declare const ROOT_ADVISORY_MIN_GAS: Readonly<Record<RootAdvisoryKind, number>>;
|
|
309
|
+
/** A HookrRoot member's derived pool terms: never typed by a creator. */
|
|
310
|
+
export interface PoolTerms {
|
|
311
|
+
rulesData: Hex;
|
|
312
|
+
/** Tightest PoolConfig.caps HookrRules accepts, plus the advisory's admitted maximum. */
|
|
313
|
+
caps: Caps;
|
|
314
|
+
rulesGasLimit: number;
|
|
315
|
+
/** The advisory admission's gas limit: HookrRoot requires exactly it. Zero without an advisory. */
|
|
316
|
+
advisoryGasLimit: number;
|
|
317
|
+
advisoryPhases: number;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Pool caps and gas limits for a launch member (`PoolConfig.caps`, `rulesGasLimit`, `advisoryGasLimit`,
|
|
321
|
+
* `advisoryPhases`). Caps are the tightest the Rules accept, plus the advisory's admitted maximum so the Root's
|
|
322
|
+
* reservation leaves the Rules their full ceilings. On a Hookr token's pool pass the minimum it binds as
|
|
323
|
+
* `ctx.minFeePips`: the quote cap then admits royalty + minimum, and a Rules admission whose quote cap cannot carry it
|
|
324
|
+
* is refused here, so no launch is built that the bind refuses. The advisory gas is the admission's, which HookrRoot requires
|
|
325
|
+
* exactly and runs the advisory's bind within, so `advisory.kind` is required: the admission's gas must clear that
|
|
326
|
+
* advisory's floor (`ROOT_ADVISORY_MIN_GAS`) and the phases must include BEFORE_SWAP (exactly BEFORE_SWAP for the
|
|
327
|
+
* session advisory). Refuses a configuration the Rules admission caps cannot carry.
|
|
328
|
+
*/
|
|
329
|
+
export declare function rulesPoolTerms(l: RulesLaunch, ctx: ParamContext & {
|
|
330
|
+
liquidityOwner?: Address;
|
|
331
|
+
}, rulesAdmission: Admission, advisory?: {
|
|
332
|
+
admission: Admission;
|
|
333
|
+
kind: RootAdvisoryKind;
|
|
334
|
+
phases?: number;
|
|
335
|
+
}): PoolTerms;
|
|
336
|
+
/**
|
|
337
|
+
* The largest fee-advisory cap a HookrRoot member may bind: min(admission cap, pool LP cap above the Rules' native
|
|
338
|
+
* ceiling). With `rulesPoolTerms` caps this is the admission cap.
|
|
339
|
+
*/
|
|
340
|
+
export declare function feeAdvisoryLimit(l: RulesLaunch, poolCaps: Caps, admissionCap: number): number;
|
|
341
|
+
/** Which side each fee premium prices: premium0 is zeroForOne, a buy when the quote is currency0. */
|
|
342
|
+
export declare function feePremiumSides(quoteIsCurrency0: boolean): {
|
|
343
|
+
premium0: "buy" | "sell";
|
|
344
|
+
premium1: "buy" | "sell";
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Checked fee-advisory bind data: the Config (and session tiers when given) against the manifest with
|
|
348
|
+
* `ctx.advisoryLimit`, then the advisory's own checks and the gas floor `feeAdvisoryMinGas(root, tiered)`.
|
|
349
|
+
* `gasLimit` is the pool's advisory gas. HookrRoot member (`root` "root", the default): the advisory admission's
|
|
350
|
+
* gas, which HookrRoot requires exactly and runs `bind` within, so at least `FEE_ADVISORY_ROOT_BIND_GAS` (80,000
|
|
351
|
+
* plain, 110,000 tiered), above the advisory's MIN_ADVISORY_GAS (30,000) and MIN_TIERED_GAS (60,000). Pair root
|
|
352
|
+
* (`"pair"`): the root's advisoryGasLimit, at least MIN_PAIR_GAS (10,000), or MIN_TIERED_GAS with tiers.
|
|
353
|
+
*/
|
|
354
|
+
export declare function encodeFeeAdvisoryParams(c: FeeAdvisoryConfig, ctx: ParamContext, gasLimit: number, tiers?: SessionTiers, root?: FeeAdvisoryRoot): Hex;
|
|
355
|
+
/** Checked session-advisory bind data: the Schedule against the manifest with `ctx.tierCap`. */
|
|
356
|
+
export declare function encodeSessionScheduleParams(s: SessionSchedule, ctx: ParamContext): Hex;
|
|
357
|
+
/** A pair root's creator knobs. Pool currencies are the pair; the hidden knobs are derived when omitted. */
|
|
358
|
+
export interface PairRootKnobs {
|
|
359
|
+
currency0: Address;
|
|
360
|
+
currency1: Address;
|
|
361
|
+
tickSpacing: number;
|
|
362
|
+
baseLpFeePips: number;
|
|
363
|
+
advisory: Address;
|
|
364
|
+
advisoryCapPips: number;
|
|
365
|
+
advisoryFailOpen?: boolean;
|
|
366
|
+
maxLpFeePips?: number;
|
|
367
|
+
advisoryGasLimit?: number;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* HookrPairRoot params from creator knobs: maxLpFeePips is base plus the advisory cap, advisoryGasLimit the factory
|
|
371
|
+
* admission's gas (at most 500,000) and advisoryFailOpen false unless `ctx.pairAdmission` is fail-open, fee-only and
|
|
372
|
+
* without a quote take, each unless given. Checked against the manifest, the constructor and, with `admission` and
|
|
373
|
+
* `advisoryCodeHash`, the root factory's admission check, which refuses a fail-open root on any other admission.
|
|
374
|
+
*/
|
|
375
|
+
export declare function pairRootParamsFor(k: PairRootKnobs, ctx?: ParamContext, admission?: {
|
|
376
|
+
admission: Admission;
|
|
377
|
+
advisoryCodeHash: Hash;
|
|
378
|
+
}): PairRootParams;
|
|
379
|
+
/** IHookrComplianceGuard.Terms: the guard's bind data. */
|
|
380
|
+
export interface ComplianceTerms {
|
|
381
|
+
listId: Hash;
|
|
382
|
+
requireAll: number;
|
|
383
|
+
blockAny: number;
|
|
384
|
+
flags: number;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Compliance flags from named options. RESTRICTED_SUBJECT is derived from the subject token, never chosen.
|
|
388
|
+
*/
|
|
389
|
+
export declare function complianceFlags(o: {
|
|
390
|
+
checkBeneficiary?: boolean;
|
|
391
|
+
kycOnSell?: boolean;
|
|
392
|
+
haltSellsWhenSourceDown?: boolean;
|
|
393
|
+
acceptCurated?: boolean;
|
|
394
|
+
directLpIfPermitted?: boolean;
|
|
395
|
+
restrictedSubject: boolean;
|
|
396
|
+
}): number;
|
|
397
|
+
/**
|
|
398
|
+
* Refuses terms HookrComplianceGuard.bind would refuse: unknown flags, a tier both required and blocked, a missing
|
|
399
|
+
* list (with `ctx.listExists`), curated swaps on a listed unrestricted subject, and a restricted subject with a
|
|
400
|
+
* subject take (with `ctx.subjectTakeBps`).
|
|
401
|
+
*/
|
|
402
|
+
export declare function checkComplianceTerms(t: ComplianceTerms, ctx?: ParamContext): void;
|
|
403
|
+
/** Checked compliance terms as the guard's canonical 128-byte bind data. */
|
|
404
|
+
export declare function encodeComplianceTerms(t: ComplianceTerms, ctx?: ParamContext): Hex;
|
|
405
|
+
/** Decodes compliance bind data, refusing any size or encoding the guard refuses. */
|
|
406
|
+
export declare function decodeComplianceTerms(data: Hex): ComplianceTerms;
|
|
407
|
+
/**
|
|
408
|
+
* A compliance-guarded member's advisory pool terms: fail closed, BEFORE_SWAP, and the admission's gas, which must
|
|
409
|
+
* clear the guard's 150,000 floor.
|
|
410
|
+
*/
|
|
411
|
+
export declare function complianceAdvisoryTerms(admission: Admission): {
|
|
412
|
+
advisoryGasLimit: number;
|
|
413
|
+
advisoryPhases: number;
|
|
414
|
+
advisoryFailOpen: false;
|
|
415
|
+
};
|