Description:
Decentralized Finance (DeFi) protocol contract providing Factory functionality.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"contracts/Contract.sol": {
"content": "// SPDX-License-Identifier: ISC
pragma solidity ^0.8.0;
interface IStableVault {
function maxDeposit() external view returns (uint256);
function depositStart() external view returns (uint64);
function depositEnd() external view returns (uint64);
function operationalMode() external view returns (uint8);
function sharesNonKyc() external view returns (uint256);
function depositCap() external view returns (uint256);
}
/**
* @title DepositChecker
* @notice Utility contract to check if the deposit pool is open according to the vault's requirements
* @dev According to the analysis, the deposit pool is open when ALL of the following conditions are met:
* 1. operationalMode() == OperationalMode.Deposit (0)
* 2. block.timestamp >= depositStart()
* 3. block.timestamp <= depositEnd()
* 4. maxDeposit() > 0 (also checks deposit cap)
* maxDeposit() returns 0 if mode is not Deposit OR window is not open
* Otherwise returns the remaining capacity: _depositCap - sharesNonKyc
*/
contract DepositChecker {
IStableVault public immutable vault;
constructor(address vaultAddress) {
vault = IStableVault(vaultAddress);
}
/**
* @notice Checks if the deposit pool is currently open and if the specified assets can be deposited
* @param assets The amount of assets to check for deposit
* @return ready True if the pool is open and the assets can be deposited, false otherwise
* @dev Explicitly checks all four conditions required for the pool to be open:
* - Operational mode must be Deposit (0)
* - Current time must be within deposit window
* - Max deposit must be greater than 0 (checks deposit cap)
* - Assets must be less than or equal to maxDeposit
*/
function checkDepositReady(
uint256 assets
) public view returns (bool ready) {
// Explicitly check operational mode
if (vault.operationalMode() != 0) {
return false;
}
// Explicitly check time window
uint64 currentTime = uint64(block.timestamp);
if (currentTime > vault.depositStart() || currentTime < vault.depositEnd()) {
return false;
}
// Check max deposit and remaining capacity
uint256 maxDeposit = vault.maxDeposit();
if (maxDeposit == 0) {
return false;
}
// Check if assets fit within the limit
return assets <= maxDeposit;
}
/**
* @notice Returns detailed state information about the vault
* @return isOpen Whether the deposit pool is currently open
* @return mode Current operational mode
* @return currentTime Current block timestamp
* @return windowStart Deposit window start timestamp
* @return windowEnd Deposit window end timestamp
* @return maxDepositAmount Maximum amount that can be deposited (0 if closed)
* @return depositCap Deposit cap
* @return sharesNonKyc Number of shares that have been deposited
* @return remainingCapacity Remaining capacity
*/
function getVaultState()
external
view
returns (
bool isOpen,
uint8 mode,
uint64 currentTime,
uint64 windowStart,
uint64 windowEnd,
uint256 maxDepositAmount,
uint256 depositCap,
uint256 sharesNonKyc,
uint256 remainingCapacity
)
{
mode = vault.operationalMode();
windowStart = vault.depositStart();
windowEnd = vault.depositEnd();
maxDepositAmount = vault.maxDeposit();
currentTime = uint64(block.timestamp);
depositCap = vault.depositCap();
sharesNonKyc = vault.sharesNonKyc();
remainingCapacity = depositCap - sharesNonKyc;
isOpen = maxDepositAmount > 0;
}
}
"
}
},
"settings": {
"evmVersion": "paris",
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": [],
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-11-06 11:47:14
Comments
Log in to comment.
No comments yet.