Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion contracts/BalancerGlobal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ contract BalancerGlobal {
function canCreateVaultPermissionlessly(
address _gauge
) public view returns (bool) {
if (checkIfGaugeKilled(_gauge)) return false;
return latestStandardVaultFromGauge(_gauge) == address(0);
}

Expand Down Expand Up @@ -678,7 +679,7 @@ contract BalancerGlobal {
if (!_permissionedUser) {
require(
canCreateVaultPermissionlessly(_gauge),
"Vault already exists"
"Vault already exists, or gauge killed."
);
}
address lptoken = ICurveGauge(_gauge).lp_token();
Expand Down Expand Up @@ -889,4 +890,17 @@ contract BalancerGlobal {
// approve our new voter strategy on the proxy
proxy.approveStrategy(_gauge, curveStrategy);
}

// Not all gauges implement is_killed. So we use a custom checker.
function checkIfGaugeKilled(address _gauge) public view returns (bool) {
(bool success, bytes memory data) = _gauge.staticcall(abi.encodeWithSignature("is_killed()"));

// If the function call was successful and the function returned true, revert.
if (success && data.length > 0 && abi.decode(data, (bool))) {
return true;
}

// If the function doesn't exist or if it's not killed, return false.
return false;
}
}