Description:
Proxy contract enabling upgradeable smart contract patterns. Delegates calls to an implementation contract.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/governance/Governable.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
/**
* @title Base for contracts that are managed by the Origin Protocol's Governor.
* @dev Copy of the openzeppelin Ownable.sol contract with nomenclature change
* from owner to governor and renounce methods removed. Does not use
* Context.sol like Ownable.sol does for simplification.
* @author Origin Protocol Inc
*/
abstract contract Governable {
// Storage position of the owner and pendingOwner of the contract
// keccak256("OUSD.governor");
bytes32 private constant governorPosition =
0x7bea13895fa79d2831e0a9e28edede30099005a50d652d8957cf8a607ee6ca4a;
// keccak256("OUSD.pending.governor");
bytes32 private constant pendingGovernorPosition =
0x44c4d30b2eaad5130ad70c3ba6972730566f3e6359ab83e800d905c61b1c51db;
// keccak256("OUSD.reentry.status");
bytes32 private constant reentryStatusPosition =
0x53bf423e48ed90e97d02ab0ebab13b2a235a6bfbe9c321847d5c175333ac4535;
// See OpenZeppelin ReentrancyGuard implementation
uint256 constant _NOT_ENTERED = 1;
uint256 constant _ENTERED = 2;
event PendingGovernorshipTransfer(
address indexed previousGovernor,
address indexed newGovernor
);
event GovernorshipTransferred(
address indexed previousGovernor,
address indexed newGovernor
);
/**
* @notice Returns the address of the current Governor.
*/
function governor() public view returns (address) {
return _governor();
}
/**
* @dev Returns the address of the current Governor.
*/
function _governor() internal view returns (address governorOut) {
bytes32 position = governorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
governorOut := sload(position)
}
}
/**
* @dev Returns the address of the pending Governor.
*/
function _pendingGovernor()
internal
view
returns (address pendingGovernor)
{
bytes32 position = pendingGovernorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
pendingGovernor := sload(position)
}
}
/**
* @dev Throws if called by any account other than the Governor.
*/
modifier onlyGovernor() {
require(isGovernor(), "Caller is not the Governor");
_;
}
/**
* @notice Returns true if the caller is the current Governor.
*/
function isGovernor() public view returns (bool) {
return msg.sender == _governor();
}
function _setGovernor(address newGovernor) internal {
emit GovernorshipTransferred(_governor(), newGovernor);
bytes32 position = governorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, newGovernor)
}
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
bytes32 position = reentryStatusPosition;
uint256 _reentry_status;
// solhint-disable-next-line no-inline-assembly
assembly {
_reentry_status := sload(position)
}
// On the first call to nonReentrant, _notEntered will be true
require(_reentry_status != _ENTERED, "Reentrant call");
// Any calls to nonReentrant after this point will fail
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, _ENTERED)
}
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, _NOT_ENTERED)
}
}
function _setPendingGovernor(address newGovernor) internal {
bytes32 position = pendingGovernorPosition;
// solhint-disable-next-line no-inline-assembly
assembly {
sstore(position, newGovernor)
}
}
/**
* @notice Transfers Governance of the contract to a new account (`newGovernor`).
* Can only be called by the current Governor. Must be claimed for this to complete
* @param _newGovernor Address of the new Governor
*/
function transferGovernance(address _newGovernor) external onlyGovernor {
_setPendingGovernor(_newGovernor);
emit PendingGovernorshipTransfer(_governor(), _newGovernor);
}
/**
* @notice Claim Governance of the contract to a new account (`newGovernor`).
* Can only be called by the new Governor.
*/
function claimGovernance() external {
require(
msg.sender == _pendingGovernor(),
"Only the pending Governor can complete the claim"
);
_changeGovernor(msg.sender);
}
/**
* @dev Change Governance of the contract to a new account (`newGovernor`).
* @param _newGovernor Address of the new Governor
*/
function _changeGovernor(address _newGovernor) internal {
require(_newGovernor != address(0), "New Governor is address(0)");
_setGovernor(_newGovernor);
}
}
"
},
"contracts/interfaces/poolBooster/IPoolBoostCentralRegistry.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
interface IPoolBoostCentralRegistry {
/**
* @dev all the supported pool booster types are listed here. It is possible
* to have multiple versions of the factory that supports the same type of
* pool booster. Factories are immutable and this can happen when a factory
* or related pool booster required code update.
* e.g. "PoolBoosterSwapxDouble" & "PoolBoosterSwapxDouble_v2"
*/
enum PoolBoosterType {
// Supports bribing 2 contracts per pool. Appropriate for Ichi vault concentrated
// liquidity pools where (which is expected in most/all cases) both pool gauges
// require bribing.
SwapXDoubleBooster,
// Supports bribing a single contract per pool. Appropriate for Classic Stable &
// Classic Volatile pools and Ichi vaults where only 1 side (1 of the 2 gauges)
// needs bribing
SwapXSingleBooster,
// Supports bribing a single contract per pool. Appropriate for Metropolis pools
MetropolisBooster,
// Supports creating a Merkl campaign.
MerklBooster
}
struct PoolBoosterEntry {
address boosterAddress;
address ammPoolAddress;
PoolBoosterType boosterType;
}
event PoolBoosterCreated(
address poolBoosterAddress,
address ammPoolAddress,
PoolBoosterType poolBoosterType,
address factoryAddress
);
event PoolBoosterRemoved(address poolBoosterAddress);
function emitPoolBoosterCreated(
address _poolBoosterAddress,
address _ammPoolAddress,
PoolBoosterType _boosterType
) external;
function emitPoolBoosterRemoved(address _poolBoosterAddress) external;
}
"
},
"contracts/poolBooster/PoolBoostCentralRegistry.sol": {
"content": "// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;
import { Governable } from "../governance/Governable.sol";
import { IPoolBoostCentralRegistry } from "../interfaces/poolBooster/IPoolBoostCentralRegistry.sol";
/**
* @title Contract that holds all governance approved pool booster Factory
* implementation deployments
* @author Origin Protocol Inc
*/
contract PoolBoostCentralRegistry is Governable, IPoolBoostCentralRegistry {
event FactoryApproved(address factoryAddress);
event FactoryRemoved(address factoryAddress);
// @notice List of approved factories
address[] public factories;
modifier onlyApprovedFactories() {
require(isApprovedFactory(msg.sender), "Not an approved factory");
_;
}
constructor() {
// set the governor of the implementation contract to zero address
_setGovernor(address(0));
}
/**
* @notice Adds a factory address to the approved factory addresses
* @param _factoryAddress address of the factory
*/
function approveFactory(address _factoryAddress) external onlyGovernor {
require(_factoryAddress != address(0), "Invalid address");
require(
!isApprovedFactory(_factoryAddress),
"Factory already approved"
);
factories.push(_factoryAddress);
emit FactoryApproved(_factoryAddress);
}
/**
* @notice Removes the factory from approved factory addresses
* @param _factoryAddress address of the factory
*/
function removeFactory(address _factoryAddress) external onlyGovernor {
require(_factoryAddress != address(0), "Invalid address");
uint256 length = factories.length;
bool factoryRemoved = false;
for (uint256 i = 0; i < length; i++) {
if (factories[i] != _factoryAddress) {
continue;
}
factories[i] = factories[length - 1];
factories.pop();
emit FactoryRemoved(_factoryAddress);
factoryRemoved = true;
break;
}
require(factoryRemoved, "Not an approved factory");
emit FactoryRemoved(_factoryAddress);
}
/**
* @notice Emits a pool booster created event
* @dev This has been created as a convenience method for the monitoring to have
* an index of all of the created pool boosters by only listening to the
* events of this contract.
* @param _poolBoosterAddress address of the pool booster created
* @param _ammPoolAddress address of the AMM pool forwarding yield to the pool booster
* @param _boosterType PoolBoosterType the type of the pool booster
*/
function emitPoolBoosterCreated(
address _poolBoosterAddress,
address _ammPoolAddress,
PoolBoosterType _boosterType
) external onlyApprovedFactories {
emit PoolBoosterCreated(
_poolBoosterAddress,
_ammPoolAddress,
_boosterType,
msg.sender // address of the factory
);
}
/**
* @notice Emits a pool booster removed event
* @dev This has been created as a convenience method for the monitoring to have
* an index of all of the removed pool boosters by only listening to the
* events of this contract.
* @param _poolBoosterAddress address of the pool booster to be removed
*/
function emitPoolBoosterRemoved(address _poolBoosterAddress)
external
onlyApprovedFactories
{
emit PoolBoosterRemoved(_poolBoosterAddress);
}
/**
* @notice Returns true if the factory is approved
* @param _factoryAddress address of the factory
*/
function isApprovedFactory(address _factoryAddress)
public
view
returns (bool)
{
uint256 length = factories.length;
for (uint256 i = 0; i < length; i++) {
if (factories[i] == _factoryAddress) {
return true;
}
}
return false;
}
/**
* @notice Returns all supported factories
*/
function getAllFactories() external view returns (address[] memory) {
return factories;
}
}
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-03 09:19:43
Comments
Log in to comment.
No comments yet.