Address
0x1bc274f7ee6970ceb2f748e2573d81789a6738a2Current Holdings
$0.00
TXs sent
not counted
First Active
2026-06-03
block 26,696,783
Last Active
104 days ago
block 26,696,792
Funded By
not identified
Net worth historyi
No net-worth snapshots recorded yet
exact matchPulseChainDynamicLeveragesolc 0.8.34+commit.80d5c536runtime exact · creation exact
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
}
interface ICEther {
function mint() external payable;
}
interface ICERC20 {
function borrow(uint256 amount) external returns (uint256);
}
interface IComptroller {
function enterMarkets(address[] calldata markets) external returns (uint256[] memory);
function getAccountLiquidity(address account) external view returns (uint256, uint256, uint256);
}
interface IDexRouter {
function swapExactTokensForETH(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
}
contract PulseChainDynamicLeverage {
address public immutable owner;
bool public marketsInitialized;
// Replace these with the live deployment addresses of your target lending protocol
address public constant cPLS = 0x4Ddc2D193948926D02f9B1fE9e1daa0718270ED5;
address public constant COMPTROLLER = 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B;
modifier onlyOwner() {
require(msg.sender == owner, "Owner only");
_;
}
constructor() {
owner = msg.sender;
}
/**
* @notice Performs market entry exactly once to guarantee contract initialization
*/
function initializeMarkets(address cTokenAddress) external onlyOwner {
require(!marketsInitialized, "Already initialized");
address[] memory markets = new address[](2);
markets[0] = cPLS;
markets[1] = cTokenAddress;
uint256[] memory errors = IComptroller(COMPTROLLER).enterMarkets(markets);
require(errors[0] == 0 && errors[1] == 0, "Market entry failed");
marketsInitialized = true;
}
/**
* @notice Executes loop by reading open protocol liquidity dynamically
*/
function executeDynamicLoop(
address cTokenAddress,
address underlyingToken,
address routerAddress,
uint256 safetyMarginPercentage // E.g., 90 means borrow only 90% of max allowed capacity to absorb fees
) external payable onlyOwner {
require(msg.value == 18000 ether, "Must send 18,000 PLS");
require(marketsInitialized, "Must initialize markets first");
require(safetyMarginPercentage <= 98, "Safety margin too high");
uint256 totalIterations = 10;
uint256 initialDeposit = 1800 ether;
address[] memory path = new address[](2);
path[0] = underlyingToken;
path[1] = 0xA1077a294dDE1B09bB078844df40758a5D0f9a27; // Fixed: Correctly Checksummed Mainnet WPLS Address
for (uint256 i = 0; i < totalIterations; i++) {
// 1. Determine active loop deposit balance
uint256 depositAmount = (i == 0) ? initialDeposit : address(this).balance;
if (depositAmount > 0) {
ICEther(cPLS).mint{value: depositAmount}();
}
// 2. Query the Comptroller to see EXACTLY how much collateral room remains
(uint256 err, uint256 liquidity, uint256 shortfall) = IComptroller(COMPTROLLER).getAccountLiquidity(address(this));
require(err == 0, "Liquidity query failed");
require(shortfall == 0, "Account has shortfall");
require(liquidity > 0, "No available credit capacity");
// 3. Compute safe borrow scale based on your safety parameter
uint256 safeBorrowAmount = (liquidity * safetyMarginPercentage) / 100;
if (safeBorrowAmount == 0) break;
// 4. Request the uncapped alternate token borrow safety tier
require(ICERC20(cTokenAddress).borrow(safeBorrowAmount) == 0, "Borrow rejected");
// 5. Instantly recycle the alternate asset back into PLS capital
uint256 borrowedBalance = IERC20(underlyingToken).balanceOf(address(this));
IERC20(underlyingToken).approve(routerAddress, borrowedBalance);
IDexRouter(routerAddress).swapExactTokensForETH(
borrowedBalance,
1,
path,
address(this),
block.timestamp + 60
);
}
}
function withdrawPLS() external onlyOwner {
(bool success, ) = owner.call{value: address(this).balance}("");
require(success, "Withdraw failed");
}
receive() external payable {}
}