Skip to content

Commit

Permalink
Merge pull request #10 from Tenderize/nv/deployment
Browse files Browse the repository at this point in the history
fix: deployment fixes
  • Loading branch information
kyriediculous authored Apr 15, 2024
2 parents 859402f + e733282 commit 8b1e34b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 17 deletions.
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }
Expand All @@ -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"
Expand Down
11 changes: 6 additions & 5 deletions script/Add_Liquidity.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions script/Factory_Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down
40 changes: 40 additions & 0 deletions script/LP_Token.s.sol
Original file line number Diff line number Diff line change
@@ -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();
}
}
6 changes: 4 additions & 2 deletions script/Swap_Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down
6 changes: 2 additions & 4 deletions src/Factory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b1e34b

Please sign in to comment.