Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
d1885a6
added initial base contracts, UniV3StyleFacet and tests
mirooon Jul 18, 2025
722f31a
Merge branch 'main' into lf-13997-lda-2.0
mirooon Jul 23, 2025
2672c1c
New changes for LDA
mirooon Jul 23, 2025
64962b9
changes
mirooon Jul 24, 2025
898424c
changes
mirooon Jul 24, 2025
322bdd7
changes
mirooon Jul 28, 2025
1516d88
adjusted new CoreRouteFacet, modified LibInputStream2, fixed LiFiDexA…
mirooon Jul 29, 2025
c5645ec
added comments and changed var name
mirooon Jul 29, 2025
89d4f39
adjusted tests for Algebra
mirooon Jul 29, 2025
e7937a7
added deal
mirooon Aug 5, 2025
dac9e04
changes
mirooon Aug 6, 2025
c7a3ca7
changes
mirooon Aug 6, 2025
bd8320d
changes
mirooon Aug 6, 2025
04765f2
added tests to facets
mirooon Aug 7, 2025
3a629c5
tests changes
mirooon Aug 8, 2025
fcf7457
tests changes
mirooon Aug 8, 2025
5c6211a
changes
mirooon Aug 8, 2025
5d79362
changes
mirooon Aug 11, 2025
5634a52
changed to _executeAndVerifySwap in Velodrome
mirooon Aug 11, 2025
3af3cc7
changed to commandType in basedexFacet
mirooon Aug 12, 2025
d934fe2
changes
mirooon Aug 12, 2025
a7e2c38
abstracted top level vars
mirooon Aug 12, 2025
c1e9ab5
changed rpcEnvName to networkName
mirooon Aug 13, 2025
24d9e25
Refactored BaseDexFacetTest: renamed _toUpper to _convertToUpperCase,…
mirooon Aug 13, 2025
1c45137
tests fixes
mirooon Aug 13, 2025
9ae4821
use auto swpa for univ3
mirooon Aug 14, 2025
d2efaed
abstracted test_CanSwap and test_CanSwap_FromDexAggregator for UniV3S…
mirooon Aug 15, 2025
48acd95
Refactored swap tests across various facets to use _getDefaultAmountF…
mirooon Aug 15, 2025
cd176e6
changes
mirooon Aug 15, 2025
fedf71c
emit Route event
mirooon Aug 15, 2025
8ec7a5e
Add minOut parameter to swap tests across multiple facets
mirooon Aug 15, 2025
b995295
Refactor swap tests in AlgebraFacet and VelodromeV2Facet to utilize _…
mirooon Aug 18, 2025
6f66efa
Add IUniV3LikePool interface and refactor pool variable usage in swap…
mirooon Aug 18, 2025
51581a1
implement onlyExpectedPool modifier in UniV3StyleFacet for callback v…
mirooon Aug 18, 2025
3bd29d8
implement onlyExpectedPool modifier in UniV3StyleFacet for callback v…
mirooon Aug 18, 2025
1308e4c
Rename IUniV3LikePool to IUniV3StylePool, update imports accordingly,…
mirooon Aug 18, 2025
f417527
Remove LdaDiamond contract and update CoreRouteFacet to utilize LibAs…
mirooon Aug 18, 2025
1650f6a
Add LibPackedStream library for compact calldata handling and refacto…
mirooon Aug 19, 2025
bf25a66
Refactor CoreRouteFacet to optimize payload handling
mirooon Aug 19, 2025
30e3b6a
Refactor test contracts to use pure functions for default token amoun…
mirooon Aug 19, 2025
353093a
Enhance CoreRouteFacet tests to utilize LibAsset for native asset han…
mirooon Aug 19, 2025
b7e4f5c
Refactor facets to utilize LibAsset for ERC20 transfers, update impor…
mirooon Aug 19, 2025
51f9ac2
Update EmergencyPauseFacet import paths and add new facet for emergen…
mirooon Aug 19, 2025
8741d63
Add BaseRouteConstants contract and refactor facets to utilize it for…
mirooon Aug 20, 2025
8056676
Add SwapCallbackNotExecuted error and BaseRouteConstants contract. Re…
mirooon Aug 20, 2025
450e913
Add IUniV2StylePool interface for Uniswap V2 style pools, refactor Un…
mirooon Aug 20, 2025
2bfdec6
Update version annotations in various contracts, remove unused LibInp…
mirooon Aug 20, 2025
6eb87c9
Refactor addFacet calls in test contracts to remove redundant address…
mirooon Aug 20, 2025
df1cad8
Update test/solidity/utils/TestBaseForksConstants.sol
0xDEnYO Aug 21, 2025
303be01
Remove new-lda-2.0.md file and update interface annotations in ICurve…
mirooon Aug 21, 2025
da81407
Merge branch 'lf-13997-lda-2.0' of github.com:lifinance/contracts int…
mirooon Aug 21, 2025
94f4725
Update SPDX license in ReentrancyGuard, add new error handling in Err…
mirooon Aug 21, 2025
5f6d8d4
Update version annotation in LibAsset to 2.1.2 and change transferNat…
mirooon Aug 21, 2025
0900971
Rename `clear` function to `disarm` in LibCallbackManager for improve…
mirooon Aug 21, 2025
42d65fe
Integrate LibAsset for ERC20 transfers in LibUniV3Logic, replacing di…
mirooon Aug 22, 2025
0c18410
fixed test_OwnerCanInitializeFacet
mirooon Aug 22, 2025
80e5170
Add LibCallbackAuthenticator for callback management. Moved modifier …
mirooon Aug 22, 2025
1494fd3
Add constructor documentation and improve comments for native asset h…
mirooon Aug 22, 2025
e3b7b70
added dev description for _runRoute
mirooon Aug 22, 2025
7da28f4
Refactor _executeRoute and balance handling in CoreRouteFacet.sol for…
mirooon Aug 22, 2025
4bf7e9e
Renamed errors for clarity: MinimalInputBalanceViolation to TokenInSp…
mirooon Aug 22, 2025
e2c3990
Renamed error identifiers in CoreRouteFacet for consistency: TokenInS…
mirooon Aug 22, 2025
be26603
Refactor CoreRouteFacet to improve clarity and consistency in command…
mirooon Aug 22, 2025
63dad2f
Update documentation in SyncSwapV2Facet to clarify support for both V…
mirooon Aug 22, 2025
9a0247b
add comments
mirooon Aug 22, 2025
546ab4d
Enhance comments in CoreRouteFacet for assembly
mirooon Aug 22, 2025
b50f8ab
Refactor UniV2StyleFacet to use a constant for fee denominator, enhan…
mirooon Aug 22, 2025
77f334a
Refactor naming conventions in test contracts and library for consist…
mirooon Aug 22, 2025
126c216
use super.setUp()
mirooon Aug 22, 2025
fa247e1
Update CoreRouteFacetTest to use USER_RECEIVER
mirooon Aug 22, 2025
1b19ed1
Refactor swap execution in test contracts to utilize _buildRouteAndEx…
mirooon Aug 22, 2025
2b6fbfa
Add LDADiamond contract and refactor addFacet calls in test contracts…
mirooon Aug 25, 2025
88b61d1
improved documentation
mirooon Aug 25, 2025
cc2def9
Update conventions.md to enforce single-line comment format for funct…
mirooon Aug 25, 2025
9fd51c9
enhance documentation in BaseDEXFacetWithCallbackTest
mirooon Aug 25, 2025
03436c4
Enhance documentation in PoolCallbackAuthenticated and Errors contrac…
mirooon Aug 25, 2025
02b95bc
Add deployment scripts
mirooon Aug 25, 2025
8567c5e
added scripts
mirooon Aug 25, 2025
3fdd94a
Update conventions.md
mirooon Aug 25, 2025
529ee1b
Add error handling for invalid indexed parameter positions in BaseCor…
mirooon Aug 25, 2025
096f038
Refactor parameter naming in swap functions across multiple facets to…
mirooon Aug 25, 2025
6ddbe21
fixed LibPackedStream
mirooon Aug 25, 2025
318d8c0
added PancakeV2
mirooon Aug 25, 2025
db268e8
Refactor Curve interfaces: removed ICurveLegacy, added ICurveV2 with …
mirooon Aug 26, 2025
aa4e0df
Enhance CurveFacet documentation and add unit tests for legacy 3pool …
mirooon Aug 26, 2025
2866e2a
Implement logic to distribute amounts in CoreRouteFacet, ensuring the…
mirooon Aug 26, 2025
1b4d000
Optimize payload handling in CoreRouteFacet by computing payload leng…
mirooon Aug 26, 2025
8ec085a
Add error handling for zero addresses and invalid fees in LDADiamond …
mirooon Aug 26, 2025
058fb8e
Remove DeployLiFiDEXAggregator scripts and LiFiDEXAggregator test fil…
mirooon Aug 26, 2025
3bade33
Add custom error handling for token transfer failures in AlgebraLiqui…
mirooon Aug 26, 2025
44d328a
Refactor NativeWrapperFacet to streamline ETH withdrawal logic and im…
mirooon Aug 27, 2025
4655934
Refactor facet instance parameter naming in test contracts to use 'ld…
mirooon Aug 27, 2025
3fe3b85
Update SPDX license identifier in TestBase.sol from Unlicense to LGPL…
mirooon Aug 27, 2025
413c062
Update SPDX license identifier in IWETH.sol from MIT to LGPL-3.0-only
mirooon Aug 27, 2025
af30e79
Refactor BaseRouteConstants to rename INTERNAL_INPUT_SOURCE to FUNDS_…
mirooon Aug 27, 2025
e157a0d
Update functionSelectors array size in BaseUniV2StyleDexFacet
mirooon Aug 27, 2025
308ec84
Merge branch 'main' into lf-13997-lda-2.0
mirooon Aug 27, 2025
b2546ee
Override setUp function in SwapperV2Test and PatcherTest to ensure pr…
mirooon Aug 27, 2025
842d77e
Update ICurve interface and CurveFacet to support payable exchanges, …
mirooon Aug 27, 2025
b247edb
Enhance CurveFacet to support legacy ETH swaps with stETH, adding tes…
mirooon Aug 27, 2025
0149234
Enhance SyncSwapV2Facet tests to validate error handling for invalid …
mirooon Aug 27, 2025
1b308cc
Refactor CurveFacet to conditionally approve ERC20 tokens based on as…
mirooon Aug 27, 2025
5cbf20a
Implement additional validation in AlgebraFacet and UniV3StyleFacet t…
mirooon Aug 27, 2025
cbebd52
Remove LiFiDEXAggregator.sol file
mirooon Aug 27, 2025
289b8ce
FUNDS_IN_RECEIVER to address(1)
mirooon Aug 27, 2025
7ebfdae
Update EmergencyPauseFacet to include InvalidConfig error handling an…
mirooon Aug 28, 2025
db1b10e
Merge branch 'main' into lf-13997-lda-2.0
mirooon Aug 28, 2025
15c94b6
updated paths
mirooon Aug 28, 2025
61c0c97
Update LDA diamond test setup with new owner and pauser addresses, an…
mirooon Aug 28, 2025
38c6a38
Refactor swap amount calculation in BaseUniV2StyleDexFacet and BaseUn…
mirooon Aug 28, 2025
9035ee0
Update AlgebraFacet test to reflect changes in aggregator address fro…
mirooon Aug 28, 2025
0cf2654
Update sender logic in BaseUniV2StyleDexFacet and BaseUniV3StyleDexFa…
mirooon Aug 28, 2025
067e252
Update sender address in CurveFacet, IzumiV3Facet, NativeWrapperFacet…
mirooon Aug 28, 2025
7062247
Update minOutput calculation in AlgebraFacet test to prevent underflo…
mirooon Aug 28, 2025
486f651
Increment version number in LibAsset library from 2.1.2 to 2.1.3
mirooon Aug 28, 2025
642b0e6
Update sender address in CurveFacet and IzumiV3Facet tests to use lda…
mirooon Aug 28, 2025
6140574
Refactor interface documentation comments in IAlgebraFactory, IAlgebr…
mirooon Aug 28, 2025
d2e69f3
Refactor isIndexed array in BaseCoreRouteTest to use dynamic sizing b…
mirooon Aug 28, 2025
169361b
improve error handling in NativeWrapperFacetTest
mirooon Aug 28, 2025
d05f15a
changed paths
mirooon Aug 28, 2025
337bc14
updates
mirooon Aug 28, 2025
f3de730
update paths
mirooon Aug 28, 2025
3131cd6
changed folder name
mirooon Aug 28, 2025
eb7b196
changed folder name
mirooon Aug 28, 2025
fbad9a0
changed folder name
mirooon Aug 28, 2025
06f73b1
changed folder name
mirooon Aug 28, 2025
2957af5
changed file name
mirooon Aug 28, 2025
a10b05d
changed folder name
mirooon Aug 28, 2025
7475797
Add KatanaV3Facet contract and corresponding unit tests for swap func…
mirooon Aug 29, 2025
5bb5f3b
Update sentinel address documentation
mirooon Aug 29, 2025
d845798
Fix type conversion for fromIndex and toIndex in CurveFacet contract
mirooon Aug 29, 2025
ff1b511
Add revert condition for native ETH input in V2 pools and correspondi…
mirooon Aug 29, 2025
b20a5b1
Improve documentation for unwrapNative function in NativeWrapperFacet…
mirooon Aug 29, 2025
db43d44
Update CoreRouteFacet instantiation and fix typo in callback document…
mirooon Aug 29, 2025
b989300
Update CurveFacet and related tests to clarify token sourcing and fee…
mirooon Aug 29, 2025
f993b80
Add LDA (LiFi DEX Aggregator) conventions to conventions.md
mirooon Aug 29, 2025
e081ffb
fix
mirooon Aug 29, 2025
1e1b503
Add LDA facets including EmergencyPause, Ownership, and Periphery Reg…
mirooon Aug 29, 2025
6370f9a
Update SPDX license identifiers to LGPL-3.0-only for LDA deployment s…
mirooon Aug 29, 2025
9aef00c
removed duplicates
mirooon Aug 29, 2025
1cb9bb4
Add LDA deployment scripts and facets, including core facets and upda…
mirooon Aug 29, 2025
c82a1d3
Add ownership transfer stage to LDA deployment script, including heal…
mirooon Sep 1, 2025
dbfa258
Add NativeWrapperFacet and IzumiV3Facet to deployment configurations …
mirooon Sep 1, 2025
0749556
Add zksync deployment configurations and scripts for LDA facets, incl…
mirooon Sep 2, 2025
d444ffe
Refactor CoreRouteFacet to remove WithdrawablePeriphery inheritance a…
mirooon Sep 2, 2025
9e70242
Remove LDA related copied scripts and related deployment scripts, tes…
mirooon Sep 2, 2025
a501d3a
Rename LDADiamond to LiFiDEXAggregatorDiamond in conventions.md and u…
mirooon Sep 2, 2025
a210154
Add detailed documentation for token swap functions in ICurve and ICu…
mirooon Sep 2, 2025
34afee3
add blank line
mirooon Sep 2, 2025
6d5c2e4
Update LDA error handling conventions: rename error file to LiFiDEXAg…
mirooon Sep 2, 2025
ee259cc
changed cur to stream
mirooon Sep 2, 2025
d822cb4
Refactor NativeWrapperFacet to optimize destination address retrieval…
mirooon Sep 2, 2025
cc4d5b5
Refactor LiFiDEXAggregatorDiamond to inherit from LiFiDiamond
mirooon Sep 2, 2025
fdb2786
Rename PoolCallbackAuthenticated to PoolCallbackAuthenticator
mirooon Sep 2, 2025
86fdc51
Refactor test files to improve structure and consistency: rename Base…
mirooon Sep 2, 2025
2495a34
Refactor test structure by removing LiFiDiamondTest and LiFiDEXAggreg…
mirooon Sep 3, 2025
58896e3
Add test for LiFiDEXAggregatorDiamond to ensure it reverts when const…
mirooon Sep 3, 2025
4c45d4a
Update conventions.md to standardize naming from LDA to LiFiDEXAggreg…
mirooon Sep 3, 2025
5992e3e
Refactor LiFiDiamond and LiFiDEXAggregatorDiamond to improve error ha…
mirooon Sep 3, 2025
01bba97
added blank space
mirooon Sep 3, 2025
f5b55ea
merge with addresses comments
mirooon Sep 4, 2025
675217b
Refactor deployment scripts and configurations to transition from LDA…
mirooon Sep 4, 2025
3ea087c
Update deployment configurations and scripts for LDA to LiFiDEXAggreg…
mirooon Sep 4, 2025
48b7faf
update deploySingleContract to also save addresses of lda contracts i…
mirooon Sep 4, 2025
bc3da25
Renamed test files
mirooon Sep 4, 2025
ef4c051
Merge branch 'lf-13997-lda-2.0-addressed-comments' into lf-13997-lda-…
mirooon Sep 4, 2025
4da34d5
Refactor update scripts to enhance clarity and maintainability, inclu…
mirooon Sep 4, 2025
5c82d5f
Update deployment files for LDA to LiFiDEXAggregator transition. Intr…
mirooon Sep 5, 2025
cd1c095
moved all lda deploy as a single for LiFiDEXAggregatorDiamond, add us…
mirooon Sep 5, 2025
18f59f8
removed deployFacetAndAddToDLADiamond and updated deployFacetAndAddTo…
mirooon Sep 5, 2025
5e6d280
removed IS_LDA_CONTRACT flag
mirooon Sep 5, 2025
0a91cb3
improved script, removed create3factory deployment, removed staging, …
mirooon Sep 5, 2025
97d1382
Update audit verification condition in gh workflow to ensure it only …
mirooon Sep 5, 2025
761106b
updated description
mirooon Sep 5, 2025
7b1b84c
Merge branch 'feat/audit-check-only-on-main-branch' into lf-13997-lda…
mirooon Sep 5, 2025
f25cf5f
Merge branch 'lf-13997-lda-2.0-addressed-comments' into lf-13997-lda-…
mirooon Sep 5, 2025
e827b74
Merge branch 'main' into lf-13997-lda-2.0
mirooon Sep 5, 2025
c2b3e58
Merge branch 'lf-13997-lda-2.0' into lf-13997-lda-2.0-addressed-comments
mirooon Sep 5, 2025
8ec8cd1
updstes
mirooon Sep 5, 2025
1eb847d
Merge branch 'lf-13997-lda-2.0-addressed-comments' into lf-13997-lda-…
mirooon Sep 5, 2025
ea98621
updates
mirooon Sep 6, 2025
7c7bad7
changes
mirooon Sep 6, 2025
05ad309
changes in deploy logs
mirooon Sep 6, 2025
3524184
changes and new deployemnt
mirooon Sep 6, 2025
b67966b
updates
mirooon Sep 7, 2025
83ad6f6
updates
mirooon Sep 7, 2025
3d201a4
Refine LDA contract check in deploySingleContract script
mirooon Sep 7, 2025
ed3f453
update
mirooon Sep 7, 2025
e6d7c0e
changed BaseDiamondTest changed to DiamondTestHelpers
mirooon Sep 8, 2025
c2c99ba
Merge branch 'lf-13997-lda-2.0-addressed-comments' into lf-13997-lda-…
mirooon Sep 8, 2025
c3f6b6e
updates
mirooon Sep 8, 2025
355b03c
Refactor UpdateScriptBase to use _getConfigContractAddress for facet …
mirooon Sep 8, 2025
6b57cee
Refactor getRpcUrl function to improve RPC URL retrieval from environ…
mirooon Sep 8, 2025
f1897b5
updated, dont mix files between environments
mirooon Sep 8, 2025
c19904e
check ownership only for production env
mirooon Sep 8, 2025
4eb8b19
updates
mirooon Sep 8, 2025
40d3700
changing "Deploy LDA facet" to "Deploy LDA contract"
mirooon Sep 8, 2025
24611c5
Merge branch 'main' into lf-13997-lda-2.0
mirooon Sep 8, 2025
9461d43
Merge branch 'lf-13997-lda-2.0' into lf-13997-lda-2.0-addressed-comments
mirooon Sep 8, 2025
3fea663
revert
mirooon Sep 8, 2025
740bbf4
Merge branch 'lf-13997-lda-2.0' into lf-13997-lda-2.0-addressed-comments
mirooon Sep 8, 2025
34e453d
Merge branch 'lf-13997-lda-2.0-addressed-comments' into lf-13997-lda-…
mirooon Sep 8, 2025
03fa2ef
moved lda contract logic to 14 selector
mirooon Sep 8, 2025
5fa279e
parallelize internal logic in diamondLogUpdate helper function
0xDEnYO Sep 9, 2025
f419d82
update saveDiamondFacets call
0xDEnYO Sep 9, 2025
9a0abc4
quote parameters + minor fixes
0xDEnYO Sep 9, 2025
e45b558
fixed PID issue
0xDEnYO Sep 9, 2025
04f1d33
changes
mirooon Sep 9, 2025
d2fc7e7
changes
mirooon Sep 9, 2025
aff1f53
changes
mirooon Sep 9, 2025
547dd31
changes
mirooon Sep 9, 2025
fe50631
changes
mirooon Sep 9, 2025
eb4511c
refactor updateDiamondLogForNetwork to return a special exit code for…
mirooon Sep 9, 2025
e724ff3
changes
mirooon Sep 9, 2025
215e9b8
changes
mirooon Sep 9, 2025
dc2a717
Merge branch 'main' into lf-13997-lda-2.0
mirooon Sep 9, 2025
dd83bde
Merge branch 'lf-13997-lda-2.0' into lf-13997-lda-2.0-addressed-comments
mirooon Sep 9, 2025
c6e074b
Merge branch 'lf-13997-lda-2.0-addressed-comments' into lf-13997-lda-…
mirooon Sep 9, 2025
fa09029
Merge branch 'lf-13997-lda-2.0-scripts' into lf-13997-lda-2.0-scripts…
mirooon Sep 9, 2025
66b5391
update
mirooon Sep 9, 2025
ecff84c
space
mirooon Sep 9, 2025
891a76a
removed space
mirooon Sep 9, 2025
ea25ccc
update
mirooon Sep 9, 2025
ab2dfad
removed quotes
mirooon Sep 9, 2025
480800e
added quotes
mirooon Sep 9, 2025
3e2a453
Merge branch 'lf-13997-lda-2.0-scripts' into lf-13997-lda-2.0-scripts…
mirooon Sep 9, 2025
5cefa01
Update GitHub Actions workflow to run version control checks only for…
mirooon Sep 9, 2025
62f6d10
Merge branch 'feat/version-control-check-only-on-main-branch' into lf…
mirooon Sep 9, 2025
a775644
update
mirooon Sep 12, 2025
fa291f4
Merge pull request #1370 from lifinance/lf-13997-lda-2.0-scripts-upda…
mirooon Sep 12, 2025
b71df7a
Merge pull request #1360 from lifinance/lf-13997-lda-2.0-scripts
mirooon Sep 12, 2025
89e8a02
Merge pull request #1356 from lifinance/lf-13997-lda-2.0-addressed-co…
mirooon Sep 12, 2025
b605d2f
Merge branch 'main' into lf-13997-lda-2.0
mirooon Sep 12, 2025
2004678
new staging arbitrum deployments
mirooon Sep 12, 2025
77c720e
Changes
mirooon Sep 14, 2025
33a05ef
Mark external swap functions as `payable` to support multihop routes …
mirooon Sep 25, 2025
852128c
new deploy logs
mirooon Sep 26, 2025
63cbebc
deploy core facets for lda for apechain
mirooon Sep 26, 2025
cf448a4
added apechain lifidexaggregator
mirooon Sep 26, 2025
ca99919
added ronin staging LDA
mirooon Sep 26, 2025
257a4ed
celo deployed core LDA facets
mirooon Sep 26, 2025
a7dd359
added celo staging LDA deployment
mirooon Sep 26, 2025
030b7b9
Merge branch 'main' into lf-13997-lda-2.0
mirooon Sep 26, 2025
0e21a5e
added plume staging diamond
mirooon Sep 30, 2025
ea034d7
deployed zksync lifi dex aggregator setup
mirooon Oct 13, 2025
e86d18b
added deployment scripts for CoreRouteFacet, KatanaV3Facet, and Velod…
mirooon Oct 14, 2025
ac5ae2f
Merge branch 'main' into lf-13997-lda-2.0
mirooon Nov 7, 2025
997a688
Enhance ABI cleaning script to remove duplicate contract ABIs and eve…
mirooon Nov 7, 2025
b005577
Fix json deployment file
mirooon Nov 7, 2025
6718394
Update deployment log files to correct OPTIMIZER_RUNS format and clea…
mirooon Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "solhint:recommended",
"plugins": ["prettier"],
"excludedFiles": ["**/src/Interfaces/**/*.sol"],
"rules": {
"avoid-call-value": "off",
"avoid-low-level-calls": "off",
Expand Down
5 changes: 5 additions & 0 deletions config/global.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
"Permit2Proxy",
"TokenWrapper"
],
"ldaCoreFacets": [
"DiamondCutFacet",
"DiamondLoupeFacet",
"OwnershipFacet"
],
"blacklistedFunctionSelectors": ["0x23b872dd"],
"whitelistPeripheryFunctions": {
"FeeCollector": [
Expand Down
195 changes: 195 additions & 0 deletions conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ We use Foundry as our primary development and testing framework. Foundry provide
- **Error Handling:**

- **Generic errors** must be defined in `src/Errors/GenericErrors.sol`
- LDA-specific errors should be defined in `src/Periphery/LDA/LiFiDEXAggregatorErrors.sol`
- Use for common validation errors that apply across multiple contracts
- When adding new generic errors, increment the version in `@custom:version` comment
- Examples: `InvalidAmount()`, `InvalidCallData()`, `UnAuthorized()`
Expand Down Expand Up @@ -263,6 +264,15 @@ We use Foundry as our primary development and testing framework. Foundry provide
/// @return Description of return value
/// @dev Additional details about implementation (optional)
```
- Incorrect format (do not use):
```solidity
/** @notice Brief description of function purpose
* @param parameterName Description of parameter
* @return Description of return value
* @dev Additional details about implementation (optional)
*/
```
- Always use `///` single-line format instead of `/** */` block format for better readability and gas efficiency

4. **Complex Logic Documentation**
- Add inline comments for complex algorithms
Expand Down Expand Up @@ -369,6 +379,191 @@ We use Foundry as our primary development and testing framework. Foundry provide
}
```

## LiFiDEXAggregator (LDA) Conventions

The LiFiDEXAggregator (LDA) is a specialized component within the LI.FI ecosystem that provides efficient, modular DEX integration capabilities through its own Diamond Standard implementation.

### Architecture Overview

#### Core Components

- **LiFiDEXAggregatorDiamond.sol**: Base EIP-2535 Diamond Proxy Contract for DEX Aggregator
- **CoreRouteFacet.sol**: Orchestrates route execution using direct function selector dispatch
- **BaseRouteConstants.sol**: Shared constants across DEX facets
- **PoolCallbackAuthenticator.sol**: Abstract contract providing pool callback authentication

#### Location Structure

```
src/Periphery/LDA/
├── LiFiDEXAggregatorDiamond.sol # LiFiDEXAggregatorDiamond Diamond proxy implementation
├── BaseRouteConstants.sol # Common constants for DEX facets
├── PoolCallbackAuthenticator.sol # Callback authentication base
├── Facets/ # LiFiDEXAggregator-specific facets
│ ├── CoreRouteFacet.sol # Route orchestration
│ ├── UniV3StyleFacet.sol # UniV3-style DEX integrations
│ ├── UniV2StyleFacet.sol # UniV2-style DEX integrations
│ ├── NativeWrapperFacet.sol # Native token wrapping
│ └── {DexName}Facet.sol # Custom DEX integrations
└── Errors/
└── Errors.sol # LiFiDEXAggregator-specific error definitions
```

### DEX Integration Decision Tree

When integrating a new DEX, follow this decision tree:

1. **Is the DEX a UniV3 fork (same logic, different callback name)?**
- ✅ Yes → Extend `UniV3StyleFacet.sol` with a new callback
- Add tests inheriting `BaseUniV3StyleDEXFacetTest`

2. **Else, is it a UniV2-style fork?**
- ✅ Yes → No new facet needed
- Add tests inheriting `BaseUniV2StyleDEXFacetTest`

3. **Else, does it use a callback?**
- ✅ Yes → Create new custom facet with swap function and callback
- Write tests inheriting `BaseDEXFacetWithCallbackTest`

4. **Else** → Create new custom facet with swap function without callbacks
- Write tests inheriting `BaseDEXFacetTest`

### LiFiDEXAggregator Facet Requirements

#### Naming and Location

- Must reside in `src/Periphery/LDA/Facets/`
- Names must include "Facet" suffix
- Use descriptive names (e.g., `UniV3StyleFacet`, `CurveFacet`)

#### Required Inheritance

- **BaseRouteConstants**: For common constants (`DIRECTION_TOKEN0_TO_TOKEN1`, `FUNDS_IN_RECEIVER`)
- **PoolCallbackAuthenticator**: For facets requiring callback verification
- **No ReentrancyGuard**: CoreRouteFacet handles reentrancy protection

#### Function Patterns

**Swap Functions:**
- Must follow pattern: `swap{DexName}(bytes memory swapData, address from, address tokenIn, uint256 amountIn)`
- Use `LibPackedStream` for efficient parameter unpacking
- Handle token transfers based on `from` parameter (if `from == msg.sender`, pull tokens)

**Callback Functions:**
- Must use `onlyExpectedPool` modifier
- **IMPORTANT**: Callback function names are protocol-specific and cannot be guessed. You must inspect the target pool contract's interface directly in the block explorer or source code to determine the exact callback function name(s). Examples include `uniswapV3SwapCallback`, `pancakeV3SwapCallback`, `swapX2YCallback`, `swapY2XCallback`, etc.
- Use `LibCallbackAuthenticator` for pool verification

#### Parameter Handling

- **swapData Encoding**: Use packed encoding for efficiency
- Common pattern: `[pool, direction, destinationAddress]`
- Additional parameters as needed per DEX
- **Direction Parameter**: Use `uint8` where `1 = token0 -> token1`, `0 = token1 -> token0`
- **Validation**: Always validate pool addresses and amounts. For invalid inputs, revert with `InvalidCallData()` from `GenericErrors.sol`

#### Error Handling

- **LiFiDEXAggregator-specific errors**: Define in `src/Periphery/LDA/LiFiDEXAggregatorErrors.sol`
- **Generic errors**: Use existing errors from `src/Errors/GenericErrors.sol`

### LiFiDEXAggregator Testing Conventions

#### Test File Structure

```
test/solidity/Periphery/LDA/
├── BaseCoreRoute.t.sol # Base route testing functionality
├── BaseDEXFacet.t.sol # Base for custom DEX tests
├── BaseDEXFacetWithCallback.t.sol # Base for callback-enabled DEX tests
├── BaseUniV3StyleDEXFacet.t.sol # Base for UniV3-style DEX tests
├── BaseUniV2StyleDEXFacet.t.sol # Base for UniV2-style DEX tests
└── Facets/
└── {DexName}Facet.t.sol # Specific DEX implementation tests
```

#### Test Implementation Requirements

**All LDA DEX tests must implement:**

1. **`_setupForkConfig()`**: Configure network and block number
- Use valid `networkName` from `config/networks.json`
- **IMPORTANT**: You must manually specify a block number where the target pools have healthy liquidity. Do not guess block numbers - check the pool's transaction history on a block explorer to find a recent block with sufficient reserves for testing
- Example:
```solidity
function _setupForkConfig() internal override {
forkConfig = ForkConfig({
networkName: "mainnet",
blockNumber: 18500000 // Manually verified block with healthy pool liquidity
});
}
```

2. **`_createFacetAndSelectors()`**: Deploy facet and return selectors
- Return facet address and function selectors for diamond cut
- Include both swap function and callback selectors (if applicable)

3. **`_setFacetInstance()`**: Connect test handle to diamond proxy
- Set local facet instance to diamond address after cut

4. **`_setupDexEnv()`**: Configure test tokens and pools
- Set `tokenIn`, `tokenOut`, `poolInOut` with sufficient liquidity
- Verify pools exist and have proper reserves

#### Test Categories by Inheritance

**BaseDEXFacetTest** (Custom DEX without callbacks):
- Implement single-hop and multi-hop tests (if supported)
- Focus on direct swap execution
- Example: `SyncSwapV2Facet.t.sol`

**BaseDEXFacetWithCallbackTest** (Custom DEX with callbacks):
- Include callback verification tests
- Override `_getCallbackSelector()` for negative tests
- Implement `_deployNoCallbackPool()` if needed
- Example: `IzumiV3Facet.t.sol`

**BaseUniV3StyleDEXFacetTest** (UniV3 forks):
- Override `_getCallbackSelector()` for DEX-specific callback
- No multi-hop support (skipped for UniV3-style)
- Example: `AlgebraFacet.t.sol`

**BaseUniV2StyleDEXFacetTest** (UniV2 forks):
- Override `_getPoolFee()` for DEX-specific fee structure
- Support multi-hop routing
- Example: `VelodromeV2Facet.t.sol`

#### Test Validation Requirements

- **Liquidity Validation**: Ensure pools have sufficient liquidity for test amounts
- **Token Decimals**: Override `_getDefaultAmountForTokenIn()` for non-18 decimal tokens
- **Pool Verification**: Verify pool addresses exist and are correctly configured. Ensure the chosen fork block number has the pools deployed and contains sufficient liquidity for testing

### LiFiDEXAggregator Deployment Scripts

#### Location and Naming

- **Location**: `script/deploy/facets/LDA/`
- **Naming**: `Deploy{DexName}Facet.s.sol`
- **Pattern**: Follow standard deployment script structure

#### Deployment Script Structure

```solidity
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity ^0.8.17;

import { DeployScriptBase } from "../utils/DeployScriptBase.sol";
import { {DexName}Facet } from "lifi/Periphery/LDA/Facets/{DexName}Facet.sol";

contract DeployScript is DeployScriptBase {
constructor() DeployScriptBase("{DexName}Facet") {}

function run() public returns ({DexName}Facet deployed) {
deployed = {DexName}Facet(deploy(type({DexName}Facet).creationCode));
}
}
```
## Solidity Test Conventions (.t.sol files)

### File Naming and Structure
Expand Down
Loading
Loading