Verified contractExactBUSL-1.1
EulerSwap
Address0x8b0e044e364f2ce913799d53b300e15a6974dc97
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.27
- Same code
Only this contract
Details
- Compiler
- solc 0.8.27+commit.40a35a09
- Language
- solidity
- Optimization
- Yes, 2,500 runs
- EVM version
- cancun
- License
- BUSL-1.1
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 23,697,905
- Creation transaction
- 0x093db3e00f…66e0a495cd
76 files
The source code is large: one file is shown at a time. Choose a file in the list.
- lib/euler-swap/src/EulerSwap.solmain5.48 KB
- @openzeppelin/contracts/interfaces/IERC1363.sol4.45 KB
- @openzeppelin/contracts/interfaces/IERC165.sol870 B
- @openzeppelin/contracts/interfaces/IERC20.sol2.78 KB
- @openzeppelin/contracts/token/ERC20/IERC20.sol2.78 KB
- @openzeppelin/contracts/utils/Address.sol6.03 KB
- @openzeppelin/contracts/utils/Errors.sol896 B
- @openzeppelin/contracts/utils/introspection/IERC165.sol870 B
- @uniswap/v4-core/src/interfaces/IHooks.sol8.3 KB
- @uniswap/v4-core/src/interfaces/IPoolManager.sol13.06 KB
- @uniswap/v4-core/src/libraries/Hooks.sol16.49 KB
- @uniswap/v4-core/src/libraries/SafeCast.sol2.27 KB
- @uniswap/v4-core/src/types/BalanceDelta.sol2.34 KB
- @uniswap/v4-core/src/types/BeforeSwapDelta.sol1.47 KB
- @uniswap/v4-core/src/types/Currency.sol5.46 KB
- @uniswap/v4-core/src/types/PoolKey.sol805 B
- ethereum-vault-connector/interfaces/IVault.sol2.13 KB
- evc/interfaces/IEthereumVaultConnector.sol30.45 KB
- evc/utils/EVCUtil.sol11.79 KB
- evk/EVault/IEVault.sol29.29 KB
- lib/ethereum-vault-connector/src/ExecutionContext.sol4.48 KB
- lib/ethereum-vault-connector/src/interfaces/IEthereumVaultConnector.sol30.45 KB
- lib/ethereum-vault-connector/src/interfaces/IVault.sol2.13 KB
- lib/ethereum-vault-connector/src/utils/EVCUtil.sol11.79 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/IExtsload.sol1.02 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/IExttload.sol699 B
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/IHooks.sol8.3 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/IPoolManager.sol13.06 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/IProtocolFees.sol2.49 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/external/IERC20Minimal.sol3.04 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/interfaces/external/IERC6909Claims.sol3.16 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/libraries/CustomRevert.sol5.17 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/libraries/Hooks.sol16.49 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/libraries/LPFeeLibrary.sol3.6 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/libraries/ParseBytes.sol1.2 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/libraries/SafeCast.sol2.27 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/types/BalanceDelta.sol2.34 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/types/BeforeSwapDelta.sol1.47 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/types/Currency.sol5.46 KB
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/types/PoolId.sol539 B
- lib/euler-swap/lib/v4-periphery/lib/v4-core/src/types/PoolKey.sol805 B
- lib/euler-swap/lib/v4-periphery/src/base/ImmutableState.sol818 B
- lib/euler-swap/lib/v4-periphery/src/interfaces/IImmutableState.sol365 B
- lib/euler-swap/lib/v4-periphery/src/utils/BaseHook.sol7.15 KB
- lib/euler-swap/src/EulerSwapBase.sol731 B
- lib/euler-swap/src/EulerSwapProtocolFeeConfig.sol4.09 KB
- lib/euler-swap/src/UniswapHook.sol6.89 KB
- lib/euler-swap/src/interfaces/IEulerSwap.sol4.63 KB
- lib/euler-swap/src/interfaces/IEulerSwapCallee.sol726 B
- lib/euler-swap/src/interfaces/IEulerSwapHookTarget.sol785 B
- lib/euler-swap/src/interfaces/IEulerSwapProtocolFeeConfig.sol1.47 KB
- lib/euler-swap/src/libraries/CtxLib.sol2.42 KB
- lib/euler-swap/src/libraries/CurveLib.sol9.14 KB
- lib/euler-swap/src/libraries/FundsLib.sol4.92 KB
- lib/euler-swap/src/libraries/QuoteLib.sol13.5 KB
- lib/euler-swap/src/libraries/SwapLib.sol7.86 KB
- lib/euler-swap/src/math/Clz.sol1.62 KB
- lib/euler-swap/src/math/FastLogic.sol514 B
- lib/euler-swap/src/math/FullMath.sol12.35 KB
- lib/euler-swap/src/math/Panic.sol940 B
- lib/euler-swap/src/math/Sqrt.sol3.69 KB
- lib/euler-swap/src/math/UnsafeMath.sol4.3 KB
- lib/euler-vault-kit/lib/permit2/src/interfaces/IAllowanceTransfer.sol7.7 KB
- lib/euler-vault-kit/lib/permit2/src/interfaces/IEIP712.sol144 B
- lib/euler-vault-kit/src/EVault/IEVault.sol29.29 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC1363.sol4.45 KB
- lib/openzeppelin-contracts/contracts/interfaces/IERC165.sol192 B
- lib/openzeppelin-contracts/contracts/interfaces/IERC20.sol181 B
- lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol2.78 KB
- lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol9.44 KB
- lib/openzeppelin-contracts/contracts/utils/Address.sol6.03 KB
- lib/openzeppelin-contracts/contracts/utils/Errors.sol896 B
- lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol870 B
- openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol9.44 KB
- permit2/src/interfaces/IAllowanceTransfer.sol7.7 KB
- v4-periphery/src/utils/BaseHook.sol7.15 KB
lib/euler-swap/src/EulerSwap.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.27;
import {IERC20} from "openzeppelin-contracts/token/ERC20/utils/SafeERC20.sol";
import {IEulerSwapCallee} from "./interfaces/IEulerSwapCallee.sol";
import {IEVault} from "evk/EVault/IEVault.sol";
import {IEulerSwap} from "./interfaces/IEulerSwap.sol";
import {UniswapHook} from "./UniswapHook.sol";
import {CtxLib} from "./libraries/CtxLib.sol";
import {QuoteLib} from "./libraries/QuoteLib.sol";
import {SwapLib} from "./libraries/SwapLib.sol";
contract EulerSwap is IEulerSwap, UniswapHook {
bytes32 public constant curve = bytes32("EulerSwap v2");
address public immutable managementImpl;
error AmountTooBig();
constructor(address evc_, address protocolFeeConfig_, address poolManager_, address managementImpl_)
UniswapHook(evc_, protocolFeeConfig_, poolManager_)
{
managementImpl = managementImpl_;
}
/// @inheritdoc IEulerSwap
function activate(DynamicParams calldata, InitialState calldata) external {
_delegateToManagementImpl();
// Uniswap hook activation
activateHook(CtxLib.getStaticParams());
}
/// @inheritdoc IEulerSwap
function setManager(address, bool) external {
_delegateToManagementImpl();
}
/// @inheritdoc IEulerSwap
function reconfigure(DynamicParams calldata, InitialState calldata) external {
_delegateToManagementImpl();
}
/// @inheritdoc IEulerSwap
function managers(address manager) external view returns (bool installed) {
CtxLib.State storage s = CtxLib.getState();
return s.managers[manager];
}
/// @inheritdoc IEulerSwap
function getStaticParams() external pure returns (StaticParams memory) {
return CtxLib.getStaticParams();
}
/// @inheritdoc IEulerSwap
function getDynamicParams() external pure returns (DynamicParams memory) {
return CtxLib.getDynamicParams();
}
/// @inheritdoc IEulerSwap
function getAssets() external view returns (address asset0, address asset1) {
StaticParams memory sParams = CtxLib.getStaticParams();
asset0 = IEVault(sParams.supplyVault0).asset();
asset1 = IEVault(sParams.supplyVault1).asset();
}
/// @inheritdoc IEulerSwap
function getReserves() external view nonReentrantView returns (uint112, uint112, uint32) {
CtxLib.State storage s = CtxLib.getState();
return (s.reserve0, s.reserve1, s.status);
}
/// @inheritdoc IEulerSwap
function isInstalled() external view nonReentrantView returns (bool) {
StaticParams memory sParams = CtxLib.getStaticParams();
return evc.isAccountOperatorAuthorized(sParams.eulerAccount, address(this));
}
/// @inheritdoc IEulerSwap
function computeQuote(address tokenIn, address tokenOut, uint256 amount, bool exactIn)
external
view
nonReentrantView
returns (uint256)
{
StaticParams memory sParams = CtxLib.getStaticParams();
DynamicParams memory dParams = CtxLib.getDynamicParams();
return QuoteLib.computeQuote(
address(evc), sParams, dParams, QuoteLib.checkTokens(sParams, tokenIn, tokenOut), amount, exactIn
);
}
/// @inheritdoc IEulerSwap
function getLimits(address tokenIn, address tokenOut)
external
view
nonReentrantView
returns (uint256 inLimit, uint256 outLimit)
{
StaticParams memory sParams = CtxLib.getStaticParams();
DynamicParams memory dParams = CtxLib.getDynamicParams();
if (!evc.isAccountOperatorAuthorized(sParams.eulerAccount, address(this))) return (0, 0);
if (dParams.expiration != 0 && dParams.expiration <= block.timestamp) return (0, 0);
bool asset0IsInput = QuoteLib.checkTokens(sParams, tokenIn, tokenOut);
uint256 fee = QuoteLib.getFeeReadOnly(dParams, asset0IsInput);
if (fee >= 1e18) return (0, 0);
(inLimit, outLimit) = QuoteLib.calcLimits(sParams, dParams, asset0IsInput, fee);
if (outLimit > 0) outLimit--; // Compensate for rounding up of exact output quotes
}
/// @inheritdoc IEulerSwap
function swap(uint256 amount0Out, uint256 amount1Out, address to, bytes calldata data)
external
callThroughEVC
nonReentrant
{
require(amount0Out <= type(uint112).max && amount1Out <= type(uint112).max, AmountTooBig());
// Setup context
SwapLib.SwapContext memory ctx = SwapLib.init(address(evc), protocolFeeConfig, _msgSender(), to);
SwapLib.setAmountsOut(ctx, amount0Out, amount1Out);
SwapLib.invokeBeforeSwapHook(ctx);
// Optimistically send tokens
SwapLib.doWithdraws(ctx);
// Invoke callback
if (data.length > 0) IEulerSwapCallee(to).eulerSwapCall(_msgSender(), amount0Out, amount1Out, data);
// Deposit all available funds
SwapLib.setAmountsIn(
ctx, IERC20(ctx.asset0).balanceOf(address(this)), IERC20(ctx.asset1).balanceOf(address(this))
);
SwapLib.doDeposits(ctx);
// Verify curve invariant is satisfied
SwapLib.finish(ctx);
}
function _delegateToManagementImpl() internal {
(bool success, bytes memory result) = managementImpl.delegatecall(msg.data);
if (!success) {
assembly {
revert(add(32, result), mload(result))
}
}
}
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"appendCBOR": true,
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"libraries": {},
"optimizer": {
"runs": 2500,
"enabled": true
},
"evmVersion": "cancun",
"remappings": [
"lib/euler-price-oracle:@openzeppelin/contracts/=lib/euler-price-oracle/lib/openzeppelin-contracts/contracts/",
"lib/euler-earn:@openzeppelin/=lib/euler-earn/lib/openzeppelin-contracts/",
"lib/euler-earn:@openzeppelin-upgradeable/=lib/euler-earn/lib/openzeppelin-contracts-upgradeable/contracts/",
"lib/euler-earn:ethereum-vault-connector/=lib/euler-earn/lib/ethereum-vault-connector/src/",
"lib/layerzero-devtools/packages/oft-evm/contracts:@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts/contracts/",
"lib/layerzero-devtools/packages/oft-evm-upgradeable/contracts:@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"lib/layerzero-devtools/packages/oapp-evm-upgradeable/contracts:@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@layerzerolabs/oft-evm/=lib/layerzero-devtools/packages/oft-evm/",
"@layerzerolabs/oapp-evm/=lib/layerzero-devtools/packages/oapp-evm/",
"@layerzerolabs/oapp-evm-upgradeable/=lib/layerzero-devtools/packages/oapp-evm-upgradeable/",
"@layerzerolabs/lz-evm-protocol-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/protocol/",
"@layerzerolabs/lz-evm-messagelib-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/messagelib/",
"@layerzerolabs/lz-evm-oapp-v2/=lib/layerzero-v2/packages/layerzero-v2/evm/oapp/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"lib/fee-flow/src:solmate/=lib/fee-flow/lib/solmate/src/",
"lib/fee-flow/utils:solmate/=lib/fee-flow/lib/solmate/utils/",
"lib/fee-flow/tokens:solmate/=lib/fee-flow/lib/solmate/tokens/",
"lib/euler-swap:solmate/=lib/euler-swap/lib/v4-periphery/lib/v4-core/lib/solmate/src/",
"ethereum-vault-connector/=lib/ethereum-vault-connector/src/",
"evc/=lib/ethereum-vault-connector/src/",
"evk/=lib/euler-vault-kit/src/",
"evk-test/=lib/euler-vault-kit/test/",
"euler-price-oracle/=lib/euler-price-oracle/src/",
"euler-price-oracle-test/=lib/euler-price-oracle/test/",
"fee-flow/=lib/fee-flow/src/",
"reward-streams/=lib/reward-streams/src/",
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"euler-earn/=lib/euler-earn/src/",
"layerzero/oft-evm/=lib/layerzero-devtools/packages/oft-evm/contracts/",
"layerzero/oft-evm-upgradeable/=lib/layerzero-devtools/packages/oft-evm-upgradeable/contracts/",
"solidity-bytes-utils/=lib/solidity-bytes-utils/",
"@ensdomains/=lib/euler-swap/lib/v4-periphery/lib/v4-core/node_modules/@ensdomains/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@pendle/core-v2/=lib/euler-price-oracle/lib/pendle-core-v2-public/contracts/",
"@pyth/=lib/euler-price-oracle/lib/pyth-sdk-solidity/",
"@redstone/evm-connector/=lib/euler-price-oracle/lib/redstone-oracles-monorepo/packages/evm-connector/contracts/",
"@solady/=lib/euler-price-oracle/lib/solady/src/",
"@uniswap/v3-core/=lib/euler-price-oracle/lib/v3-core/",
"@uniswap/v3-periphery/=lib/euler-price-oracle/lib/v3-periphery/",
"@uniswap/v4-core/=lib/euler-swap/lib/v4-periphery/lib/v4-core/",
"ds-test/=lib/ethereum-vault-connector/lib/forge-std/lib/ds-test/src/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"euler-swap/=lib/euler-swap/",
"euler-vault-kit/=lib/euler-vault-kit/",
"forge-gas-snapshot/=lib/euler-vault-kit/lib/permit2/lib/forge-gas-snapshot/src/",
"forge-std/=lib/forge-std/src/",
"halmos-cheatcodes/=lib/openzeppelin-contracts-upgradeable/lib/halmos-cheatcodes/src/",
"hardhat/=lib/euler-swap/lib/v4-periphery/lib/v4-core/node_modules/hardhat/",
"layerzero-devtools/=lib/layerzero-devtools/packages/toolbox-foundry/src/",
"layerzero-v2/=lib/layerzero-v2/",
"openzeppelin/=lib/ethereum-vault-connector/lib/openzeppelin-contracts/contracts/",
"pendle-core-v2-public/=lib/euler-price-oracle/lib/pendle-core-v2-public/contracts/",
"permit2/=lib/euler-vault-kit/lib/permit2/",
"pyth-sdk-solidity/=lib/euler-price-oracle/lib/pyth-sdk-solidity/",
"redstone-oracles-monorepo/=lib/euler-price-oracle/lib/",
"solady/=lib/euler-price-oracle/lib/solady/src/",
"solmate/=lib/fee-flow/lib/solmate/src/",
"v3-core/=lib/euler-price-oracle/lib/v3-core/contracts/",
"v3-periphery/=lib/euler-price-oracle/lib/v3-periphery/contracts/",
"v4-core/=lib/euler-swap/lib/v4-periphery/lib/v4-core/src/",
"v4-periphery/=lib/euler-swap/lib/v4-periphery/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.