Index / EulerSwap
product · BUSL-1.1 · last updated 2026-08-27
EulerSwap
Custom curve via beforeSwapReturnDelta: take input to Euler vaults, pay output, skip CLAMM math.
Euler’s UniswapHook (BUSL-1.1) quotes amountIn/amountOut off the v3 tick curve, returns a BeforeSwapDelta so PoolManager’s concentrated liquidity is unused, takes the input to vaults and settles the output from vaults. beforeInitialize / beforeAddLiquidity / beforeDonate stay enabled so BaseHook’s default revert blocks stray inits, CLAMM LP, and donations. Study this for “hook is the AMM.” Do not paste BUSL into a new MIT repo without reading the license. Full UniswapHook.sol at the permalink. Listing is not an audit.
Permission bits
These bits must match the deployed address. Confirm on-chain before you route.
beforeInitializebeforeAddLiquiditybeforeSwapbeforeDonatebeforeSwapReturnDelta
Solidity
Excerpt from src/UniswapHook.sol. Production hook. Study the callbacks, do not paste it as your factory. Not an audit.
// SPDX-License-Identifier: BUSL-1.1
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({
beforeInitialize: true,
afterInitialize: false,
beforeAddLiquidity: true,
afterAddLiquidity: false,
beforeRemoveLiquidity: false,
afterRemoveLiquidity: false,
beforeSwap: true,
afterSwap: false,
beforeDonate: true,
afterDonate: false,
beforeSwapReturnDelta: true,
afterSwapReturnDelta: false,
afterAddLiquidityReturnDelta: false,
afterRemoveLiquidityReturnDelta: false
});
}
// take input to Euler vaults, pay output, offset the CLAMM swap
function _beforeSwap(address sender, PoolKey calldata key, IPoolManager.SwapParams calldata params, bytes calldata)
internal
override
nonReentrant
returns (bytes4, BeforeSwapDelta, uint24)
{
// QuoteLib.computeQuote → poolManager.take(input) → vaults → poolManager.settle(output)
BeforeSwapDelta returnDelta = isExactInput
? toBeforeSwapDelta(amountIn.toInt128(), -(amountOut.toInt128()))
: toBeforeSwapDelta(-(amountOut.toInt128()), amountIn.toInt128());
return (BaseHook.beforeSwap.selector, returnDelta, 0);
}Spec
| Kind | product |
|---|---|
| Status | production |
| License | BUSL-1.1 |
| Source | https://github.com/euler-xyz/euler-swap |
| Categories | LendingLP management |
| Properties | Vanilla swap |
| Chains | Ethereum |
| Website | https://app.euler.finance/swap |
FAQ
Can I paste this into production? The snippet is an excerpt. Use the full file at the source URL, match flags to the address, and treat this page as a map, not a guarantee.
How do I build this safely? Start with secure v4 hooks and the OpenZeppelin hooks guide.