Verified contractExactMIT
SRockHook
Address0xdca17c9e4696f87a39ed747d01653790d4e8e840
- Balance
0 ETH
- Transactions
79
- Compiler
solc 0.8.33
- Same code
Only this contract
Details
- Compiler
- solc 0.8.33+commit.64118f21
- Language
- solidity
- Optimization
- Yes, 200 runs
- EVM version
- prague
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 26,127,234
- Creation transaction
- 0x8ba50b3de3…1da2013cb1
52 files
The source code is large: one file is shown at a time. Choose a file in the list.
- src/SRockHook.solmain47.27 KB
- lib/solady/src/auth/Ownable.sol12.55 KB
- lib/solady/src/tokens/ERC20.sol31.12 KB
- lib/solady/src/utils/Base64.sol7.72 KB
- lib/solady/src/utils/DynamicBufferLib.sol43.74 KB
- lib/solady/src/utils/LibBit.sol13.24 KB
- lib/solady/src/utils/LibBytes.sol38.18 KB
- lib/solady/src/utils/LibString.sol44.25 KB
- lib/solady/src/utils/ReentrancyGuard.sol2.33 KB
- lib/v4-periphery/lib/permit2/src/interfaces/IAllowanceTransfer.sol7.7 KB
- lib/v4-periphery/lib/permit2/src/interfaces/IEIP712.sol144 B
- lib/v4-periphery/lib/v4-core/src/interfaces/IExtsload.sol1.02 KB
- lib/v4-periphery/lib/v4-core/src/interfaces/IExttload.sol699 B
- lib/v4-periphery/lib/v4-core/src/interfaces/IHooks.sol8.23 KB
- lib/v4-periphery/lib/v4-core/src/interfaces/IPoolManager.sol12.84 KB
- lib/v4-periphery/lib/v4-core/src/interfaces/IProtocolFees.sol2.49 KB
- lib/v4-periphery/lib/v4-core/src/interfaces/callback/IUnlockCallback.sol488 B
- lib/v4-periphery/lib/v4-core/src/interfaces/external/IERC20Minimal.sol3.04 KB
- lib/v4-periphery/lib/v4-core/src/interfaces/external/IERC6909Claims.sol3.16 KB
- lib/v4-periphery/lib/v4-core/src/libraries/BitMath.sol2.61 KB
- lib/v4-periphery/lib/v4-core/src/libraries/CustomRevert.sol5.17 KB
- lib/v4-periphery/lib/v4-core/src/libraries/FixedPoint96.sol366 B
- lib/v4-periphery/lib/v4-core/src/libraries/FullMath.sol5.46 KB
- lib/v4-periphery/lib/v4-core/src/libraries/Hooks.sol16.51 KB
- lib/v4-periphery/lib/v4-core/src/libraries/LPFeeLibrary.sol3.6 KB
- lib/v4-periphery/lib/v4-core/src/libraries/ParseBytes.sol1.2 KB
- lib/v4-periphery/lib/v4-core/src/libraries/SafeCast.sol2.27 KB
- lib/v4-periphery/lib/v4-core/src/libraries/TickMath.sol12.38 KB
- lib/v4-periphery/lib/v4-core/src/types/BalanceDelta.sol2.34 KB
- lib/v4-periphery/lib/v4-core/src/types/BeforeSwapDelta.sol1.47 KB
- lib/v4-periphery/lib/v4-core/src/types/Currency.sol5.46 KB
- lib/v4-periphery/lib/v4-core/src/types/PoolId.sol539 B
- lib/v4-periphery/lib/v4-core/src/types/PoolKey.sol805 B
- lib/v4-periphery/lib/v4-core/src/types/PoolOperation.sol907 B
- lib/v4-periphery/src/interfaces/IEIP712_v4.sol328 B
- lib/v4-periphery/src/interfaces/IERC721Permit_v4.sol2.14 KB
- lib/v4-periphery/src/interfaces/IImmutableState.sol365 B
- lib/v4-periphery/src/interfaces/IMulticall_v4.sol774 B
- lib/v4-periphery/src/interfaces/INotifier.sol3.2 KB
- lib/v4-periphery/src/interfaces/IPermit2Forwarder.sol1.44 KB
- lib/v4-periphery/src/interfaces/IPoolInitializer_v4.sol782 B
- lib/v4-periphery/src/interfaces/IPositionManager.sol3.5 KB
- lib/v4-periphery/src/interfaces/ISubscriber.sol2.27 KB
- lib/v4-periphery/src/interfaces/IUnorderedNonce.sol799 B
- lib/v4-periphery/src/libraries/Actions.sol2.59 KB
- lib/v4-periphery/src/libraries/LiquidityAmounts.sol3.8 KB
- lib/v4-periphery/src/libraries/PositionInfoLibrary.sol3.92 KB
- src/SRockArt.sol22.03 KB
- src/SRockGate.sol6.52 KB
- src/SRockMirror.sol11.12 KB
- src/SRockNames.sol9.5 KB
- src/base/BaseHook.sol6.61 KB
src/SRockHook.sol
// SPDX-License-Identifier: MIT
/*
* _.--------._
* .-' '-.
* / ============ \
* | ======== |
* | ==== |
* \ /
* '-.__ __.-'
* '------'
*
* sRock · a rock that remembers who held it
* https://srock.art · https://x.com/srock_art · dev @ippg
*/
pragma solidity ^0.8.28;
import {ERC20} from "solady/src/tokens/ERC20.sol";
import {Ownable} from "solady/src/auth/Ownable.sol";
import {ReentrancyGuard} from "solady/src/utils/ReentrancyGuard.sol";
import {LibBit} from "solady/src/utils/LibBit.sol";
import {LibString} from "solady/src/utils/LibString.sol";
import {IPositionManager} from "@uniswap/v4-periphery/src/interfaces/IPositionManager.sol";
import {Actions} from "@uniswap/v4-periphery/src/libraries/Actions.sol";
import {LiquidityAmounts} from "@uniswap/v4-periphery/src/libraries/LiquidityAmounts.sol";
import {IAllowanceTransfer} from "permit2/src/interfaces/IAllowanceTransfer.sol";
import {IHooks} from "@uniswap/v4-core/src/interfaces/IHooks.sol";
import {IPoolManager} from "@uniswap/v4-core/src/interfaces/IPoolManager.sol";
import {IUnlockCallback} from "@uniswap/v4-core/src/interfaces/callback/IUnlockCallback.sol";
import {Hooks} from "@uniswap/v4-core/src/libraries/Hooks.sol";
import {TickMath} from "@uniswap/v4-core/src/libraries/TickMath.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
import {ModifyLiquidityParams, SwapParams} from "@uniswap/v4-core/src/types/PoolOperation.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";
import {BaseHook} from "./base/BaseHook.sol";
import {SRockGate} from "./SRockGate.sol";
import {SRockMirror, Line} from "./SRockMirror.sol";
/// @title SRockHook
/// @author @ippg (https://srock.art)
/// @notice A coin that carves the name of everyone who held it, bigger the longer they held.
/// Each whole token is one persistent rock; each rock keeps the five longest holds of its
/// history, and holders can inscribe a short quote whose price buys and burns the coin.
/// @dev The ERC-20 and the v4 hook in one contract (DN404-style). Rocks move only in the ERC-20
/// transfer path: a wallet sends its newest rock (LIFO), the Quarry (every rock no holder
/// owns, i.e. the pool's) hands out its oldest (FIFO). A wallet takes rocks from the Quarry
/// front whenever its backed balance crosses an integer upward (a buy on the pool, fractions
/// merged by a transfer, owed rocks served), and only a whole token sold on the pool sends
/// one to its back. The swap path records those amounts and never reverts a sell; a buy
/// reverts only in the two-block launch window when it does not come through SRockGate. No
/// one but this contract can initialize the pool or add liquidity to it. No admin halt, no
/// drain: the owner can only seed once, and the pool fee accrues to an immutable recipient.
/// See RULES.md.
/// @custom:inspired Vectorized's DN404 (https://github.com/Vectorized/dn404).
contract SRockHook is ERC20, BaseHook, Ownable, ReentrancyGuard, IUnlockCallback {
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CUSTOM ERRORS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev `seed()` already called.
error AlreadySeeded();
/// @dev A required address is the zero address.
error ZeroAddress();
/// @dev Rock ids must fit a uint16 (below its max), the quote price and pool fee must be usable.
error InvalidConfig();
/// @dev Someone other than this contract tried to initialize a pool with this hook.
error InitializeGuarded();
/// @dev Liquidity can only be added by `seed()` (AUDIT.md R2-H-01).
error LiquidityLocked();
/// @dev Caller is neither owner nor approved for the rock.
error NotOwnerOrApproved();
/// @dev Rock does not exist (never did, or was crushed) or `from` does not own it.
error InvalidTokenId();
/// @dev Caller is not the mirror.
error MirrorOnly();
/// @dev Rock transfer recipient is address(0).
error TransferToZero();
/// @dev Rock transfer recipient is the pool manager or this contract (never holders).
error TransferToReserved();
/// @dev Rock transfer source equals recipient.
error SelfTransferDisallowed();
/// @dev Only the rock's current holder may inscribe it.
error NotRockHolder();
/// @dev Quote empty, longer than MAX_QUOTE_CHARS, or outside [a-zA-Z0-9 !?'-].
error InvalidQuote();
/// @dev `msg.value` is not exactly chars × QUOTE_PRICE.
error WrongPayment();
/// @dev A crush found the Quarry empty. Unreachable: floor(supply) ≥ Σ floor(balances) always.
error QuarryEmpty();
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* EVENTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice The pool was created and all rocks were placed in it.
event Seeded(uint256 indexed positionId, int24 tickUpper, uint128 liquidity);
/// @notice A holder's stint on a rock made (or grew) one of its five carved lines.
event Engraved(uint256 indexed rockId, address indexed holder, uint256 heldTotal);
/// @notice A holder wrote a quote on their line; its price bought and burned `burned` tokens.
event Inscribed(uint256 indexed rockId, address indexed holder, string quote, uint256 burned);
/// @notice Supply crossed below an integer and the emptiest Quarry rock was destroyed.
event Crushed(uint256 indexed rockId);
/// @notice Accrued pool fees were sent to FEE_RECIPIENT.
event FeesCollected(uint256 eth, uint256 tokens);
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTANTS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
uint256 public constant UNIT = 1 ether;
int24 public constant TICK_SPACING = 200;
/// @notice Carved lines kept per rock.
uint256 public constant MAX_LINES = 5;
/// @notice Blocks from the seed block (included) during which buys must come through GATE.
uint256 public constant LAUNCH_WINDOW = 2;
/// @notice Longest quote; a quote fits one bytes20 slot.
uint256 public constant MAX_QUOTE_CHARS = 20;
/// @dev Crush buckets are keyed `lines * CHAR_KEYS + chars`: fewest lines first, then fewest
/// quote chars. 6 × 101 = 606 keys, one bit each in a 3-word bitmap.
uint256 private constant CHAR_KEYS = MAX_LINES * MAX_QUOTE_CHARS + 1;
uint256 private constant BUCKET_WORDS = 3;
/// @dev Transient slot for the realignment-skip flag.
uint256 private constant _SILENT_SLOT = 0x9a8f8d1e3c5b7a9d6e2f4a8c7b5d3f9e1a6c4b8d2e7f5a9c3b1d6e8f2a4c7b9d;
/// @dev Transient: tokens bought on the pool in this transaction and not yet paid out.
/// keccak256("srock.credit").
uint256 private constant _CREDIT_SLOT = 0x2b228ed9cfa28ab9af7b9cb2f0d95e8c5b053664e0f9b08ae0250c4c171002cb;
/// @dev Transient: tokens sold on the pool in this transaction and not yet paid in.
/// keccak256("srock.sold").
uint256 private constant _SOLD_SLOT = 0x7aef80a5ab62dd663f972d0a4b4ffa0d41a4bfaf2b0b016bce1a0658eec3726b;
/// @dev Transient: seed of each holder's unbacked-balance slot. keccak256("srock.unbacked").
uint256 private constant _UNBACKED_SEED = 0x6d1bcef6fd7a7cbbbce5405e010a785cdfc7448b7c43f147053da7c00af83578;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* IMMUTABLES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
address public immutable POSM;
address public immutable PERMIT2;
SRockMirror public immutable mirror;
/// @notice Genesis rock count; ids run 1..ROCKS.
uint256 public immutable ROCKS;
/// @notice Genesis supply, ROCKS whole tokens.
uint256 public immutable SUPPLY;
/// @notice Static pool fee in pips (1% = 10_000), both ways.
uint24 public immutable POOL_FEE;
/// @notice Wei per quote character.
uint256 public immutable QUOTE_PRICE;
/// @notice Receives the pool's accrued fees. Immutable: there is no admin to redirect them.
address public immutable FEE_RECIPIENT;
/// @notice The only swapper allowed to buy during the launch window (SRockGate: verified .eth names).
address public immutable GATE;
bytes32 private immutable _name;
bytes32 private immutable _symbol;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* STORAGE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev One slot per rock. A rock sits in exactly one doubly-linked list at a time (its
/// holder's wallet, or the Quarry), through `prev`/`next`. `bucketNext` chains it inside
/// its crush bucket while in the Quarry; `since` starts its holder's clock; `lines` and
/// `chars` cache the rock's crush key so moving it never reads the lines.
struct Rock {
address owner; // holder, this contract (Quarry), or 0 (genesis Quarry / crushed)
uint16 prev;
uint16 next;
uint16 bucketNext;
uint32 since;
uint8 lines;
uint8 chars;
}
/// @dev A holder's rocks, oldest at `head`, newest at `tail`.
struct Wallet {
uint16 head;
uint16 tail;
uint16 count;
}
/// @dev The Quarry queue, front to back: the list from `head` up to `firstBack` (rocks parked
/// back, not sold), then the untouched genesis range [nextGenesis, ROCKS] (id order, never
/// written until handed out), then the list from `firstBack` to `tail` (rocks sold back).
struct Quarry {
uint16 head;
uint16 tail;
uint16 firstBack; // 0 when no rock was sold back
uint16 listed;
uint16 nextGenesis;
uint16 rocks; // live rocks, always floor(totalSupply / UNIT)
}
/// @notice Block of the one-shot `seed()`; 0 until then.
uint64 public launchBlock;
uint256 public positionId;
Quarry private _quarry;
mapping(uint256 => Rock) private _rocks;
mapping(uint256 => Line[MAX_LINES]) private _lines;
mapping(uint256 => bytes20) private _liveQuote;
mapping(address => Wallet) private _wallets;
/// @dev Crush buckets, 8 per word: `head | tail << 16` in each 32-bit lane.
mapping(uint256 => uint256) private _buckets;
uint256[BUCKET_WORDS] private _bucketBits;
mapping(uint256 => address) private _nftApprovals;
mapping(address => mapping(address => bool)) private _nftOperatorApprovals;
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CONSTRUCTOR */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @param rocks Genesis rock count (the .env supply), at most 65534.
/// @param quotePrice Wei per quote character.
/// @param poolFee Static pool fee in pips.
/// @param feeRecipient Receives the pool fees forever.
/// @param gate The launch-window gate (SRockGate).
constructor(
IPoolManager _poolManager,
address _owner,
address _posm,
address _permit2,
address feeRecipient,
string memory name_,
string memory symbol_,
uint256 rocks,
uint256 quotePrice,
uint24 poolFee,
address gate
) BaseHook(_poolManager) {
if (
_owner == address(0) || _posm == address(0) || _permit2 == address(0) || feeRecipient == address(0)
|| gate == address(0)
) revert ZeroAddress();
// Below uint16 max: the genesis cursor steps to ROCKS + 1.
if (rocks == 0 || rocks >= type(uint16).max || quotePrice == 0 || poolFee >= 1_000_000) revert InvalidConfig();
POSM = _posm;
PERMIT2 = _permit2;
FEE_RECIPIENT = feeRecipient;
GATE = gate;
ROCKS = rocks;
SUPPLY = rocks * UNIT;
QUOTE_PRICE = quotePrice;
POOL_FEE = poolFee;
_name = LibString.packOne(name_);
_symbol = LibString.packOne(symbol_);
mirror = new SRockMirror(address(this), rocks);
_quarry = Quarry({head: 0, tail: 0, firstBack: 0, listed: 0, nextGenesis: 1, rocks: uint16(rocks)});
_initializeOwner(_owner);
_mint(address(this), SUPPLY);
_approve(address(this), _permit2, type(uint256).max);
IAllowanceTransfer(_permit2).approve(address(this), _posm, type(uint160).max, type(uint48).max);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC20 METADATA */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice Token name, set at deploy from `.env` (`SROCK_NAME`).
function name() public view override returns (string memory) {
return LibString.unpackOne(_name);
}
/// @notice Token ticker, set at deploy from `.env` (`SROCK_TICKER`).
function symbol() public view override returns (string memory) {
return LibString.unpackOne(_symbol);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* V4 HOOK */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice The hook's callbacks, encoded in its address (low bits 0x2840).
/// @dev beforeInitialize: the seed guard. beforeAddLiquidity: only the seed adds liquidity.
/// afterSwap: records buys and sells (RULES.md §3) and gates buys in the launch window.
function getHookPermissions() public pure override returns (Hooks.Permissions memory p) {
p.beforeInitialize = true;
p.beforeAddLiquidity = true;
p.afterSwap = true;
}
/// @dev Always reverts. `seed()` initializes the pool itself, and v4 skips hook callbacks when
/// the caller is the hook (noSelfCall), so the guard only ever fires on someone else: no
/// one can front-run the seed with a pool at a hostile price, or open a second pool on
/// this hook.
function _beforeInitialize(address, PoolKey calldata, uint160) internal pure override returns (bytes4) {
revert InitializeGuarded();
}
/// @dev Only `seed()` provides liquidity (it reaches this through the position manager while
/// launchBlock is still 0). Anyone else's add, above all a same-transaction JIT position
/// that would refund the 1% fee of a Quarry walk, reverts (AUDIT.md R2-H-01). Removing
/// liquidity is not hooked: the only position is this contract's own.
function _beforeAddLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
internal
view
override
returns (bytes4)
{
if (launchBlock != 0) revert LiquidityLocked();
return IHooks.beforeAddLiquidity.selector;
}
/// @dev Records what a buy paid out or a sell took in, so the matching token transfers in this
/// transaction take rocks off the Quarry front or send them to its back (RULES.md §3).
/// A sell never reverts. In the launch window a buy that did not come through GATE.buy is
/// checked by GATE against the signer (tx.origin), so any router works but only a verified
/// .eth name under the cap can buy (RULES.md §11).
function _afterSwap(
address sender,
PoolKey calldata,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata
) internal override returns (bytes4, int128) {
if (params.zeroForOne) {
if (block.number < launchBlock + LAUNCH_WINDOW && sender != GATE) {
SRockGate(GATE).check(tx.origin, uint128(delta.amount1()));
}
_setCredit(_credit() + uint128(delta.amount1()));
} else {
_setSold(_sold() + uint128(-delta.amount1()));
}
return (IHooks.afterSwap.selector, 0);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* SEED */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice Opens the ETH pool with the whole supply, single-sided, starting at `tickUpper`.
/// @dev One-shot. The position spans [minUsableTick, tickUpper] and the price starts at
/// tickUpper, so it holds only tokens and the first buy trades immediately. The
/// position NFT stays on this contract forever: there is no path to remove liquidity.
/// @param tickUpper Launch price tick (tokens per ETH), a multiple of TICK_SPACING.
function seed(int24 tickUpper) external onlyOwner returns (uint256 id) {
if (launchBlock != 0) revert AlreadySeeded();
PoolKey memory key = _poolKey();
int24 tickLower = TickMath.minUsableTick(TICK_SPACING);
uint160 sqrtUpper = TickMath.getSqrtPriceAtTick(tickUpper);
uint128 liquidity =
LiquidityAmounts.getLiquidityForAmount1(TickMath.getSqrtPriceAtTick(tickLower), sqrtUpper, SUPPLY);
poolManager.initialize(key, sqrtUpper);
bytes memory actions = abi.encodePacked(uint8(Actions.MINT_POSITION), uint8(Actions.SETTLE_PAIR));
bytes[] memory params = new bytes[](2);
params[0] = abi.encode(key, tickLower, tickUpper, liquidity, uint256(0), SUPPLY, address(this), bytes(""));
params[1] = abi.encode(key.currency0, key.currency1);
id = IPositionManager(POSM).nextTokenId();
positionId = id;
IPositionManager(POSM).modifyLiquidities(abi.encode(actions, params), block.timestamp);
// Set last: until now the liquidity guard lets the position manager mint this position.
launchBlock = uint64(block.number);
emit Seeded(id, tickUpper, liquidity);
}
/// @notice Sends the pool's accrued fees (ETH and tokens) to FEE_RECIPIENT. Permissionless.
function collectFees() external nonReentrant {
uint256 ethBefore = FEE_RECIPIENT.balance;
uint256 tokensBefore = balanceOf(FEE_RECIPIENT);
bytes memory actions = abi.encodePacked(uint8(Actions.DECREASE_LIQUIDITY), uint8(Actions.TAKE_PAIR));
bytes[] memory params = new bytes[](2);
params[0] = abi.encode(positionId, uint256(0), uint128(0), uint128(0), bytes(""));
params[1] = abi.encode(Currency.wrap(address(0)), Currency.wrap(address(this)), FEE_RECIPIENT);
IPositionManager(POSM).modifyLiquidities(abi.encode(actions, params), block.timestamp);
emit FeesCollected(FEE_RECIPIENT.balance - ethBefore, balanceOf(FEE_RECIPIENT) - tokensBefore);
}
function _poolKey() internal view returns (PoolKey memory) {
return PoolKey({
currency0: Currency.wrap(address(0)),
currency1: Currency.wrap(address(this)),
fee: POOL_FEE,
tickSpacing: TICK_SPACING,
hooks: IHooks(address(this))
});
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* QUOTES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice Writes `quote` on your own line of rock `id`, replacing any previous one. Costs
/// QUOTE_PRICE per character; all of it buys the coin from the pool and burns it.
/// @dev The quote travels with the holder's line: frozen when they let the rock go, hidden
/// while they are outside the top five. The charset excludes '.', '/', ':' and markup,
/// so a quote can carry no URL, no fake .eth and no SVG injection. A burn crossing an
/// integer crushes the emptiest Quarry rock, never a held one.
/// @param id A rock you hold.
/// @param quote 1..20 chars of [a-zA-Z0-9 !?'-].
function inscribe(uint256 id, string calldata quote) external payable nonReentrant {
if (_rocks[id].owner != msg.sender) revert NotRockHolder();
uint256 len = bytes(quote).length;
if (len == 0 || len > MAX_QUOTE_CHARS || !_isCarvable(quote)) revert InvalidQuote();
if (msg.value != len * QUOTE_PRICE) revert WrongPayment();
_liveQuote[id] = bytes20(bytes(quote));
uint256 burned = abi.decode(poolManager.unlock(abi.encode(msg.value)), (uint256));
_burn(address(this), burned);
mirror.emitMetadataUpdate(id);
emit Inscribed(id, msg.sender, quote, burned);
}
/// @dev Exact-input ETH → token swap on our own pool, bought tokens taken here to be burned.
/// The hook calls the pool manager directly, so no hook callback runs on this swap.
function unlockCallback(bytes calldata data) external onlyPoolManager returns (bytes memory) {
uint256 ethIn = abi.decode(data, (uint256));
BalanceDelta delta = poolManager.swap(
_poolKey(),
SwapParams({
zeroForOne: true, amountSpecified: -int256(ethIn), sqrtPriceLimitX96: TickMath.MIN_SQRT_PRICE + 1
}),
""
);
uint256 bought = uint128(delta.amount1());
poolManager.settle{value: uint128(-delta.amount0())}();
poolManager.take(Currency.wrap(address(this)), address(this), bought);
return abi.encode(bought);
}
function _isCarvable(string calldata quote) private pure returns (bool) {
bytes calldata b = bytes(quote);
for (uint256 i; i < b.length; ++i) {
bytes1 c = b[i];
if (!((c >= "a" && c <= "z") || (c >= "A" && c <= "Z") || (c >= "0" && c <= "9") || c == " " || c == "!"
|| c == "?" || c == "'" || c == "-")) return false;
}
return true;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ERC20 → ROCK SYNC */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Keeps `rocks held == floor(backed balance)` for every holder. A sender gives up its
/// newest rocks: straight to the recipient when it gains whole tokens, the rest to the
/// Quarry; a recipient takes any further rocks from the front of the Quarry. A burn crushes
/// Quarry rocks until the rock count is floor(totalSupply) again.
///
/// The Quarry's order can only be bought, never cycled for gas (RULES.md §3):
/// - Tokens leaving the pool manager beyond what was bought on the pool in this
/// transaction (a flash `take`, another pool, a claim or position withdrawn) are
/// unbacked until it ends and leave a wallet first, so a flash loan pulls no rock.
/// - Rocks reach the back of the Quarry only for tokens sold on the pool, one rock per whole
/// token sold and paid in. Any other deposit (a repay, ERC-6909 claims, liquidity, another
/// pool) and any fractional crossing parks its rocks at the front, where the next wallet
/// served takes them (the same holder's owed rocks or next buy, or the next buyer). Otherwise
/// deposit-then-withdraw, or a 1-wei sell and 1-wei buy across an integer, would walk the
/// queue one rock per cycle.
function _afterTokenTransfer(address from, address to, uint256 amount) internal override {
if (_isSilent()) return;
uint256 unbacked;
if (from == address(poolManager)) {
if (_isHolder(to)) {
uint256 credit = _credit();
uint256 covered = amount < credit ? amount : credit;
_setCredit(credit - covered);
unbacked = amount - covered;
if (unbacked != 0) _setUnbacked(to, _unbacked(to) + unbacked);
}
} else if (_isHolder(from)) {
uint256 u = _unbacked(from);
unbacked = amount < u ? amount : u;
if (unbacked != 0) {
_setUnbacked(from, u - unbacked);
if (_isHolder(to)) _setUnbacked(to, _unbacked(to) + unbacked);
}
}
uint256 surplus = _isHolder(from) ? _surplus(from) : 0;
uint256 deficit = _isHolder(to) ? _deficit(to) : 0;
uint256 direct = surplus < deficit ? surplus : deficit;
for (uint256 i; i < direct; ++i) {
_handOver(from, to, _wallets[from].tail);
}
if (surplus > direct) {
uint256 back = to == address(poolManager) ? _consumeSold(surplus - direct, (amount - unbacked) / UNIT) : 0;
for (uint256 i = direct; i < surplus; ++i) {
_toQuarry(from, _wallets[from].tail, i - direct < back);
}
}
for (uint256 i = direct; i < deficit; ++i) {
_fromQuarry(to);
}
if (to == address(0)) {
while (_quarry.rocks > totalSupply() / UNIT) _crush();
}
}
/// @dev How many of the `released` rocks of a deposit go to the back of the Quarry: one per whole
/// backed token paid in (`paidWhole`) that the pool also took in on a sale in this
/// transaction, and that sale is spent per whole rock. Counting in whole tokens, not wei,
/// is what stops a 1-wei sell across an integer from sending a whole rock to the back
/// (AUDIT.md H-01).
function _consumeSold(uint256 released, uint256 paidWhole) private returns (uint256 back) {
uint256 sold = _sold();
back = released < paidWhole ? released : paidWhole;
if (back > sold / UNIT) back = sold / UNIT;
if (back != 0) _setSold(sold - back * UNIT);
}
/// @dev The pool manager (the Quarry's tokens) and this contract never hold rocks.
function _isHolder(address a) private view returns (bool) {
return a != address(0) && a != address(poolManager) && a != address(this);
}
function _surplus(address a) private view returns (uint256) {
uint256 held = _wallets[a].count;
uint256 whole = _backedWhole(a);
return held > whole ? held - whole : 0;
}
function _deficit(address a) private view returns (uint256) {
uint256 held = _wallets[a].count;
uint256 whole = _backedWhole(a);
return whole > held ? whole - held : 0;
}
/// @dev Whole tokens a holder may hold rocks for right now. Unbacked ≤ balance: it only grows
/// with an equal inflow and is spent first on every ERC-20 outflow. An NFT move sends one
/// backed token and needs a held rock (balance - unbacked ≥ UNIT), so it keeps that bound.
function _backedWhole(address a) private view returns (uint256) {
return (balanceOf(a) - _unbacked(a)) / UNIT;
}
/// @notice Takes up to `maxCount` of the rocks your balance entitles you to but you do not hold
/// yet, from the front of the Quarry.
/// @dev Owed rocks come from tokens that reached you unbacked (bought on another pool, fee
/// collection, claims or liquidity withdrawn): their rocks wait for a later transaction.
/// Rocks parked by such deposits wait at the front for whoever is served next: a holder who
/// parks and withdraws gets the same rocks back only if nobody buys first. Any later
/// transfer to you serves owed rocks too.
function claimRocks(uint256 maxCount) external {
if (!_isHolder(msg.sender)) return;
uint256 owed = _deficit(msg.sender);
uint256 n = owed < maxCount ? owed : maxCount;
for (uint256 i; i < n; ++i) {
_fromQuarry(msg.sender);
}
}
/// @notice Rocks `holder` is entitled to but does not hold yet (see `claimRocks`).
function owedRocks(address holder) external view returns (uint256) {
return _isHolder(holder) ? _deficit(holder) : 0;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ROCK MOVES */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
function _handOver(address from, address to, uint16 id) private {
_release(from, id);
_receive(to, id);
delete _nftApprovals[id];
mirror.emitTransfer(from, to, id);
}
/// @dev A sold rock goes to the back of the Quarry, a parked one to its front (see
/// `_afterTokenTransfer`), and to the same end of its crush bucket, so a bucket's head is
/// always the earliest of its rocks in the Quarry queue.
function _toQuarry(address from, uint16 id, bool sold) private {
_release(from, id);
Quarry memory q = _quarry;
if (sold) {
(q.head, q.tail) = _link(q.head, q.tail, id);
if (q.firstBack == 0) q.firstBack = id;
} else {
(q.head, q.tail) = _linkFront(q.head, q.tail, id);
}
unchecked {
++q.listed; // listed ≤ rocks ≤ type(uint16).max
}
_quarry = q;
Rock storage r = _rocks[id];
r.owner = address(this);
r.since = 0;
if (sold) _pushBucket(_keyOf(r), id);
else _pushBucketFront(_keyOf(r), id);
delete _nftApprovals[id];
mirror.emitTransfer(from, address(this), id);
}
/// @dev Hands out the front of the Quarry: parked rocks, then untouched genesis rocks in id
/// order, then sold-back rocks oldest first. The list head is the head of its own bucket.
function _fromQuarry(address to) private {
Quarry memory q = _quarry;
uint16 id;
if ((q.head == 0 || q.head == q.firstBack) && q.nextGenesis <= ROCKS) {
id = q.nextGenesis++;
} else {
id = q.head;
if (id == q.firstBack) q.firstBack = _rocks[id].next;
(q.head, q.tail) = _unlink(q.head, q.tail, id);
unchecked {
--q.listed;
}
_popBucket(_keyOf(_rocks[id]));
}
_quarry = q;
_receive(to, id);
mirror.emitTransfer(address(this), to, id);
}
/// @dev Destroys the emptiest Quarry rock: fewest lines, then fewest quote chars, then the
/// front of the queue. Untouched genesis rocks are blank and go first (ahead even of a
/// blank parked rock). A held rock is never a candidate.
function _crush() private {
Quarry memory q = _quarry;
uint16 id;
if (q.nextGenesis <= ROCKS) {
id = q.nextGenesis++;
} else {
id = _popBucket(_lowestBucket());
if (id == q.firstBack) q.firstBack = _rocks[id].next;
(q.head, q.tail) = _unlink(q.head, q.tail, id);
unchecked {
--q.listed;
}
delete _rocks[id];
}
unchecked {
--q.rocks; // a crush only runs while rocks > floor(totalSupply) ≥ 0
}
_quarry = q;
mirror.emitTransfer(address(this), address(0), id);
emit Crushed(id);
}
/// @dev Takes rock `id` out of `from`'s wallet and engraves the stint that just ended.
function _release(address from, uint16 id) private {
_engrave(id, from);
Wallet memory w = _wallets[from];
(w.head, w.tail) = _unlink(w.head, w.tail, id);
unchecked {
--w.count;
}
_wallets[from] = w;
}
/// @dev Appends rock `id` to `to`'s wallet (it becomes their newest) and starts their clock.
function _receive(address to, uint16 id) private {
Wallet memory w = _wallets[to];
(w.head, w.tail) = _link(w.head, w.tail, id);
unchecked {
++w.count; // count ≤ rocks ≤ type(uint16).max
}
_wallets[to] = w;
Rock storage r = _rocks[id];
r.owner = to;
r.since = uint32(block.timestamp);
}
/// @dev Appends `id` after `tail` in a list; returns the new (head, tail).
function _link(uint16 head, uint16 tail, uint16 id) private returns (uint16, uint16) {
Rock storage r = _rocks[id];
r.prev = tail;
r.next = 0;
if (tail == 0) return (id, id);
_rocks[tail].next = id;
return (head, id);
}
/// @dev Prepends `id` before `head` in a list; returns the new (head, tail).
function _linkFront(uint16 head, uint16 tail, uint16 id) private returns (uint16, uint16) {
Rock storage r = _rocks[id];
r.prev = 0;
r.next = head;
if (head == 0) return (id, id);
_rocks[head].prev = id;
return (id, tail);
}
/// @dev Removes `id` from a list; returns the new (head, tail).
function _unlink(uint16 head, uint16 tail, uint16 id) private returns (uint16, uint16) {
Rock storage r = _rocks[id];
uint16 prev = r.prev;
uint16 next = r.next;
if (prev == 0) head = next;
else _rocks[prev].next = next;
if (next == 0) tail = prev;
else _rocks[next].prev = prev;
return (head, tail);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CARVING */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev Records `holder`'s finished stint on rock `id`. A zero-length stint (same block: a
/// router hop, a pass-through contract) carves nothing. A returning holder's time adds to
/// their line; otherwise the stint takes a free line, or displaces the shortest line only
/// if strictly longer (ties keep the incumbent; among tied shortest lines the last one
/// goes, as in `carving()`'s stable sort). The live quote always leaves with the
/// holder: onto their line if they made it, discarded if they did not.
function _engrave(uint16 id, address holder) private {
bytes20 quote = _liveQuote[id];
if (quote != 0) delete _liveQuote[id];
Rock storage r = _rocks[id];
uint256 held = block.timestamp - r.since;
if (held == 0) return;
uint8 qc = _quoteLength(quote);
Line[MAX_LINES] storage lines = _lines[id];
uint256 n = r.lines;
uint256 shortest;
uint256 shortestHeld = type(uint256).max;
for (uint256 i; i < n; ++i) {
Line storage l = lines[i];
if (l.holder == holder) {
l.held += uint32(held); // Σ disjoint stints ≤ time since launch: no overflow before 2106
if (quote != 0) {
r.chars = r.chars - l.chars + qc;
l.chars = qc;
l.quote = quote;
}
emit Engraved(id, holder, l.held);
return;
}
if (l.held <= shortestHeld) (shortest, shortestHeld) = (i, l.held);
}
uint256 slot = n;
if (n < MAX_LINES) {
r.lines = uint8(n + 1);
} else {
if (held <= shortestHeld) return;
slot = shortest;
r.chars -= lines[shortest].chars;
}
r.chars += qc;
lines[slot] = Line({holder: holder, held: uint32(held), chars: qc, quote: quote});
emit Engraved(id, holder, held);
}
/// @dev Quotes are stored left-aligned and zero-padded; carvable chars are never zero.
function _quoteLength(bytes20 quote) private pure returns (uint8 len) {
while (len < MAX_QUOTE_CHARS && quote[len] != 0) ++len;
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* CRUSH BUCKETS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @dev A rock's key is frozen while it sits in the Quarry (no live holder can change its lines).
function _keyOf(Rock storage r) private view returns (uint256) {
return uint256(r.lines) * CHAR_KEYS + r.chars;
}
function _bucket(uint256 key) private view returns (uint16 head, uint16 tail) {
uint256 lane = _buckets[key >> 3] >> ((key & 7) << 5);
return (uint16(lane), uint16(lane >> 16));
}
function _setBucket(uint256 key, uint16 head, uint16 tail) private {
uint256 shift = (key & 7) << 5;
uint256 word = _buckets[key >> 3] & ~(uint256(0xFFFFFFFF) << shift);
_buckets[key >> 3] = word | ((uint256(head) | (uint256(tail) << 16)) << shift);
}
function _pushBucket(uint256 key, uint16 id) private {
(uint16 head, uint16 tail) = _bucket(key);
_rocks[id].bucketNext = 0;
if (tail == 0) {
head = id;
_bucketBits[key >> 8] |= 1 << (key & 255);
} else {
_rocks[tail].bucketNext = id;
}
_setBucket(key, head, id);
}
function _pushBucketFront(uint256 key, uint16 id) private {
(uint16 head, uint16 tail) = _bucket(key);
_rocks[id].bucketNext = head;
if (head == 0) {
tail = id;
_bucketBits[key >> 8] |= 1 << (key & 255);
}
_setBucket(key, id, tail);
}
function _popBucket(uint256 key) private returns (uint16 id) {
(uint16 head, uint16 tail) = _bucket(key);
id = head;
uint16 next = _rocks[id].bucketNext;
_rocks[id].bucketNext = 0;
if (next == 0) {
tail = 0;
_bucketBits[key >> 8] &= ~(1 << (key & 255));
}
_setBucket(key, next, tail);
}
function _lowestBucket() private view returns (uint256) {
for (uint256 w; w < BUCKET_WORDS; ++w) {
uint256 bits = _bucketBits[w];
if (bits != 0) return (w << 8) | LibBit.ffs(bits);
}
revert QuarryEmpty();
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* MIRROR CALLBACKS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
modifier onlyMirror() {
if (msg.sender != address(mirror)) revert MirrorOnly();
_;
}
/// @dev Moves one chosen rock and exactly one whole token with it (silently, so the ERC-20
/// leg does not move a second rock). Quarry rocks have no approvable owner and cannot move.
function handleNFTTransfer(address from, address to, uint256 tokenId, address caller)
external
onlyMirror
nonReentrant
{
if (to == address(0)) revert TransferToZero();
// The pool manager and this contract are not holders: a rock parked on either would sit
// outside both the wallet accounting and the Quarry.
if (!_isHolder(to)) revert TransferToReserved();
if (from == to) revert SelfTransferDisallowed();
address owner_ = _rocks[tokenId].owner;
if (owner_ != from || !_isHolder(from)) revert InvalidTokenId();
if (caller != owner_ && _nftApprovals[tokenId] != caller && !_nftOperatorApprovals[owner_][caller]) {
revert NotOwnerOrApproved();
}
_handOver(from, to, uint16(tokenId));
_setSilent(true);
_transfer(from, to, UNIT);
_setSilent(false);
}
/// @dev Mirror-only. A Quarry rock has no holder to approve it, so it can never be moved.
function handleNFTApprove(address spender, uint256 tokenId, address caller) external onlyMirror {
address owner_ = _rocks[tokenId].owner;
if (!_isHolder(owner_)) revert InvalidTokenId();
if (caller != owner_ && !_nftOperatorApprovals[owner_][caller]) revert NotOwnerOrApproved();
_nftApprovals[tokenId] = spender;
mirror.emitApproval(owner_, spender, tokenId);
}
/// @dev Mirror-only. Operator approval for `caller`'s rocks.
function handleNFTSetApprovalForAll(address operator, bool approved, address caller) external onlyMirror {
_nftOperatorApprovals[caller][operator] = approved;
mirror.emitApprovalForAll(caller, operator, approved);
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* ROCK VIEWS */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
/// @notice Holder of rock `tokenId`, or this contract while it waits in the Quarry.
/// @dev Reverts for a crushed or never-existing id.
function nftOwnerOf(uint256 tokenId) public view returns (address o) {
o = _rocks[tokenId].owner;
if (o == address(0)) {
if (tokenId < _quarry.nextGenesis || tokenId > ROCKS) revert InvalidTokenId();
o = address(this);
}
}
/// @notice Rocks held by `owner_`; for this contract, the Quarry size.
function nftBalanceOf(address owner_) external view returns (uint256) {
return owner_ == address(this) ? quarrySize() : _wallets[owner_].count;
}
/// @notice Address approved to move rock `tokenId` (cleared whenever it moves).
function nftGetApproved(uint256 tokenId) external view returns (address) {
return _nftApprovals[tokenId];
}
/// @notice Whether `s` may move every rock of `o`.
function nftIsApprovedForAll(address o, address s) external view returns (bool) {
return _nftOperatorApprovals[o][s];
}
/// @notice Live rocks: floor(totalSupply), shrinking as quotes burn the coin.
function rockCount() external view returns (uint256) {
return _quarry.rocks;
}
/// @notice Rocks no holder owns (the pool's), waiting to be handed out.
function quarrySize() public view returns (uint256) {
return ROCKS + 1 - _quarry.nextGenesis + _quarry.listed;
}
/// @notice The Quarry in exit order: the next rock bought comes first.
function quarryQueue() external view returns (uint256[] memory ids) {
Quarry memory q = _quarry;
ids = new uint256[](quarrySize());
uint256 k;
uint256 id = q.head;
for (; id != 0 && id != q.firstBack; id = _rocks[id].next) {
ids[k++] = id;
}
for (uint256 g = q.nextGenesis; g <= ROCKS; ++g) {
ids[k++] = g;
}
for (; id != 0; id = _rocks[id].next) {
ids[k++] = id;
}
}
/// @notice `owner_`'s rocks, oldest first. The last one is the next an ERC-20 move sends.
function rocksOf(address owner_) external view returns (uint256[] memory ids) {
Wallet memory w = _wallets[owner_];
ids = new uint256[](w.count);
uint256 k;
for (uint256 id = w.head; id != 0; id = _rocks[id].next) {
ids[k++] = id;
}
}
/// @notice What is carved on rock `tokenId` right now: up to five lines, longest hold first,
/// the live holder included with their running time and current quote.
/// @dev A live holder already carved from an earlier stint shows once, with both stints summed.
function carving(uint256 tokenId) external view returns (Line[] memory out) {
address live = nftOwnerOf(tokenId);
Rock memory r = _rocks[tokenId];
uint256 n = r.lines;
Line[] memory all = new Line[](n + 1);
for (uint256 i; i < n; ++i) {
all[i] = _lines[tokenId][i];
}
uint256 held = _isHolder(live) ? block.timestamp - r.since : 0;
if (held != 0) {
uint256 i;
while (i < n && all[i].holder != live) ++i;
if (i == n) all[n++].holder = live;
all[i].held += uint32(held);
bytes20 quote = _liveQuote[tokenId];
if (quote != 0) {
all[i].chars = _quoteLength(quote);
all[i].quote = quote;
}
}
for (uint256 i = 1; i < n; ++i) {
Line memory l = all[i];
uint256 j = i;
for (; j != 0 && all[j - 1].held < l.held; --j) {
all[j] = all[j - 1];
}
all[j] = l;
}
out = new Line[](n < MAX_LINES ? n : MAX_LINES);
for (uint256 i; i < out.length; ++i) {
out[i] = all[i];
}
}
/*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/
/* TRANSIENT STATE */
/*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/
function _setSilent(bool v) private {
assembly {
tstore(_SILENT_SLOT, v)
}
}
function _isSilent() private view returns (bool v) {
assembly {
v := tload(_SILENT_SLOT)
}
}
function _credit() private view returns (uint256 v) {
assembly {
v := tload(_CREDIT_SLOT)
}
}
function _setCredit(uint256 v) private {
assembly {
tstore(_CREDIT_SLOT, v)
}
}
function _sold() private view returns (uint256 v) {
assembly {
v := tload(_SOLD_SLOT)
}
}
function _setSold(uint256 v) private {
assembly {
tstore(_SOLD_SLOT, v)
}
}
function _unbacked(address a) private view returns (uint256 v) {
assembly {
mstore(0x00, a)
mstore(0x20, _UNBACKED_SEED)
v := tload(keccak256(0x00, 0x40))
}
}
function _setUnbacked(address a, uint256 v) private {
assembly {
mstore(0x00, a)
mstore(0x20, _UNBACKED_SEED)
tstore(keccak256(0x00, 0x40), v)
}
}
}
Compiler settingsShow
{
"viaIR": true,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 200,
"enabled": true
},
"evmVersion": "prague",
"remappings": [
"solady/=lib/solady/",
"@uniswap/v4-core/=lib/v4-periphery/lib/v4-core/",
"@uniswap/v4-periphery/=lib/v4-periphery/",
"permit2/=lib/v4-periphery/lib/permit2/",
"forge-std/=lib/forge-std/src/",
"solmate/=lib/v4-periphery/lib/v4-core/lib/solmate/",
"@openzeppelin/contracts/=lib/v4-periphery/lib/v4-core/lib/openzeppelin-contracts/contracts/",
"@ensdomains/=lib/v4-core/node_modules/@ensdomains/",
"ds-test/=lib/v4-core/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/v4-core/lib/openzeppelin-contracts/lib/erc4626-tests/",
"forge-gas-snapshot/=lib/permit2/lib/forge-gas-snapshot/src/",
"hardhat/=lib/v4-core/node_modules/hardhat/",
"openzeppelin-contracts/=lib/v4-core/lib/openzeppelin-contracts/",
"v4-core/=lib/v4-core/src/",
"v4-periphery/=lib/v4-periphery/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.