hookr-sdk 0.2.1 → 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 +286 -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 +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 -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
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* quote and swap through Hookr's router, read markets, and claim payouts.
|
|
2
|
+
* hookr-sdk: build on Hookr 1, Hookr's Uniswap v4 hook on Robinhood Chain.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* README for a quickstart.
|
|
4
|
+
* `./core` is the release SDK of the release commit, copied byte for byte (`provenance.json` names the commit and
|
|
5
|
+
* every file's hash). `./releases` adds the addresses and deployment of the production release and its canary, the
|
|
6
|
+
* chain for viem, and builds the DeploymentManifest the core builders take.
|
|
9
7
|
*/
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./rules.js";
|
|
13
|
-
export * from "./fees.js";
|
|
14
|
-
export * from "./market.js";
|
|
15
|
-
export * from "./swap.js";
|
|
16
|
-
export * from "./reads.js";
|
|
17
|
-
export * from "./claims.js";
|
|
18
|
-
export * from "./links.js";
|
|
8
|
+
export * from "./core/index.js";
|
|
9
|
+
export * from "./releases.js";
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* quote and swap through Hookr's router, read markets, and claim payouts.
|
|
2
|
+
* hookr-sdk: build on Hookr 1, Hookr's Uniswap v4 hook on Robinhood Chain.
|
|
4
3
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* README for a quickstart.
|
|
4
|
+
* `./core` is the release SDK of the release commit, copied byte for byte (`provenance.json` names the commit and
|
|
5
|
+
* every file's hash). `./releases` adds the addresses and deployment of the production release and its canary, the
|
|
6
|
+
* chain for viem, and builds the DeploymentManifest the core builders take.
|
|
9
7
|
*/
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./rules.js";
|
|
13
|
-
export * from "./fees.js";
|
|
14
|
-
export * from "./market.js";
|
|
15
|
-
export * from "./swap.js";
|
|
16
|
-
export * from "./reads.js";
|
|
17
|
-
export * from "./claims.js";
|
|
18
|
-
export * from "./links.js";
|
|
8
|
+
export * from "./core/index.js";
|
|
9
|
+
export * from "./releases.js";
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hookr 1 on Robinhood Chain: the production release `hookr-1`, its canary `canary-hookr-1-a`, each release's
|
|
3
|
+
* deployment, and the deployment manifest the builders take.
|
|
4
|
+
*
|
|
5
|
+
* Every address is fixed by CREATE3 from the release deployer, the release id and the contract's name, so it is known
|
|
6
|
+
* before the contract is deployed and is the same on every machine. `test/releases.test.ts` derives each one again
|
|
7
|
+
* from those inputs. The canary runs the same code at its own addresses and exists to prove a release before
|
|
8
|
+
* production; build on `HOOKR_1`.
|
|
9
|
+
*/
|
|
10
|
+
import { type Chain } from "viem";
|
|
11
|
+
import { type Address, type ContractRole, type DeploymentManifest, type Hash } from "./core/index.js";
|
|
12
|
+
/** Robinhood Chain's id. */
|
|
13
|
+
export declare const CHAIN_ID = 4663;
|
|
14
|
+
/**
|
|
15
|
+
* The chain's public, keyless RPC endpoint. Fine for a few reads. Under load it rate limits, and a wide `eth_getLogs`
|
|
16
|
+
* can come back as an empty array instead of an error, so anything that must not miss data should use a provider
|
|
17
|
+
* endpoint of its own.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RPC_URL = "https://rpc.mainnet.chain.robinhood.com";
|
|
20
|
+
/** The block explorer people open: RobinScan, where every contract's source is verified. No trailing slash. */
|
|
21
|
+
export declare const EXPLORER_URL = "https://robin.etherscan.io";
|
|
22
|
+
/**
|
|
23
|
+
* Robinhood Chain for viem, on any viem 2, with RobinScan as its explorer. viem 2.55 and later also ship it as
|
|
24
|
+
* `robinhood` from `viem/chains`, with the same id and RPC endpoint and Blockscout as its explorer.
|
|
25
|
+
*/
|
|
26
|
+
export declare const ROBINHOOD_CHAIN: Chain;
|
|
27
|
+
/** An address's page on the explorer. */
|
|
28
|
+
export declare function explorerAddressUrl(address: Address): string;
|
|
29
|
+
/** A transaction's page on the explorer. */
|
|
30
|
+
export declare function explorerTxUrl(hash: Hash): string;
|
|
31
|
+
/** Uniswap v4's dynamic-fee flag. Every Hookr pool's `PoolKey.fee` is this: the hook sets the LP fee on each swap. */
|
|
32
|
+
export declare const DYNAMIC_FEE = 8388608;
|
|
33
|
+
/** The price limit for a `zeroForOne` swap that may fill in full: TickMath's MIN_SQRT_PRICE + 1. */
|
|
34
|
+
export declare const MIN_SQRT_PRICE_LIMIT = 4295128740n;
|
|
35
|
+
/** The price limit for a `oneForZero` swap that may fill in full: TickMath's MAX_SQRT_PRICE - 1. */
|
|
36
|
+
export declare const MAX_SQRT_PRICE_LIMIT = 1461446703485210103287273052203988822378723970341n;
|
|
37
|
+
/** Uniswap v4's PoolManager on Robinhood Chain. Every Hookr pool lives in it. */
|
|
38
|
+
export declare const POOL_MANAGER: Address;
|
|
39
|
+
/** The account that deploys both releases. CREATE3 addresses depend on it, never on a nonce. */
|
|
40
|
+
export declare const RELEASE_DEPLOYER: Address;
|
|
41
|
+
/** The CREATE3 factory both releases deploy through. */
|
|
42
|
+
export declare const CREATE3_FACTORY: Address;
|
|
43
|
+
/** The source commit both releases are built from. */
|
|
44
|
+
export declare const RELEASE_SOURCE_COMMIT = "412960b37a631ce145d49fb4a1887f04a4d1fa74";
|
|
45
|
+
/** The release digest: the hash of the build both releases deploy from. */
|
|
46
|
+
export declare const RELEASE_PACKET_DIGEST = "83962c12ff55df431612ffae8bfc66a30041eb310035cfc30eab1bb9bdc0e031";
|
|
47
|
+
/** Every contract of a release, by contract name. */
|
|
48
|
+
export interface ReleaseContracts {
|
|
49
|
+
HookrRegistryChecks: Address;
|
|
50
|
+
HookrRegistryAdmin: Address;
|
|
51
|
+
HookrRegistry: Address;
|
|
52
|
+
HookrTreasury: Address;
|
|
53
|
+
HookrForwarder: Address;
|
|
54
|
+
HookrRouter: Address;
|
|
55
|
+
HookrQuoter: Address;
|
|
56
|
+
HookrLaunchChecks: Address;
|
|
57
|
+
HookrTokenDeployer: Address;
|
|
58
|
+
HookrLauncher: Address;
|
|
59
|
+
HookrReferralRegistry: Address;
|
|
60
|
+
HookrProgramsAdmin: Address;
|
|
61
|
+
HookrPrograms: Address;
|
|
62
|
+
/** Created by HookrPrograms. */
|
|
63
|
+
HookrMilestoneNFTFactory: Address;
|
|
64
|
+
/** Created by HookrPrograms. */
|
|
65
|
+
HookrProgramValidator: Address;
|
|
66
|
+
HookrReferralDistributor: Address;
|
|
67
|
+
/** The hook every pool of the release names in `PoolKey.hooks`. */
|
|
68
|
+
HookrRoot: Address;
|
|
69
|
+
/** Created by HookrRoot: the arb recapture lane. */
|
|
70
|
+
HookrLane: Address;
|
|
71
|
+
HookrRules: Address;
|
|
72
|
+
/** Created by HookrRules: the arb recapture split. */
|
|
73
|
+
HookrRecapture: Address;
|
|
74
|
+
HookrFamilyRouter: Address;
|
|
75
|
+
HookrFamilyLock: Address;
|
|
76
|
+
HookrCompliance: Address;
|
|
77
|
+
HookrComplianceGuard: Address;
|
|
78
|
+
HookrAccountCalls: Address;
|
|
79
|
+
HookrPaymasterAdmin: Address;
|
|
80
|
+
HookrPaymaster: Address;
|
|
81
|
+
HookrRootFactory: Address;
|
|
82
|
+
HookrSessionAdvisory: Address;
|
|
83
|
+
HookrFeeAdvisory: Address;
|
|
84
|
+
HookrLiquidityVault: Address;
|
|
85
|
+
HookrOwnedProfiles: Address;
|
|
86
|
+
HookrOwnedRootsLens: Address;
|
|
87
|
+
HookrOwnedRootFactory: Address;
|
|
88
|
+
HookrLpBoost: Address;
|
|
89
|
+
}
|
|
90
|
+
export type ReleaseContractName = keyof ReleaseContracts;
|
|
91
|
+
/** The id each contract's salt is derived from. */
|
|
92
|
+
export type HookrReleaseId = "hookr-1" | "canary-hookr-1-a";
|
|
93
|
+
export interface HookrRelease {
|
|
94
|
+
/** The release id each contract's salt is derived from. */
|
|
95
|
+
releaseId: HookrReleaseId;
|
|
96
|
+
/** True for the canary: the same code at its own addresses, run before production. */
|
|
97
|
+
canary: boolean;
|
|
98
|
+
chainId: typeof CHAIN_ID;
|
|
99
|
+
contracts: Readonly<ReleaseContracts>;
|
|
100
|
+
/**
|
|
101
|
+
* The deployment as the release's verified app manifest records it, or null in a version of this package made
|
|
102
|
+
* before the release was deployed and verified. `releaseManifest` and `readReleaseManifest` use it by default.
|
|
103
|
+
*/
|
|
104
|
+
deployment: Readonly<ReleaseDeployment> | null;
|
|
105
|
+
}
|
|
106
|
+
/** The production release. Build on this one. */
|
|
107
|
+
export declare const HOOKR_1: HookrRelease;
|
|
108
|
+
/** The canary: the same contracts at their own addresses, deployed and proven before production. Not for users. */
|
|
109
|
+
export declare const CANARY_HOOKR_1_A: HookrRelease;
|
|
110
|
+
/** Both releases by release id. */
|
|
111
|
+
export declare const RELEASES: Readonly<Record<HookrReleaseId, HookrRelease>>;
|
|
112
|
+
/** The contract each manifest role pins, in the order the manifest lists them. */
|
|
113
|
+
export declare const MANIFEST_ROLES: Readonly<Partial<Record<ContractRole, ReleaseContractName | "PoolManager">>>;
|
|
114
|
+
/** The address a manifest role pins in a release. */
|
|
115
|
+
export declare function releaseAddress(release: HookrRelease, role: keyof typeof MANIFEST_ROLES): Address;
|
|
116
|
+
/** What a manifest needs beyond the addresses: the deployment as the chain has it and its source verification. */
|
|
117
|
+
export interface ReleaseDeployment {
|
|
118
|
+
/** The block the manifest starts from, as a decimal string: the block the release's app manifest was read at. */
|
|
119
|
+
startBlock: string;
|
|
120
|
+
/** That block's hash. The manifest calls it `parentHash`. */
|
|
121
|
+
parentHash: Hash;
|
|
122
|
+
/** keccak256 of each role's runtime code. Every role of `MANIFEST_ROLES` needs one. */
|
|
123
|
+
runtimeHashes: Readonly<Partial<Record<ContractRole, Hash>>>;
|
|
124
|
+
/**
|
|
125
|
+
* The hash of the release's source verification records on Blockscout. The manifest carries it to say the release
|
|
126
|
+
* is verified; the builders check its form, not its content.
|
|
127
|
+
*/
|
|
128
|
+
evidenceHash: Hash;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The DeploymentManifest the builders take for a release: every role at its fixed address with its runtime hash, from
|
|
132
|
+
* the release's own deployment unless one is given. It makes no reads. Refuses a role without a runtime hash, and
|
|
133
|
+
* anything `deployment()` refuses.
|
|
134
|
+
*
|
|
135
|
+
* It is the builders' manifest. Its release id is the release's, `hookr-1`, so it is not the manifest a Hookr service
|
|
136
|
+
* publishes: `HookrClient` takes the release id and manifest hash the service names.
|
|
137
|
+
*/
|
|
138
|
+
export declare function releaseManifest(release: HookrRelease, d?: Readonly<ReleaseDeployment> | null): DeploymentManifest;
|
|
139
|
+
/** The two reads `readReleaseManifest` makes. A viem PublicClient has both. */
|
|
140
|
+
export interface ReleaseReader {
|
|
141
|
+
getCode(args: {
|
|
142
|
+
address: Address;
|
|
143
|
+
blockNumber?: bigint;
|
|
144
|
+
}): Promise<`0x${string}` | undefined>;
|
|
145
|
+
getBlock(args: {
|
|
146
|
+
blockNumber: bigint;
|
|
147
|
+
}): Promise<{
|
|
148
|
+
hash: Hash | null;
|
|
149
|
+
}>;
|
|
150
|
+
}
|
|
151
|
+
/** Overrides for `readReleaseManifest`. With none, it reads the release's own deployment. */
|
|
152
|
+
export interface ReadReleaseOptions {
|
|
153
|
+
/** The block the manifest starts from. Defaults to the release's. */
|
|
154
|
+
startBlock?: bigint;
|
|
155
|
+
/** The release's source verification hash. Defaults to the release's. */
|
|
156
|
+
evidenceHash?: Hash;
|
|
157
|
+
/** The block the code is read at. Defaults to the latest. */
|
|
158
|
+
blockNumber?: bigint;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* `releaseManifest` with each role's runtime hash and the start block's hash read from chain. Refuses a role with no
|
|
162
|
+
* code: the release is not deployed, or not on this chain. Where the release carries its deployment, it also refuses
|
|
163
|
+
* a role whose code is not the release's, and a start block whose hash is not the release's.
|
|
164
|
+
*/
|
|
165
|
+
export declare function readReleaseManifest(client: ReleaseReader, release: HookrRelease, options?: ReadReleaseOptions): Promise<DeploymentManifest>;
|
|
166
|
+
/**
|
|
167
|
+
* The gas floor a swap on an arb recapture pool must carry while its lane is on: `2 × gasCap + gasCap / 63 + 755,000`
|
|
168
|
+
* (HookrLane), the `gasFloor` `laneOf(id)` returns. At the 3,000,000 cap the lane opens with it is 6,802,619. A swap
|
|
169
|
+
* sent with less reverts `InsufficientLaneGas`. The swap's own gas comes on top: the release rehearsal's lane swap
|
|
170
|
+
* needed a gas limit of 7,419,835, so a fixed limit on such a pool should be at least 7,500,000.
|
|
171
|
+
*/
|
|
172
|
+
export declare function laneGasFloor(gasCap: number | bigint): bigint;
|
package/dist/releases.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hookr 1 on Robinhood Chain: the production release `hookr-1`, its canary `canary-hookr-1-a`, each release's
|
|
3
|
+
* deployment, and the deployment manifest the builders take.
|
|
4
|
+
*
|
|
5
|
+
* Every address is fixed by CREATE3 from the release deployer, the release id and the contract's name, so it is known
|
|
6
|
+
* before the contract is deployed and is the same on every machine. `test/releases.test.ts` derives each one again
|
|
7
|
+
* from those inputs. The canary runs the same code at its own addresses and exists to prove a release before
|
|
8
|
+
* production; build on `HOOKR_1`.
|
|
9
|
+
*/
|
|
10
|
+
import { defineChain, keccak256 } from "viem";
|
|
11
|
+
import { deployment } from "./core/index.js";
|
|
12
|
+
import { DEPLOYMENTS } from "./deployments.js";
|
|
13
|
+
/** Robinhood Chain's id. */
|
|
14
|
+
export const CHAIN_ID = 4663;
|
|
15
|
+
/**
|
|
16
|
+
* The chain's public, keyless RPC endpoint. Fine for a few reads. Under load it rate limits, and a wide `eth_getLogs`
|
|
17
|
+
* can come back as an empty array instead of an error, so anything that must not miss data should use a provider
|
|
18
|
+
* endpoint of its own.
|
|
19
|
+
*/
|
|
20
|
+
export const RPC_URL = "https://rpc.mainnet.chain.robinhood.com";
|
|
21
|
+
/** The block explorer people open: RobinScan, where every contract's source is verified. No trailing slash. */
|
|
22
|
+
export const EXPLORER_URL = "https://robin.etherscan.io";
|
|
23
|
+
/**
|
|
24
|
+
* Robinhood Chain for viem, on any viem 2, with RobinScan as its explorer. viem 2.55 and later also ship it as
|
|
25
|
+
* `robinhood` from `viem/chains`, with the same id and RPC endpoint and Blockscout as its explorer.
|
|
26
|
+
*/
|
|
27
|
+
export const ROBINHOOD_CHAIN = defineChain({
|
|
28
|
+
id: CHAIN_ID,
|
|
29
|
+
name: "Robinhood Chain",
|
|
30
|
+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
|
|
31
|
+
rpcUrls: { default: { http: [RPC_URL] } },
|
|
32
|
+
blockExplorers: { default: { name: "RobinScan", url: EXPLORER_URL } },
|
|
33
|
+
contracts: { multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11" } },
|
|
34
|
+
});
|
|
35
|
+
/** An address's page on the explorer. */
|
|
36
|
+
export function explorerAddressUrl(address) {
|
|
37
|
+
return `${EXPLORER_URL}/address/${address}`;
|
|
38
|
+
}
|
|
39
|
+
/** A transaction's page on the explorer. */
|
|
40
|
+
export function explorerTxUrl(hash) {
|
|
41
|
+
return `${EXPLORER_URL}/tx/${hash}`;
|
|
42
|
+
}
|
|
43
|
+
/** Uniswap v4's dynamic-fee flag. Every Hookr pool's `PoolKey.fee` is this: the hook sets the LP fee on each swap. */
|
|
44
|
+
export const DYNAMIC_FEE = 0x800000;
|
|
45
|
+
/** The price limit for a `zeroForOne` swap that may fill in full: TickMath's MIN_SQRT_PRICE + 1. */
|
|
46
|
+
export const MIN_SQRT_PRICE_LIMIT = 4295128740n;
|
|
47
|
+
/** The price limit for a `oneForZero` swap that may fill in full: TickMath's MAX_SQRT_PRICE - 1. */
|
|
48
|
+
export const MAX_SQRT_PRICE_LIMIT = 1461446703485210103287273052203988822378723970341n;
|
|
49
|
+
/** Uniswap v4's PoolManager on Robinhood Chain. Every Hookr pool lives in it. */
|
|
50
|
+
export const POOL_MANAGER = "0x8366a39CC670B4001A1121B8F6A443A643e40951";
|
|
51
|
+
/** The account that deploys both releases. CREATE3 addresses depend on it, never on a nonce. */
|
|
52
|
+
export const RELEASE_DEPLOYER = "0x0c0967485A25F18E70262a2Ee80c7595CC64a5fC";
|
|
53
|
+
/** The CREATE3 factory both releases deploy through. */
|
|
54
|
+
export const CREATE3_FACTORY = "0xc7c662Fc760FE1d5cB97fd8A68cb43A046da3F7d";
|
|
55
|
+
/** The source commit both releases are built from. */
|
|
56
|
+
export const RELEASE_SOURCE_COMMIT = "412960b37a631ce145d49fb4a1887f04a4d1fa74";
|
|
57
|
+
/** The release digest: the hash of the build both releases deploy from. */
|
|
58
|
+
export const RELEASE_PACKET_DIGEST = "83962c12ff55df431612ffae8bfc66a30041eb310035cfc30eab1bb9bdc0e031";
|
|
59
|
+
/** A deployment, frozen, so no caller can change the facts a release carries. */
|
|
60
|
+
function frozen(d) {
|
|
61
|
+
return d && Object.freeze({ ...d, runtimeHashes: Object.freeze({ ...d.runtimeHashes }) });
|
|
62
|
+
}
|
|
63
|
+
/** The production release. Build on this one. */
|
|
64
|
+
export const HOOKR_1 = Object.freeze({
|
|
65
|
+
releaseId: "hookr-1",
|
|
66
|
+
canary: false,
|
|
67
|
+
chainId: CHAIN_ID,
|
|
68
|
+
deployment: frozen(DEPLOYMENTS["hookr-1"]),
|
|
69
|
+
contracts: Object.freeze({
|
|
70
|
+
HookrRegistryChecks: "0xB9F5c54E5Cc7ac6c7a96335E5A334Cf4eA496E98",
|
|
71
|
+
HookrRegistryAdmin: "0x675ac2102E8c69E2467F64656E3c235AF3901Ac1",
|
|
72
|
+
HookrRegistry: "0x463c82beA1a52F4Cc05ca0741a24F0AD24bA4602",
|
|
73
|
+
HookrTreasury: "0x2242F7FC75606500503075f29ea8cDA684EfB4a9",
|
|
74
|
+
HookrForwarder: "0xe7863CC0E2Fb783b44c279aB159bcD812c2ceA1c",
|
|
75
|
+
HookrRouter: "0xC2Bc9a3fe6c4Ce8C2F7EB4655b0869b01D8c93C9",
|
|
76
|
+
HookrQuoter: "0x445D7891381Aa7F91F5048EdBC6a611ccBDe7865",
|
|
77
|
+
HookrLaunchChecks: "0x8567369a70100828611BB6F44ec051B48F10fb59",
|
|
78
|
+
HookrTokenDeployer: "0x1B23D6d7beBcB61E39317E9F0Bc02AEB91aFCcAe",
|
|
79
|
+
HookrLauncher: "0x1cf2748A6670572425eAbf9Ab9e5BC4eb2eB8Ef4",
|
|
80
|
+
HookrReferralRegistry: "0xefD1DfBA80c06E72F793601706c3a1c71aab3057",
|
|
81
|
+
HookrProgramsAdmin: "0x40B40D65543E70a9C757eda1A2208517a8BC7292",
|
|
82
|
+
HookrPrograms: "0x9fA204AC99176782Fd20615b2b2A516D1F8C328F",
|
|
83
|
+
HookrMilestoneNFTFactory: "0xa340F964F1E685c681dC3ABB5B0405E608914d00",
|
|
84
|
+
HookrProgramValidator: "0x33e0249083Be7Cd8bD2fe175E0671AcfD0516850",
|
|
85
|
+
HookrReferralDistributor: "0x690539c53212899A9c6AEEE3b4B6737A5c4851d9",
|
|
86
|
+
HookrRoot: "0x89c9FB50d1f03192230FFB1c279BB6E7d3Fe6aCc",
|
|
87
|
+
HookrLane: "0x9A8a1006469BA196f8FEfc017a53505C83A060BB",
|
|
88
|
+
HookrRules: "0x4a71c270b1520F94064268102AebD744b0DE7942",
|
|
89
|
+
HookrRecapture: "0xF83569E564d70daebc35950f66a73f2e2B915583",
|
|
90
|
+
HookrFamilyRouter: "0x854f3Fa7AC342B244DF0d9A8c8F597b051aAE559",
|
|
91
|
+
HookrFamilyLock: "0xfAFEcE64099C1E791C4B46189c277f00c0c7e00b",
|
|
92
|
+
HookrCompliance: "0x9D205e8a68464761A9d84bdeCcEa0C3CB1e7B1EC",
|
|
93
|
+
HookrComplianceGuard: "0x6CD70db1ac99344416a6fD7184e23FA8f09f313A",
|
|
94
|
+
HookrAccountCalls: "0x0579a95A7760070E2d6D34e5beCe571e5F1c4818",
|
|
95
|
+
HookrPaymasterAdmin: "0x1d81F4B131832f741392edf7B91b4CF099FbB008",
|
|
96
|
+
HookrPaymaster: "0x1c4682915092E742231ea038C4fcA61e96a83c99",
|
|
97
|
+
HookrRootFactory: "0x21E438FaBE10770afb4407cF6b09d32369CBdCE4",
|
|
98
|
+
HookrSessionAdvisory: "0x78Bc6b7302Dda8632e661c8d74966bdBea1c66b1",
|
|
99
|
+
HookrFeeAdvisory: "0x3B6b3f00684987B831fcF9EB5f0d5B806afF7306",
|
|
100
|
+
HookrLiquidityVault: "0xA408923EF811945Ef119Bc700B1950Dab65467Fc",
|
|
101
|
+
HookrOwnedProfiles: "0xb46c318B6AEA2d6274f5566da414b09fDa6CC325",
|
|
102
|
+
HookrOwnedRootsLens: "0x6Bb5c9d21dD095F788cb8373d0143429ad277366",
|
|
103
|
+
HookrOwnedRootFactory: "0xA6c2a401597301dFf57A59bC8F70a9622499f3ec",
|
|
104
|
+
HookrLpBoost: "0x52536F5F4E5BC7cEA2197c8F1BB49bf2B133E7f1",
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
/** The canary: the same contracts at their own addresses, deployed and proven before production. Not for users. */
|
|
108
|
+
export const CANARY_HOOKR_1_A = Object.freeze({
|
|
109
|
+
releaseId: "canary-hookr-1-a",
|
|
110
|
+
canary: true,
|
|
111
|
+
chainId: CHAIN_ID,
|
|
112
|
+
deployment: frozen(DEPLOYMENTS["canary-hookr-1-a"]),
|
|
113
|
+
contracts: Object.freeze({
|
|
114
|
+
HookrRegistryChecks: "0x4598d64B6c5730813a469e4B36cf379DbfB24118",
|
|
115
|
+
HookrRegistryAdmin: "0x57252DB7C9ed51213a324A2160934Ee2f840d6E8",
|
|
116
|
+
HookrRegistry: "0x91eDc45319B66dc4f168BcF7B957e8f753771834",
|
|
117
|
+
HookrTreasury: "0x3cA2926E5971Cda3E3667e9A6835b2cDfF8DD836",
|
|
118
|
+
HookrForwarder: "0xDd3407eB6DbFF4a3Cb6258923C35F3e306C86320",
|
|
119
|
+
HookrRouter: "0x3b6848A557F5Aedc18EbE5f3E5b6EafB4F46f6F9",
|
|
120
|
+
HookrQuoter: "0xc324D74339763E8b12709092a2c9d8f04CD02c88",
|
|
121
|
+
HookrLaunchChecks: "0xa22BF1F6a8709441Fc7af410891204454Ed24026",
|
|
122
|
+
HookrTokenDeployer: "0x85b6B07688Da8089F4191439dbFC315a4757DB0F",
|
|
123
|
+
HookrLauncher: "0x064a2b59f7c3d70ECdC0009be30Eb464110Ae787",
|
|
124
|
+
HookrReferralRegistry: "0x8EC0AE84b21BF2dD187ED390dbDA7A967ECfC5dD",
|
|
125
|
+
HookrProgramsAdmin: "0x2Bec6C3bEB51c062C0Ef59ddC67237354E86BeF1",
|
|
126
|
+
HookrPrograms: "0x3A11ea03e1B6c6750dEF8A5fBb41bd4c3d0C3d97",
|
|
127
|
+
HookrMilestoneNFTFactory: "0xFeE0AbA75f9C0A23bB5AB686314a5112dfe3f0b2",
|
|
128
|
+
HookrProgramValidator: "0xA6883F0424FA4Ec11E0591Aa14A26be957EE863A",
|
|
129
|
+
HookrReferralDistributor: "0x9ab480d01e89F9d9A1D1e3cd8433DCbC825BA4cC",
|
|
130
|
+
HookrRoot: "0x4C0904bfbdaEC6AA847C36BBf395E5f61325eacc",
|
|
131
|
+
HookrLane: "0x3ba186E41b83ABd4E91a2a72c2fF3BAF8f88003C",
|
|
132
|
+
HookrRules: "0x8Ef8869CD47d9928d563001F1d38D65c3c3e01Ab",
|
|
133
|
+
HookrRecapture: "0xe7035c0d8523a5eE9Fc5Ba5Ec97a4f1D771a6F87",
|
|
134
|
+
HookrFamilyRouter: "0xD6F31D46D06d4Aa91e937407369a369D1DB9C684",
|
|
135
|
+
HookrFamilyLock: "0xC39144589aC7336eFC9baB9d7608c7B014Fe757e",
|
|
136
|
+
HookrCompliance: "0xed326114d79b8bf64f00585fF3Ca1D5C01693649",
|
|
137
|
+
HookrComplianceGuard: "0xB6a3d34513020458fBC80D71F5753fC41a863CE5",
|
|
138
|
+
HookrAccountCalls: "0xdd706C93179730cFE73b8c1627bEc6103e51E3a3",
|
|
139
|
+
HookrPaymasterAdmin: "0x7a44B8E11097c4B801bcf195EF09295882538bF3",
|
|
140
|
+
HookrPaymaster: "0x1Bf7C2e0755b8776C04f21208Ea4CF29A0942866",
|
|
141
|
+
HookrRootFactory: "0x2B2fF011b4A3854b7796e86307736AEB558C80C7",
|
|
142
|
+
HookrSessionAdvisory: "0x6fE7e2244257664e4658FEcB308Cf374e6c83Af1",
|
|
143
|
+
HookrFeeAdvisory: "0x02B13627a634dfebBb864389cDb3E4D6945e80Ac",
|
|
144
|
+
HookrLiquidityVault: "0x67E93f59E3fD78e7976960aBce835E27c63Aa8c9",
|
|
145
|
+
HookrOwnedProfiles: "0xeCeD7a6D923Dc5C0c49B0a8c5089f372C6c40244",
|
|
146
|
+
HookrOwnedRootsLens: "0x76f0F2a48C154c8261110a4c13cdc5d4437A0631",
|
|
147
|
+
HookrOwnedRootFactory: "0xEFD7bE480bbA7e3b14dbA0878F34AB436bC08ff8",
|
|
148
|
+
HookrLpBoost: "0xe06dac9dea02424fAd01CEE10feA0ce5517765A9",
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
/** Both releases by release id. */
|
|
152
|
+
export const RELEASES = Object.freeze({
|
|
153
|
+
"hookr-1": HOOKR_1,
|
|
154
|
+
"canary-hookr-1-a": CANARY_HOOKR_1_A,
|
|
155
|
+
});
|
|
156
|
+
/** The contract each manifest role pins, in the order the manifest lists them. */
|
|
157
|
+
export const MANIFEST_ROLES = Object.freeze({
|
|
158
|
+
poolManager: "PoolManager",
|
|
159
|
+
registry: "HookrRegistry",
|
|
160
|
+
root: "HookrRoot",
|
|
161
|
+
rules: "HookrRules",
|
|
162
|
+
router: "HookrRouter",
|
|
163
|
+
quoter: "HookrQuoter",
|
|
164
|
+
launcher: "HookrLauncher",
|
|
165
|
+
treasury: "HookrTreasury",
|
|
166
|
+
programs: "HookrPrograms",
|
|
167
|
+
referrals: "HookrReferralRegistry",
|
|
168
|
+
commissions: "HookrReferralDistributor",
|
|
169
|
+
forwarder: "HookrForwarder",
|
|
170
|
+
rootFactory: "HookrRootFactory",
|
|
171
|
+
feeAdvisory: "HookrFeeAdvisory",
|
|
172
|
+
sessionAdvisory: "HookrSessionAdvisory",
|
|
173
|
+
liquidityVault: "HookrLiquidityVault",
|
|
174
|
+
});
|
|
175
|
+
/** The address a manifest role pins in a release. */
|
|
176
|
+
export function releaseAddress(release, role) {
|
|
177
|
+
const name = MANIFEST_ROLES[role];
|
|
178
|
+
if (!name)
|
|
179
|
+
throw new Error(`No ${role} in ${release.releaseId}`);
|
|
180
|
+
return name === "PoolManager" ? POOL_MANAGER : release.contracts[name];
|
|
181
|
+
}
|
|
182
|
+
/** What a version of this package made before the release was verified tells a caller. */
|
|
183
|
+
function noDeployment(release) {
|
|
184
|
+
return new Error(`This version of hookr-sdk has no deployment for ${release.releaseId}: pass its startBlock and evidenceHash`);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The DeploymentManifest the builders take for a release: every role at its fixed address with its runtime hash, from
|
|
188
|
+
* the release's own deployment unless one is given. It makes no reads. Refuses a role without a runtime hash, and
|
|
189
|
+
* anything `deployment()` refuses.
|
|
190
|
+
*
|
|
191
|
+
* It is the builders' manifest. Its release id is the release's, `hookr-1`, so it is not the manifest a Hookr service
|
|
192
|
+
* publishes: `HookrClient` takes the release id and manifest hash the service names.
|
|
193
|
+
*/
|
|
194
|
+
export function releaseManifest(release, d = release.deployment) {
|
|
195
|
+
if (!d)
|
|
196
|
+
throw noDeployment(release);
|
|
197
|
+
const contracts = Object.keys(MANIFEST_ROLES).map((role) => {
|
|
198
|
+
const runtimeHash = d.runtimeHashes[role];
|
|
199
|
+
if (!runtimeHash)
|
|
200
|
+
throw new Error(`No runtime hash for ${role}`);
|
|
201
|
+
return {
|
|
202
|
+
role,
|
|
203
|
+
address: releaseAddress(release, role).toLowerCase(),
|
|
204
|
+
runtimeHash,
|
|
205
|
+
startBlock: d.startBlock,
|
|
206
|
+
};
|
|
207
|
+
});
|
|
208
|
+
return deployment({
|
|
209
|
+
schema: "hookr.engagement.sources.v1",
|
|
210
|
+
releaseId: release.releaseId,
|
|
211
|
+
chainId: String(release.chainId),
|
|
212
|
+
startBlock: d.startBlock,
|
|
213
|
+
parentHash: d.parentHash,
|
|
214
|
+
contracts,
|
|
215
|
+
qualification: { status: "verified", evidenceHash: d.evidenceHash, sourceCommit: RELEASE_SOURCE_COMMIT },
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* `releaseManifest` with each role's runtime hash and the start block's hash read from chain. Refuses a role with no
|
|
220
|
+
* code: the release is not deployed, or not on this chain. Where the release carries its deployment, it also refuses
|
|
221
|
+
* a role whose code is not the release's, and a start block whose hash is not the release's.
|
|
222
|
+
*/
|
|
223
|
+
export async function readReleaseManifest(client, release, options = {}) {
|
|
224
|
+
const pinned = release.deployment;
|
|
225
|
+
const startBlock = options.startBlock ?? (pinned ? BigInt(pinned.startBlock) : undefined);
|
|
226
|
+
const evidenceHash = options.evidenceHash ?? pinned?.evidenceHash;
|
|
227
|
+
if (startBlock === undefined || evidenceHash === undefined)
|
|
228
|
+
throw noDeployment(release);
|
|
229
|
+
const roles = Object.keys(MANIFEST_ROLES);
|
|
230
|
+
const [block, codes] = await Promise.all([
|
|
231
|
+
client.getBlock({ blockNumber: startBlock }),
|
|
232
|
+
Promise.all(roles.map((role) => client.getCode({ address: releaseAddress(release, role), blockNumber: options.blockNumber }))),
|
|
233
|
+
]);
|
|
234
|
+
if (!block.hash)
|
|
235
|
+
throw new Error(`Block ${startBlock} has no hash yet`);
|
|
236
|
+
const pinnedStart = pinned && startBlock === BigInt(pinned.startBlock);
|
|
237
|
+
if (pinnedStart && block.hash.toLowerCase() !== pinned.parentHash.toLowerCase())
|
|
238
|
+
throw new Error(`Block ${startBlock} is not ${release.releaseId}'s start block on this chain`);
|
|
239
|
+
const runtimeHashes = {};
|
|
240
|
+
roles.forEach((role, i) => {
|
|
241
|
+
const code = codes[i];
|
|
242
|
+
if (!code || code === "0x")
|
|
243
|
+
throw new Error(`No code at ${role} ${releaseAddress(release, role)}`);
|
|
244
|
+
const runtimeHash = keccak256(code);
|
|
245
|
+
const expected = pinned?.runtimeHashes[role];
|
|
246
|
+
if (expected && runtimeHash !== expected.toLowerCase())
|
|
247
|
+
throw new Error(`${role} ${releaseAddress(release, role)} does not run ${release.releaseId}'s code`);
|
|
248
|
+
runtimeHashes[role] = runtimeHash;
|
|
249
|
+
});
|
|
250
|
+
return releaseManifest(release, {
|
|
251
|
+
startBlock: startBlock.toString(),
|
|
252
|
+
parentHash: block.hash,
|
|
253
|
+
runtimeHashes,
|
|
254
|
+
evidenceHash,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The gas floor a swap on an arb recapture pool must carry while its lane is on: `2 × gasCap + gasCap / 63 + 755,000`
|
|
259
|
+
* (HookrLane), the `gasFloor` `laneOf(id)` returns. At the 3,000,000 cap the lane opens with it is 6,802,619. A swap
|
|
260
|
+
* sent with less reverts `InsufficientLaneGas`. The swap's own gas comes on top: the release rehearsal's lane swap
|
|
261
|
+
* needed a gas limit of 7,419,835, so a fixed limit on such a pool should be at least 7,500,000.
|
|
262
|
+
*/
|
|
263
|
+
export function laneGasFloor(gasCap) {
|
|
264
|
+
const cap = BigInt(gasCap);
|
|
265
|
+
if (cap <= 0n)
|
|
266
|
+
return 0n;
|
|
267
|
+
return 2n * cap + cap / 63n + 755000n;
|
|
268
|
+
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,65 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hookr-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Build
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Build on Hookr 1: launch tokens with Hook Blocks, open pools, quote, swap and claim on Robinhood Chain.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
7
|
+
"homepage": "https://hookr.fun/docs",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"hookr",
|
|
10
|
+
"uniswap",
|
|
11
|
+
"uniswap-v4",
|
|
12
|
+
"v4-hooks",
|
|
13
|
+
"hooks",
|
|
14
|
+
"hook-blocks",
|
|
15
|
+
"launchpad",
|
|
16
|
+
"robinhood-chain",
|
|
17
|
+
"viem",
|
|
18
|
+
"sdk"
|
|
19
|
+
],
|
|
11
20
|
"exports": {
|
|
12
21
|
".": {
|
|
13
22
|
"types": "./dist/index.d.ts",
|
|
14
23
|
"import": "./dist/index.js"
|
|
15
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
16
26
|
},
|
|
17
27
|
"main": "./dist/index.js",
|
|
18
28
|
"types": "./dist/index.d.ts",
|
|
19
29
|
"files": [
|
|
20
30
|
"dist",
|
|
21
|
-
"
|
|
31
|
+
"provenance.json",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"MIGRATING.md",
|
|
35
|
+
"LICENSE"
|
|
22
36
|
],
|
|
37
|
+
"sideEffects": false,
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.16"
|
|
40
|
+
},
|
|
41
|
+
"devEngines": {
|
|
42
|
+
"runtime": {
|
|
43
|
+
"name": "node",
|
|
44
|
+
"version": ">=22.18",
|
|
45
|
+
"onFail": "error"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
23
48
|
"peerDependencies": {
|
|
24
|
-
"viem": "^2"
|
|
49
|
+
"viem": "^2.0.0"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "24.3.0",
|
|
53
|
+
"typescript": "5.9.3",
|
|
54
|
+
"viem": "2.55.10"
|
|
25
55
|
},
|
|
26
56
|
"scripts": {
|
|
27
|
-
"build": "tsc -p tsconfig.json"
|
|
57
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && node scripts/declarations.mjs",
|
|
58
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
59
|
+
"test": "node --test test/*.test.ts",
|
|
60
|
+
"sync": "node scripts/sync-core.mjs",
|
|
61
|
+
"deployment": "node scripts/release-deployment.mjs",
|
|
62
|
+
"prepack": "npm run build",
|
|
63
|
+
"prepublishOnly": "node scripts/release-deployment.mjs --require hookr-1"
|
|
28
64
|
}
|
|
29
65
|
}
|
package/provenance.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": "hookr-sdk.provenance.v1",
|
|
3
|
+
"algorithm": "sha256",
|
|
4
|
+
"source": {
|
|
5
|
+
"commit": "412960b37a631ce145d49fb4a1887f04a4d1fa74",
|
|
6
|
+
"path": "labs/hooks/hookr-phase-one/sdk/src",
|
|
7
|
+
"package": "@hookr/phase-one-sdk@0.1.0"
|
|
8
|
+
},
|
|
9
|
+
"packetDigest": "83962c12ff55df431612ffae8bfc66a30041eb310035cfc30eab1bb9bdc0e031",
|
|
10
|
+
"contractSources": "Verified on RobinScan at each contract's address: https://robin.etherscan.io",
|
|
11
|
+
"files": {
|
|
12
|
+
"abi.ts": "615359c9865eaa8b12ddde68f3e115bcf4cc922c2ba9578cd4c4ba9c0836d416",
|
|
13
|
+
"advisories.ts": "2fd12057ddb8c8527c19438574366ca9b15a48183b841d56d44e38506b823ded",
|
|
14
|
+
"client.ts": "78c386458e747e9c520926e3c22c33292a4ef0ae26dfcf4b671ccd7302e19328",
|
|
15
|
+
"generated.ts": "2fa220f53b64b85cb8fd7b34e06dd3a346027b6d8aa4e93835f69f92697a0fe7",
|
|
16
|
+
"index.ts": "5789edae589547442a6529111dd8c2e02d6a8791784f6da45c96e189567b3059",
|
|
17
|
+
"launch.ts": "dffb0d1321a30f68d4510dc30523599ae28b9a30f6df9880366e149974555268",
|
|
18
|
+
"pair.ts": "1b3f3f2d3dbf6a3e69655c9d35324e5f656ab64b2d7b846c7621dd6a4ca4e43d",
|
|
19
|
+
"params.ts": "5fa75b9ede3bbb20d4b48f2b907220f9b832b05977c3aeefa5b69d0169f85521",
|
|
20
|
+
"policies.ts": "07411d29d46f7175ff77624242cabcf4d3a235a287507f3d83a0df4a06985410",
|
|
21
|
+
"proofs.ts": "81f1f4a0f2c267b8a2b7897ecd4847fb8791f512f8babc51f1c8976d9d047bb8",
|
|
22
|
+
"quotes.ts": "c3483a97ca247533cc5ef9d5648b43df591d47db3c434e8f8ff6b634b44359c3",
|
|
23
|
+
"referrals.ts": "9426b5a128ddff1c9f7b54e483a81a30458dea04c7d40adff8d1e4084f048987",
|
|
24
|
+
"registry.ts": "fec429bc5b7bd91a83124d46055171269ded20678c185ad3e40d7d5e1153cee8",
|
|
25
|
+
"rules.ts": "d34b23187424756293b06815c6ee31dc772c87f2ae1cbba63f966148ece64543",
|
|
26
|
+
"schema.ts": "caa6caa9f15ae9a597bf8b2a2d098ef40780b8b6410a3a72a4f2be62b84c98e5",
|
|
27
|
+
"stocks.generated.ts": "8809cd3b82612bbc6e96bca23b756ee0bb7b99d391d991415f6ffb9d2aa705fd",
|
|
28
|
+
"vault.ts": "e01d26ed5517547bfc29dc89ca58836c762d665e88a5db58523475248f5de387",
|
|
29
|
+
"wallet.ts": "25fd97be3dde9755414f0eeacae2a9cfc14358951f98d6573af1025403895dba"
|
|
30
|
+
}
|
|
31
|
+
}
|