文件 1 的 4:Context.sol
pragma solidity ^0.8.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
文件 2 的 4:INonfungiblePositionManager.sol
pragma solidity >=0.4.23 <0.9.0;
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
interface INonfungiblePositionManager {
function collect(
CollectParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
}
文件 3 的 4:Ownable.sol
pragma solidity ^0.8.0;
import "Context.sol";
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() {
_transferOwnership(_msgSender());
}
modifier onlyOwner() {
_checkOwner();
_;
}
function owner() public view virtual returns (address) {
return _owner;
}
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
文件 4 的 4:UniswapV3FeeCollector.sol
pragma solidity 0.8.9;
import "Ownable.sol";
import "INonfungiblePositionManager.sol";
contract LPFeeCollector is Ownable {
address private immutable _EEFI_FURNACE =
0xe9B230DA91FE0f451d9b92Fd5213Bde058567Cd1;
address private constant _POSITION_MANAGER =
0xC36442b4a4522E871399CD717aBDD847Ab11FE88;
INonfungiblePositionManager public constant position_manager =
INonfungiblePositionManager(_POSITION_MANAGER);
function getCurrentReward(
uint256 _tokenId,
uint128 _amount0Max,
uint128 _amount1Max
) public onlyOwner returns (uint256 amount0, uint256 amount1) {
CollectParams memory params = CollectParams({
tokenId: _tokenId,
recipient: _EEFI_FURNACE,
amount0Max: _amount0Max,
amount1Max: _amount1Max
});
(amount0, amount1) = position_manager.collect(params);
}
function collectUniswapV3Fees(
uint256 _tokenId,
uint128 _amount0Max,
uint128 _amount1Max
) external onlyOwner {
position_manager.collect(
CollectParams({
tokenId: _tokenId,
recipient: _EEFI_FURNACE,
amount0Max: _amount0Max,
amount1Max: _amount1Max
})
);
}
}
{
"compilationTarget": {
"UniswapV3FeeCollector.sol": "LPFeeCollector"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint128","name":"_amount0Max","type":"uint128"},{"internalType":"uint128","name":"_amount1Max","type":"uint128"}],"name":"collectUniswapV3Fees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint128","name":"_amount0Max","type":"uint128"},{"internalType":"uint128","name":"_amount1Max","type":"uint128"}],"name":"getCurrentReward","outputs":[{"internalType":"uint256","name":"amount0","type":"uint256"},{"internalType":"uint256","name":"amount1","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"position_manager","outputs":[{"internalType":"contract INonfungiblePositionManager","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]