Description:
Decentralized Finance (DeFi) protocol contract providing Swap, Factory, Oracle functionality.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"src/MiladyCultSwapperBurner.sol": {
"content": "// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;
/// @notice Standard contract ownership (https://eips.ethereum.org/EIPS/eip-173).
/// @author Zolidity (https://github.com/z0r0z/zolidity/blob/main/src/ERC173.sol)
abstract contract ERC173 {
event OwnershipTransferred(address indexed from, address indexed to);
error Unauthorized();
address public owner;
modifier onlyOwner() virtual {
require(msg.sender == owner, Unauthorized());
_;
}
constructor(address _owner) {
emit OwnershipTransferred(address(0), owner = _owner);
}
function transferOwnership(address _owner) public payable virtual onlyOwner {
emit OwnershipTransferred(msg.sender, owner = _owner);
}
}
/// @notice Swap ETH to CULT on Uniswap V3 1% pool. Also Miladys on NFTXV2.
contract MiladyCultSwapperBurner is ERC173 {
uint256 public cultPriceInWei;
uint16 public cultSlippageBps;
address constant CULT_POOL = 0xC4ce8E63921b8B6cBdB8fCB6Bd64cC701Fb926f2;
address constant MILADY_POOL = 0x15A8E38942F9e353BEc8812763fb3C104c89eCf4;
address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
uint160 constant MAX_SQRT_RATIO_MINUS_ONE = 1461446703485210103287273052203988822378723970341;
address constant CTC = 0x0000000000cDC1F8d393415455E382c30FBc0a84; // CheckTheChain.sol
constructor() payable ERC173(tx.origin) {
syncPriceInWei();
}
error Slippage();
/// @dev Raw receipts treated as burner sink.
receive() external payable {
swapCult(address(0), _amountOutMin()); // oracle-ish
}
/// @dev Execute exact-in ETH->CULT swap via Uniswap V3 (1%).
function swapCult(address to, uint256 minOut) public payable {
(int256 a0,) =
IUniswapV3(CULT_POOL).swap(to, false, int256(msg.value), MAX_SQRT_RATIO_MINUS_ONE, "");
require(uint256(-(a0)) >= minOut, Slippage());
}
/// @dev Execute exact-in ETH->MILADY swap via Uniswap V2.
function swapMilady(address to, uint256 minOut) public payable {
assembly ("memory-safe") {
pop(call(gas(), WETH, callvalue(), codesize(), 0x00, codesize(), 0x00))
mstore(0x14, MILADY_POOL)
mstore(0x34, callvalue())
mstore(0x00, 0xa9059cbb000000000000000000000000)
pop(call(gas(), WETH, 0, 0x10, 0x44, codesize(), 0x00))
mstore(0x34, 0)
}
unchecked {
(uint112 r0, uint112 r1,) = IUniswapV2(MILADY_POOL).getReserves();
uint256 amountInWithFee = msg.value * 997;
uint256 numerator = amountInWithFee * r0;
uint256 denominator = uint256(r1) * 1000 + amountInWithFee;
uint256 amount0Out = numerator / denominator;
require(amount0Out >= minOut, Slippage());
IUniswapV2(MILADY_POOL).swap(amount0Out, 0, to, "");
}
}
/// @dev Handle Uniswap V3 callback.
fallback() external payable {
require(msg.sender == CULT_POOL, Unauthorized()); // sanity check pool caller
assembly ("memory-safe") {
let amount1Delta := calldataload(0x24)
pop(call(gas(), WETH, amount1Delta, codesize(), 0x00, codesize(), 0x00))
mstore(0x00, 0xa9059cbb000000000000000000000000)
mstore(0x14, CULT_POOL)
mstore(0x34, amount1Delta)
pop(call(gas(), WETH, 0, 0x10, 0x44, codesize(), 0x00))
}
}
// RECEIVE() SLIPPAGE MGMT
error InvalidSlippageSetting();
function _amountOutMin() internal view returns (uint256) {
unchecked {
return (msg.value * 1e18 * 10_000) / (cultPriceInWei * (10_000 + cultSlippageBps));
}
}
function setSlippageBps(uint16 _slippageBps) public payable onlyOwner {
require(_slippageBps < 10_000, InvalidSlippageSetting());
cultSlippageBps = _slippageBps;
}
function syncPriceInWei() public payable onlyOwner returns (uint256 _priceInWei) {
(_priceInWei,) = checkPriceInETH("CULT");
cultPriceInWei = _priceInWei;
}
function checkPriceInETH(string memory)
public
view
returns (uint256 price, string memory priceStr)
{
return MiladyCultSwapperBurner(payable(CTC)).checkPriceInETH("CULT");
}
}
/// @dev Minimal Uniswap V3 swap interface.
interface IUniswapV3 {
function swap(address, bool, int256, uint160, bytes calldata)
external
returns (int256, int256);
}
/// @dev Minimal Uniswap V2 swap interface.
interface IUniswapV2 {
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data)
external;
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32);
}
"
}
},
"settings": {
"remappings": [
"@solady/=lib/solady/",
"@soledge/=lib/soledge/",
"@forge/=lib/forge-std/src/",
"forge-std/=lib/forge-std/src/",
"solady/=lib/solady/src/"
],
"optimizer": {
"enabled": true,
"runs": 9999999
},
"metadata": {
"useLiteralContent": false,
"bytecodeHash": "ipfs",
"appendCBOR": true
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"evmVersion": "prague",
"viaIR": true
}
}}
Submitted on: 2025-09-27 18:00:01
Comments
Log in to comment.
No comments yet.