Skip to content
Verified contractPartialMIT

ProgramBurnFu

Address0x80e59bef516c47eede3d04ebfe541df0f9c9427a
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.26

 

Same code

2 more contracts

 

Details

Compiler
solc 0.8.26+commit.8a97fa7a
Language
solidity
Optimization
Yes, 44,444,444 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,192,147
Creation transaction
0xe5fea7b8b2…dfdd383b0c

src/programs/Programs.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {IProgram, SwapContext} from "../interfaces/IProgram.sol";
import {Params, MorphepeBounds} from "../libraries/MorphepeBounds.sol";

/// @notice CONSTRUCT: the base program. Returns the swarm's parameters unchanged.
contract ProgramConstruct is IProgram {
    function quote(SwapContext calldata, Params calldata base) external pure returns (Params memory) {
        return base;
    }

    function name() external pure returns (string memory) {
        return "CONSTRUCT";
    }
}

/// @notice BURN-FU: when a buy moves the price hard, shift fee from LPs to the burn.
contract ProgramBurnFu is IProgram {
    uint24 public constant TRIGGER_TICKS = 50; // ~0.5% move inside the block

    function quote(SwapContext calldata ctx, Params calldata base) external pure returns (Params memory p) {
        p = base;
        if (!ctx.isBuy || ctx.tickMove < TRIGGER_TICKS) return p;
        uint256 burn = uint256(p.burnShare) + 20;
        if (burn > MorphepeBounds.MAX_BURN) burn = MorphepeBounds.MAX_BURN;
        uint256 lp = 100 - burn - p.bountyShare;
        if (lp < MorphepeBounds.MIN_LP) {
            lp = MorphepeBounds.MIN_LP;
            burn = 100 - lp - p.bountyShare;
        }
        p.burnShare = uint8(burn);
        p.lpShare = uint8(lp);
    }

    function name() external pure returns (string memory) {
        return "BURN-FU";
    }
}

/// @notice KEYMAKER: routes more of the fee to liquidity providers, taken from the burn share.
contract ProgramKeymaker is IProgram {
    function quote(SwapContext calldata, Params calldata base) external pure returns (Params memory p) {
        p = base;
        uint256 lp = uint256(p.lpShare) + 20;
        if (lp > MorphepeBounds.MAX_LP) lp = MorphepeBounds.MAX_LP;
        if (lp > 100 - p.bountyShare) lp = 100 - p.bountyShare;
        p.lpShare = uint8(lp);
        p.burnShare = uint8(100 - lp - p.bountyShare);
    }

    function name() external pure returns (string memory) {
        return "KEYMAKER";
    }
}

/// @notice EMP: charges the maximum fee to sandwich back-runs and to swap bursts inside one block.
contract ProgramEMP is IProgram {
    uint32 public constant BURST = 3;

    function quote(SwapContext calldata ctx, Params calldata base) external pure returns (Params memory p) {
        p = base;
        if (ctx.reversal || ctx.swapsThisBlock >= BURST) p.fee = MorphepeBounds.MAX_FEE;
    }

    function name() external pure returns (string memory) {
        return "EMP";
    }
}

/// @notice THE ORACLE: fee follows how far the price has moved inside the current block.
contract ProgramOracle is IProgram {
    uint256 public constant PIPS_PER_TICK = 80;

    function quote(SwapContext calldata ctx, Params calldata base) external pure returns (Params memory p) {
        p = base;
        p.fee = MorphepeBounds.clampFee(uint256(base.fee) / 2 + uint256(ctx.tickMove) * PIPS_PER_TICK);
    }

    function name() external pure returns (string memory) {
        return "THE ORACLE";
    }
}

src/interfaces/IProgram.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

import {Params} from "../libraries/MorphepeBounds.sol";

/// @notice What the hook knows about the swap being priced.
struct SwapContext {
    bool isBuy; // ETH -> token
    bool exactInput;
    uint256 amountSpecified; // absolute value of the swap's specified amount
    uint32 swapsThisBlock; // swaps already executed in this block before this one
    uint24 tickMove; // |current tick - tick at the start of the block|
    bool reversal; // the same tx.origin already swapped in the opposite direction this block
}

/// @notice A program is a pure pricing strategy. It returns fee settings and can never move funds.
/// @dev The hook calls `quote` with a gas cap through staticcall. A revert, an out-of-gas or an invalid
///      result makes the hook fall back to the base parameters for that swap.
interface IProgram {
    function quote(SwapContext calldata ctx, Params calldata base) external view returns (Params memory);

    function name() external view returns (string memory);
}

src/libraries/MorphepeBounds.sol

// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;

/// @notice Fee settings for one swap.
/// @dev `fee` is in pips (1_000_000 = 100%). The three shares are percentages of the fee and must add up to 100.
struct Params {
    uint24 fee;
    uint8 burnShare;
    uint8 lpShare;
    uint8 bountyShare;
}

/// @notice Hard limits shared by the hook and the programs. Nothing in the system can move outside them.
library MorphepeBounds {
    uint24 internal constant MIN_FEE = 3_000; // 0.30%
    uint24 internal constant MAX_FEE = 30_000; // 3.00%
    uint8 internal constant MAX_BURN = 60;
    uint8 internal constant MIN_LP = 20;
    uint8 internal constant MAX_LP = 80;
    uint8 internal constant MIN_BOUNTY = 10;
    uint8 internal constant MAX_BOUNTY = 30;

    /// @notice True when `p` is inside every absolute bound and its shares add up to 100.
    function isValid(Params memory p) internal pure returns (bool) {
        return p.fee >= MIN_FEE && p.fee <= MAX_FEE && p.burnShare <= MAX_BURN && p.lpShare >= MIN_LP
            && p.lpShare <= MAX_LP && p.bountyShare >= MIN_BOUNTY && p.bountyShare <= MAX_BOUNTY
            && uint256(p.burnShare) + p.lpShare + p.bountyShare == 100;
    }

    function clampFee(uint256 fee) internal pure returns (uint24) {
        if (fee < MIN_FEE) return MIN_FEE;
        if (fee > MAX_FEE) return MAX_FEE;
        return uint24(fee);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "none",
    "useLiteralContent": false
  },
  "libraries": {},
  "optimizer": {
    "runs": 44444444,
    "enabled": true
  },
  "evmVersion": "cancun",
  "remappings": [
    "@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
    "v4-core/=lib/v4-periphery/lib/v4-core/src/",
    "v4-periphery/=lib/v4-periphery/",
    "@uniswap/v4-periphery/=lib/v4-periphery/",
    "permit2/=lib/v4-periphery/lib/permit2/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "forge-std/=lib/forge-std/src/",
    "solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
    "lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/lib/forge-std/lib/ds-test/src/",
    "lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/:ds-test/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/",
    "lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
    "lib/v4-periphery/lib/permit2/lib/forge-std/:ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
    "lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
    "lib/v4-periphery/lib/permit2/lib/solmate/:ds-test/=lib/v4-periphery/lib/permit2/lib/solmate/lib/ds-test/src/",
    "lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/:erc4626-tests/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
    "lib/v4-periphery/lib/v4-core/lib/solmate/:ds-test/=lib/v4-periphery/lib/v4-core/lib/solmate/lib/ds-test/src/",
    "lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "lib/openzeppelin-contracts/:erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "@ensdomains/=lib/v4-periphery/lib/v4-core/node_modules/@ensdomains/",
    "@openzeppelin/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/",
    "ds-test/=lib/v4-periphery/lib/permit2/lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "forge-gas-snapshot/=lib/v4-periphery/lib/permit2/lib/forge-gas-snapshot/src/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "hardhat/=lib/v4-periphery/lib/v4-core/node_modules/hardhat/"
  ]
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.