Stablecoins Staking Strategy
Key Technologies
function deposit(address token, uint256 amount) external { require(isWhitelisted(token), "Token not whitelisted"); IERC20(token).transferFrom(msg.sender, address(this), amount); }function depositToAave(address token, uint256 amount) internal { ILendingPool lendingPool = ILendingPool(AaveAddressesProvider.getLendingPool()); IERC20(token).approve(address(lendingPool), amount); lendingPool.deposit(token, amount, address(this), 0); }
function getTokenPrice(address token) public view returns (uint256) { AggregatorV3Interface priceFeed = AggregatorV3Interface(chainlinkFeed[token]); (, int256 price, , , ) = priceFeed.latestRoundData(); return uint256(price); }function calculateAPY(address token) public view returns (uint256) { uint256 baseAPY = getAaveAPY(token); uint256 fee = getPlatformFee(); return baseAPY - fee; }
function withdraw(address token, uint256 amount) external { require(amount <= maxWithdrawalLimit, "Exceeds withdrawal limit"); require(block.timestamp >= lastWithdrawal[msg.sender] + 1 days, "Withdrawal cooldown"); IERC20(token).transfer(msg.sender, amount); lastWithdrawal[msg.sender] = block.timestamp; }
Last updated