diff --git a/foundry.toml b/foundry.toml index c0793a1..040116c 100644 --- a/foundry.toml +++ b/foundry.toml @@ -24,7 +24,7 @@ tab_width = 4 wrap_comments = true [etherscan] -arbitrum_one = { key = "${API_KEY_ARBISCAN}" } +arbitrum = { key = "${API_KEY_ARBISCAN}" } # avalanche = { key = "${API_KEY_SNOWTRACE}" } # bnb_smart_chain = { key = "${API_KEY_BSCSCAN}" } # gnosis_chain = { key = "${API_KEY_GNOSISSCAN}" } @@ -35,7 +35,7 @@ mainnet = { key = "${API_KEY_ETHERSCAN}" } # sepolia = { key = "${API_KEY_ETHERSCAN}" } [rpc_endpoints] -arbitrum_one = "https://arb-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}" +arbitrum = "https://arb-mainnet.g.alchemy.com/v2/${API_KEY_ALCHEMY}" # avalanche = "https://avalanche-mainnet.infura.io/v3/${API_KEY_INFURA}" # bnb_smart_chain = "https://bsc-dataseed.binance.org" # gnosis_chain = "https://rpc.gnosischain.com" diff --git a/script/Add_Liquidity.s.sol b/script/Add_Liquidity.s.sol index adebae7..4cf5cfe 100644 --- a/script/Add_Liquidity.s.sol +++ b/script/Add_Liquidity.s.sol @@ -14,14 +14,15 @@ contract Add_Liquidity is Script { // Start broadcasting with private key from `.env` file uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); address underlying = vm.envAddress("UNDERLYING"); + uint256 amount = vm.envUint("AMOUNT"); + address swap = vm.envAddress("SWAP"); function run() public { vm.startBroadcast(deployerPrivateKey); - TenderSwap swap = TenderSwap(0x2C7b29B0d07276bA2DF4abE02E9A38b5693af9c6); - ERC20(underlying).approve(address(swap), 500_000 ether); - swap.deposit(500_000 ether, 0); - console2.log("liabilities", swap.liabilities()); - console2.log("liquidity", swap.liquidity()); + TenderSwap swap = TenderSwap(swap); + ERC20(underlying).approve(address(swap), amount); + swap.deposit(amount, 0); + // ERC20(0x2eaC4210B90D13666f7E88635096BdC17C51FB70).approve(address(swap), 10 ether); // (uint256 out, uint256 fee) = swap.quote(0x2eaC4210B90D13666f7E88635096BdC17C51FB70, 10 ether); diff --git a/script/Factory_Deploy.s.sol b/script/Factory_Deploy.s.sol index ff3ed15..382ef29 100644 --- a/script/Factory_Deploy.s.sol +++ b/script/Factory_Deploy.s.sol @@ -7,9 +7,9 @@ import { ERC1967Proxy } from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy. address constant FACTORY = address(0); -uint256 constant VERSION = 1; +uint256 constant VERSION = 2; -contract Swap_Deploy is Script { +contract Factory_Deploy is Script { // Contracts are deployed deterministically. // e.g. `foo = new Foo{salt: salt}(constructorArgs)` // The presence of the salt argument tells forge to use https://github.com/Arachnid/deterministic-deployment-proxy @@ -18,10 +18,14 @@ contract Swap_Deploy is Script { // Start broadcasting with private key from `.env` file uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + address fac = 0xBF0e7CE92bb073b2EC5940D7Fae52D3EA4Db70f6; + function run() public { vm.startBroadcast(deployerPrivateKey); - address fac = address(new SwapFactory{ salt: SALT }()); - address proxy = address(new ERC1967Proxy{ salt: SALT }(fac, abi.encodeWithSelector(SwapFactory.initialize.selector))); + // address fac = address(new SwapFactory{ salt: SALT }()); + address proxy = address(new ERC1967Proxy{ salt: SALT }(fac, "")); + SwapFactory(proxy).initialize(); + console2.log("SwapFactory deployed at: ", proxy); console2.log("Implementation deployed at: ", fac); vm.stopBroadcast(); diff --git a/script/LP_Token.s.sol b/script/LP_Token.s.sol new file mode 100644 index 0000000..e2677ed --- /dev/null +++ b/script/LP_Token.s.sol @@ -0,0 +1,40 @@ +// Matic Swap: 0x422BEF50e75098c3337790627689fF1aAA06C057 +// Grt Swap: 0x7ee73bCa91f833C4E06BDC5F0e9f9aB7Ed9dB67d +// Lpt swap: 0x686962481543d543934903C3FE8bDe8c5dB9Bd97 +import { Script, console2 } from "forge-std/Script.sol"; +import { ERC20 } from "solmate/tokens/ERC20.sol"; +import { TenderSwap } from "@tenderize/swap/Swap.sol"; + +contract Add_Liquidity is Script { + // Contracts are deployed deterministically. + // e.g. `foo = new Foo{salt: salt}(constructorArgs)` + // The presence of the salt argument tells forge to use https://github.com/Arachnid/deterministic-deployment-proxy + bytes32 private constant salt = 0x0; + + // Start broadcasting with private key from `.env` file + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + + address swap = 0x686962481543d543934903C3FE8bDe8c5dB9Bd97; + + function run() public { + vm.startBroadcast(deployerPrivateKey); + TenderSwap swap = TenderSwap(swap); + address lpToken = address(swap.lpToken()); + console2.log("Lp Token :", lpToken); + + // ERC20(0x2eaC4210B90D13666f7E88635096BdC17C51FB70).approve(address(swap), 10 ether); + + // (uint256 out, uint256 fee) = swap.quote(0x2eaC4210B90D13666f7E88635096BdC17C51FB70, 10 ether); + // console2.log("quote", out); + // ERC20(0x2eaC4210B90D13666f7E88635096BdC17C51FB70).approve(address(swap), 10 ether); + // // (out, fee) = swap.swap(0x2eaC4210B90D13666f7E88635096BdC17C51FB70, 10 ether, 0); + // console2.log("out", out); + // console2.log("fee", fee); + + // // Other Tenderizer: 0xD58Fed21106A046093086903909478AD96D310a8 + // (out, fee) = swap.quote(0xD58Fed21106A046093086903909478AD96D310a8, 10 ether); + // console2.log("quote", out); + + vm.stopBroadcast(); + } +} diff --git a/script/Swap_Deploy.s.sol b/script/Swap_Deploy.s.sol index b597802..0af618a 100644 --- a/script/Swap_Deploy.s.sol +++ b/script/Swap_Deploy.s.sol @@ -11,7 +11,7 @@ import { ERC1967Proxy } from "openzeppelin-contracts/proxy/ERC1967/ERC1967Proxy. // TENDERIZE POOLS BASE FEE = 0.025% with K=4 // EXOTIC POOLS BASE FEE = 0.1% with K=4 -address constant FACTORY = address(0); +address constant FACTORY = 0xcB78EbD81D08df037973Afd70D7FeF7b6b0C6B06; contract Swap_Deploy is Script { // Contracts are deployed deterministically. @@ -34,7 +34,9 @@ contract Swap_Deploy is Script { function run() public { vm.startBroadcast(deployerPrivateKey); - address implementation = address(new TenderSwap{ salt: bytes32(uint256(1)) }(cfg)); + uint256 v = 1; + address implementation = 0xFF343ba942310c099D1e427e946C9eBDC999d27C; // address(new TenderSwap{ salt: bytes32(uint256(v)) + // }(cfg)); (address proxy) = SwapFactory(FACTORY).deploy(implementation); console2.log("Deployment for ", underlying); console2.log("TenderSwap deployed at: ", proxy); diff --git a/src/Factory.sol b/src/Factory.sol index 22b862e..6b23776 100644 --- a/src/Factory.sol +++ b/src/Factory.sol @@ -40,10 +40,8 @@ contract SwapFactory is Initializable, UUPSUpgradeable, OwnableUpgradeable { function deploy(address implementation) external onlyOwner returns (address proxy) { uint256 v = 1; // deploy the contract - proxy = address( - new ERC1967Proxy{ salt: bytes32("tenderswap") }(implementation, abi.encodeWithSelector(TenderSwap.initialize.selector)) - ); - + proxy = address(new ERC1967Proxy{ salt: bytes32("tenderswap") }(implementation, "")); + TenderSwap(proxy).initialize(); TenderSwap(proxy).transferOwnership(owner()); version[proxy] = v; emit SwapDeployed(address(TenderSwap(proxy).UNDERLYING()), proxy, implementation);