Verified contractPartialMIT
SapBuyback
Address0x1e4182f9182ddc6633f4bc184882ea6c0f69cb46
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.36
- Same code
Only this contract
Details
- Compiler
- solc 0.8.36+commit.8a079791
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- prague
- Via IR
- yes
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,465,329
- Creation transaction
- 0x32665a7738…0fd712489f
src/SapBuyback.sol
// SPDX-License-Identifier: MIT
//
// sap.fun | start a project
//
// web: https://sap.fun
// x: https://x.com/LaunchWithSAP
//
pragma solidity ^0.8.24;
interface ISwapRouter02 {
struct ExactInputParams {
bytes path;
address recipient;
uint256 amountIn;
uint256 amountOutMinimum;
}
function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);
}
interface IWETHLike {
function deposit() external payable;
function approve(address, uint256) external returns (bool);
}
interface IERC20Like2 {
function balanceOf(address) external view returns (uint256);
function transfer(address, uint256) external returns (bool);
}
/// @title SapBuyback — buyback-and-burn vault for the $SAP flagship token
/// @notice Receives 20% of every sap.fun platform fee. buyAndBurnSap() swaps
/// accumulated ETH for $SAP along an owner-configured Uniswap V3 path
/// (default WETH → USDC → SAP, since the flagship pool is SAP/USDC)
/// and sends the tokens straight to the dead address.
/// Fees that arrive in ERC-20 quote assets can be swept by the
/// operator for conversion (sweeps are logged; SAP bought with them
/// must be burned the same way — $SAP itself can only be swept to
/// the dead address).
contract SapBuyback {
address public constant DEAD = 0x000000000000000000000000000000000000dEaD;
address public owner;
address public immutable sap;
address public immutable weth;
ISwapRouter02 public immutable router;
/// @notice V3 exactInput path from WETH to SAP (packed token/fee hops).
bytes public buyPath;
uint256 public totalEthUsed;
uint256 public totalSapBurned;
event BuybackExecuted(uint256 ethIn, uint256 sapBurned);
event Swept(address indexed token, address indexed to, uint256 amount);
event BuyPathChanged(bytes path);
event OwnerChanged(address owner);
modifier onlyOwner() {
require(msg.sender == owner, "Buyback: not owner");
_;
}
constructor(address sap_, address weth_, address router_, bytes memory buyPath_) {
require(sap_ != address(0) && weth_ != address(0) && router_ != address(0), "Buyback: zero addr");
owner = msg.sender;
sap = sap_;
weth = weth_;
router = ISwapRouter02(router_);
_setBuyPath(buyPath_);
}
receive() external payable {}
/// @notice Swap `ethAmount` of the vault's ETH for $SAP and burn it.
/// minSapOut guards against sandwiching — quote it off-chain.
function buyAndBurnSap(uint256 ethAmount, uint256 minSapOut) external onlyOwner returns (uint256 sapBurned) {
require(ethAmount > 0 && ethAmount <= address(this).balance, "Buyback: bad amount");
IWETHLike(weth).deposit{value: ethAmount}();
IWETHLike(weth).approve(address(router), ethAmount);
sapBurned = router.exactInput(
ISwapRouter02.ExactInputParams({
path: buyPath,
recipient: DEAD,
amountIn: ethAmount,
amountOutMinimum: minSapOut
})
);
totalEthUsed += ethAmount;
totalSapBurned += sapBurned;
emit BuybackExecuted(ethAmount, sapBurned);
}
/// @notice Sweep ERC-20 quote-asset fees out for off-vault conversion.
function sweepFromVault(address token, address to, uint256 amount) external onlyOwner {
require(to != address(0), "Buyback: zero addr");
if (token == sap) require(to == DEAD, "Buyback: sap only burns");
require(IERC20Like2(token).transfer(to, amount), "Buyback: transfer failed");
emit Swept(token, to, amount);
}
function setSapBuyPath(bytes calldata newPath) external onlyOwner {
_setBuyPath(newPath);
}
function _setBuyPath(bytes memory newPath) internal {
// packed path: 20b token (+ 3b fee + 20b token)+ — must run WETH → … → SAP
require(newPath.length >= 43 && (newPath.length - 20) % 23 == 0, "Buyback: bad path");
require(_tokenAt(newPath, 0) == weth, "Buyback: path must start WETH");
require(_tokenAt(newPath, newPath.length - 20) == sap, "Buyback: path must end SAP");
buyPath = newPath;
emit BuyPathChanged(newPath);
}
function _tokenAt(bytes memory path, uint256 offset) internal pure returns (address token) {
assembly {
token := shr(96, mload(add(add(path, 32), offset)))
}
}
function setBuybackOwner(address newOwner) external onlyOwner {
require(newOwner != address(0), "Buyback: zero addr");
owner = newOwner;
emit OwnerChanged(newOwner);
}
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "prague"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.