Hooks
The protocol uses two kinds of hook: transfer-restriction hooks consulted on token transfers, and a Uniswap v4 hook used by LiquiLeX pools.
Transfer-restriction hooks
ITransferRestrictionHook
interface ITransferRestrictionHook {
function checkTransferRestriction(
address from,
address to,
uint256 tokenId, // token id for cyberCERTs; amount for cyberSCRIP
bytes memory data
) external view returns (bool allowed, string memory reason);
}Both LedgerEntryToken (the cert printer, formerly CyberCertPrinter) and CyberScrip consult these hooks on transfer:
CyberScripholds an array of hooks (setRestrictionHook); every hook must allow the transfer or it revertsRestrictedTransfer(reason).LedgerEntryTokenholds per-id hooks (setRestrictionHook(id, hook)) and aglobalRestrictionHook(setGlobalRestrictionHook).
Implementations
BaseTransferHook
Common base for transfer-restriction hooks.
WhitelistTransferHook
Allows transfers only between whitelisted addresses.
ToggleTransferHook
Per-token transfer on/off switch, with a configurable default.
These three implement
ITransferRestrictionHook. Consult each contract's source for its admin functions (whitelist management, toggle setters).
Uniswap v4 hook
MetalexIssuerFeeHook
In src/hooks/uniswap/. A Uniswap v4 hook for LiquiLeX AMM pools that splits swap fees between MetaLeX and the issuer, so a cyberSCRIP / stablecoin pool pays the issuer onchain on every trade.
Per-pool configuration via
setPoolConfig(onlyAdmin): aPoolFeeConfigwith the MetaLeX and issuer recipients,metalexFeeBps/issuerFeeBps(their sum capped at 10 000 bps), and anenabledflag.Registers
beforeSwap/afterSwappermissions with return deltas and handles all four swap flows: exact-input swaps are charged inbeforeSwap, exact-output swaps inafterSwap, in both directions (zeroForOneandoneForZero).
See the source for the hook-address requirements Uniswap v4 imposes.
Last updated
Was this helpful?
