-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathBaseHooks.sol
More file actions
122 lines (109 loc) · 3.48 KB
/
BaseHooks.sol
File metadata and controls
122 lines (109 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.24;
import { IHooks } from "@balancer-labs/v3-interfaces/contracts/vault/IHooks.sol";
import {
AddLiquidityKind,
HookFlags,
LiquidityManagement,
RemoveLiquidityKind,
TokenConfig,
PoolSwapParams,
AfterSwapParams
} from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol";
/**
* @notice Base for pool hooks contracts.
* @dev Hook contracts that only implement a subset of callbacks can inherit from here instead of IHooks,
* and only override what they need. `VaultGuard` allows use of the `onlyVault` modifier, which isn't used
* in this abstract contract, but should be used in real derived hook contracts.
*/
abstract contract BaseHooks is IHooks {
/// @inheritdoc IHooks
function onRegister(
address,
address,
TokenConfig[] memory,
LiquidityManagement calldata
) public virtual returns (bool) {
// By default, deny all factories. This method must be overwritten by the hook contract.
return false;
}
/// @inheritdoc IHooks
function getHookFlags() public view virtual returns (HookFlags memory);
/// @inheritdoc IHooks
function onBeforeInitialize(uint256[] memory, bytes memory) public virtual returns (bool) {
return false;
}
/// @inheritdoc IHooks
function onAfterInitialize(uint256[] memory, uint256, bytes memory) public virtual returns (bool) {
return false;
}
/// @inheritdoc IHooks
function onBeforeAddLiquidity(
address,
address,
AddLiquidityKind,
uint256[] memory,
uint256,
uint256[] memory,
bytes memory
) public virtual returns (bool) {
return false;
}
/// @inheritdoc IHooks
function onAfterAddLiquidity(
address,
address,
AddLiquidityKind,
uint256[] memory,
uint256[] memory amountsInRaw,
uint256,
uint256[] memory,
bytes memory
) public virtual returns (bool, uint256[] memory) {
return (false, amountsInRaw);
}
/// @inheritdoc IHooks
function onBeforeRemoveLiquidity(
address,
address,
RemoveLiquidityKind,
uint256,
uint256[] memory,
uint256[] memory,
bytes memory
) public virtual returns (bool) {
return false;
}
/// @inheritdoc IHooks
function onAfterRemoveLiquidity(
address,
address,
RemoveLiquidityKind,
uint256,
uint256[] memory,
uint256[] memory amountsOutRaw,
uint256[] memory,
bytes memory
) public virtual returns (bool, uint256[] memory) {
return (false, amountsOutRaw);
}
/// @inheritdoc IHooks
function onBeforeSwap(PoolSwapParams calldata, address) public virtual returns (bool) {
// return false to trigger an error if shouldCallBeforeSwap is true but this function is not overridden.
return false;
}
/// @inheritdoc IHooks
function onAfterSwap(AfterSwapParams calldata) public virtual returns (bool, uint256) {
// return false to trigger an error if shouldCallAfterSwap is true but this function is not overridden.
// The second argument is not used.
return (false, 0);
}
/// @inheritdoc IHooks
function onComputeDynamicSwapFeePercentage(
PoolSwapParams calldata,
address,
uint256
) public view virtual returns (bool, uint256) {
return (false, 0);
}
}