-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP]: add PoC for tasks in Solidity.
- Loading branch information
1 parent
2dcbae8
commit 7662f58
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.23; | ||
|
||
// Foundry | ||
import {console} from "forge-std/console.sol"; | ||
import {Script} from "forge-std/Script.sol"; | ||
|
||
import {OethARM} from "contracts/OethARM.sol"; | ||
|
||
// Utils | ||
import {Mainnet} from "test/utils/Addresses.sol"; | ||
|
||
contract SwapScript is Script { | ||
address public deployer; | ||
|
||
bytes32 emptyStringHash = keccak256(abi.encodePacked("")); | ||
////////////////////////////////////////////////////// | ||
/// --- SETUP | ||
////////////////////////////////////////////////////// | ||
|
||
function setUp() public { | ||
if (vm.envExists("DEPLOYER_PRIVATE_KEY")) { | ||
console.log("Deployer private key found in env"); | ||
// Fetch PK from env and derive the deployer address | ||
deployer = vm.addr(vm.envUint("DEPLOYER_PRIVATE_KEY")); | ||
} else { | ||
// If no PK is provided, use a default deployer address | ||
deployer = makeAddr("deployer"); | ||
} | ||
} | ||
|
||
////////////////////////////////////////////////////// | ||
/// --- TASKS | ||
////////////////////////////////////////////////////// | ||
function swap(address from, address to, uint256 amount) public { | ||
vm.startBroadcast(deployer); | ||
|
||
if (from != address(0) && to != address(0)) { | ||
revert("Cannot specify both from and to asset. It has to be one or the other"); | ||
} | ||
|
||
if (from != address(0)) { | ||
require(from == Mainnet.OETH || from == Mainnet.WETH, "Invalid from asset"); | ||
|
||
to = from == Mainnet.OETH ? Mainnet.WETH : Mainnet.OETH; | ||
|
||
string memory message = string( | ||
abi.encodePacked( | ||
"About to swap ", | ||
vm.toString(amount), | ||
" ", | ||
vm.toString(from), | ||
" to ", | ||
vm.toString(to), | ||
" for ", | ||
vm.toString(deployer) | ||
) | ||
); | ||
|
||
console.log(message); | ||
//OethARM(Mainnet.) | ||
} | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |