|
| 1 | +// SPDX-License-Identifier: UNLICENSED |
| 2 | +pragma solidity ^0.8.13; |
| 3 | + |
| 4 | +import {Script, console} from "forge-std/Script.sol"; |
| 5 | + |
| 6 | +import {SkipGoSwapRouter} from "../src/SkipGoSwapRouter.sol"; |
| 7 | + |
| 8 | +import {UniswapV2Adapter} from "../src/adapters/UniswapV2Adapter.sol"; |
| 9 | +import {UniswapV3Adapter} from "../src/adapters/UniswapV3Adapter.sol"; |
| 10 | +import {VelodromeAdapter} from "../src/adapters/VelodromeAdapter.sol"; |
| 11 | + |
| 12 | +contract DeployAdapter is Script { |
| 13 | + function run(string memory _dexType) external { |
| 14 | + console.log("Deploying adapter for dex type", _dexType); |
| 15 | + |
| 16 | + SkipGoSwapRouter router = SkipGoSwapRouter(payable(_router())); |
| 17 | + |
| 18 | + SkipGoSwapRouter.ExchangeType dexType = _getDexType(_dexType); |
| 19 | + |
| 20 | + if (dexType == SkipGoSwapRouter.ExchangeType.UNISWAP_V2) { |
| 21 | + UniswapV2Adapter uniswapV2Adapter = new UniswapV2Adapter(); |
| 22 | + router.addAdapter(dexType, address(uniswapV2Adapter)); |
| 23 | + } else if (dexType == SkipGoSwapRouter.ExchangeType.UNISWAP_V3) { |
| 24 | + UniswapV3Adapter uniswapV3Adapter = new UniswapV3Adapter(); |
| 25 | + router.addAdapter(dexType, address(uniswapV3Adapter)); |
| 26 | + } else if (dexType == SkipGoSwapRouter.ExchangeType.VELODROME) { |
| 27 | + VelodromeAdapter velodromeAdapter = new VelodromeAdapter(); |
| 28 | + router.addAdapter(dexType, address(velodromeAdapter)); |
| 29 | + } |
| 30 | + |
| 31 | + console.log("Adapter deployed at", address(router)); |
| 32 | + } |
| 33 | + |
| 34 | + function _router() internal view returns (address) { |
| 35 | + if (block.chainid == 1) { |
| 36 | + return 0xd1eE705D774d59541d3D395e72A16E48389DF7C7; |
| 37 | + } else if (block.chainid == 42161) { |
| 38 | + return 0xA307099736ff10f6A639D8a00F3C0AC62E10424a; |
| 39 | + } else if (block.chainid == 43114) { |
| 40 | + return 0xfF19fcC8563Aef3a1a83A2F52AeF9AE41D767333; |
| 41 | + } else if (block.chainid == 56) { |
| 42 | + return 0xbC4bdEB1E85C62f5Da9cb732a5209408db7B4769; |
| 43 | + } else if (block.chainid == 8453) { |
| 44 | + return 0xD57611Dd97eacb7AE19aE5d789e943d07f4dfa4f; |
| 45 | + } else if (block.chainid == 81457) { |
| 46 | + return 0x32Fb43172c0afB63770372fDe4A84E9b827Ec903; |
| 47 | + } else if (block.chainid == 42220) { |
| 48 | + return 0xF29F1f9f06054F23B5bC9De9bC5017bff8bF1a05; |
| 49 | + } else if (block.chainid == 10) { |
| 50 | + return 0xc352fB0E5fC310FCbfD736542d45Efa27B9E1Cae; |
| 51 | + } else if (block.chainid == 137) { |
| 52 | + return 0x8A68Dd4b423Ef7568d0cdf3bB8E4863Ca1041a9e; |
| 53 | + } |
| 54 | + |
| 55 | + revert("Chain not supported"); |
| 56 | + } |
| 57 | + |
| 58 | + function _getDexType(string memory dexType) internal pure returns (SkipGoSwapRouter.ExchangeType) { |
| 59 | + if (keccak256(bytes(dexType)) == keccak256(bytes("UNISWAP_V2"))) { |
| 60 | + return SkipGoSwapRouter.ExchangeType.UNISWAP_V2; |
| 61 | + } else if (keccak256(bytes(dexType)) == keccak256(bytes("UNISWAP_V3"))) { |
| 62 | + return SkipGoSwapRouter.ExchangeType.UNISWAP_V3; |
| 63 | + } else if (keccak256(bytes(dexType)) == keccak256(bytes("VELODROME"))) { |
| 64 | + return SkipGoSwapRouter.ExchangeType.VELODROME; |
| 65 | + } |
| 66 | + |
| 67 | + revert("Invalid dex type"); |
| 68 | + } |
| 69 | +} |
0 commit comments