// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; // Interface for NAVIS ERC-20 token interface NAVIS { function transfer(address to, uint256 amount) external returns (bool); function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); function balanceOf(address account) external view returns (uint256); // Add other ERC-20 methods if necessary } contract NAVISVAULT is Ownable, ReentrancyGuard { using SafeMath for uint256; mapping(address => uint256) public fiatBalances; mapping(address => uint256) public lastInterestClaim; NAVIS public navisToken; // Replace with the actual NAVIS token interface AggregatorV3Interface public priceFeed; // Replace with the actual Chainlink price feed uint256 public interestRate; // Annual interest rate in basis points (1 basis point = 0.01%) event Deposit(address indexed user, uint256 amount); event Withdrawal(address indexed user, uint256 amount); event Payment(address indexed sender, address indexed recipient, uint256 amount); event InterestClaimed(address indexed user, uint256 amount); event Minted(address indexed to, uint256 amount); modifier onlyPositiveAmount(uint256 amount) { require(amount > 0, "Amount must be greater than zero"); _; } constructor(address _navisToken, address _priceFeed) { navisToken = NAVIS(_navisToken); priceFeed = AggregatorV3Interface(_priceFeed); } // Function to set the annual interest rate (onlyOwner) function setInterestRate(uint256 _interestRate) external onlyOwner { interestRate = _interestRate; } // Function to deposit fiat into the wallet function deposit(uint256 amount) external onlyPositiveAmount(amount) nonReentrant { fiatBalances[msg.sender] = fiatBalances[msg.sender].add(amount); lastInterestClaim[msg.sender] = block.timestamp; emit Deposit(msg.sender, amount); } // Function to withdraw fiat from the wallet function withdraw(uint256 amount) external onlyPositiveAmount(amount) nonReentrant { claimInterest(msg.sender); // Claim interest before withdrawal require(amount <= fiatBalances[msg.sender], "Insufficient balance"); fiatBalances[msg.sender] = fiatBalances[msg.sender].sub(amount); emit Withdrawal(msg.sender, amount); } // Function to make a payment using fiat function makePayment(address recipient, uint256 amount) external onlyPositiveAmount(amount) nonReentrant { claimInterest(msg.sender); // Claim interest before making a payment require(amount <= fiatBalances[msg.sender], "Insufficient balance"); fiatBalances[msg.sender] = fiatBalances[msg.sender].sub(amount); fiatBalances[recipient] = fiatBalances[recipient].add(amount); emit Payment(msg.sender, recipient, amount); } // Function to claim interest function claimInterest(address user) public nonReentrant { uint256 elapsedTime = block.timestamp.sub(lastInterestClaim[user]); uint256 interest = (fiatBalances[user].mul(interestRate).mul(elapsedTime)).div(365 days.mul(10000)); fiatBalances[user] = fiatBalances[user].add(interest); lastInterestClaim[user] = block.timestamp; emit InterestClaimed(user, interest); } // Function to check the fiat balance of a user function getFiatBalance(address user) external view returns (uint256) { return fiatBalances[user]; } // Function to check the last interest claim timestamp of a user function getLastInterestClaim(address user) external view returns (uint256) { return lastInterestClaim[user]; } mapping(address => uint256) public cryptoBalances; event CryptoDeposit(address indexed user, uint256 amount); event CryptoWithdrawal(address indexed user, uint256 amount); event CryptoPayment(address indexed sender, address indexed recipient, uint256 amount); // Function to deposit crypto into the wallet function depositCrypto(uint256 amount) external onlyPositiveAmount(amount) nonReentrant { navisToken.transferFrom(msg.sender, address(this), amount); cryptoBalances[msg.sender] = cryptoBalances[msg.sender].add(amount); emit CryptoDeposit(msg.sender, amount); } // Function to withdraw crypto from the wallet function withdrawCrypto(uint256 amount) external onlyPositiveAmount(amount) nonReentrant { require(amount <= cryptoBalances[msg.sender], "Insufficient balance"); cryptoBalances[msg.sender] = cryptoBalances[msg.sender].sub(amount); navisToken.transfer(msg.sender, amount); emit CryptoWithdrawal(msg.sender, amount); } // Function to make a payment using crypto function makeCryptoPayment(address recipient, uint256 amount) external onlyPositiveAmount(amount) nonReentrant { require(amount <= cryptoBalances[msg.sender], "Insufficient balance"); cryptoBalances[msg.sender] = cryptoBalances[msg.sender].sub(amount); cryptoBalances[recipient] = cryptoBalances[recipient].add(amount); emit CryptoPayment(msg.sender, recipient, amount); } // Function to check the crypto balance of a user function getCryptoBalance(address user) external view returns (uint256) { return cryptoBalances[user]; } // Function to transfer crypto between users function transferCrypto(address recipient, uint256 amount) external onlyPositiveAmount(amount) nonReentrant { require(amount <= cryptoBalances[msg.sender], "Insufficient balance"); cryptoBalances[msg.sender] = cryptoBalances[msg.sender].sub(amount); cryptoBalances[recipient] = cryptoBalances[recipient].add(amount); emit CryptoPayment(msg.sender, recipient, amount); } // Function to mint NAVIS tokens to the wallet function mintNAVIS(uint256 amount) external onlyOwner { _mint(address(this), amount); emit Minted(address(this), amount); } // Internal function to mint NAVIS tokens function _mint(address to, uint256 amount) internal { require(amount > 0, "Mint amount must be greater than zero"); navisToken.mint(to, amount); emit Minted(to, amount); } // Function to get live cryptocurrency and stock market ticker function getMarketTicker() external view returns (string memory) { // This is a simplified example, and integration with external APIs is not possible directly in a smart contract. // Consider using oracles to fetch external data. // For now, returning a placeholder value. return "BTC: $40,000 | AAPL: $150.50"; } // Function to swap crypto assets using a decentralized exchange or external protocol function swapCrypto(address inputToken, address outputToken, uint256 amount) external nonReentrant { // Implement swapping logic using a decentralized exchange (DEX) or an external protocol // Ensure that proper approvals are given for token transfers // Emit relevant events } // Additional functions and features can be added based on The NAVIS App requirements... // Customize and add more features based on The NAVIS App requirements... }