// SPDX-License-Identifier: MIT pragma solidity 0.8.24; interface IERC20 { function transferFrom(address from, address to, uint256 amount) external returns (bool); function transfer(address to, uint256 amount) external returns (bool); function balanceOf(address who) external view returns (uint256); } /// A deliberately minimal share vault, written for the SombraX sample report. Not a real protocol. contract SampleVault { IERC20 public immutable asset; address public immutable owner; uint256 public constant MAX_PAUSE = 72 hours; uint256 public totalSupply; mapping(address => uint256) public balanceOf; uint256 public pausedUntil; bool public pausedOnce; uint256 private _lock = 1; modifier nonReentrant() { require(_lock == 1, "locked"); _lock = 2; _; _lock = 1; } constructor(IERC20 asset_) { asset = asset_; owner = msg.sender; } function totalAssets() public view returns (uint256) { return asset.balanceOf(address(this)); } function deposit(uint256 assets, address to) external nonReentrant returns (uint256 shares) { shares = totalSupply == 0 ? assets : (assets * totalSupply) / totalAssets(); asset.transferFrom(msg.sender, address(this), assets); totalSupply += shares; balanceOf[to] += shares; } function redeem(uint256 shares, address to) external nonReentrant returns (uint256 assets) { require(block.timestamp >= pausedUntil, "paused"); assets = (shares * totalAssets()) / totalSupply; balanceOf[msg.sender] -= shares; totalSupply -= shares; asset.transfer(to, assets); } /// The owner may pause withdrawals once, for at most MAX_PAUSE. function pause() external { require(msg.sender == owner, "owner"); require(!pausedOnce, "already paused once"); pausedOnce = true; pausedUntil = block.timestamp + MAX_PAUSE; } }