ETH Price: $2,784.47 (+1.72%)

Contract

0xd8291316C82F3979ecff4f1113e93caA0a2f4749
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Set Addresses218037772025-02-08 19:07:2313 days ago1739041643IN
0xd8291316...A0a2f4749
0 ETH0.000410343

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ActivePool

Compiler Version
v0.8.21+commit.d9974bed

Optimization Enabled:
Yes with 1 runs

Other Settings:
paris EvmVersion
File 1 of 10 : ActivePool.sol
// 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)));
    }
}

File 2 of 10 : Ownable.sol
// 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);
    }
}

File 3 of 10 : IERC20.sol
// 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);
}

File 4 of 10 : Context.sol
// 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;
    }
}

File 5 of 10 : Guardable.sol
// 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);
    }
}

File 6 of 10 : IActivePool.sol
// 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;
}

File 7 of 10 : ICanReceiveCollateral.sol
// 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;
}

File 8 of 10 : IPool.sol
// 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;
}

File 9 of 10 : IPositionManager.sol
// 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);
}

File 10 of 10 : IRecoverable.sol
// 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;
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 1
  },
  "evmVersion": "paris",
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_Collateral","type":"uint256"}],"name":"ActivePoolCollateralBalanceUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_STABLEDebt","type":"uint256"}],"name":"ActivePoolStableDebtUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_to","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"CollateralSent","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousGuardian","type":"address"},{"indexed":true,"internalType":"address","name":"newGuardian","type":"address"}],"name":"WatchTransferred","type":"event"},{"inputs":[],"name":"backstopPoolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"collateralAssetAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"decreaseStableDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultPoolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint8","name":"version","type":"uint8"}],"name":"extractOrphanedTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCollateral","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStableDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"increaseStableDebt","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionControllerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"positionManagerAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"receiveCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"releaseGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"sendCollateral","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_positionControllerAddress","type":"address"},{"internalType":"address","name":"_positionManagerAddress","type":"address"},{"internalType":"address","name":"_backstopPoolAddress","type":"address"},{"internalType":"address","name":"_defaultPoolAddress","type":"address"},{"internalType":"address","name":"_collateralAssetAddress","type":"address"}],"name":"setAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"transferWatch","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b5061001a33610028565b61002333610078565b6100ca565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f0f4b7c1c615f05db5d396c69cf5146c8f2949c2b53ef79a3260b33fbed11682d90600090a35050565b610d4f806100d96000396000f3fe608060405234801561001057600080fd5b50600436106100f15760003560e01c806301f9f3a2146100f657806304071a4a1461010d5780630b8c19dc146101225780631b3b541a146101355780631d49f8c1146101555780632f60d0711461016857806334a93f2514610170578063446a3f4614610183578063452a9320146101965780635c1548fb1461019e5780635dd68acd146101a657806362502169146101b9578063715018a6146101cc5780637a8a1113146101d45780638da5cb5b146101e7578063974c6456146101ef578063aac1846f14610202578063c547dae914610215578063f2fde38b14610228575b600080fd5b6008545b6040519081526020015b60405180910390f35b61012061011b366004610b0c565b61023b565b005b610120610130366004610b41565b610293565b600254610148906001600160a01b031681565b6040516101049190610b6b565b600554610148906001600160a01b031681565b61012061034f565b61012061017e366004610b7f565b610363565b610120610191366004610ba1565b6103e1565b6101486105b5565b6007546100fa565b6101206101b4366004610bde565b6105c4565b6101206101c7366004610b41565b610631565b610120610780565b600454610148906001600160a01b031681565b610148610792565b6101206101fd366004610b0c565b6107a1565b600654610148906001600160a01b031681565b600354610148906001600160a01b031681565b610120610236366004610b7f565b6107bb565b610243610831565b80600860008282546102559190610c59565b90915550506008546040519081527f5de4869832eb5aa8b6179ab8262728d8336ebc53214ecffddee62bef4b3f3faa9060200160405180910390a150565b61029b6108ba565b6002546001600160a01b038381169116146103105760405162461bcd60e51b815260206004820152602a60248201527f416374697665506f6f6c3a205761732073656e7420756e65787065637465642060448201526918dbdb1b185d195c985b60b21b60648201526084015b60405180910390fd5b80600760008282546103229190610c72565b9091555050600754604051908152600080516020610cda8339815191529060200160405180910390a15050565b610357610931565b610361600061099e565b565b61036b610931565b6001600160a01b0381166103d55760405162461bcd60e51b815260206004820152602b60248201527f477561726461626c653a206e657720677561726469616e20697320746865207a60448201526a65726f206164647265737360a81b6064820152608401610307565b6103de8161099e565b50565b6103e9610931565b6004805460408051631217161960e31b815290516001600160a01b03909216926390b8b0c892828201926020929082900301816000875af1158015610432573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104569190610c85565b6104c85760405162461bcd60e51b815260206004820152603d60248201527f4f727068616e656420746f6b656e732063616e206f6e6c79206265206578747260448201527f616374656420696620636f6c6c61746572616c2069732073756e7365740000006064820152608401610307565b6002546001600160a01b03168063a9059cbb6104e26105b5565b6040516370a0823160e01b81526001600160a01b038516906370a082319061050e903090600401610b6b565b602060405180830381865afa15801561052b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054f9190610ca7565b6040518363ffffffff1660e01b815260040161056c929190610cc0565b6020604051808303816000875af115801561058b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105af9190610c85565b50505050565b6001546001600160a01b031690565b6105cc6109f0565b600280546001600160a01b03199081166001600160a01b03848116919091179092556003805482168884161790556004805482168784161790556005805482168684161790556006805490911691841691909117905561062a610780565b5050505050565b610639610831565b806007600082825461064b9190610c59565b9091555050600754604051908152600080516020610cda8339815191529060200160405180910390a17f342693d2465f6f44931e41128424a0227e0cbc69d1c3917a839e6de71696d44c82826040516106a5929190610cc0565b60405180910390a160025460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106df9085908590600401610cc0565b6020604051808303816000875af11580156106fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107229190610c85565b61077c5760405162461bcd60e51b815260206004820152602560248201527f416374697665506f6f6c3a2073656e64696e6720436f6c6c61746572616c2066604482015264185a5b195960da1b6064820152608401610307565b5050565b6107886109f0565b6103616000610a4f565b6000546001600160a01b031690565b6107a9610a9f565b80600860008282546102559190610c72565b6107c36109f0565b6001600160a01b0381166108285760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610307565b6103de81610a4f565b6003546001600160a01b031633148061085457506004546001600160a01b031633145b8061086957506005546001600160a01b031633145b6103615760405162461bcd60e51b815260206004820152602e6024820152600080516020610cfa83398151915260448201526d0206e6f7220504d206e6f722042560941b6064820152608401610307565b6003546001600160a01b03163314806108dd57506006546001600160a01b031633145b6103615760405162461bcd60e51b81526020600482015260316024820152600080516020610cfa833981519152604482015270081b9bdc88111959985d5b1d08141bdbdb607a1b6064820152608401610307565b3361093a6105b5565b6001600160a01b0316146103615760405162461bcd60e51b815260206004820152602560248201527f477561726461626c653a2063616c6c6572206973206e6f742074686520677561604482015264393234b0b760d91b6064820152608401610307565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f0f4b7c1c615f05db5d396c69cf5146c8f2949c2b53ef79a3260b33fbed11682d90600090a35050565b336109f9610792565b6001600160a01b0316146103615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610307565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6003546001600160a01b0316331480610ac257506004546001600160a01b031633145b6103615760405162461bcd60e51b81526020600482015260276024820152600080516020610cfa833981519152604482015266206e6f7220504d60c81b6064820152608401610307565b600060208284031215610b1e57600080fd5b5035919050565b80356001600160a01b0381168114610b3c57600080fd5b919050565b60008060408385031215610b5457600080fd5b610b5d83610b25565b946020939093013593505050565b6001600160a01b0391909116815260200190565b600060208284031215610b9157600080fd5b610b9a82610b25565b9392505050565b60008060408385031215610bb457600080fd5b610bbd83610b25565b9150602083013560ff81168114610bd357600080fd5b809150509250929050565b600080600080600060a08688031215610bf657600080fd5b610bff86610b25565b9450610c0d60208701610b25565b9350610c1b60408701610b25565b9250610c2960608701610b25565b9150610c3760808701610b25565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b81810381811115610c6c57610c6c610c43565b92915050565b80820180821115610c6c57610c6c610c43565b600060208284031215610c9757600080fd5b81518015158114610b9a57600080fd5b600060208284031215610cb957600080fd5b5051919050565b6001600160a01b0392909216825260208201526040019056fe51e7c30439c76308c020a84ca2a666735d3baa69d070e13beaf83e15bb697eb3416374697665506f6f6c3a2043616c6c6572206973206e656974686572205043a26469706673582212205faa20ff8db39d416646fae6908428e9916d65a000d384ef269af51e2f9a427c64736f6c63430008150033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106100f15760003560e01c806301f9f3a2146100f657806304071a4a1461010d5780630b8c19dc146101225780631b3b541a146101355780631d49f8c1146101555780632f60d0711461016857806334a93f2514610170578063446a3f4614610183578063452a9320146101965780635c1548fb1461019e5780635dd68acd146101a657806362502169146101b9578063715018a6146101cc5780637a8a1113146101d45780638da5cb5b146101e7578063974c6456146101ef578063aac1846f14610202578063c547dae914610215578063f2fde38b14610228575b600080fd5b6008545b6040519081526020015b60405180910390f35b61012061011b366004610b0c565b61023b565b005b610120610130366004610b41565b610293565b600254610148906001600160a01b031681565b6040516101049190610b6b565b600554610148906001600160a01b031681565b61012061034f565b61012061017e366004610b7f565b610363565b610120610191366004610ba1565b6103e1565b6101486105b5565b6007546100fa565b6101206101b4366004610bde565b6105c4565b6101206101c7366004610b41565b610631565b610120610780565b600454610148906001600160a01b031681565b610148610792565b6101206101fd366004610b0c565b6107a1565b600654610148906001600160a01b031681565b600354610148906001600160a01b031681565b610120610236366004610b7f565b6107bb565b610243610831565b80600860008282546102559190610c59565b90915550506008546040519081527f5de4869832eb5aa8b6179ab8262728d8336ebc53214ecffddee62bef4b3f3faa9060200160405180910390a150565b61029b6108ba565b6002546001600160a01b038381169116146103105760405162461bcd60e51b815260206004820152602a60248201527f416374697665506f6f6c3a205761732073656e7420756e65787065637465642060448201526918dbdb1b185d195c985b60b21b60648201526084015b60405180910390fd5b80600760008282546103229190610c72565b9091555050600754604051908152600080516020610cda8339815191529060200160405180910390a15050565b610357610931565b610361600061099e565b565b61036b610931565b6001600160a01b0381166103d55760405162461bcd60e51b815260206004820152602b60248201527f477561726461626c653a206e657720677561726469616e20697320746865207a60448201526a65726f206164647265737360a81b6064820152608401610307565b6103de8161099e565b50565b6103e9610931565b6004805460408051631217161960e31b815290516001600160a01b03909216926390b8b0c892828201926020929082900301816000875af1158015610432573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104569190610c85565b6104c85760405162461bcd60e51b815260206004820152603d60248201527f4f727068616e656420746f6b656e732063616e206f6e6c79206265206578747260448201527f616374656420696620636f6c6c61746572616c2069732073756e7365740000006064820152608401610307565b6002546001600160a01b03168063a9059cbb6104e26105b5565b6040516370a0823160e01b81526001600160a01b038516906370a082319061050e903090600401610b6b565b602060405180830381865afa15801561052b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061054f9190610ca7565b6040518363ffffffff1660e01b815260040161056c929190610cc0565b6020604051808303816000875af115801561058b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105af9190610c85565b50505050565b6001546001600160a01b031690565b6105cc6109f0565b600280546001600160a01b03199081166001600160a01b03848116919091179092556003805482168884161790556004805482168784161790556005805482168684161790556006805490911691841691909117905561062a610780565b5050505050565b610639610831565b806007600082825461064b9190610c59565b9091555050600754604051908152600080516020610cda8339815191529060200160405180910390a17f342693d2465f6f44931e41128424a0227e0cbc69d1c3917a839e6de71696d44c82826040516106a5929190610cc0565b60405180910390a160025460405163a9059cbb60e01b81526001600160a01b039091169063a9059cbb906106df9085908590600401610cc0565b6020604051808303816000875af11580156106fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107229190610c85565b61077c5760405162461bcd60e51b815260206004820152602560248201527f416374697665506f6f6c3a2073656e64696e6720436f6c6c61746572616c2066604482015264185a5b195960da1b6064820152608401610307565b5050565b6107886109f0565b6103616000610a4f565b6000546001600160a01b031690565b6107a9610a9f565b80600860008282546102559190610c72565b6107c36109f0565b6001600160a01b0381166108285760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610307565b6103de81610a4f565b6003546001600160a01b031633148061085457506004546001600160a01b031633145b8061086957506005546001600160a01b031633145b6103615760405162461bcd60e51b815260206004820152602e6024820152600080516020610cfa83398151915260448201526d0206e6f7220504d206e6f722042560941b6064820152608401610307565b6003546001600160a01b03163314806108dd57506006546001600160a01b031633145b6103615760405162461bcd60e51b81526020600482015260316024820152600080516020610cfa833981519152604482015270081b9bdc88111959985d5b1d08141bdbdb607a1b6064820152608401610307565b3361093a6105b5565b6001600160a01b0316146103615760405162461bcd60e51b815260206004820152602560248201527f477561726461626c653a2063616c6c6572206973206e6f742074686520677561604482015264393234b0b760d91b6064820152608401610307565b600180546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f0f4b7c1c615f05db5d396c69cf5146c8f2949c2b53ef79a3260b33fbed11682d90600090a35050565b336109f9610792565b6001600160a01b0316146103615760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610307565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6003546001600160a01b0316331480610ac257506004546001600160a01b031633145b6103615760405162461bcd60e51b81526020600482015260276024820152600080516020610cfa833981519152604482015266206e6f7220504d60c81b6064820152608401610307565b600060208284031215610b1e57600080fd5b5035919050565b80356001600160a01b0381168114610b3c57600080fd5b919050565b60008060408385031215610b5457600080fd5b610b5d83610b25565b946020939093013593505050565b6001600160a01b0391909116815260200190565b600060208284031215610b9157600080fd5b610b9a82610b25565b9392505050565b60008060408385031215610bb457600080fd5b610bbd83610b25565b9150602083013560ff81168114610bd357600080fd5b809150509250929050565b600080600080600060a08688031215610bf657600080fd5b610bff86610b25565b9450610c0d60208701610b25565b9350610c1b60408701610b25565b9250610c2960608701610b25565b9150610c3760808701610b25565b90509295509295909350565b634e487b7160e01b600052601160045260246000fd5b81810381811115610c6c57610c6c610c43565b92915050565b80820180821115610c6c57610c6c610c43565b600060208284031215610c9757600080fd5b81518015158114610b9a57600080fd5b600060208284031215610cb957600080fd5b5051919050565b6001600160a01b0392909216825260208201526040019056fe51e7c30439c76308c020a84ca2a666735d3baa69d070e13beaf83e15bb697eb3416374697665506f6f6c3a2043616c6c6572206973206e656974686572205043a26469706673582212205faa20ff8db39d416646fae6908428e9916d65a000d384ef269af51e2f9a427c64736f6c63430008150033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.