Flash unwinder contracts and scripts, relay lane tuning, trustless bridge and token-aggregation updates.

Made-with: Cursor
This commit is contained in:
defiQUG
2026-04-12 06:33:54 -07:00
parent 662b35ad69
commit 6817f53591
40 changed files with 682 additions and 88 deletions

View File

@@ -14,7 +14,7 @@ contract DEXIntegrationTest is Test {
LiquidityPoolETH public liquidityPool;
address public constant WETH = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public constant UNISWAP_V3_ROUTER = address(0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45);
address public constant UNISWAP_V3_ROUTER = address(0xE592427A0AEce92De3Edee1F18E0157C05861564);
address public constant CURVE_3POOL = address(0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7);
address public constant ONEINCH_ROUTER = address(0x1111111254EEB25477B68fb85Ed929f73A960582);
address public constant USDT = address(0xdAC17F958D2ee523a2206206994597C13D831ec7);
@@ -59,4 +59,3 @@ contract DEXIntegrationTest is Test {
// Note: Actual swap tests would require forking mainnet or using mocks
// This is a placeholder for integration tests
}

View File

@@ -27,7 +27,7 @@ interface IERC20Token {
*/
contract ForkTests is Test {
// Ethereum Mainnet addresses
address constant UNISWAP_V3_ROUTER = 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45;
address constant UNISWAP_V3_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
address constant CURVE_3POOL = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7;
address constant ONEINCH_ROUTER = 0x1111111254EEB25477B68fb85Ed929f73A960582;
address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;

View File

@@ -69,7 +69,8 @@ contract AaveQuotePushFlashReceiverMainnetForkTest is Test {
receiver = new AaveQuotePushFlashReceiver(AAVE_POOL_MAINNET);
unwinder = new AaveForkMockExternalUnwinder(IERC20(CWUSDC), IERC20(USDC), 112, 100);
deal(USDC, address(unwinder), 100_000_000); // 100 USDC quote inventory for unwind payouts
// PMM + unwind sizing can require materially more than 100 USDC on a live reserve snapshot.
deal(USDC, address(unwinder), 50_000_000_000); // 50k USDC (6 decimals) for mock unwind payouts
}
function testFork_aaveQuotePush_usesRealAaveAndRealMainnetPmm() public skipIfNoFork {

View File

@@ -39,7 +39,8 @@ contract DODOIntegrationExternalUnwinderMainnetForkTest is Test {
function testFork_cWUSDCToUSDC_unwindsThroughMainnetDodoIntegration() public skipIfNoFork {
uint256 amountIn = 1_000_000; // 1 cWUSDC
deal(CWUSDC, address(unwinder), amountIn);
deal(CWUSDC, address(this), amountIn);
IERC20(CWUSDC).approve(address(unwinder), amountIn);
uint256 before = IERC20(USDC).balanceOf(address(this));
uint256 amountOut = unwinder.unwind(CWUSDC, USDC, amountIn, 1, abi.encode(POOL_CWUSDC_USDC));

View File

@@ -76,8 +76,8 @@ contract QuotePushFlashWorkflowBorrowerMainnetForkTest is Test {
unwinder = new ForkMockExternalUnwinder(IERC20(CWUSDC), IERC20(USDC), 112, 100);
// Seed the local lender and unwind venue with enough quote on the fork.
deal(USDC, address(vault), 100_000_000); // 100 USDC
deal(USDC, address(unwinder), 100_000_000); // 100 USDC
deal(USDC, address(vault), 50_000_000_000);
deal(USDC, address(unwinder), 50_000_000_000);
}
function testFork_quotePush_usesLiveMainnetPmmLegAndRepays() public skipIfNoFork {

View File

@@ -6,7 +6,8 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {UniswapV3ExternalUnwinder} from "../../contracts/flash/UniswapV3ExternalUnwinder.sol";
contract UniswapV3ExternalUnwinderForkTest is Test {
address constant UNISWAP_V3_ROUTER = 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45;
// SwapRouter (not SwapRouter02): exactInputSingle selector matches `ISwapRouter` in this repo.
address constant UNISWAP_V3_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
address constant WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address constant USDC = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address constant CWUSDC = 0x2de5F116bFcE3d0f922d9C8351e0c5Fc24b9284a;
@@ -38,7 +39,8 @@ contract UniswapV3ExternalUnwinderForkTest is Test {
}
function testFork_knownRoute_WETHToUSDC_singleHopWorks() public skipIfNoFork {
deal(WETH, address(unwinder), 1 ether);
deal(WETH, address(this), 1 ether);
IERC20(WETH).approve(address(unwinder), type(uint256).max);
uint256 before = IERC20(USDC).balanceOf(address(this));
uint256 amountOut = unwinder.unwind(WETH, USDC, 1 ether, 1, abi.encode(uint24(3000)));
@@ -49,7 +51,8 @@ contract UniswapV3ExternalUnwinderForkTest is Test {
}
function testFork_cWUSDCToUSDC_routeUnavailableOnUniswapV3() public skipIfNoFork {
deal(CWUSDC, address(unwinder), 1_000_000);
deal(CWUSDC, address(this), 1_000_000);
IERC20(CWUSDC).approve(address(unwinder), 1_000_000);
vm.expectRevert();
unwinder.unwind(CWUSDC, USDC, 1_000_000, 1, abi.encode(uint24(3000)));