Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"contracts/Guardable.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
/**
* @title Guardable
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (a guardian) that can be granted exclusive access to
* specific functions.
*
* This module is essentially a renamed version of the OpenZeppelin Ownable contract.
* The main difference is in terminology:
* - 'owner' is renamed to 'guardian'
* - 'ownership' concepts are renamed to 'watch' or 'guard'
*
* By default, the guardian account will be the one that deploys the contract. This
* can later be changed with {transferWatch}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyGuardian`, which can be applied to your functions to restrict their use to
* the guardian.
*/
abstract contract Guardable {
address private _guardian;
event WatchTransferred(address indexed previousGuardian, address indexed newGuardian);
/**
* @dev Initializes the contract setting the deployer as the initial guardian.
*/
constructor() {
_transferWatch(msg.sender);
}
/**
* @dev Throws if called by any account other than the guardian.
*/
modifier onlyGuardian() {
_checkGuardian();
_;
}
/**
* @dev Returns the address of the current guardian.
*/
function guardian() public view virtual returns (address) {
return _guardian;
}
/**
* @dev Throws if the sender is not the guardian.
*/
function _checkGuardian() internal view virtual {
require(guardian() == msg.sender, "Guardable: caller is not the guardian");
}
/**
* @dev Leaves the contract without guardian. It will not be possible to call
* `onlyGuardian` functions anymore. Can only be called by the current guardian.
*
* NOTE: Renouncing guardianship will leave the contract without a guardian,
* thereby removing any functionality that is only available to the guardian.
*/
function releaseGuard() public virtual onlyGuardian {
_transferWatch(address(0));
}
/**
* @dev Transfers guardianship of the contract to a new account (`newGuardian`).
* Can only be called by the current guardian.
*/
function transferWatch(address newGuardian) public virtual onlyGuardian {
require(newGuardian != address(0), "Guardable: new guardian is the zero address");
_transferWatch(newGuardian);
}
/**
* @dev Transfers guardianship of the contract to a new account (`newGuardian`).
* Internal function without access restriction.
*/
function _transferWatch(address newGuardian) internal virtual {
address oldGuardian = _guardian;
_guardian = newGuardian;
emit WatchTransferred(oldGuardian, newGuardian);
}
}"
},
"contracts/interfaces/IActivePool.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import "./IPool.sol";
import "./ICanReceiveCollateral.sol";
/// @title IActivePool Interface
/// @notice Interface for the ActivePool contract which manages the main collateral pool
interface IActivePool is IPool, ICanReceiveCollateral {
/// @notice Emitted when the stable debt in the ActivePool is updated
/// @param _STABLEDebt The new total stable debt amount
event ActivePoolStableDebtUpdated(uint _STABLEDebt);
/// @notice Emitted when the collateral balance in the ActivePool is updated
/// @param _Collateral The new total collateral amount
event ActivePoolCollateralBalanceUpdated(uint _Collateral);
/// @notice Sends collateral from the ActivePool to a specified account
/// @param _account The address of the account to receive the collateral
/// @param _amount The amount of collateral to send
function sendCollateral(address _account, uint _amount) external;
/// @notice Sets the addresses of connected contracts and components
/// @param _positionControllerAddress Address of the PositionController contract
/// @param _positionManagerAddress Address of the PositionManager contract
/// @param _backstopPoolAddress Address of the BackstopPool contract
/// @param _defaultPoolAddress Address of the DefaultPool contract
/// @param _collateralAssetAddress Address of the collateral asset token
function setAddresses(
address _positionControllerAddress,
address _positionManagerAddress,
address _backstopPoolAddress,
address _defaultPoolAddress,
address _collateralAssetAddress
) external;
}"
},
"contracts/interfaces/ICanReceiveCollateral.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
// Common interface for the contracts which need internal collateral counters to be updated.
interface ICanReceiveCollateral {
function receiveCollateral(address asset, uint amount) external;
}
"
},
"contracts/interfaces/IPool.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
/// @title IPool Interface
/// @notice Interface for Pool contracts that manage collateral and stable debt
interface IPool {
/// @notice Emitted when collateral is sent from the pool
/// @param _to The address receiving the collateral
/// @param _amount The amount of collateral sent
event CollateralSent(address _to, uint _amount);
/// @notice Gets the total amount of collateral in the pool
/// @return The total amount of collateral
function getCollateral() external view returns (uint);
/// @notice Gets the total amount of stable debt in the pool
/// @return The total amount of stable debt
function getStableDebt() external view returns (uint);
/// @notice Increases the stable debt in the pool
/// @param _amount The amount to increase the debt by
function increaseStableDebt(uint _amount) external;
/// @notice Decreases the stable debt in the pool
/// @param _amount The amount to decrease the debt by
function decreaseStableDebt(uint _amount) external;
}"
},
"contracts/interfaces/IPositionManager.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
/// @title IPositionManager Interface
/// @notice Interface for the PositionManager contract which manages individual positions
interface IPositionManager {
/// @notice Emitted when a redemption occurs
/// @param _attemptedStableAmount The amount of stable tokens attempted to redeem
/// @param _actualStableAmount The actual amount of stable tokens redeemed
/// @param _CollateralSent The amount of collateral sent to the redeemer
/// @param _CollateralFee The fee paid in collateral for the redemption
event Redemption(uint _attemptedStableAmount, uint _actualStableAmount, uint _CollateralSent, uint _CollateralFee);
/// @notice Emitted when total stakes are updated
/// @param _newTotalStakes The new total stakes value
event TotalStakesUpdated(uint _newTotalStakes);
/// @notice Emitted when system snapshots are updated
/// @param _totalStakesSnapshot The new total stakes snapshot
/// @param _totalCollateralSnapshot The new total collateral snapshot
event SystemSnapshotsUpdated(uint _totalStakesSnapshot, uint _totalCollateralSnapshot);
/// @notice Emitted when L terms are updated
/// @param _L_Collateral The new L_Collateral value
/// @param _L_STABLE The new L_STABLE value
event LTermsUpdated(uint _L_Collateral, uint _L_STABLE);
/// @notice Emitted when position snapshots are updated
/// @param _L_Collateral The new L_Collateral value for the position
/// @param _L_STABLEDebt The new L_STABLEDebt value for the position
event PositionSnapshotsUpdated(uint _L_Collateral, uint _L_STABLEDebt);
/// @notice Emitted when a position's index is updated
/// @param _borrower The address of the position owner
/// @param _newIndex The new index value
event PositionIndexUpdated(address _borrower, uint _newIndex);
/// @notice Get the total count of position owners
/// @return The number of position owners
function getPositionOwnersCount() external view returns (uint);
/// @notice Get a position owner's address by index
/// @param _index The index in the position owners array
/// @return The address of the position owner
function getPositionFromPositionOwnersArray(uint _index) external view returns (address);
/// @notice Get the nominal ICR (Individual Collateral Ratio) of a position
/// @param _borrower The address of the position owner
/// @return The nominal ICR of the position
function getNominalICR(address _borrower) external view returns (uint);
/// @notice Get the current ICR of a position
/// @param _borrower The address of the position owner
/// @param _price The current price of the collateral
/// @return The current ICR of the position
function getCurrentICR(address _borrower, uint _price) external view returns (uint);
/// @notice Liquidate a single position
/// @param _borrower The address of the position owner to liquidate
function liquidate(address _borrower) external;
/// @notice Liquidate multiple positions
/// @param _n The number of positions to attempt to liquidate
function liquidatePositions(uint _n) external;
/// @notice Batch liquidate a specific set of positions
/// @param _positionArray An array of position owner addresses to liquidate
function batchLiquidatePositions(address[] calldata _positionArray) external;
/// @notice Queue a redemption request
/// @param _stableAmount The amount of stable tokens to queue for redemption
function queueRedemption(uint _stableAmount) external;
/// @notice Redeem collateral for stable tokens
/// @param _stableAmount The amount of stable tokens to redeem
/// @param _firstRedemptionHint The address of the first position to consider for redemption
/// @param _upperPartialRedemptionHint The address of the position just above the partial redemption
/// @param _lowerPartialRedemptionHint The address of the position just below the partial redemption
/// @param _partialRedemptionHintNICR The nominal ICR of the partial redemption hint
/// @param _maxIterations The maximum number of iterations to perform in the redemption algorithm
/// @param _maxFee The maximum acceptable fee percentage for the redemption
function redeemCollateral(
uint _stableAmount,
address _firstRedemptionHint,
address _upperPartialRedemptionHint,
address _lowerPartialRedemptionHint,
uint _partialRedemptionHintNICR,
uint _maxIterations,
uint _maxFee
) external;
/// @notice Update the stake and total stakes for a position
/// @param _borrower The address of the position owner
/// @return The new stake value
function updateStakeAndTotalStakes(address _borrower) external returns (uint);
/// @notice Update the reward snapshots for a position
/// @param _borrower The address of the position owner
function updatePositionRewardSnapshots(address _borrower) external;
/// @notice Add a position owner to the array of position owners
/// @param _borrower The address of the position owner
/// @return index The index of the new position owner in the array
function addPositionOwnerToArray(address _borrower) external returns (uint index);
/// @notice Apply pending rewards to a position
/// @param _borrower The address of the position owner
function applyPendingRewards(address _borrower) external;
/// @notice Get the pending collateral reward for a position
/// @param _borrower The address of the position owner
/// @return The amount of pending collateral reward
function getPendingCollateralReward(address _borrower) external view returns (uint);
/// @notice Get the pending stable debt reward for a position
/// @param _borrower The address of the position owner
/// @return The amount of pending stable debt reward
function getPendingStableDebtReward(address _borrower) external view returns (uint);
/// @notice Check if a position has pending rewards
/// @param _borrower The address of the position owner
/// @return True if the position has pending rewards, false otherwise
function hasPendingRewards(address _borrower) external view returns (bool);
/// @notice Get the entire debt and collateral for a position, including pending rewards
/// @param _borrower The address of the position owner
/// @return debt The total debt of the position
/// @return coll The total collateral of the position
/// @return pendingStableDebtReward The pending stable debt reward
/// @return pendingCollateralReward The pending collateral reward
function getEntireDebtAndColl(address _borrower)
external view returns (uint debt, uint coll, uint pendingStableDebtReward, uint pendingCollateralReward);
/// @notice Close a position
/// @param _borrower The address of the position owner
function closePosition(address _borrower) external;
/// @notice Remove the stake for a position
/// @param _borrower The address of the position owner
function removeStake(address _borrower) external;
/// @notice Get the current redemption rate
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The current redemption rate
function getRedemptionRate(uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Get the redemption rate with decay
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The redemption rate with decay applied
function getRedemptionRateWithDecay(uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Get the redemption fee with decay
/// @param _CollateralDrawn The amount of collateral drawn
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The redemption fee with decay applied
function getRedemptionFeeWithDecay(uint _CollateralDrawn, uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Get the current borrowing rate
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The current borrowing rate
function getBorrowingRate(uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Get the borrowing rate with decay
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The borrowing rate with decay applied
function getBorrowingRateWithDecay(uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Get the borrowing fee
/// @param stableDebt The amount of stable debt
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The borrowing fee
function getBorrowingFee(uint stableDebt, uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Get the borrowing fee with decay
/// @param _stableDebt The amount of stable debt
/// @param suggestedAdditiveFeePCT The suggested additive fee percentage
/// @return The borrowing fee with decay applied
function getBorrowingFeeWithDecay(uint _stableDebt, uint suggestedAdditiveFeePCT) external view returns (uint);
/// @notice Decay the base rate from borrowing
function decayBaseRateFromBorrowing() external;
/// @notice Get the status of a position
/// @param _borrower The address of the position owner
/// @return The status of the position
function getPositionStatus(address _borrower) external view returns (uint);
/// @notice Get the stake of a position
/// @param _borrower The address of the position owner
/// @return The stake of the position
function getPositionStake(address _borrower) external view returns (uint);
/// @notice Get the debt of a position
/// @param _borrower The address of the position owner
/// @return The debt of the position
function getPositionDebt(address _borrower) external view returns (uint);
/// @notice Get the collateral of a position
/// @param _borrower The address of the position owner
/// @return The collateral of the position
function getPositionColl(address _borrower) external view returns (uint);
/// @notice Set the status of a position
/// @param _borrower The address of the position owner
/// @param num The new status value
function setPositionStatus(address _borrower, uint num) external;
/// @notice Increase the collateral of a position
/// @param _borrower The address of the position owner
/// @param _collIncrease The amount of collateral to increase
/// @return The new collateral amount
function increasePositionColl(address _borrower, uint _collIncrease) external returns (uint);
/// @notice Decrease the collateral of a position
/// @param _borrower The address of the position owner
/// @param _collDecrease The amount of collateral to decrease
/// @return The new collateral amount
function decreasePositionColl(address _borrower, uint _collDecrease) external returns (uint);
/// @notice Increase the debt of a position
/// @param _borrower The address of the position owner
/// @param _debtIncrease The amount of debt to increase
/// @return The new debt amount
function increasePositionDebt(address _borrower, uint _debtIncrease) external returns (uint);
/// @notice Decrease the debt of a position
/// @param _borrower The address of the position owner
/// @param _debtDecrease The amount of debt to decrease
/// @return The new debt amount
function decreasePositionDebt(address _borrower, uint _debtDecrease) external returns (uint);
/// @notice Get the entire debt of the system
/// @return total The total debt in the system
function getEntireDebt() external view returns (uint total);
/// @notice Get the entire collateral in the system
/// @return total The total collateral in the system
function getEntireCollateral() external view returns (uint total);
/// @notice Get the Total Collateral Ratio (TCR) of the system
/// @param _price The current price of the collateral
/// @return TCR The Total Collateral Ratio
function getTCR(uint _price) external view returns(uint TCR);
/// @notice Check if the system is in Recovery Mode
/// @param _price The current price of the collateral
/// @return True if the system is in Recovery Mode, false otherwise
function checkRecoveryMode(uint _price) external returns(bool);
/// @notice Check if the position manager is in sunset mode
/// @return True if the position manager is in sunset mode, false otherwise
function isSunset() external returns(bool);
}"
},
"contracts/interfaces/IRecoverable.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
/// @title IRecoverable Interface
/// @notice Interface for contracts that can recover orphaned tokens
interface IRecoverable {
/// @notice Extracts orphaned tokens from the contract
/// @dev This function should only be callable by authorized roles (e.g., guardian)
/// @param asset The address of the token to be extracted
/// @param version The version of the token (if applicable)
function extractOrphanedTokens(address asset, uint8 version) external;
}"
},
"contracts/stable/collateral/instance/ActivePool.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../../interfaces/IActivePool.sol";
import "../../../interfaces/IPositionManager.sol";
import "../../../Guardable.sol";
import "../../../interfaces/IRecoverable.sol";
/**
* @title ActivePool
* @dev Contract for managing the active pool of collateral and stable debt in the system.
*
* Key features:
* 1. Collateral Management: Tracks and manages the collateral balance in the system.
* 2. Stable Debt Tracking: Keeps record of the total stable debt in the system.
* 3. Access Control: Restricts certain functions to specific system contracts.
* 4. Token Recovery: Allows extraction of orphaned tokens in case of a sunset event.
*/
contract ActivePool is Ownable, IActivePool, Guardable, IRecoverable {
// Addresses of key contracts and tokens in the system
address public collateralAssetAddress;
address public positionControllerAddress;
address public positionManagerAddress;
address public backstopPoolAddress;
address public defaultPoolAddress;
// Internal state variables
uint256 internal Collateral; // Total collateral in the pool
uint256 internal stableDebt; // Total stable debt in the system
/**
* @dev Sets the addresses of key contracts in the system
* @param _positionControllerAddress Address of the Position Controller contract
* @param _positionManagerAddress Address of the Position Manager contract
* @param _backstopPoolAddress Address of the Backstop Pool contract
* @param _defaultPoolAddress Address of the Default Pool contract
* @param _collateralAssetAddress Address of the Collateral Asset token
*/
function setAddresses(
address _positionControllerAddress,
address _positionManagerAddress,
address _backstopPoolAddress,
address _defaultPoolAddress,
address _collateralAssetAddress
)
external
onlyOwner
{
collateralAssetAddress = _collateralAssetAddress;
positionControllerAddress = _positionControllerAddress;
positionManagerAddress = _positionManagerAddress;
backstopPoolAddress = _backstopPoolAddress;
defaultPoolAddress = _defaultPoolAddress;
renounceOwnership();
}
/**
* @dev Returns the current collateral balance in the pool
* @return The amount of collateral in the pool
*/
function getCollateral() external view override returns (uint) {
return Collateral;
}
/**
* @dev Returns the current stable debt in the system
* @return The amount of stable debt
*/
function getStableDebt() external view override returns (uint) {
return stableDebt;
}
/**
* @dev Sends collateral to a specified account
* @param _account The address to receive the collateral
* @param _amount The amount of collateral to send
*/
function sendCollateral(address _account, uint _amount) external override {
_requireCallerIsPCorPMorBP();
Collateral -= _amount;
emit ActivePoolCollateralBalanceUpdated(Collateral);
emit CollateralSent(_account, _amount);
require(IERC20(collateralAssetAddress).transfer(_account, _amount), "ActivePool: sending Collateral failed");
}
/**
* @dev Receives collateral into the pool
* @param asset The address of the collateral asset
* @param amount The amount of collateral to receive
*/
function receiveCollateral(address asset, uint amount) external override {
_requireCallerIsPositionControllerOrDefaultPool();
require(asset == collateralAssetAddress, "ActivePool: Was sent unexpected collateral");
Collateral += amount;
emit ActivePoolCollateralBalanceUpdated(Collateral);
}
/**
* @dev Increases the stable debt in the system
* @param _amount The amount to increase the stable debt by
*/
function increaseStableDebt(uint _amount) external override {
_requireCallerIsPCorPM();
stableDebt += _amount;
emit ActivePoolStableDebtUpdated(stableDebt);
}
/**
* @dev Decreases the stable debt in the system
* @param _amount The amount to decrease the stable debt by
*/
function decreaseStableDebt(uint _amount) external override {
_requireCallerIsPCorPMorBP();
stableDebt -= _amount;
emit ActivePoolStableDebtUpdated(stableDebt);
}
/**
* @dev Checks if the caller is either the Position Controller or Default Pool
*/
function _requireCallerIsPositionControllerOrDefaultPool() internal view {
require(
msg.sender == positionControllerAddress ||
msg.sender == defaultPoolAddress,
"ActivePool: Caller is neither PC nor Default Pool");
}
/**
* @dev Checks if the caller is either the Position Controller, Position Manager, or Backstop Pool
*/
function _requireCallerIsPCorPMorBP() internal view {
require(
msg.sender == positionControllerAddress ||
msg.sender == positionManagerAddress ||
msg.sender == backstopPoolAddress,
"ActivePool: Caller is neither PC nor PM nor BP");
}
/**
* @dev Checks if the caller is either the Position Controller or Position Manager
*/
function _requireCallerIsPCorPM() internal view {
require(
msg.sender == positionControllerAddress ||
msg.sender == positionManagerAddress,
"ActivePool: Caller is neither PC nor PM");
}
/**
* @dev Extracts orphaned tokens from the contract in case of a sunset event
* @param asset The address of the asset to extract
* @param version The version of the extraction (unused in this implementation)
*/
function extractOrphanedTokens(address asset, uint8 version) external override onlyGuardian {
require(
IPositionManager(positionManagerAddress).isSunset(),
"Orphaned tokens can only be extracted if collateral is sunset"
);
IERC20 collateral = IERC20(collateralAssetAddress);
collateral.transfer(guardian(), collateral.balanceOf(address(this)));
}
}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 1
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}
}}
Submitted on: 2025-10-28 12:41:59
Comments
Log in to comment.
No comments yet.