-
Notifications
You must be signed in to change notification settings - Fork 74
ft: Integrate euler-swap-v2 #1257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||||||||||||||
Test coverage changes:
|
User description
Why did we need it?
Related Issue
Release Note
How Has This Been Tested?
Screenshots (if appropriate):
PR Type
Enhancement, Tests
Description
Integrated Euler Swap V2 with complete pool simulator, tracker, and pool list updater implementations
Refactored existing Euler Swap V1 code into versioned package structure (
v1namespace) with shared utilitiesCreated shared package containing common types, constants, utilities, and error definitions for both V1 and V2
Implemented comprehensive hook system for V2 swap operations with before/after swap callbacks and dynamic fee calculation
Added mathematical utilities for V2 curve calculations including square root, division, and curve point functions
Registered V1 and V2 pool simulators in msgpack serialization and pool types registry
Added integration tests for V2
ComputeQuotefunctionality validating against on-chain valuesIncluded complete ABI definitions for V1 and V2 contracts (EulerSwap, EVault, EVC, Registry, Router, and Hook contracts)
Updated value object registry to support
ExchangeEulerSwapV2exchange typeDiagram Walkthrough
File Walkthrough
23 files
pool_simulator.go
Euler Swap V2 Pool Simulator Implementationpkg/liquidity-source/euler-swap/v2/pool_simulator.go
of core swap logic
CalcAmountOutandCalcAmountInmethods for swap amountcalculations
verification
calculation
pool_tracker.go
Euler Swap V2 Pool State Trackerpkg/liquidity-source/euler-swap/v2/pool_tracker.go
lines
dynamic parameters
across multiple vaults
pool_list_updater.go
Euler Swap V2 Pool List Updaterpkg/liquidity-source/euler-swap/v2/pool_list_updater.go
V2 with 252 lines
parameters
math.go
Euler Swap V2 Mathematical Utilitiespkg/liquidity-source/euler-swap/v2/math.go
calculations
rounding
_Fand_FInversefor swappricing
types.go
Euler Swap V2 Type Definitionspkg/liquidity-source/euler-swap/v2/types.go
StaticExtra,DynamicParams, andExtratypes for poolconfiguration
data
math.go
Refactor math module for v1 versioning and shared constantspkg/liquidity-source/euler-swap/v1/math.go
eulerswaptov1to support versioningsharedpackage for reuseacross versions
shared.ErrDivisionByZeroshared.E18Intandshared.E36types.go
Add shared type definitions for euler-swap versionspkg/liquidity-source/euler-swap/shared/types.go
VaultInfo,ReserveRPC,VaultRPC,AccountLiquidityRPCfor RPCinteractions
VaultStatewith JSON serialization tags for state managementSwapInfoandTrackerDatafor swap and tracking operationspooltypes.go
Support euler-swap v1 and v2 in pool types registrypkg/pooltypes/pooltypes.go
eulerswapv1package instead of genericeulerswapeulerswapv2packageEulerSwapV2field toTypesstructDexTypemappings to use versioned package constantsconstant.go
Extract shared constants for euler-swap versionspkg/liquidity-source/euler-swap/shared/constant.go
method names
VirtualAmount,E36,MaxUint112,E18Intfrom v1 math moduleRAfor calculationstypes.go
Add v1-specific type definitions for pool managementpkg/liquidity-source/euler-swap/v1/types.go
PoolExtra,StaticExtra,Extrafor pool state managementParamsRPCfor RPC parameter decoding with ABI tagsexchange.go
Register euler-swap v2 exchange types in value objectspkg/valueobject/exchange.go
ExchangeEulerSwapV2constant for v2 exchange typeExchangeUniswapV4EulerV2constant for uniswap v4 euler v2ExchangeEulerSwapV2toSingleSwapSourceSetmaphooks.go
Implement hook system for euler-swap v2 swapspkg/liquidity-source/euler-swap/v2/hooks/hooks.go
HookBeforeSwap,HookGetFee,HookAfterSwap)GetFeeParams,BeforeSwapParams,AfterSwapParams)utils.go
Add shared utility functions for vault operationspkg/liquidity-source/euler-swap/shared/utils.go
ConvertToAssetsfor share-to-asset conversion with virtualamount
SubTill0for safe subtraction clamped to zeroDecodeCapfor decoding encoded capacity valuesabis.go
Add ABI loading for euler-swap v2 contractspkg/liquidity-source/euler-swap/v2/abis.go
contracts
abis.go
Add ABI loading for euler-swap v1 contractspkg/liquidity-source/euler-swap/v1/abis.go
contracts
base_hook.go
Implement base hook for v2 swap operationspkg/liquidity-source/euler-swap/v2/hooks/base_hook.go
ErrHookNotSupported,ErrHookCallFailed)Hookinterface methods with default implementationserrors.go
Define shared error types for euler-swappkg/liquidity-source/euler-swap/shared/errors.go
embed.go
Add hook ABI embedding for euler-swap v2pkg/liquidity-source/euler-swap/v2/hooks/embed.go
constant.go
Add v2-specific constants and configurationpkg/liquidity-source/euler-swap/v2/constant.go
DexTypeas"euler-swap-v2"config.go
Move config to shared package for version reusepkg/liquidity-source/euler-swap/shared/config.go
eulerswappackage tosharedpackageeulerswaptosharedconstant.go
Add v1-specific constants and configurationpkg/liquidity-source/euler-swap/v1/constant.go
DexTypeas"euler-swap"embed.go
Add ABI file embedding for euler-swap v2pkg/liquidity-source/euler-swap/v2/embed.go
abis/directoryembed.go
Update v1 embed package declarationpkg/liquidity-source/euler-swap/v1/embed.go
eulerswaptov14 files
pool_simulator.go
Euler Swap V1 Package Restructuring and Refactoringpkg/liquidity-source/euler-swap/v1/pool_simulator.go
eulerswaptov1namespace(
shared.ErrSwapIsPaused,shared.BufferSwapLimit)SwapInfostruct field names to use PascalCase (e.g.,reserves→
Reserves)bignumber.ZeroBIinstead ofinteger.Zero()pool_tracker.go
Euler Swap V1 Pool Tracker Package Restructuringpkg/liquidity-source/euler-swap/v1/pool_tracker.go
eulerswaptov1namespaceshared.VaultMethodCash)pool_list_updater.go
Euler Swap V1 Pool List Updater Package Restructuringpkg/liquidity-source/euler-swap/v1/pool_list_updater.go
eulerswaptov1namespaceConfigtype reference to useshared.Configshared.PoolMethodGetAssets)shared.BatchSizepool_list_updater_test.go
Euler Swap V1 Pool List Updater Test Refactoringpkg/liquidity-source/euler-swap/v1/pool_list_updater_test.go
eulerswaptov1namespaceshared.Configtype instead of localConfig3 files
integration_test.go
Euler Swap V2 Integration Testspkg/liquidity-source/euler-swap/v2/integration_test.go
ComputeQuotefunctionality against on-chain valuespoints
pool_simulator_test.go
Update v1 pool simulator tests for package refactoringpkg/liquidity-source/euler-swap/v1/pool_simulator_test.go
eulerswaptov1sharedpackageshared.ErrSwapLimitExceededpool_list_updater_test.go
Add tests for euler-swap v2 pool list updaterpkg/liquidity-source/euler-swap/v2/pool_list_updater_test.go
3 files
register_pool_types.gen.go
Msgpack Registration for Euler Swap V1 and V2pkg/msgpack/register_pool_types.gen.go
pkg_liquiditysource_eulerswaptopkg_liquiditysource_eulerswap_v1andpkg_liquiditysource_eulerswap_v2PoolSimulatortypes for msgpackserialization
EthereumVaultConnector.json
EthereumVaultConnector ABI definition for Euler Swap v1pkg/liquidity-source/euler-swap/v1/abis/EthereumVaultConnector.json
contract
handling, and controller operations
authorization, and status checks
EulerSwapHook.json
EulerSwapHook ABI definition for Euler Swap v2pkg/liquidity-source/euler-swap/v2/hooks/abis/EulerSwapHook.json
functions
beforeSwaphook for pre-swap validation andafterSwaphookfor post-swap processing
getFeefunction to calculate dynamic fees based on reserveratios and input direction
4 files
EulerSwap.json
Add v2 EulerSwap pool contract ABIpkg/liquidity-source/euler-swap/v2/abis/EulerSwap.json
EVault.json
Add EVault contract ABI for v1pkg/liquidity-source/euler-swap/v1/abis/EVault.json
functions
EulerSwapRegistry.json
Add v2 EulerSwapRegistry contract ABIpkg/liquidity-source/euler-swap/v2/abis/EulerSwapRegistry.json
functions
EulerRouter.json
Add EulerRouter contract ABI for v1pkg/liquidity-source/euler-swap/v1/abis/EulerRouter.json
2 files
EulerSwap.json
Fix JSON file formattingpkg/liquidity-source/euler-swap/v1/abis/EulerSwap.json
EulerSwapFactory.json
Fix JSON file formattingpkg/liquidity-source/euler-swap/v1/abis/EulerSwapFactory.json
6 files