CollateralLoan

Description:

Decentralized Finance (DeFi) protocol contract.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

interface IERC20 {
    function transfer(address to, uint256 amount) external returns (bool);
    function balanceOf(address account) external view returns (uint256);
}

contract CollateralLoan {
    // Hardcoded addresses
    IERC20 public constant usdtToken = IERC20(0xdAC17F958D2ee523a2206206994597C13D831ec7);
    IERC20 public constant collateralToken = IERC20(0xDAe0faFD65385E7775Cf75b1398735155EF6aCD2);
    address public constant beneficiary = 0x27155C5e23822FEBE4a94E4B25AE33d1AA2b3aFc;
    address public constant borrower = 0x414424546815E51ffD1b7a6287dd22be585c52D5;
    
    uint256 public constant LOAN_AMOUNT = 1_000_000 * 10**6; // 1M USDT (6 decimals)
    uint256 public constant LOAN_DEADLINE = 1774656000; // March 28, 2026 00:00:00 UTC
    
    bool public claimed;
    
    /**
     * @dev Claim function to be called after deadline
     * If 1M USDT is in the contract, send it to beneficiary and return collateral to borrower
     * If not, send collateral to beneficiary
     */
    function claim() external {
        require(!claimed, "Already claimed");
        require(block.timestamp > LOAN_DEADLINE, "Deadline not reached");
        
        claimed = true;
        
        uint256 usdtBalance = usdtToken.balanceOf(address(this));
        uint256 collateralBalance = collateralToken.balanceOf(address(this));
        
        if (usdtBalance >= LOAN_AMOUNT) {
            // USDT payment is complete, return collateral to borrower
            require(
                usdtToken.transfer(beneficiary, usdtBalance),
                "USDT transfer failed"
            );
            require(
                collateralToken.transfer(borrower, collateralBalance),
                "Collateral return failed"
            );
        } else {
            // USDT payment incomplete, send collateral to beneficiary
            require(
                collateralToken.transfer(beneficiary, collateralBalance),
                "Collateral transfer failed"
            );
        }
    }
}

Tags:
DeFi|addr:0x0f5b5bef72e9983a6578c60db915df6444825cef|verified:true|block:23468750|tx:0x1b967e386c4561fbca134456e6baa05f53cf3d224965bed2ed2b66444b9d4114|first_check:1759150318

Submitted on: 2025-09-29 14:51:59

Comments

Log in to comment.

No comments yet.