Address
0xf52ee0d08e548151f3559beefb4c19ac8e5e9d65Current Holdings
$0.00
TXs sent
0
First Active
2026-08-03
block 27,194,032
Last Active
today
block 27,543,559
Funded By
not identified
Net worth historyi
No net-worth snapshots recorded yet
exact matchResonanceShadowSurplusGuardV2solc 0.8.19+commit.7dd6d404runtime exact · creation exact
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IPulseXPairSR {
function skim(address to) external;
function getReserves()
external
view
returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function token0() external view returns (address);
function token1() external view returns (address);
}
interface IERC20BalanceSR {
function balanceOf(address account) external view returns (uint256);
}
/**
* @title ResonanceShadowSurplusGuardV2
* @notice Keeper-operated skim-to-burn guard for the SHADOW/RESONANCE PulseX V2 pair.
* @dev SHADOW reflection surplus controls the normal sweep trigger.
*/
contract ResonanceShadowSurplusGuardV2 {
address public constant SHADOW =
0xcC1C700B4CDE776DAAd00132605301AEB58a91c2;
address public constant DEAD =
0x0000000000000000000000000000000000000369;
uint256 public constant INITIAL_THRESHOLD = 10_000e18;
address public immutable PAIR;
address public immutable RESONANCE;
bool public immutable SHADOW_IS_TOKEN0;
address public keeper;
address public pendingKeeper;
uint256 public minSurplusThreshold;
uint256 public totalSwept0;
uint256 public totalSwept1;
uint256 public sweepCount;
event SurplusSwept(
uint256 surplus0,
uint256 surplus1,
address indexed triggeredBy
);
event ThresholdUpdated(uint256 oldThreshold, uint256 newThreshold);
event KeeperTransferStarted(
address indexed oldKeeper,
address indexed newKeeper
);
event KeeperTransferCancelled(address indexed cancelledKeeper);
event KeeperTransferred(
address indexed oldKeeper,
address indexed newKeeper
);
constructor(
address pair_,
address resonance_,
address initialKeeper_
) {
require(pair_ != address(0), "pair zero");
require(resonance_ != address(0), "resonance zero");
require(initialKeeper_ != address(0), "keeper zero");
require(pair_.code.length > 0, "pair not contract");
address token0 = IPulseXPairSR(pair_).token0();
address token1 = IPulseXPairSR(pair_).token1();
bool valid =
(token0 == SHADOW && token1 == resonance_) ||
(token0 == resonance_ && token1 == SHADOW);
require(valid, "wrong SHADOW/RESONANCE pair");
PAIR = pair_;
RESONANCE = resonance_;
SHADOW_IS_TOKEN0 = token0 == SHADOW;
keeper = initialKeeper_;
minSurplusThreshold = INITIAL_THRESHOLD;
}
modifier onlyKeeper() {
require(msg.sender == keeper, "not keeper");
_;
}
function sweepSurplus() external onlyKeeper {
(uint256 surplus0, uint256 surplus1) = _getSurplus();
uint256 shadowSurplus =
SHADOW_IS_TOKEN0 ? surplus0 : surplus1;
require(
shadowSurplus >= minSurplusThreshold,
"below SHADOW threshold"
);
_executeSweep(surplus0, surplus1);
}
function emergencySweep() external onlyKeeper {
(uint256 surplus0, uint256 surplus1) = _getSurplus();
require(surplus0 > 0 || surplus1 > 0, "no surplus");
_executeSweep(surplus0, surplus1);
}
function _executeSweep(
uint256 surplus0,
uint256 surplus1
) internal {
IPulseXPairSR(PAIR).skim(DEAD);
totalSwept0 += surplus0;
totalSwept1 += surplus1;
sweepCount += 1;
emit SurplusSwept(surplus0, surplus1, msg.sender);
}
function _getSurplus()
internal
view
returns (uint256 surplus0, uint256 surplus1)
{
(uint112 reserve0, uint112 reserve1, ) =
IPulseXPairSR(PAIR).getReserves();
address token0 = IPulseXPairSR(PAIR).token0();
address token1 = IPulseXPairSR(PAIR).token1();
uint256 balance0 =
IERC20BalanceSR(token0).balanceOf(PAIR);
uint256 balance1 =
IERC20BalanceSR(token1).balanceOf(PAIR);
surplus0 =
balance0 > uint256(reserve0)
? balance0 - uint256(reserve0)
: 0;
surplus1 =
balance1 > uint256(reserve1)
? balance1 - uint256(reserve1)
: 0;
}
function getSurplus()
external
view
returns (uint256 surplus0, uint256 surplus1)
{
return _getSurplus();
}
function reflectionSurplus()
external
view
returns (uint256)
{
(uint256 surplus0, uint256 surplus1) = _getSurplus();
return SHADOW_IS_TOKEN0 ? surplus0 : surplus1;
}
function getPairState()
external
view
returns (
uint256 balance0,
uint256 balance1,
uint112 reserve0,
uint112 reserve1,
uint256 surplus0,
uint256 surplus1
)
{
(reserve0, reserve1, ) =
IPulseXPairSR(PAIR).getReserves();
address token0 = IPulseXPairSR(PAIR).token0();
address token1 = IPulseXPairSR(PAIR).token1();
balance0 = IERC20BalanceSR(token0).balanceOf(PAIR);
balance1 = IERC20BalanceSR(token1).balanceOf(PAIR);
surplus0 =
balance0 > uint256(reserve0)
? balance0 - uint256(reserve0)
: 0;
surplus1 =
balance1 > uint256(reserve1)
? balance1 - uint256(reserve1)
: 0;
}
function setThreshold(
uint256 newThreshold
) external onlyKeeper {
emit ThresholdUpdated(
minSurplusThreshold,
newThreshold
);
minSurplusThreshold = newThreshold;
}
function transferKeeper(
address newKeeper
) external onlyKeeper {
require(newKeeper != address(0), "keeper zero");
require(newKeeper != keeper, "already keeper");
pendingKeeper = newKeeper;
emit KeeperTransferStarted(
keeper,
newKeeper
);
}
function cancelKeeperTransfer() external onlyKeeper {
address cancelled = pendingKeeper;
pendingKeeper = address(0);
emit KeeperTransferCancelled(cancelled);
}
function acceptKeeper() external {
require(
msg.sender == pendingKeeper,
"not pending keeper"
);
address oldKeeper = keeper;
keeper = pendingKeeper;
pendingKeeper = address(0);
emit KeeperTransferred(oldKeeper, keeper);
}
}