@paraswap/dex-lib 4.7.18-before-multi-route.0 → 4.7.18
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/build/abi/PendleRouterStatic.json +19 -0
- package/build/abi/apex-defi/ApexDefiFactory.abi.json +1749 -0
- package/build/abi/apex-defi/ApexDefiRouter.abi.json +1120 -0
- package/build/abi/apex-defi/ApexDefiToken.abi.json +229 -0
- package/build/abi/apex-defi/ApexDefiWrapper.abi.json +92 -0
- package/build/abi/apex-defi/ApexDefiWrapperFactory.abi.json +1107 -0
- package/build/abi/pangolin-v3/PangolinV3StateMulticall.abi.json +796 -0
- package/build/abi/pendle/pendle-deployer.abi.json +520 -0
- package/build/abi/pendle/pendle-oracle.abi.json +413 -0
- package/build/abi/pharaoh-v3/PharaohV3Factory.abi.json +101 -0
- package/build/abi/ring-v2/few-wrapped-token.json +587 -0
- package/build/abi/ring-v2/ring-v2-factory.json +125 -0
- package/build/abi/ring-v2/ring-v2-pool.json +461 -0
- package/build/abi/ring-v2/ring-v2-router.json +332 -0
- package/build/abi/stabull/stabull-curve.json +738 -0
- package/build/abi/stabull/stabull-router.json +76 -0
- package/build/abi/uniswap-v4/hooks/SpotDynamicFeeManager.json +26 -0
- package/build/abi/uniswap-v4/hooks/SpotHook.json +54 -0
- package/build/abi/uniswap-v4/hooks/SpotPolicyManager.json +45 -0
- package/build/abi/uniswap-v4/hooks/cabalcoin-hook.abi.json +682 -0
- package/build/abi/uniswap-v4/hooks/fee-hook.abi.json +1335 -0
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.d.ts +29 -0
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js +153 -0
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying-factory.js.map +1 -0
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.d.ts +40 -0
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js +323 -0
- package/build/dex/aave-pt-to-underlying/aave-pt-to-underlying.js.map +1 -0
- package/build/dex/aave-pt-to-underlying/config.d.ts +3 -0
- package/build/dex/aave-pt-to-underlying/config.js +24 -0
- package/build/dex/aave-pt-to-underlying/config.js.map +1 -0
- package/build/dex/aave-pt-to-underlying/constants.d.ts +2 -0
- package/build/dex/aave-pt-to-underlying/constants.js +6 -0
- package/build/dex/aave-pt-to-underlying/constants.js.map +1 -0
- package/build/dex/aave-pt-to-underlying/types.d.ts +24 -0
- package/build/dex/aave-pt-to-underlying/types.js +3 -0
- package/build/dex/aave-pt-to-underlying/types.js.map +1 -0
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.d.ts +39 -0
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js +244 -0
- package/build/dex/aave-pt-to-usdc/aave-pt-to-usdc.js.map +1 -0
- package/build/dex/aave-pt-to-usdc/config.d.ts +3 -0
- package/build/dex/aave-pt-to-usdc/config.js +47 -0
- package/build/dex/aave-pt-to-usdc/config.js.map +1 -0
- package/build/dex/aave-pt-to-usdc/constants.d.ts +2 -0
- package/build/dex/aave-pt-to-usdc/constants.js +6 -0
- package/build/dex/aave-pt-to-usdc/constants.js.map +1 -0
- package/build/dex/aave-pt-to-usdc/types.d.ts +22 -0
- package/build/dex/aave-pt-to-usdc/types.js +3 -0
- package/build/dex/aave-pt-to-usdc/types.js.map +1 -0
- package/build/dex/apex-defi/apex-defi-factory.d.ts +26 -0
- package/build/dex/apex-defi/apex-defi-factory.js +53 -0
- package/build/dex/apex-defi/apex-defi-factory.js.map +1 -0
- package/build/dex/apex-defi/apex-defi-pool.d.ts +55 -0
- package/build/dex/apex-defi/apex-defi-pool.js +247 -0
- package/build/dex/apex-defi/apex-defi-pool.js.map +1 -0
- package/build/dex/apex-defi/apex-defi-wrapper-factory.d.ts +57 -0
- package/build/dex/apex-defi/apex-defi-wrapper-factory.js +250 -0
- package/build/dex/apex-defi/apex-defi-wrapper-factory.js.map +1 -0
- package/build/dex/apex-defi/apex-defi.d.ts +97 -0
- package/build/dex/apex-defi/apex-defi.js +1021 -0
- package/build/dex/apex-defi/apex-defi.js.map +1 -0
- package/build/dex/apex-defi/config.d.ts +4 -0
- package/build/dex/apex-defi/config.js +138 -0
- package/build/dex/apex-defi/config.js.map +1 -0
- package/build/dex/apex-defi/types.d.ts +32 -0
- package/build/dex/apex-defi/types.js +3 -0
- package/build/dex/apex-defi/types.js.map +1 -0
- package/build/dex/apex-defi/utils.d.ts +46 -0
- package/build/dex/apex-defi/utils.js +133 -0
- package/build/dex/apex-defi/utils.js.map +1 -0
- package/build/dex/idle-dao/idle-dao.d.ts +0 -1
- package/build/dex/idle-dao/idle-dao.js +11 -23
- package/build/dex/idle-dao/idle-dao.js.map +1 -1
- package/build/dex/maker-psm/maker-psm.d.ts +41 -4
- package/build/dex/maker-psm/maker-psm.js +143 -40
- package/build/dex/maker-psm/maker-psm.js.map +1 -1
- package/build/dex/miro-migrator/miro-migrator-state.d.ts +27 -0
- package/build/dex/miro-migrator/miro-migrator-state.js +89 -0
- package/build/dex/miro-migrator/miro-migrator-state.js.map +1 -0
- package/build/dex/simple-exchange.js +1 -7
- package/build/dex/simple-exchange.js.map +1 -1
- package/build/dex/stabull/config.d.ts +3 -0
- package/build/dex/stabull/config.js +177 -0
- package/build/dex/stabull/config.js.map +1 -0
- package/build/dex/stabull/stabull-pool.d.ts +46 -0
- package/build/dex/stabull/stabull-pool.js +113 -0
- package/build/dex/stabull/stabull-pool.js.map +1 -0
- package/build/dex/stabull/stabull.d.ts +55 -0
- package/build/dex/stabull/stabull.js +286 -0
- package/build/dex/stabull/stabull.js.map +1 -0
- package/build/dex/stabull/types.d.ts +21 -0
- package/build/dex/stabull/types.js +3 -0
- package/build/dex/stabull/types.js.map +1 -0
- package/build/dex/uniswap-v2/constants.js +2 -0
- package/build/dex/uniswap-v2/constants.js.map +1 -1
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.d.ts +4 -0
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js +56 -0
- package/build/dex/uniswap-v3/forks/pangolin-v3/utils.js.map +1 -0
- package/build/dex/uniswap-v4/config.js +2 -0
- package/build/dex/uniswap-v4/config.js.map +1 -1
- package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.d.ts +2 -1
- package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js +28 -9
- package/build/dex/uniswap-v4/contract-math/uniswap-v4-pool-math.js.map +1 -1
- package/build/dex/uniswap-v4/hooks/arena/arena-hook.js +4 -4
- package/build/dex/uniswap-v4/hooks/arena/arena-hook.js.map +1 -1
- package/build/dex/uniswap-v4/hooks/arena.d.ts +6 -0
- package/build/dex/uniswap-v4/hooks/arena.js +10 -0
- package/build/dex/uniswap-v4/hooks/arena.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/base-fee/base-fee-hook.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/base-fee/base-fee-hook.js +2 -0
- package/build/dex/uniswap-v4/hooks/base-fee/base-fee-hook.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.d.ts +7 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js +28 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/cabalcoin-hook-pool.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js +2 -0
- package/build/dex/uniswap-v4/hooks/cabalcoin-hook/types.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.d.ts +7 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js +28 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/fee-hook-pool.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/types.d.ts +0 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/types.js +2 -0
- package/build/dex/uniswap-v4/hooks/fee-hook/types.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/index.d.ts +1 -0
- package/build/dex/uniswap-v4/hooks/index.js +18 -0
- package/build/dex/uniswap-v4/hooks/index.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/spot.d.ts +15 -0
- package/build/dex/uniswap-v4/hooks/spot.js +109 -0
- package/build/dex/uniswap-v4/hooks/spot.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/template.d.ts +150 -0
- package/build/dex/uniswap-v4/hooks/template.js +104 -0
- package/build/dex/uniswap-v4/hooks/template.js.map +1 -0
- package/build/dex/uniswap-v4/hooks/types.d.ts +4 -0
- package/build/dex/uniswap-v4/subgraph.d.ts +4 -4
- package/build/dex/uniswap-v4/subgraph.js +24 -21
- package/build/dex/uniswap-v4/subgraph.js.map +1 -1
- package/build/dex/uniswap-v4/types.d.ts +2 -0
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.d.ts +7 -1
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js +54 -9
- package/build/dex/uniswap-v4/uniswap-v4-pool-manager.js.map +1 -1
- package/build/dex/uniswap-v4/uniswap-v4-pool.d.ts +3 -1
- package/build/dex/uniswap-v4/uniswap-v4-pool.js +3 -1
- package/build/dex/uniswap-v4/uniswap-v4-pool.js.map +1 -1
- package/build/dex/uniswap-v4/uniswap-v4.d.ts +3 -1
- package/build/dex/uniswap-v4/uniswap-v4.js +15 -5
- package/build/dex/uniswap-v4/uniswap-v4.js.map +1 -1
- package/build/dex/uniswap-v4/utils.d.ts +2 -1
- package/build/dex/uniswap-v4/utils.js +11 -0
- package/build/dex/uniswap-v4/utils.js.map +1 -1
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.d.ts +26 -0
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js +75 -0
- package/build/dex/usdc-transmuter/usdc-transmuter-pool.js.map +1 -0
- package/build/dex/usual/usual-usdc-usdc.d.ts +17 -0
- package/build/dex/usual/usual-usdc-usdc.js +59 -0
- package/build/dex/usual/usual-usdc-usdc.js.map +1 -0
- package/build/dex/yo/config.d.ts +3 -0
- package/build/dex/yo/config.js +21 -0
- package/build/dex/yo/config.js.map +1 -0
- package/build/dex/yo/types.d.ts +13 -0
- package/build/dex/yo/types.js +3 -0
- package/build/dex/yo/types.js.map +1 -0
- package/build/dex/yo/yo-pool.d.ts +13 -0
- package/build/dex/yo/yo-pool.js +26 -0
- package/build/dex/yo/yo-pool.js.map +1 -0
- package/build/dex/yo/yo.d.ts +39 -0
- package/build/dex/yo/yo.js +248 -0
- package/build/dex/yo/yo.js.map +1 -0
- package/build/implementations/api-paraswap-sdk.d.ts +25 -0
- package/build/implementations/api-paraswap-sdk.js +102 -0
- package/build/implementations/api-paraswap-sdk.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { SwapSide } from '@paraswap/core';
|
|
2
|
+
import { DeepReadonly } from 'ts-essentials';
|
|
3
|
+
import { IDexHelper } from '../../../dex-helper';
|
|
4
|
+
import { Address, Log, Logger } from '../../../types';
|
|
5
|
+
import { Pool, PoolState, SubgraphPool } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Hook permission bits used by the Uniswap v4 hook address encoding.
|
|
8
|
+
* They match https://docs.uniswap.org/contracts/v4/concepts/hooks#permissions.
|
|
9
|
+
* Re-using Kyber's mapping so downstream teams have a familiar API.
|
|
10
|
+
*/
|
|
11
|
+
export declare enum HookPermission {
|
|
12
|
+
AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA = 0,
|
|
13
|
+
AFTER_ADD_LIQUIDITY_RETURNS_DELTA = 1,
|
|
14
|
+
AFTER_SWAP_RETURNS_DELTA = 2,
|
|
15
|
+
BEFORE_SWAP_RETURNS_DELTA = 3,
|
|
16
|
+
AFTER_DONATE = 4,
|
|
17
|
+
BEFORE_DONATE = 5,
|
|
18
|
+
AFTER_SWAP = 6,
|
|
19
|
+
BEFORE_SWAP = 7,
|
|
20
|
+
AFTER_REMOVE_LIQUIDITY = 8,
|
|
21
|
+
BEFORE_REMOVE_LIQUIDITY = 9,
|
|
22
|
+
AFTER_ADD_LIQUIDITY = 10,
|
|
23
|
+
BEFORE_ADD_LIQUIDITY = 11,
|
|
24
|
+
AFTER_INITIALIZE = 12,
|
|
25
|
+
BEFORE_INITIALIZE = 13
|
|
26
|
+
}
|
|
27
|
+
export declare const hasHookPermission: (address: Address, permission: HookPermission) => boolean;
|
|
28
|
+
export declare const canBeforeSwap: (address: Address) => boolean;
|
|
29
|
+
export declare const canAfterSwap: (address: Address) => boolean;
|
|
30
|
+
export type HookFactoryParams = {
|
|
31
|
+
dexHelper: IDexHelper;
|
|
32
|
+
dexKey: string;
|
|
33
|
+
logger: Logger;
|
|
34
|
+
network: number;
|
|
35
|
+
hookAddress: Address;
|
|
36
|
+
};
|
|
37
|
+
export type HookBootstrapParams = HookFactoryParams & {
|
|
38
|
+
pool: SubgraphPool;
|
|
39
|
+
};
|
|
40
|
+
export type HookStateContext = HookFactoryParams & {
|
|
41
|
+
pool: Pool;
|
|
42
|
+
poolState: DeepReadonly<PoolState>;
|
|
43
|
+
blockNumber: number;
|
|
44
|
+
};
|
|
45
|
+
export type HookBeforeSwapParams = HookStateContext & {
|
|
46
|
+
amountSpecified: bigint;
|
|
47
|
+
zeroForOne: boolean;
|
|
48
|
+
side: SwapSide;
|
|
49
|
+
};
|
|
50
|
+
export type HookBeforeSwapResult = {
|
|
51
|
+
/**
|
|
52
|
+
* Optional override for the amount specified that will be forwarded to pool math.
|
|
53
|
+
* Useful for hooks that deduct their own fee prior to the swap.
|
|
54
|
+
*/
|
|
55
|
+
amountSpecified?: bigint;
|
|
56
|
+
/**
|
|
57
|
+
* Override for lpFee if the hook is dynamically adjusting the pool fee.
|
|
58
|
+
*/
|
|
59
|
+
lpFeeOverride?: bigint;
|
|
60
|
+
/**
|
|
61
|
+
* Extra calldata that needs to be appended to router.swap parameters.
|
|
62
|
+
*/
|
|
63
|
+
hookData?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Optional state patch that will be merged in-memory before simulation continues.
|
|
66
|
+
*/
|
|
67
|
+
statePatch?: Partial<PoolState>;
|
|
68
|
+
/**
|
|
69
|
+
* Free-form metadata (e.g. diagnostics, gas estimates) propagated to afterSwap.
|
|
70
|
+
*/
|
|
71
|
+
metadata?: Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
export type HookAfterSwapParams = HookStateContext & {
|
|
74
|
+
amountIn: bigint;
|
|
75
|
+
amountOut: bigint;
|
|
76
|
+
zeroForOne: boolean;
|
|
77
|
+
side: SwapSide;
|
|
78
|
+
metadata?: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
export type HookAfterSwapResult = {
|
|
81
|
+
deltaAmountIn?: bigint;
|
|
82
|
+
deltaAmountOut?: bigint;
|
|
83
|
+
statePatch?: Partial<PoolState>;
|
|
84
|
+
};
|
|
85
|
+
export type HookEventParams = HookFactoryParams & {
|
|
86
|
+
pool: Pool;
|
|
87
|
+
poolState: PoolState;
|
|
88
|
+
eventName: string;
|
|
89
|
+
eventArgs: any;
|
|
90
|
+
log: Log;
|
|
91
|
+
blockNumber: number;
|
|
92
|
+
};
|
|
93
|
+
export interface IUniswapV4Hook {
|
|
94
|
+
readonly name: string;
|
|
95
|
+
readonly hookAddress: Address;
|
|
96
|
+
readonly description?: string;
|
|
97
|
+
/**
|
|
98
|
+
* Optional hook-level initialization invoked once after the pool list is fetched.
|
|
99
|
+
*/
|
|
100
|
+
bootstrap?(params: HookBootstrapParams): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* Allows hooks to filter pools beyond address equality (e.g. min TVL, custom fee).
|
|
103
|
+
*/
|
|
104
|
+
supportsPool(pool: SubgraphPool): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Gives hooks a chance to enrich pool state (e.g. fetch additional storage slots).
|
|
107
|
+
*/
|
|
108
|
+
extendPoolState?(context: HookStateContext): Promise<Partial<PoolState> | void>;
|
|
109
|
+
/**
|
|
110
|
+
* Invoked before SwapMath is executed to let hooks override inputs or provide hookData.
|
|
111
|
+
*/
|
|
112
|
+
beforeSwap?(params: HookBeforeSwapParams): Promise<HookBeforeSwapResult | void>;
|
|
113
|
+
/**
|
|
114
|
+
* Invoked after pool math completes so hooks can settle their internal accounting.
|
|
115
|
+
*/
|
|
116
|
+
afterSwap?(params: HookAfterSwapParams): Promise<HookAfterSwapResult | void>;
|
|
117
|
+
/**
|
|
118
|
+
* Hooks may request direct access to PoolManager events for bespoke state sync.
|
|
119
|
+
*/
|
|
120
|
+
handlePoolEvent?(params: HookEventParams): Promise<Partial<PoolState> | void>;
|
|
121
|
+
/**
|
|
122
|
+
* Destroy internal caches.
|
|
123
|
+
*/
|
|
124
|
+
destroy?(): void;
|
|
125
|
+
}
|
|
126
|
+
export declare abstract class BaseUniswapV4Hook implements IUniswapV4Hook {
|
|
127
|
+
readonly hookAddress: Address;
|
|
128
|
+
readonly name: string;
|
|
129
|
+
protected readonly params: HookFactoryParams;
|
|
130
|
+
readonly description?: string;
|
|
131
|
+
protected constructor(hookAddress: Address, name: string, params: HookFactoryParams);
|
|
132
|
+
bootstrap(_params: HookBootstrapParams): Promise<void>;
|
|
133
|
+
supportsPool(pool: SubgraphPool): boolean;
|
|
134
|
+
extendPoolState(_context: HookStateContext): Promise<Partial<PoolState> | void>;
|
|
135
|
+
beforeSwap(_params: HookBeforeSwapParams): Promise<HookBeforeSwapResult | void>;
|
|
136
|
+
afterSwap(_params: HookAfterSwapParams): Promise<HookAfterSwapResult | void>;
|
|
137
|
+
handlePoolEvent(_params: HookEventParams): Promise<Partial<PoolState> | void>;
|
|
138
|
+
destroy(): void;
|
|
139
|
+
protected get logger(): Logger;
|
|
140
|
+
protected get dexHelper(): IDexHelper;
|
|
141
|
+
}
|
|
142
|
+
export type HookFactory = (params: HookFactoryParams) => IUniswapV4Hook;
|
|
143
|
+
export declare class UniswapV4HookRegistry {
|
|
144
|
+
private readonly factories;
|
|
145
|
+
registerFactory(address: Address, factory: HookFactory): this;
|
|
146
|
+
unregisterFactory(address: Address): boolean;
|
|
147
|
+
getFactory(address: Address): HookFactory | undefined;
|
|
148
|
+
createHook(address: Address, params: Omit<HookFactoryParams, 'hookAddress'>): IUniswapV4Hook | undefined;
|
|
149
|
+
}
|
|
150
|
+
export declare const uniswapV4HookRegistry: UniswapV4HookRegistry;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniswapV4HookRegistry = exports.UniswapV4HookRegistry = exports.BaseUniswapV4Hook = exports.canAfterSwap = exports.canBeforeSwap = exports.hasHookPermission = exports.HookPermission = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Hook permission bits used by the Uniswap v4 hook address encoding.
|
|
6
|
+
* They match https://docs.uniswap.org/contracts/v4/concepts/hooks#permissions.
|
|
7
|
+
* Re-using Kyber's mapping so downstream teams have a familiar API.
|
|
8
|
+
*/
|
|
9
|
+
var HookPermission;
|
|
10
|
+
(function (HookPermission) {
|
|
11
|
+
HookPermission[HookPermission["AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA"] = 0] = "AFTER_REMOVE_LIQUIDITY_RETURNS_DELTA";
|
|
12
|
+
HookPermission[HookPermission["AFTER_ADD_LIQUIDITY_RETURNS_DELTA"] = 1] = "AFTER_ADD_LIQUIDITY_RETURNS_DELTA";
|
|
13
|
+
HookPermission[HookPermission["AFTER_SWAP_RETURNS_DELTA"] = 2] = "AFTER_SWAP_RETURNS_DELTA";
|
|
14
|
+
HookPermission[HookPermission["BEFORE_SWAP_RETURNS_DELTA"] = 3] = "BEFORE_SWAP_RETURNS_DELTA";
|
|
15
|
+
HookPermission[HookPermission["AFTER_DONATE"] = 4] = "AFTER_DONATE";
|
|
16
|
+
HookPermission[HookPermission["BEFORE_DONATE"] = 5] = "BEFORE_DONATE";
|
|
17
|
+
HookPermission[HookPermission["AFTER_SWAP"] = 6] = "AFTER_SWAP";
|
|
18
|
+
HookPermission[HookPermission["BEFORE_SWAP"] = 7] = "BEFORE_SWAP";
|
|
19
|
+
HookPermission[HookPermission["AFTER_REMOVE_LIQUIDITY"] = 8] = "AFTER_REMOVE_LIQUIDITY";
|
|
20
|
+
HookPermission[HookPermission["BEFORE_REMOVE_LIQUIDITY"] = 9] = "BEFORE_REMOVE_LIQUIDITY";
|
|
21
|
+
HookPermission[HookPermission["AFTER_ADD_LIQUIDITY"] = 10] = "AFTER_ADD_LIQUIDITY";
|
|
22
|
+
HookPermission[HookPermission["BEFORE_ADD_LIQUIDITY"] = 11] = "BEFORE_ADD_LIQUIDITY";
|
|
23
|
+
HookPermission[HookPermission["AFTER_INITIALIZE"] = 12] = "AFTER_INITIALIZE";
|
|
24
|
+
HookPermission[HookPermission["BEFORE_INITIALIZE"] = 13] = "BEFORE_INITIALIZE";
|
|
25
|
+
})(HookPermission || (exports.HookPermission = HookPermission = {}));
|
|
26
|
+
const ADDRESS_HEX_PREFIX = '0x';
|
|
27
|
+
const normalizeAddress = (address) => address.toLowerCase().startsWith(ADDRESS_HEX_PREFIX)
|
|
28
|
+
? address.toLowerCase()
|
|
29
|
+
: `${ADDRESS_HEX_PREFIX}${address.toLowerCase()}`;
|
|
30
|
+
const decodePermissionBits = (address) => {
|
|
31
|
+
const normalized = normalizeAddress(address).slice(2).padStart(40, '0');
|
|
32
|
+
const lastTwoBytes = normalized.slice(-4);
|
|
33
|
+
return parseInt(lastTwoBytes, 16);
|
|
34
|
+
};
|
|
35
|
+
const hasHookPermission = (address, permission) => {
|
|
36
|
+
const bits = decodePermissionBits(address);
|
|
37
|
+
return (bits & (1 << permission)) !== 0;
|
|
38
|
+
};
|
|
39
|
+
exports.hasHookPermission = hasHookPermission;
|
|
40
|
+
const canBeforeSwap = (address) => (0, exports.hasHookPermission)(address, HookPermission.BEFORE_SWAP);
|
|
41
|
+
exports.canBeforeSwap = canBeforeSwap;
|
|
42
|
+
const canAfterSwap = (address) => (0, exports.hasHookPermission)(address, HookPermission.AFTER_SWAP);
|
|
43
|
+
exports.canAfterSwap = canAfterSwap;
|
|
44
|
+
class BaseUniswapV4Hook {
|
|
45
|
+
hookAddress;
|
|
46
|
+
name;
|
|
47
|
+
params;
|
|
48
|
+
description;
|
|
49
|
+
constructor(hookAddress, name, params) {
|
|
50
|
+
this.hookAddress = hookAddress;
|
|
51
|
+
this.name = name;
|
|
52
|
+
this.params = params;
|
|
53
|
+
}
|
|
54
|
+
async bootstrap(_params) {
|
|
55
|
+
// No-op by default.
|
|
56
|
+
}
|
|
57
|
+
supportsPool(pool) {
|
|
58
|
+
return normalizeAddress(pool.hooks) === normalizeAddress(this.hookAddress);
|
|
59
|
+
}
|
|
60
|
+
async extendPoolState(_context) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
async beforeSwap(_params) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
async afterSwap(_params) {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
async handlePoolEvent(_params) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
destroy() {
|
|
73
|
+
// No-op by default.
|
|
74
|
+
}
|
|
75
|
+
get logger() {
|
|
76
|
+
return this.params.logger;
|
|
77
|
+
}
|
|
78
|
+
get dexHelper() {
|
|
79
|
+
return this.params.dexHelper;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.BaseUniswapV4Hook = BaseUniswapV4Hook;
|
|
83
|
+
class UniswapV4HookRegistry {
|
|
84
|
+
factories = new Map();
|
|
85
|
+
registerFactory(address, factory) {
|
|
86
|
+
this.factories.set(normalizeAddress(address), factory);
|
|
87
|
+
return this;
|
|
88
|
+
}
|
|
89
|
+
unregisterFactory(address) {
|
|
90
|
+
return this.factories.delete(normalizeAddress(address));
|
|
91
|
+
}
|
|
92
|
+
getFactory(address) {
|
|
93
|
+
return this.factories.get(normalizeAddress(address));
|
|
94
|
+
}
|
|
95
|
+
createHook(address, params) {
|
|
96
|
+
const factory = this.getFactory(address);
|
|
97
|
+
if (!factory)
|
|
98
|
+
return undefined;
|
|
99
|
+
return factory({ ...params, hookAddress: normalizeAddress(address) });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.UniswapV4HookRegistry = UniswapV4HookRegistry;
|
|
103
|
+
exports.uniswapV4HookRegistry = new UniswapV4HookRegistry();
|
|
104
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/dex/uniswap-v4/hooks/template.ts"],"names":[],"mappings":";;;AAOA;;;;GAIG;AACH,IAAY,cAeX;AAfD,WAAY,cAAc;IACxB,mHAAwC,CAAA;IACxC,6GAAqC,CAAA;IACrC,2FAA4B,CAAA;IAC5B,6FAA6B,CAAA;IAC7B,mEAAgB,CAAA;IAChB,qEAAiB,CAAA;IACjB,+DAAc,CAAA;IACd,iEAAe,CAAA;IACf,uFAA0B,CAAA;IAC1B,yFAA2B,CAAA;IAC3B,kFAAwB,CAAA;IACxB,oFAAyB,CAAA;IACzB,4EAAqB,CAAA;IACrB,8EAAsB,CAAA;AACxB,CAAC,EAfW,cAAc,8BAAd,cAAc,QAezB;AAED,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAEhC,MAAM,gBAAgB,GAAG,CAAC,OAAgB,EAAU,EAAE,CACpD,OAAO,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,kBAAkB,CAAC;IAClD,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE;IACvB,CAAC,CAAC,GAAG,kBAAkB,GAAG,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC;AAEtD,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAU,EAAE;IACxD,MAAM,UAAU,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IACxE,MAA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
|
53
53
|
afterAddLiquidity?(sender: string, key: PoolKey, params: ModifyLiquidityParams, delta0: BalanceDelta, delta1: BalanceDelta, hookData: string): [string, BalanceDelta];
|
|
54
54
|
afterRemoveLiquidity?(sender: string, key: PoolKey, params: ModifyLiquidityParams, delta0: BalanceDelta, delta1: BalanceDelta, hookData: string): [string, BalanceDelta];
|
|
55
55
|
beforeSwap?(sender: string, key: PoolKey, params: SwapParams, hookData: string): [string, BeforeSwapDelta, number];
|
|
56
|
+
/**
|
|
57
|
+
* The hook implementing this method should return the final
|
|
58
|
+
* modified amount exactly as swapExactAmountIn/Out would return
|
|
59
|
+
*/
|
|
56
60
|
afterSwap?(sender: string, key: PoolKey, params: SwapParams, delta: BalanceDelta, hookData: string): bigint;
|
|
57
61
|
beforeDonate?(sender: string, key: PoolKey, amount0: string, amount1: string, hookData: string): string;
|
|
58
62
|
afterDonate?(sender: string, key: PoolKey, amount0: string, amount1: string, hookData: string): string;
|
|
@@ -3,10 +3,10 @@ import { IDexHelper } from '../../dex-helper';
|
|
|
3
3
|
import { Logger } from 'log4js';
|
|
4
4
|
import { Address } from '@paraswap/core';
|
|
5
5
|
export declare function queryTicksForPool(dexHelper: IDexHelper, logger: Logger, dexKey: string, subgraphUrl: string, blockNumber: number, id: string, skip: number, limit: number, latestBlock?: boolean): Promise<SubgraphTick[]>;
|
|
6
|
-
export declare function queryAvailablePoolsForToken(dexHelper: IDexHelper, logger: Logger, dexKey: string, subgraphUrl: string, tokenAddress: string, limit: number, staticPoolsList?: string[]): Promise<{
|
|
6
|
+
export declare function queryAvailablePoolsForToken(dexHelper: IDexHelper, logger: Logger, dexKey: string, subgraphUrl: string, tokenAddress: string, limit: number, staticPoolsList?: string[], hooks?: string[]): Promise<{
|
|
7
7
|
pools0: SubgraphConnectorPool[];
|
|
8
8
|
pools1: SubgraphConnectorPool[];
|
|
9
9
|
}>;
|
|
10
|
-
export declare function queryAvailablePoolsForPairFromSubgraph(dexHelper: IDexHelper, subgraphUrl: string, srcToken: Address, destToken: Address): Promise<SubgraphPool[]>;
|
|
11
|
-
export declare function queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper: IDexHelper, logger: Logger, dexKey: string, subgraphUrl: string, blockNumber: number, skip: number, limit: number, latestBlock?: boolean): Promise<SubgraphPool[]>;
|
|
12
|
-
export declare function queryPoolsFromSubgraph(dexHelper: IDexHelper, subgraphUrl: string, poolIds: string[]): Promise<SubgraphPool[]
|
|
10
|
+
export declare function queryAvailablePoolsForPairFromSubgraph(dexHelper: IDexHelper, subgraphUrl: string, srcToken: Address, destToken: Address, hooks?: string[]): Promise<SubgraphPool[]>;
|
|
11
|
+
export declare function queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper: IDexHelper, logger: Logger, dexKey: string, subgraphUrl: string, blockNumber: number, skip: number, limit: number, hooks?: string[], latestBlock?: boolean): Promise<SubgraphPool[]>;
|
|
12
|
+
export declare function queryPoolsFromSubgraph(dexHelper: IDexHelper, subgraphUrl: string, poolIds: string[], hooks?: string[]): Promise<SubgraphPool[]>;
|
|
@@ -37,15 +37,15 @@ async function queryTicksForPool(dexHelper, logger, dexKey, subgraphUrl, blockNu
|
|
|
37
37
|
}
|
|
38
38
|
return res.data.ticks || [];
|
|
39
39
|
}
|
|
40
|
-
async function queryAvailablePoolsForToken(dexHelper, logger, dexKey, subgraphUrl, tokenAddress, limit, staticPoolsList) {
|
|
40
|
+
async function queryAvailablePoolsForToken(dexHelper, logger, dexKey, subgraphUrl, tokenAddress, limit, staticPoolsList, hooks = [constants_2.NULL_ADDRESS]) {
|
|
41
41
|
const list = staticPoolsList
|
|
42
42
|
? staticPoolsList.map(t => `"${t}"`).join(',')
|
|
43
43
|
: '';
|
|
44
|
-
const poolsQuery = `query ($token: Bytes!, $hooks: Bytes
|
|
44
|
+
const poolsQuery = `query ($token: Bytes!, $hooks: [Bytes!], $minTVL: Int!, $count: Int) {
|
|
45
45
|
pools0: pools(
|
|
46
46
|
where: {
|
|
47
47
|
token0: $token
|
|
48
|
-
|
|
48
|
+
hooks_in: $hooks
|
|
49
49
|
liquidity_gt: 0
|
|
50
50
|
totalValueLockedUSD_gte: $minTVL
|
|
51
51
|
${list ? `id_in: [${list}]` : ''}
|
|
@@ -71,7 +71,7 @@ async function queryAvailablePoolsForToken(dexHelper, logger, dexKey, subgraphUr
|
|
|
71
71
|
pools1: pools(
|
|
72
72
|
where: {
|
|
73
73
|
token1: $token
|
|
74
|
-
|
|
74
|
+
hooks_in: $hooks
|
|
75
75
|
liquidity_gt: 0
|
|
76
76
|
totalValueLockedUSD_gte: $minTVL
|
|
77
77
|
${list ? `id_in: [${list}]` : ''}
|
|
@@ -101,20 +101,20 @@ async function queryAvailablePoolsForToken(dexHelper, logger, dexKey, subgraphUr
|
|
|
101
101
|
variables: {
|
|
102
102
|
token: tokenAddress,
|
|
103
103
|
count: limit,
|
|
104
|
-
hooks
|
|
104
|
+
hooks,
|
|
105
105
|
minTVL: constants_1.POOL_MIN_TVL_USD,
|
|
106
106
|
},
|
|
107
107
|
}, { timeout: constants_1.SUBGRAPH_TIMEOUT });
|
|
108
108
|
if (res.errors && res.errors.length) {
|
|
109
109
|
throw new Error(res.errors[0].message);
|
|
110
110
|
}
|
|
111
|
-
return
|
|
111
|
+
return res.data;
|
|
112
112
|
}
|
|
113
|
-
async function queryAvailablePoolsForPairFromSubgraph(dexHelper, subgraphUrl, srcToken, destToken) {
|
|
113
|
+
async function queryAvailablePoolsForPairFromSubgraph(dexHelper, subgraphUrl, srcToken, destToken, hooks = [constants_2.NULL_ADDRESS]) {
|
|
114
114
|
const ticksLimit = 300;
|
|
115
|
-
const poolsQuery = `query ($token0: Bytes!, $token1: Bytes!, $minTVL: Int!, $hooks: Bytes!) {
|
|
115
|
+
const poolsQuery = `query ($token0: Bytes!, $token1: Bytes!, $minTVL: Int!, $hooks: [Bytes!]) {
|
|
116
116
|
pools(
|
|
117
|
-
where: { token0: $token0, token1: $token1,
|
|
117
|
+
where: { token0: $token0, token1: $token1, hooks_in: $hooks, liquidity_gt: 0, totalValueLockedUSD_gte: $minTVL },
|
|
118
118
|
orderBy: totalValueLockedUSD
|
|
119
119
|
orderDirection: desc
|
|
120
120
|
) {
|
|
@@ -146,7 +146,7 @@ async function queryAvailablePoolsForPairFromSubgraph(dexHelper, subgraphUrl, sr
|
|
|
146
146
|
token0,
|
|
147
147
|
token1,
|
|
148
148
|
minTVL: constants_1.POOL_MIN_TVL_USD,
|
|
149
|
-
hooks
|
|
149
|
+
hooks,
|
|
150
150
|
},
|
|
151
151
|
}, { timeout: constants_1.SUBGRAPH_TIMEOUT });
|
|
152
152
|
if (res.errors && res.errors.length) {
|
|
@@ -154,10 +154,10 @@ async function queryAvailablePoolsForPairFromSubgraph(dexHelper, subgraphUrl, sr
|
|
|
154
154
|
}
|
|
155
155
|
return res.data.pools;
|
|
156
156
|
}
|
|
157
|
-
async function queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper, logger, dexKey, subgraphUrl, blockNumber, skip, limit, latestBlock = false) {
|
|
158
|
-
const poolsQuery = `query ($skip: Int!, $minTVL: Int!, $hooks: Bytes!) {
|
|
157
|
+
async function queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper, logger, dexKey, subgraphUrl, blockNumber, skip, limit, hooks = [constants_2.NULL_ADDRESS], latestBlock = false) {
|
|
158
|
+
const poolsQuery = `query ($skip: Int!, $minTVL: Int!, $hooks: [Bytes!]) {
|
|
159
159
|
pools(
|
|
160
|
-
where: {
|
|
160
|
+
where: { hooks_in: $hooks, liquidity_gt: 0, totalValueLockedUSD_gte: $minTVL },
|
|
161
161
|
${latestBlock ? '' : `block: { number: ${blockNumber} }`}
|
|
162
162
|
orderBy: totalValueLockedUSD
|
|
163
163
|
orderDirection: desc
|
|
@@ -180,15 +180,15 @@ async function queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper, logger, d
|
|
|
180
180
|
const res = await dexHelper.httpRequest.querySubgraph(subgraphUrl, {
|
|
181
181
|
query: poolsQuery,
|
|
182
182
|
variables: {
|
|
183
|
-
skip
|
|
184
|
-
hooks
|
|
183
|
+
skip,
|
|
184
|
+
hooks,
|
|
185
185
|
minTVL: constants_1.POOL_MIN_TVL_USD,
|
|
186
186
|
},
|
|
187
187
|
}, { timeout: constants_1.SUBGRAPH_TIMEOUT });
|
|
188
188
|
if (res.errors && res.errors.length) {
|
|
189
189
|
if (res.errors[0].message.includes('missing block')) {
|
|
190
190
|
logger.info(`${dexKey}: subgraph fallback to the latest block...`);
|
|
191
|
-
return queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper, logger, dexKey, subgraphUrl, blockNumber, skip, limit, true);
|
|
191
|
+
return queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper, logger, dexKey, subgraphUrl, blockNumber, skip, limit, hooks, true);
|
|
192
192
|
}
|
|
193
193
|
else {
|
|
194
194
|
throw new Error(res.errors[0].message);
|
|
@@ -196,9 +196,9 @@ async function queryOnePageForAllAvailablePoolsFromSubgraph(dexHelper, logger, d
|
|
|
196
196
|
}
|
|
197
197
|
return res.data.pools;
|
|
198
198
|
}
|
|
199
|
-
async function queryPoolsFromSubgraph(dexHelper, subgraphUrl, poolIds) {
|
|
200
|
-
const poolsQuery = `query ($minTVL: Int!, $hooks: Bytes
|
|
201
|
-
pools(where: {liquidity_gt: 0, totalValueLockedUSD_gte: $minTVL, id_in: $pools}) {
|
|
199
|
+
async function queryPoolsFromSubgraph(dexHelper, subgraphUrl, poolIds, hooks = [constants_2.NULL_ADDRESS]) {
|
|
200
|
+
const poolsQuery = `query ($minTVL: Int!, $hooks: [Bytes!], $pools: [Bytes!]!) {
|
|
201
|
+
pools(where: {liquidity_gt: 0, totalValueLockedUSD_gte: $minTVL, id_in: $pools, hooks_in: $hooks}) {
|
|
202
202
|
id
|
|
203
203
|
fee: feeTier
|
|
204
204
|
volumeUSD
|
|
@@ -215,11 +215,14 @@ async function queryPoolsFromSubgraph(dexHelper, subgraphUrl, poolIds) {
|
|
|
215
215
|
const res = await dexHelper.httpRequest.querySubgraph(subgraphUrl, {
|
|
216
216
|
query: poolsQuery,
|
|
217
217
|
variables: {
|
|
218
|
-
hooks
|
|
218
|
+
hooks,
|
|
219
219
|
minTVL: constants_1.POOL_MIN_TVL_USD,
|
|
220
220
|
pools: poolIds,
|
|
221
221
|
},
|
|
222
222
|
}, { timeout: constants_1.SUBGRAPH_TIMEOUT });
|
|
223
|
-
|
|
223
|
+
if (res.errors && res.errors.length) {
|
|
224
|
+
throw new Error(res.errors[0].message);
|
|
225
|
+
}
|
|
226
|
+
return res?.data?.pools ?? [];
|
|
224
227
|
}
|
|
225
228
|
//# sourceMappingURL=subgraph.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/subgraph.ts"],"names":[],"mappings":";;AAOA,8CA8DC;AAED,
|
|
1
|
+
{"version":3,"file":"subgraph.js","sourceRoot":"","sources":["../../../src/dex/uniswap-v4/subgraph.ts"],"names":[],"mappings":";;AAOA,8CA8DC;AAED,kEAiGC;AAED,wFAgEC;AAED,oGAwEC;AAED,wDA6CC;AAlWD,2CAAiE;AAIjE,+CAA+C;AAExC,KAAK,UAAU,iBAAiB,CACrC,SAAqB,EACrB,MAAc,EACd,MAAc,EACd,WAAmB,EACnB,WAAmB,EACnB,EAAU,EACV,IAAY,EACZ,KAAa,EACb,WAAW,GAAG,KAAK;IAEnB,MAAM,UAAU,GAAG;;;iBAGJ,KAAK;;;;UAIZ,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oBAAoB,WAAW,IAAI;;;;;;IAM5D,CAAC;IAEH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,aAAa,CAMnD,WAAW,EACX;QACE,KAAK,EAAE,UAAU;QACjB,SAAS,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE;KAChC,EACD,EAAE,OAAO,EAAE,4BAAgB,EAAE,CAC9B,CAAC;IAEF,IAAI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;AAEM,KAAK,UAAU,sBAAsB,CAC1C,SAAqB,EACrB,WAAmB,EACnB,OAAiB,EACjB,QAAkB,CAAC,wBAAY,CAAC;IAEhC,MAAM,UAAU,GAAG;;;;;;;;;;;;;;MAcf,CAAC;IAEL,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,aAAa,CAMnD,WAAW,EACX;QACE,KAAK,EAAE,UAAU;QACjB,SAAS,EAAE;YACT,KAAK;YACL,MAAM,EAAE,4BAAgB;YACxB,KAAK,EAAE,OAAO;SACf;KACF,EACD,EAAE,OAAO,EAAE,4BAAgB,EAAE,CAC9B,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Address, NumberAsString } from '../../types';
|
|
2
|
+
import { HookConstructor } from './hooks/types';
|
|
2
3
|
export type ModifyLiquidityParams = {
|
|
3
4
|
liquidityDelta: bigint;
|
|
4
5
|
tickLower: bigint;
|
|
@@ -95,6 +96,7 @@ export type DexParams = {
|
|
|
95
96
|
stateView: string;
|
|
96
97
|
skipPoolsWithUnconventionalFees?: boolean;
|
|
97
98
|
stateMulticall: string;
|
|
99
|
+
supportedHooks?: HookConstructor[];
|
|
98
100
|
};
|
|
99
101
|
export type PoolKey = {
|
|
100
102
|
currency0: Address;
|
|
@@ -8,6 +8,7 @@ import { LogDescription } from '@ethersproject/abi/lib.esm';
|
|
|
8
8
|
import { FactoryState } from '../uniswap-v3/types';
|
|
9
9
|
import { UniswapV4Pool } from './uniswap-v4-pool';
|
|
10
10
|
import { PoolState } from './types';
|
|
11
|
+
import { IBaseHook } from './hooks/types';
|
|
11
12
|
export declare class UniswapV4PoolManager extends StatefulEventSubscriber<PoolManagerState> {
|
|
12
13
|
readonly dexHelper: IDexHelper;
|
|
13
14
|
private readonly network;
|
|
@@ -24,7 +25,9 @@ export declare class UniswapV4PoolManager extends StatefulEventSubscriber<PoolMa
|
|
|
24
25
|
stateMulticallIface: Interface;
|
|
25
26
|
private wethAddress;
|
|
26
27
|
private poolsCacheKey;
|
|
27
|
-
|
|
28
|
+
private supportedHookAddresses;
|
|
29
|
+
private hookInstancesByAddress;
|
|
30
|
+
constructor(dexHelper: IDexHelper, parentName: string, network: number, config: DexParams, supportedHooks: IBaseHook[], logger: Logger, mapKey?: string);
|
|
28
31
|
initialize(blockNumber: number, options?: InitializeStateOptions<PoolManagerState>): Promise<void>;
|
|
29
32
|
generateState(): FactoryState;
|
|
30
33
|
protected processLog(_: DeepReadonly<FactoryState>, log: Readonly<Log>): Promise<FactoryState>;
|
|
@@ -33,6 +36,9 @@ export declare class UniswapV4PoolManager extends StatefulEventSubscriber<PoolMa
|
|
|
33
36
|
private queryAllAvailablePools;
|
|
34
37
|
handleInitializeEvent(event: LogDescription, log: Log): Promise<PoolManagerState>;
|
|
35
38
|
private isPoolWithUnconventionalFees;
|
|
39
|
+
private registerHookPools;
|
|
40
|
+
private getHook;
|
|
36
41
|
private getBitmapRange;
|
|
37
42
|
generateMultiplePoolStates(pools: SubgraphConnectorPool[], blockNumber: number): Promise<(PoolState | null)[]>;
|
|
43
|
+
private isHookSupported;
|
|
38
44
|
}
|
|
@@ -31,7 +31,9 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
31
31
|
stateMulticallIface;
|
|
32
32
|
wethAddress;
|
|
33
33
|
poolsCacheKey = 'pools_cache';
|
|
34
|
-
|
|
34
|
+
supportedHookAddresses;
|
|
35
|
+
hookInstancesByAddress;
|
|
36
|
+
constructor(dexHelper, parentName, network, config, supportedHooks, logger, mapKey = '') {
|
|
35
37
|
super(parentName, `${parentName} PoolManager`, dexHelper, logger, false, mapKey);
|
|
36
38
|
this.dexHelper = dexHelper;
|
|
37
39
|
this.network = network;
|
|
@@ -44,6 +46,11 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
44
46
|
this.wethAddress =
|
|
45
47
|
this.dexHelper.config.data.wrappedNativeTokenAddress.toLowerCase();
|
|
46
48
|
this.logDecoder = (log) => this.poolManagerIface.parseLog(log);
|
|
49
|
+
this.hookInstancesByAddress = Object.fromEntries(supportedHooks.map(hook => [hook.address.toLowerCase(), hook]));
|
|
50
|
+
this.supportedHookAddresses = [
|
|
51
|
+
constants_1.NULL_ADDRESS, // always include pools without hooks
|
|
52
|
+
...Object.keys(this.hookInstancesByAddress),
|
|
53
|
+
];
|
|
47
54
|
// Add handlers
|
|
48
55
|
this.handlers['Initialize'] = this.handleInitializeEvent.bind(this);
|
|
49
56
|
}
|
|
@@ -74,7 +81,14 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
74
81
|
this.eventPools[_poolId] = null;
|
|
75
82
|
return null;
|
|
76
83
|
}
|
|
77
|
-
|
|
84
|
+
const poolKey = {
|
|
85
|
+
currency0: subgraphPool.token0.address.toLowerCase(),
|
|
86
|
+
currency1: subgraphPool.token1.address.toLowerCase(),
|
|
87
|
+
fee: subgraphPool.fee,
|
|
88
|
+
tickSpacing: parseInt(subgraphPool.tickSpacing),
|
|
89
|
+
hooks: subgraphPool.hooks,
|
|
90
|
+
};
|
|
91
|
+
eventPool = new uniswap_v4_pool_1.UniswapV4Pool(this.dexHelper, this.parentName, this.network, this.config, this.logger, this.mapKey, _poolId, poolKey.currency0, poolKey.currency1, poolKey.fee, poolKey.hooks, poolKey.tickSpacing.toString(), this.getHook(_poolId, poolKey));
|
|
78
92
|
await eventPool.initialize(blockNumber);
|
|
79
93
|
this.eventPools[_poolId] = eventPool;
|
|
80
94
|
return this.eventPools[_poolId];
|
|
@@ -118,7 +132,7 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
118
132
|
async queryAllAvailablePools(blockNumber) {
|
|
119
133
|
const staticPoolsList = config_1.UniswapV4PoolsList[this.network];
|
|
120
134
|
if (staticPoolsList) {
|
|
121
|
-
return staticPoolsList;
|
|
135
|
+
return staticPoolsList.filter(pool => this.isHookSupported(pool.hooks.toLowerCase()));
|
|
122
136
|
}
|
|
123
137
|
const cachedPoolsRaw = await this.dexHelper.cache.getAndCacheLocally(this.parentName, this.network, this.poolsCacheKey, constants_2.POOL_CACHE_REFRESH_INTERVAL);
|
|
124
138
|
let cachedPools = [];
|
|
@@ -127,6 +141,7 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
127
141
|
const poolsTTL = await this.dexHelper.cache.ttl(this.parentName, this.network, this.poolsCacheKey);
|
|
128
142
|
if (cachedPools.length &&
|
|
129
143
|
poolsTTL > constants_2.POOL_CACHE_STORE_INTERVAL - constants_2.POOL_CACHE_REFRESH_INTERVAL) {
|
|
144
|
+
this.registerHookPools(cachedPools);
|
|
130
145
|
return cachedPools;
|
|
131
146
|
}
|
|
132
147
|
this.logger.info(`Pools cache TTL is ${poolsTTL}, refreshing`);
|
|
@@ -134,13 +149,14 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
134
149
|
let pools = [];
|
|
135
150
|
try {
|
|
136
151
|
const defaultPerPageLimit = 1000;
|
|
152
|
+
const hooksToQuery = this.supportedHookAddresses;
|
|
137
153
|
let curPage = 0;
|
|
138
|
-
let currentSubgraphPools = await (0, subgraph_1.queryOnePageForAllAvailablePoolsFromSubgraph)(this.dexHelper, this.logger, this.parentName, this.config.subgraphURL, blockNumber, curPage * defaultPerPageLimit, defaultPerPageLimit);
|
|
154
|
+
let currentSubgraphPools = await (0, subgraph_1.queryOnePageForAllAvailablePoolsFromSubgraph)(this.dexHelper, this.logger, this.parentName, this.config.subgraphURL, blockNumber, curPage * defaultPerPageLimit, defaultPerPageLimit, hooksToQuery);
|
|
139
155
|
pools = pools.concat(currentSubgraphPools);
|
|
140
156
|
while (currentSubgraphPools.length === defaultPerPageLimit) {
|
|
141
157
|
curPage++;
|
|
142
158
|
currentSubgraphPools =
|
|
143
|
-
await (0, subgraph_1.queryOnePageForAllAvailablePoolsFromSubgraph)(this.dexHelper, this.logger, this.parentName, this.config.subgraphURL, blockNumber, curPage * defaultPerPageLimit, defaultPerPageLimit);
|
|
159
|
+
await (0, subgraph_1.queryOnePageForAllAvailablePoolsFromSubgraph)(this.dexHelper, this.logger, this.parentName, this.config.subgraphURL, blockNumber, curPage * defaultPerPageLimit, defaultPerPageLimit, hooksToQuery);
|
|
144
160
|
pools = pools.concat(currentSubgraphPools);
|
|
145
161
|
}
|
|
146
162
|
if (this.config.skipPoolsWithUnconventionalFees) {
|
|
@@ -155,6 +171,7 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
155
171
|
// always refresh pools in cache, even when subgraph queries failed
|
|
156
172
|
// so next time we can use previously cached pools
|
|
157
173
|
this.dexHelper.cache.setexAndCacheLocally(this.parentName, this.network, this.poolsCacheKey, constants_2.POOL_CACHE_STORE_INTERVAL, JSON.stringify(pools));
|
|
174
|
+
this.registerHookPools(pools);
|
|
158
175
|
return pools;
|
|
159
176
|
}
|
|
160
177
|
async handleInitializeEvent(event, log) {
|
|
@@ -164,9 +181,7 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
164
181
|
const fee = event.args.fee;
|
|
165
182
|
const tickSpacing = parseInt(event.args.tickSpacing);
|
|
166
183
|
const hooks = event.args.hooks;
|
|
167
|
-
|
|
168
|
-
const tick = parseInt(event.args.tick);
|
|
169
|
-
if (hooks !== constants_1.NULL_ADDRESS) {
|
|
184
|
+
if (!this.isHookSupported(hooks.toLowerCase())) {
|
|
170
185
|
this.logger.warn(`Pool ${id} has hooks ${hooks}, which is not supported yet. Skipping.`);
|
|
171
186
|
return {};
|
|
172
187
|
}
|
|
@@ -193,7 +208,14 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
193
208
|
},
|
|
194
209
|
tickSpacing: tickSpacing.toString(),
|
|
195
210
|
});
|
|
196
|
-
const
|
|
211
|
+
const poolKey = {
|
|
212
|
+
currency0: currency0.toLowerCase(),
|
|
213
|
+
currency1: currency1.toLowerCase(),
|
|
214
|
+
fee: fee.toString(),
|
|
215
|
+
tickSpacing,
|
|
216
|
+
hooks,
|
|
217
|
+
};
|
|
218
|
+
const eventPool = new uniswap_v4_pool_1.UniswapV4Pool(this.dexHelper, this.parentName, this.network, this.config, this.logger, this.mapKey, id, poolKey.currency0, poolKey.currency1, poolKey.fee, poolKey.hooks, poolKey.tickSpacing.toString(), this.getHook(id, poolKey));
|
|
197
219
|
await eventPool.initialize(log.blockNumber);
|
|
198
220
|
this.eventPools[id] = eventPool;
|
|
199
221
|
return {};
|
|
@@ -201,6 +223,26 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
201
223
|
isPoolWithUnconventionalFees(fee) {
|
|
202
224
|
return +fee % 100 !== 0;
|
|
203
225
|
}
|
|
226
|
+
registerHookPools(pools) {
|
|
227
|
+
for (const pool of pools) {
|
|
228
|
+
const poolKey = {
|
|
229
|
+
currency0: pool.token0.address.toLowerCase(),
|
|
230
|
+
currency1: pool.token1.address.toLowerCase(),
|
|
231
|
+
fee: pool.fee,
|
|
232
|
+
tickSpacing: parseInt(pool.tickSpacing),
|
|
233
|
+
hooks: pool.hooks,
|
|
234
|
+
};
|
|
235
|
+
this.getHook(pool.id, poolKey);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
getHook(poolId, poolKey) {
|
|
239
|
+
const hook = this.hookInstancesByAddress[poolKey.hooks.toLowerCase()];
|
|
240
|
+
if (!hook) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
hook.registerPool(poolId, poolKey);
|
|
244
|
+
return hook;
|
|
245
|
+
}
|
|
204
246
|
getBitmapRange() {
|
|
205
247
|
const networkId = this.dexHelper.config.data.network;
|
|
206
248
|
const tickBitMapToUse = constants_3.TICK_BITMAP_TO_USE_BY_CHAIN[networkId] ?? constants_3.TICK_BITMAP_TO_USE;
|
|
@@ -282,6 +324,9 @@ class UniswapV4PoolManager extends stateful_event_subscriber_1.StatefulEventSubs
|
|
|
282
324
|
});
|
|
283
325
|
return poolStates;
|
|
284
326
|
}
|
|
327
|
+
isHookSupported(hook) {
|
|
328
|
+
return this.supportedHookAddresses.includes(hook.toLowerCase());
|
|
329
|
+
}
|
|
285
330
|
}
|
|
286
331
|
exports.UniswapV4PoolManager = UniswapV4PoolManager;
|
|
287
332
|
//# sourceMappingURL=uniswap-v4-pool-manager.js.map
|