Skip to content
Verified contractPartialUNLICENSED

WarehousePool

Address0x26ea9cf9050f9281dc633c747033de2d7c2fed48
Balance

0 ETH

 

Transactions

6

 

Compiler

solc 0.8.27

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.27+commit.40a35a09
Language
solidity
Optimization
Yes, 200 runs
EVM version
cancun
Via IR
yes
License
UNLICENSED
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,325,182
Creation transaction
0xf2b9b8cf19…7616d8adc4

92 files

The source code is large: one file is shown at a time. Choose a file in the list.

src/WarehousePool.sol

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.27;

import {StabilityPool7540} from "./StabilityPool7540.sol";
import {IPRUSD} from "./interfaces/IPRUSD.sol";
import {IStabilityPoolSettlementLedger} from "./interfaces/IStabilityPoolSettlementLedger.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Roles} from "./libraries/Roles.sol";
import {TestDrain} from "./libraries/TestDrain.sol";
import {Warehouse} from "./Warehouse.sol";
import {WarehouseSourceAuth, IWarehouseTreasuryBinding} from "./WarehouseSourceAuth.sol";
import {SupportedChains} from "./libraries/SupportedChains.sol";

/// @notice Warehouse funding hook for the ERC-7540 exit-queue investor core (mainnet, Sepolia, Anvil).
contract WarehousePool is StabilityPool7540 {
    using SafeERC20 for IERC20;
    error OnlyWarehouseSource();

    constructor(address admin, IPRUSD asset_, IStabilityPoolSettlementLedger ledger_, uint256 cid)
        StabilityPool7540(admin, asset_, ledger_, cid, "Warehouse PRUSD pool shares", "wPRUSD")
    {
        SupportedChains.check();
    }

    function _grantRole(bytes32 role, address account) internal override returns (bool) {
        if (role == Roles.WAREHOUSE_FUNDING_ROLE) _requireWarehouse(account);
        return super._grantRole(role, account);
    }

    function _requireWarehouse(address account) private view {
        if (
            account.code.length == 0
                || account != WarehouseSourceAuth.canonical(address(settlementLedger), collateralId)
                || Warehouse(account).pool() != address(this)
        ) revert OnlyWarehouseSource();
    }

    function fundWarehouseCycle(uint256 amount)
        external
        onlyRole(Roles.WAREHOUSE_FUNDING_ROLE)
        nonReentrant
    {
        _requireWarehouse(msg.sender);
        if (
            msg.sender
                != IWarehouseTreasuryBinding(address(settlementLedger))
                    .settlementSource(address(this))
        ) {
            revert OnlyWarehouseSource();
        }
        if (amount == 0) revert ZeroAmount();
        if (settlementPending) revert SettlementPending();
        _syncSurplus();
        if (amount > workingCapital) revert InsufficientWorkingCapital(amount, workingCapital);
        settlementPending = true;
        absorbedDebt = amount;
        cycleId++;
        workingCapital -= amount;
        IERC20(asset()).safeTransfer(msg.sender, amount);
        emit LiquidationAbsorbed(cycleId, amount, workingCapital);
    }

    /// @notice Task 0300 test-deployment teardown: sends `amount` of `token` to the caller, no accounting update.
    function drain(address token, uint256 amount) external onlyRole(Roles.TEST_DRAIN_ROLE) {
        TestDrain.send(token, amount);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "lib/openzeppelin-community-contracts/contracts/:@openzeppelin/contracts/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts/contracts/",
    "lib/openzeppelin-community-contracts/contracts/:@openzeppelin/contracts/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "forge-std/=lib/forge-std/src/",
    "@openzeppelin/community-contracts/=lib/openzeppelin-community-contracts/contracts/",
    "@openzeppelin7540/contracts/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts/contracts/",
    "composable-cow/=lib/composable-cow/src/",
    "lib/composable-cow/:@openzeppelin/=lib/composable-cow/lib/@openzeppelin/",
    "lib/composable-cow/:@openzeppelin/=lib/composable-cow/lib/@openzeppelin/",
    "cowprotocol/=lib/composable-cow/lib/cowprotocol/src/",
    "safe/=lib/composable-cow/lib/safe/contracts/",
    "@axelar-network/axelar-gmp-sdk-solidity/=lib/openzeppelin-community-contracts/lib/axelar-gmp-sdk-solidity/",
    "@openzeppelin-contracts/=lib/openzeppelin-community-contracts/lib/@openzeppelin-contracts/",
    "@openzeppelin/=lib/composable-cow/lib/@openzeppelin/",
    "@zk-email/contracts/=lib/openzeppelin-community-contracts/lib/zk-email-verify/packages/contracts/",
    "@zk-email/email-tx-builder/=lib/openzeppelin-community-contracts/lib/email-tx-builder/packages/contracts/",
    "ds-test/=lib/composable-cow/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "murky/=lib/composable-cow/lib/murky/src/",
    "openzeppelin-community-contracts/=lib/openzeppelin-community-contracts/contracts/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/composable-cow/lib/@openzeppelin/contracts/",
    "wormhole-solidity-sdk/=lib/openzeppelin-community-contracts/lib/wormhole-solidity-sdk/src/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.