diff --git a/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol b/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol index d6d22d9a..e1470b98 100644 --- a/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol +++ b/contracts/adapters/velodrome/VelodromeV2RouterAdapter.sol @@ -158,9 +158,11 @@ contract VelodromeV2RouterAdapter is AbstractAdapter, IVelodromeV2RouterAdapter tokenOut = routes[len - 1].to; valid = isPoolAllowed(routes[0].from, routes[0].to, routes[0].stable, routes[0].factory); if (valid && len > 1) { - valid = isPoolAllowed(routes[1].from, routes[1].to, routes[1].stable, routes[1].factory); + valid = isPoolAllowed(routes[1].from, routes[1].to, routes[1].stable, routes[1].factory) + && (routes[0].to == routes[1].from); if (valid && len > 2) { - valid = isPoolAllowed(routes[2].from, routes[2].to, routes[2].stable, routes[2].factory); + valid = isPoolAllowed(routes[2].from, routes[2].to, routes[2].stable, routes[2].factory) + && (routes[1].to == routes[2].from); } } } diff --git a/contracts/test/config/USDC_Optimism_config.sol b/contracts/test/config/USDC_Optimism_config.sol index bdddb376..21ef79fd 100644 --- a/contracts/test/config/USDC_Optimism_config.sol +++ b/contracts/test/config/USDC_Optimism_config.sol @@ -22,14 +22,14 @@ import { contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { string public constant id = "optimism-usdc-v3"; uint256 public constant chainId = 10; - Tokens public constant underlying = Tokens.USDC; + Tokens public constant underlying = Tokens.USDC_e; bool public constant supportsQuotas = true; uint256 public constant getAccountAmount = 10_000_000_000; // POOL string public constant symbol = "dUSDCV3"; - string public constant name = "USDC v3"; + string public constant name = "Main USDC.e v3"; PoolV3DeployParams _poolParams = PoolV3DeployParams({withdrawalFee: 0, totalDebtLimit: 100_000_000_000_000}); @@ -51,34 +51,30 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { constructor() { _gaugeRates.push(GaugeRate({token: Tokens.DAI, minRate: 4, maxRate: 12_00})); _gaugeRates.push(GaugeRate({token: Tokens.USDT, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.WBTC, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.WETH, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.OP, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.WLD, minRate: 80, maxRate: 24_00})); - _gaugeRates.push(GaugeRate({token: Tokens.LINK, minRate: 80, maxRate: 24_00})); - _gaugeRates.push(GaugeRate({token: Tokens.SNX, minRate: 80, maxRate: 24_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvWETH, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvOP, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.wstETH, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.rETH, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvDAI, minRate: 5, maxRate: 8_50})); - _gaugeRates.push(GaugeRate({token: Tokens.yvUSDC, minRate: 5, maxRate: 7_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvUSDT, minRate: 5, maxRate: 9_00})); + _gaugeRates.push(GaugeRate({token: Tokens.WBTC, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.WETH, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.OP, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.WLD, minRate: 80, maxRate: 50_00})); + _gaugeRates.push(GaugeRate({token: Tokens.SNX, minRate: 80, maxRate: 50_00})); + _gaugeRates.push(GaugeRate({token: Tokens.yvWETH, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.wstETH, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.rETH, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.yvDAI, minRate: 5, maxRate: 15_00})); + _gaugeRates.push(GaugeRate({token: Tokens.yvUSDC_e, minRate: 5, maxRate: 15_00})); + _gaugeRates.push(GaugeRate({token: Tokens.yvUSDT, minRate: 5, maxRate: 15_00})); _quotaLimits.push(PoolQuotaLimit({token: Tokens.DAI, quotaIncreaseFee: 1, limit: 3_000_000_000_000})); _quotaLimits.push(PoolQuotaLimit({token: Tokens.USDT, quotaIncreaseFee: 1, limit: 1_500_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.WBTC, quotaIncreaseFee: 1, limit: 500_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.WETH, quotaIncreaseFee: 1, limit: 3_000_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.OP, quotaIncreaseFee: 1, limit: 1_300_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.WBTC, quotaIncreaseFee: 1, limit: 300_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.WETH, quotaIncreaseFee: 1, limit: 1_500_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.OP, quotaIncreaseFee: 1, limit: 1_000_000_000_000})); _quotaLimits.push(PoolQuotaLimit({token: Tokens.WLD, quotaIncreaseFee: 5, limit: 600_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.LINK, quotaIncreaseFee: 5, limit: 50_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.SNX, quotaIncreaseFee: 5, limit: 400_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvWETH, quotaIncreaseFee: 1, limit: 400_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvOP, quotaIncreaseFee: 1, limit: 550_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.wstETH, quotaIncreaseFee: 1, limit: 3_000_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.rETH, quotaIncreaseFee: 1, limit: 3_000_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.SNX, quotaIncreaseFee: 5, limit: 300_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvWETH, quotaIncreaseFee: 1, limit: 500_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.wstETH, quotaIncreaseFee: 1, limit: 1_000_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.rETH, quotaIncreaseFee: 1, limit: 800_000_000_000})); _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvDAI, quotaIncreaseFee: 0, limit: 230_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvUSDC, quotaIncreaseFee: 0, limit: 330_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvUSDT, quotaIncreaseFee: 0, limit: 300_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvUSDC_e, quotaIncreaseFee: 0, limit: 330_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvUSDT, quotaIncreaseFee: 0, limit: 230_000_000_000})); { /// CREDIT_MANAGER_0 @@ -87,21 +83,25 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { cp.minDebt = 1_000_000_000; cp.maxDebt = 200_000_000_000; cp.feeInterest = 2500; - cp.feeLiquidation = 50; - cp.liquidationPremium = 100; - cp.feeLiquidationExpired = 50; - cp.liquidationPremiumExpired = 100; + cp.feeLiquidation = 100; + cp.liquidationPremium = 200; + cp.feeLiquidationExpired = 100; + cp.liquidationPremiumExpired = 200; cp.whitelisted = false; cp.expirable = false; cp.skipInit = false; cp.poolLimit = 2_000_000_000_000; CollateralTokenHuman[] storage cts = cp.collateralTokens; - cts.push(CollateralTokenHuman({token: Tokens.WETH, lt: 96_00})); + cts.push(CollateralTokenHuman({token: Tokens.DAI, lt: 96_00})); + + cts.push(CollateralTokenHuman({token: Tokens.USDT, lt: 96_00})); + + cts.push(CollateralTokenHuman({token: Tokens.WETH, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.WBTC, lt: 96_00})); + cts.push(CollateralTokenHuman({token: Tokens.WBTC, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.OP, lt: 96_00})); + cts.push(CollateralTokenHuman({token: Tokens.OP, lt: 90_00})); cts.push(CollateralTokenHuman({token: Tokens.yvWETH, lt: 94_00})); @@ -109,19 +109,25 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { cts.push(CollateralTokenHuman({token: Tokens.rETH, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.yvOP, lt: 94_00})); + cts.push(CollateralTokenHuman({token: Tokens.yvUSDC_e, lt: 94_00})); + + cts.push(CollateralTokenHuman({token: Tokens.yvDAI, lt: 94_00})); + + cts.push(CollateralTokenHuman({token: Tokens.yvUSDT, lt: 94_00})); + + cts.push(CollateralTokenHuman({token: Tokens._3CRV, lt: 0})); Contracts[] storage cs = cp.contracts; cs.push(Contracts.UNISWAP_V3_ROUTER); UniswapV3Pair[] storage uv3p = cp.uniswapV3Pairs; uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.OP, fee: 3000})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 500})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.WBTC, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.wstETH, token1: Tokens.WETH, fee: 100})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.WBTC, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.OP, token1: Tokens.USDC, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.OP, token1: Tokens.USDC_e, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.OP, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.rETH, fee: 500})); + uv3p.push(UniswapV3Pair({token0: Tokens.USDC_e, token1: Tokens.USDT, fee: 100})); cs.push(Contracts.BALANCER_VAULT); BalancerPool[] storage bp = cp.balancerPools; @@ -133,10 +139,6 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { BalancerPool({poolId: 0x7ca75bdea9dede97f8b13c6641b768650cb837820002000000000000000000d5, status: 2}) ); - bp.push( - BalancerPool({poolId: 0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb200020000000000000000008b, status: 2}) - ); - bp.push( BalancerPool({poolId: 0x39965c9dab5448482cf7e002f583c812ceb53046000100000000000000000003, status: 2}) ); @@ -161,7 +163,7 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { vv2p.push( VelodromeV2Pool({ token0: Tokens.OP, - token1: Tokens.USDC, + token1: Tokens.USDC_e, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) @@ -169,7 +171,7 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { vv2p.push( VelodromeV2Pool({ token0: Tokens.WETH, - token1: Tokens.USDC, + token1: Tokens.USDC_e, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) @@ -182,8 +184,27 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) ); + vv2p.push( + VelodromeV2Pool({ + token0: Tokens.USDC_e, + token1: Tokens.DAI, + stable: true, + factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a + }) + ); + vv2p.push( + VelodromeV2Pool({ + token0: Tokens.USDC_e, + token1: Tokens.USDT, + stable: true, + factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a + }) + ); + cs.push(Contracts.CURVE_3CRV_POOL_OP); cs.push(Contracts.YEARN_WETH_VAULT); - cs.push(Contracts.YEARN_OP_VAULT); + cs.push(Contracts.YEARN_DAI_VAULT); + cs.push(Contracts.YEARN_USDC_E_VAULT); + cs.push(Contracts.YEARN_USDT_VAULT); } { /// CREDIT_MANAGER_1 @@ -202,79 +223,38 @@ contract CONFIG_OPTIMISM_USDC_V3 is IPoolV3DeployConfig { cp.poolLimit = 500_000_000_000; CollateralTokenHuman[] storage cts = cp.collateralTokens; - cts.push(CollateralTokenHuman({token: Tokens.WETH, lt: 95_00})); - - cts.push(CollateralTokenHuman({token: Tokens.WLD, lt: 92_00})); + cts.push(CollateralTokenHuman({token: Tokens.WETH, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.LINK, lt: 92_00})); + cts.push(CollateralTokenHuman({token: Tokens.WLD, lt: 85_00})); - cts.push(CollateralTokenHuman({token: Tokens.SNX, lt: 92_00})); + cts.push(CollateralTokenHuman({token: Tokens.SNX, lt: 85_00})); Contracts[] storage cs = cp.contracts; cs.push(Contracts.UNISWAP_V3_ROUTER); UniswapV3Pair[] storage uv3p = cp.uniswapV3Pairs; - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 3000})); - uv3p.push(UniswapV3Pair({token0: Tokens.USDC, token1: Tokens.WLD, fee: 10000})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.LINK, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 500})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.USDC_e, token1: Tokens.WLD, fee: 10000})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.WLD, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.SNX, fee: 3000})); cs.push(Contracts.VELODROME_V2_ROUTER); VelodromeV2Pool[] storage vv2p = cp.velodromeV2Pools; vv2p.push( VelodromeV2Pool({ token0: Tokens.WETH, - token1: Tokens.USDC, + token1: Tokens.USDC_e, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) ); vv2p.push( VelodromeV2Pool({ - token0: Tokens.USDC, + token0: Tokens.USDC_e, token1: Tokens.SNX, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) ); } - { - /// CREDIT_MANAGER_2 - CreditManagerV3DeployParams storage cp = _creditManagers.push(); - - cp.minDebt = 10_000_000_000; - cp.maxDebt = 100_000_000_000; - cp.feeInterest = 2500; - cp.feeLiquidation = 50; - cp.liquidationPremium = 100; - cp.feeLiquidationExpired = 50; - cp.liquidationPremiumExpired = 100; - cp.whitelisted = true; - cp.expirable = false; - cp.skipInit = false; - cp.poolLimit = 1_000_000_000_000; - - CollateralTokenHuman[] storage cts = cp.collateralTokens; - cts.push(CollateralTokenHuman({token: Tokens.DAI, lt: 98_00})); - - cts.push(CollateralTokenHuman({token: Tokens.USDT, lt: 98_00})); - - cts.push(CollateralTokenHuman({token: Tokens.yvUSDC, lt: 96_00})); - - cts.push(CollateralTokenHuman({token: Tokens.yvDAI, lt: 96_00})); - - cts.push(CollateralTokenHuman({token: Tokens.yvUSDT, lt: 96_00})); - - cts.push(CollateralTokenHuman({token: Tokens._3Crv, lt: 0})); - Contracts[] storage cs = cp.contracts; - cs.push(Contracts.UNISWAP_V3_ROUTER); - UniswapV3Pair[] storage uv3p = cp.uniswapV3Pairs; - uv3p.push(UniswapV3Pair({token0: Tokens.USDC, token1: Tokens.USDT, fee: 100})); - uv3p.push(UniswapV3Pair({token0: Tokens.DAI, token1: Tokens.USDC, fee: 100})); - uv3p.push(UniswapV3Pair({token0: Tokens.USDT, token1: Tokens.DAI, fee: 100})); - cs.push(Contracts.CURVE_3CRV_POOL); - cs.push(Contracts.YEARN_DAI_VAULT); - cs.push(Contracts.YEARN_USDC_VAULT); - cs.push(Contracts.YEARN_USDT_VAULT); - } } // GETTERS diff --git a/contracts/test/config/WETH_Optimism_config.sol b/contracts/test/config/WETH_Optimism_config.sol index f8ef7b84..a9257896 100644 --- a/contracts/test/config/WETH_Optimism_config.sol +++ b/contracts/test/config/WETH_Optimism_config.sol @@ -24,7 +24,7 @@ contract CONFIG_OPTIMISM_WETH_V3 is IPoolV3DeployConfig { uint256 public constant chainId = 10; Tokens public constant underlying = Tokens.WETH; bool public constant supportsQuotas = true; - uint256 public constant getAccountAmount = 5_000_000_000_000_000_000; + uint256 public constant getAccountAmount = 10_000_000_000_000_000_000; // POOL @@ -32,7 +32,7 @@ contract CONFIG_OPTIMISM_WETH_V3 is IPoolV3DeployConfig { string public constant name = "WETH v3"; PoolV3DeployParams _poolParams = - PoolV3DeployParams({withdrawalFee: 0, totalDebtLimit: 50_000_000_000_000_000_000_000}); + PoolV3DeployParams({withdrawalFee: 0, totalDebtLimit: 150_000_000_000_000_000_000_000}); LinearIRMV3DeployParams _irm = LinearIRMV3DeployParams({ U_1: 70_00, @@ -50,78 +50,85 @@ contract CONFIG_OPTIMISM_WETH_V3 is IPoolV3DeployConfig { CreditManagerV3DeployParams[] _creditManagers; constructor() { - _gaugeRates.push(GaugeRate({token: Tokens.WBTC, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.USDC, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.OP, minRate: 4, maxRate: 12_00})); - _gaugeRates.push(GaugeRate({token: Tokens.WLD, minRate: 80, maxRate: 24_00})); - _gaugeRates.push(GaugeRate({token: Tokens.LINK, minRate: 80, maxRate: 24_00})); - _gaugeRates.push(GaugeRate({token: Tokens.SNX, minRate: 80, maxRate: 24_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvOP, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvUSDC, minRate: 5, maxRate: 7_00})); - _gaugeRates.push(GaugeRate({token: Tokens.yvWETH, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.wstETH, minRate: 4, maxRate: 15_00})); - _gaugeRates.push(GaugeRate({token: Tokens.rETH, minRate: 4, maxRate: 15_00})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.WBTC, quotaIncreaseFee: 1, limit: 300_000_000_000_000_000_000})); + _gaugeRates.push(GaugeRate({token: Tokens.WBTC, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.USDC_e, minRate: 4, maxRate: 12_00})); + _gaugeRates.push(GaugeRate({token: Tokens.OP, minRate: 4, maxRate: 40_00})); + _gaugeRates.push(GaugeRate({token: Tokens.WLD, minRate: 80, maxRate: 50_00})); + _gaugeRates.push(GaugeRate({token: Tokens.SNX, minRate: 80, maxRate: 50_00})); + _gaugeRates.push(GaugeRate({token: Tokens.yvUSDC_e, minRate: 5, maxRate: 27_00})); + _gaugeRates.push(GaugeRate({token: Tokens.yvWETH, minRate: 4, maxRate: 5_00})); + _gaugeRates.push(GaugeRate({token: Tokens.wstETH, minRate: 4, maxRate: 5_00})); + _gaugeRates.push(GaugeRate({token: Tokens.rETH, minRate: 4, maxRate: 5_00})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.WBTC, quotaIncreaseFee: 1, limit: 150_000_000_000_000_000_000})); _quotaLimits.push( - PoolQuotaLimit({token: Tokens.USDC, quotaIncreaseFee: 1, limit: 1_500_000_000_000_000_000_000}) + PoolQuotaLimit({token: Tokens.USDC_e, quotaIncreaseFee: 1, limit: 1_000_000_000_000_000_000_000}) ); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.OP, quotaIncreaseFee: 1, limit: 900_000_000_000_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.WLD, quotaIncreaseFee: 5, limit: 50_000_000_000_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.LINK, quotaIncreaseFee: 5, limit: 25_000_000_000_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.SNX, quotaIncreaseFee: 5, limit: 500_000_000_000_000_000_000})); - _quotaLimits.push(PoolQuotaLimit({token: Tokens.yvOP, quotaIncreaseFee: 1, limit: 275_000_000_000_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.OP, quotaIncreaseFee: 1, limit: 300_000_000_000_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.WLD, quotaIncreaseFee: 5, limit: 100_000_000_000_000_000_000})); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.SNX, quotaIncreaseFee: 5, limit: 100_000_000_000_000_000_000})); _quotaLimits.push( - PoolQuotaLimit({token: Tokens.yvUSDC, quotaIncreaseFee: 0, limit: 165_000_000_000_000_000_000}) + PoolQuotaLimit({token: Tokens.yvUSDC_e, quotaIncreaseFee: 0, limit: 100_000_000_000_000_000_000}) ); _quotaLimits.push( - PoolQuotaLimit({token: Tokens.yvWETH, quotaIncreaseFee: 1, limit: 200_000_000_000_000_000_000}) + PoolQuotaLimit({token: Tokens.yvWETH, quotaIncreaseFee: 0, limit: 180_000_000_000_000_000_000}) ); _quotaLimits.push( - PoolQuotaLimit({token: Tokens.wstETH, quotaIncreaseFee: 1, limit: 1_500_000_000_000_000_000_000}) - ); - _quotaLimits.push( - PoolQuotaLimit({token: Tokens.rETH, quotaIncreaseFee: 1, limit: 1_500_000_000_000_000_000_000}) + PoolQuotaLimit({token: Tokens.wstETH, quotaIncreaseFee: 0, limit: 1_000_000_000_000_000_000_000}) ); + _quotaLimits.push(PoolQuotaLimit({token: Tokens.rETH, quotaIncreaseFee: 0, limit: 500_000_000_000_000_000_000})); { /// CREDIT_MANAGER_0 CreditManagerV3DeployParams storage cp = _creditManagers.push(); - cp.minDebt = 500_000_000_000_000_000; - cp.maxDebt = 100_000_000_000_000_000_000; + cp.minDebt = 350_000_000_000_000_000; + cp.maxDebt = 150_000_000_000_000_000_000; cp.feeInterest = 2500; - cp.feeLiquidation = 50; - cp.liquidationPremium = 100; - cp.feeLiquidationExpired = 50; - cp.liquidationPremiumExpired = 100; + cp.feeLiquidation = 100; + cp.liquidationPremium = 200; + cp.feeLiquidationExpired = 100; + cp.liquidationPremiumExpired = 200; cp.whitelisted = false; cp.expirable = false; cp.skipInit = false; - cp.poolLimit = 1_000_000_000_000_000_000_000; + cp.poolLimit = 700_000_000_000_000_000_000; CollateralTokenHuman[] storage cts = cp.collateralTokens; - cts.push(CollateralTokenHuman({token: Tokens.USDC, lt: 96_00})); + cts.push(CollateralTokenHuman({token: Tokens.USDC_e, lt: 94_00})); + + cts.push(CollateralTokenHuman({token: Tokens.WBTC, lt: 94_00})); + + cts.push(CollateralTokenHuman({token: Tokens.OP, lt: 90_00})); - cts.push(CollateralTokenHuman({token: Tokens.WBTC, lt: 96_00})); + cts.push(CollateralTokenHuman({token: Tokens.yvUSDC_e, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.OP, lt: 96_00})); + cts.push(CollateralTokenHuman({token: Tokens.wstETH, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.yvUSDC, lt: 94_00})); + cts.push(CollateralTokenHuman({token: Tokens.rETH, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.yvOP, lt: 94_00})); + cts.push(CollateralTokenHuman({token: Tokens.yvWETH, lt: 94_00})); Contracts[] storage cs = cp.contracts; cs.push(Contracts.UNISWAP_V3_ROUTER); UniswapV3Pair[] storage uv3p = cp.uniswapV3Pairs; uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.OP, fee: 3000})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 500})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.WBTC, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.wstETH, token1: Tokens.WETH, fee: 100})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.WBTC, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.OP, token1: Tokens.USDC, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.OP, token1: Tokens.USDC_e, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.OP, fee: 500})); cs.push(Contracts.BALANCER_VAULT); BalancerPool[] storage bp = cp.balancerPools; + bp.push( + BalancerPool({poolId: 0x4fd63966879300cafafbb35d157dc5229278ed2300020000000000000000002b, status: 2}) + ); + + bp.push( + BalancerPool({poolId: 0x7ca75bdea9dede97f8b13c6641b768650cb837820002000000000000000000d5, status: 2}) + ); + bp.push( BalancerPool({poolId: 0x39965c9dab5448482cf7e002f583c812ceb53046000100000000000000000003, status: 2}) ); @@ -138,7 +145,7 @@ contract CONFIG_OPTIMISM_WETH_V3 is IPoolV3DeployConfig { vv2p.push( VelodromeV2Pool({ token0: Tokens.OP, - token1: Tokens.USDC, + token1: Tokens.USDC_e, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) @@ -146,20 +153,28 @@ contract CONFIG_OPTIMISM_WETH_V3 is IPoolV3DeployConfig { vv2p.push( VelodromeV2Pool({ token0: Tokens.WETH, - token1: Tokens.USDC, + token1: Tokens.USDC_e, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) ); - cs.push(Contracts.YEARN_USDC_VAULT); - cs.push(Contracts.YEARN_OP_VAULT); + vv2p.push( + VelodromeV2Pool({ + token0: Tokens.wstETH, + token1: Tokens.WETH, + stable: false, + factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a + }) + ); + cs.push(Contracts.YEARN_USDC_E_VAULT); + cs.push(Contracts.YEARN_WETH_VAULT); } { /// CREDIT_MANAGER_1 CreditManagerV3DeployParams storage cp = _creditManagers.push(); - cp.minDebt = 500_000_000_000_000_000; - cp.maxDebt = 25_000_000_000_000_000_000; + cp.minDebt = 350_000_000_000_000_000; + cp.maxDebt = 35_000_000_000_000_000_000; cp.feeInterest = 2500; cp.feeLiquidation = 100; cp.liquidationPremium = 200; @@ -168,96 +183,41 @@ contract CONFIG_OPTIMISM_WETH_V3 is IPoolV3DeployConfig { cp.whitelisted = false; cp.expirable = false; cp.skipInit = false; - cp.poolLimit = 250_000_000_000_000_000_000; + cp.poolLimit = 350_000_000_000_000_000_000; CollateralTokenHuman[] storage cts = cp.collateralTokens; - cts.push(CollateralTokenHuman({token: Tokens.USDC, lt: 95_00})); - - cts.push(CollateralTokenHuman({token: Tokens.WLD, lt: 92_00})); + cts.push(CollateralTokenHuman({token: Tokens.USDC_e, lt: 94_00})); - cts.push(CollateralTokenHuman({token: Tokens.LINK, lt: 92_00})); + cts.push(CollateralTokenHuman({token: Tokens.WLD, lt: 85_00})); - cts.push(CollateralTokenHuman({token: Tokens.SNX, lt: 92_00})); + cts.push(CollateralTokenHuman({token: Tokens.SNX, lt: 85_00})); Contracts[] storage cs = cp.contracts; cs.push(Contracts.UNISWAP_V3_ROUTER); UniswapV3Pair[] storage uv3p = cp.uniswapV3Pairs; - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 500})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 500})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.USDC_e, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.USDC, token1: Tokens.WLD, fee: 10000})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.LINK, fee: 3000})); + uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.WLD, fee: 3000})); uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.SNX, fee: 3000})); cs.push(Contracts.VELODROME_V2_ROUTER); VelodromeV2Pool[] storage vv2p = cp.velodromeV2Pools; vv2p.push( VelodromeV2Pool({ token0: Tokens.WETH, - token1: Tokens.USDC, + token1: Tokens.USDC_e, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) ); vv2p.push( VelodromeV2Pool({ - token0: Tokens.USDC, + token0: Tokens.USDC_e, token1: Tokens.SNX, stable: false, factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a }) ); } - { - /// CREDIT_MANAGER_2 - CreditManagerV3DeployParams storage cp = _creditManagers.push(); - - cp.minDebt = 5_000_000_000_000_000_000; - cp.maxDebt = 50_000_000_000_000_000_000; - cp.feeInterest = 2500; - cp.feeLiquidation = 50; - cp.liquidationPremium = 100; - cp.feeLiquidationExpired = 50; - cp.liquidationPremiumExpired = 100; - cp.whitelisted = true; - cp.expirable = false; - cp.skipInit = false; - cp.poolLimit = 1_500_000_000_000_000_000_000; - - CollateralTokenHuman[] storage cts = cp.collateralTokens; - cts.push(CollateralTokenHuman({token: Tokens.wstETH, lt: 98_00})); - - cts.push(CollateralTokenHuman({token: Tokens.rETH, lt: 98_00})); - - cts.push(CollateralTokenHuman({token: Tokens.yvWETH, lt: 96_00})); - Contracts[] storage cs = cp.contracts; - cs.push(Contracts.UNISWAP_V3_ROUTER); - UniswapV3Pair[] storage uv3p = cp.uniswapV3Pairs; - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.wstETH, fee: 100})); - uv3p.push(UniswapV3Pair({token0: Tokens.WETH, token1: Tokens.rETH, fee: 100})); - cs.push(Contracts.BALANCER_VAULT); - BalancerPool[] storage bp = cp.balancerPools; - - bp.push( - BalancerPool({poolId: 0x4fd63966879300cafafbb35d157dc5229278ed2300020000000000000000002b, status: 2}) - ); - - bp.push( - BalancerPool({poolId: 0x7ca75bdea9dede97f8b13c6641b768650cb837820002000000000000000000d5, status: 2}) - ); - - bp.push( - BalancerPool({poolId: 0x7b50775383d3d6f0215a8f290f2c9e2eebbeceb200020000000000000000008b, status: 2}) - ); - cs.push(Contracts.VELODROME_V2_ROUTER); - VelodromeV2Pool[] storage vv2p = cp.velodromeV2Pools; - vv2p.push( - VelodromeV2Pool({ - token0: Tokens.wstETH, - token1: Tokens.WETH, - stable: false, - factory: 0xF1046053aa5682b4F9a81b5481394DA16BE5FF5a - }) - ); - cs.push(Contracts.YEARN_WETH_VAULT); - } } // GETTERS diff --git a/contracts/test/live/adapters/aave/Live_AaveV2LendingPoolEquivalenceTest.sol b/contracts/test/live/adapters/aave/Live_AaveV2LendingPoolEquivalenceTest.sol index 20cf261e..2c03108f 100644 --- a/contracts/test/live/adapters/aave/Live_AaveV2LendingPoolEquivalenceTest.sol +++ b/contracts/test/live/adapters/aave/Live_AaveV2LendingPoolEquivalenceTest.sol @@ -6,6 +6,9 @@ pragma solidity ^0.8.17; import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol"; import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol"; +import { + CollateralDebtData, CollateralCalcTask +} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol"; import {IAaveV2_LendingPoolAdapter} from "../../../../interfaces/aave/IAaveV2_LendingPoolAdapter.sol"; import {ILendingPool} from "../../../../integrations/aave/ILendingPool.sol"; import {IAToken} from "../../../../integrations/aave/IAToken.sol"; @@ -159,4 +162,24 @@ contract Live_AaveV2LendingPoolEquivalenceTest is LiveTestHelper { comparator.compareAllSnapshots(creditAccount, savedBalanceSnapshots); } } + + function test_diag_profits() public attachOrLiveTest { + uint256 cmProfit = 0; + + address[] memory creditAccounts = creditManager.creditAccounts(); + + for (uint256 j = 0; j < creditAccounts.length; ++j) { + CollateralDebtData memory cdd = + creditManager.calcDebtAndCollateral(creditAccounts[j], CollateralCalcTask.DEBT_ONLY); + + cmProfit += cdd.accruedFees; + } + + emit log_address(address(creditManager)); + emit log_uint(cmProfit); + } + + function test_diag_pf() public attachOrLiveTest { + emit log_uint(priceOracle.getPrice(tokenTestSuite.addressOf(Tokens.ezETH))); + } } diff --git a/contracts/test/unit/adapters/velodrome/VelodromeV2Adapter.unit.t.sol b/contracts/test/unit/adapters/velodrome/VelodromeV2Adapter.unit.t.sol index 3cc1a0d1..0031562f 100644 --- a/contracts/test/unit/adapters/velodrome/VelodromeV2Adapter.unit.t.sol +++ b/contracts/test/unit/adapters/velodrome/VelodromeV2Adapter.unit.t.sol @@ -165,6 +165,28 @@ contract VelodtomeV2AdapterUnitTest is } } + /// @notice U:[VELO2-7]: `_validatePath` works as expected + function test_U_VELO2_07_validatePath_filters_disjunct_paths() public { + bool isValid; + address tokenIn; + address tokenOut; + Route[] memory routes; + + VelodromeV2PoolStatus[] memory pools = new VelodromeV2PoolStatus[](2); + pools[0] = VelodromeV2PoolStatus(tokens[0], tokens[1], false, address(42), true); + pools[1] = VelodromeV2PoolStatus(tokens[2], tokens[3], false, address(42), true); + vm.prank(configurator); + adapter.setPoolStatusBatch(pools); + + routes = new Route[](2); + routes[0] = Route({from: tokens[0], to: tokens[1], stable: false, factory: address(42)}); + routes[1] = Route({from: tokens[2], to: tokens[3], stable: false, factory: address(42)}); + + (isValid, tokenIn, tokenOut) = adapter.validatePath(routes); + + assertFalse(isValid, "Path incorrectly valid"); + } + // ------- // // HELPERS // // ------- //