Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix legacy v1 test #149

Open
wants to merge 31 commits into
base: earthquake-v2-sherlock-audit
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c1205aa
fix issue https://github.com/sherlock-audit/2023-03-Y2K-judging/issue…
3xHarry Apr 6, 2023
413b28a
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/163
3xHarry Apr 6, 2023
f6e9e28
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/75
3xHarry Apr 6, 2023
e8fdd85
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/72
3xHarry Apr 7, 2023
57bf491
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/2
3xHarry Apr 7, 2023
0efdff3
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/505
3xHarry Apr 7, 2023
2ba5a03
https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/480
3xHarry Apr 7, 2023
6fd592e
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/435
3xHarry Apr 10, 2023
4221a60
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/418
3xHarry Apr 10, 2023
8843085
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/387
3xHarry Apr 10, 2023
39bb0b5
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/300
3xHarry Apr 10, 2023
638a181
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/293
3xHarry Apr 10, 2023
eef2eff
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/208
3xHarry Apr 10, 2023
e560897
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/181
3xHarry Apr 10, 2023
f0aee47
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/122
3xHarry Apr 10, 2023
acf4ce4
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/108
3xHarry Apr 11, 2023
2f51468
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/70
3xHarry Apr 11, 2023
a2f139e
fix https://github.com/sherlock-audit/2023-03-Y2K-judging/issues/1
3xHarry Apr 11, 2023
5b5cd83
change oracle for token
3xHarry Apr 16, 2023
ca74f10
remove token to oracle and replace with market to oracle mapping
3xHarry Apr 18, 2023
35912e5
adjust deployment script
3xHarry Apr 23, 2023
7607153
fix queue deposit relayerFee change
3xHarry Apr 27, 2023
ad38862
lint
3xHarry Apr 27, 2023
79c29c1
typo
3xHarry Apr 29, 2023
11de481
add direct admin change on timelocker
3xHarry May 1, 2023
5a7037f
prettier
3xHarry May 1, 2023
16a1875
refactor vault
3xHarry May 2, 2023
5cb2890
fix test
3xHarry May 2, 2023
17dbca9
update dependencies
icyage May 8, 2023
6dd562d
fix compiler version issue
icyage May 8, 2023
73f03f3
update version of legacy v1
icyage May 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions script/v2/Helper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// SPDX-License-Identifier;
pragma solidity 0.8.17;

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "forge-std/Test.sol";
//TODO change this after deploy y2k token
import "@openzeppelin/contracts/utils/Strings.sol";
// import "../keepers/KeeperDepeg.sol";
// import "../keepers/KeeperEndEpoch.sol";

/// @author MiguelBits

contract HelperV2 is Script {
using stdJson for string;

struct ConfigVariables{
uint256 amountOfNewEpochs;
uint256 amountOfNewFarms;
uint256 amountOfNewMarkets;
uint256[] epochsIds;
uint256[] farmsIds;
uint256[] marketsIds;
bool newEpochs;
bool newFarms;
bool newMarkets;
}
struct ConfigAddresses {
address admin;
address arbitrum_sequencer;
address controller;
address gelatoOpsV2;
address gelatoTaskTreasury;
address keeperDepeg;
address keeperEndEpoch;
address oracleDAI;
address oracleFEI;
address oracleFRAX;
address oracleMIM;
address oracleUSDC;
address oracleUSDT;
address policy;
address rewardsFactory;
address tokenDAI;
address tokenFEI;
address tokenFRAX;
address tokenMIM;
address tokenUSDC;
address tokenUSDT;
address treasury;
address vaultFactory;
address weth;
address y2k;
}

struct ConfigMarket {
uint256 marketId;
string name;
address oracle;
int256 strikePrice;
address token;
}

struct ConfigEpochs {
uint256 epochBegin;
uint256 epochEnd;
uint256 epochFee;
uint256 marketId;
}

struct ConfigFarms {
uint256 epochEnd;
string farmRewardsHEDGE;
string farmRewardsRISK;
uint marketId;
}



ConfigVariables configVariables;

function setVariables() public {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configJSON.json");
string memory json = vm.readFile(path);
bytes memory parseJsonByteCode = json.parseRaw(".variables");
configVariables = abi.decode(parseJsonByteCode, (ConfigVariables));
// console2.log("ConfigVariables ", rawConstants.amountOfNewMarkets);
}

// function contractToAddresses(ConfigAddresses memory configAddresses) public {
// vaultFactory = VaultFactory(configAddresses.vaultFactory);
// controller = Controller(configAddresses.controller);
// rewardsFactory = RewardsFactory(configAddresses.rewardsFactory);
// y2k = Y2K(configAddresses.y2k);
// keeperDepeg = KeeperGelatoDepeg(configAddresses.keeperDepeg);
// keeperEndEpoch = KeeperGelatoEndEpoch(configAddresses.keeperEndEpoch);
// }

// function startKeepers(uint _marketIndex, uint _epochEnd) public {
// keeperDepeg.startTask(_marketIndex, _epochEnd);
// keeperEndEpoch.startTask(_marketIndex, _epochEnd);
// }

function getConfigAddresses(bool isTestEnv) public returns (ConfigAddresses memory) {
string memory root = vm.projectRoot();
string memory path;
if(isTestEnv){
path = string.concat(root, "/configTestEnv.json");
}
else{
path = string.concat(root, "/configAddresses.json");
}
string memory json = vm.readFile(path);
bytes memory parseJsonByteCode = json.parseRaw(".configAddresses[0]");
ConfigAddresses memory rawConstants = abi.decode(parseJsonByteCode, (ConfigAddresses));
//console2.log("ConfigAddresses ", rawConstants.weth);
return rawConstants;
}

function getConfigMarket(uint256 index) public returns (ConfigMarket memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configJSON.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".markets", "[", Strings.toString(index), "]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigMarket memory rawConstants = abi.decode(transactionDetails, (ConfigMarket));
//console2.log("ConfigMarkets ", rawConstants.name);
return rawConstants;
}

function getConfigEpochs(uint256 index) public returns (ConfigEpochs memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configJSON.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".epochs", "[", Strings.toString(index), "]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigEpochs memory rawConstants = abi.decode(transactionDetails, (ConfigEpochs));
//console2.log("ConfigEpochs ", rawConstants.name);
return rawConstants;
}

function getConfigFarms(uint256 index) public returns (ConfigFarms memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configJSON.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".farms", "[", Strings.toString(index), "]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigFarms memory rawConstants = abi.decode(transactionDetails, (ConfigFarms));
//console2.log("ConfigEpochs ", rawConstants.name);
return rawConstants;
}

function verifyConfig(ConfigMarket memory marketConstants) public view {
// require(marketConstants.epochBegin < marketConstants.epochEnd, "epochBegin is not < epochEnd");
// require(marketConstants.epochEnd > block.timestamp, "epochEnd in the past");
// require(marketConstants.strikePrice > 900000000000000000, "strikePrice is not above 0.90");
// require(marketConstants.strikePrice < 1000000000000000000, "strikePrice is not below 1.00");
// //TODO add more checks
}

function verifyConfig(ConfigMarket memory marketConstants, ConfigEpochs memory epochConstants) public view {
// require(epochConstants.epochBegin > marketConstants.epochEnd, "epochBegin is not > marketEnd");
// require(epochConstants.epochBegin < epochConstants.epochEnd, "epochBegin is not < epochEnd");
// require(epochConstants.epochEnd > block.timestamp, "epochEnd in the past");
// //TODO add more checks

}

function stringToUint(string memory s) public pure returns (uint) {
bytes memory b = bytes(s);
uint result = 0;
for (uint256 i = 0; i < b.length; i++) {
uint256 c = uint256(uint8(b[i]));
if (c >= 48 && c <= 57) {
result = result * 10 + (c - 48);
}
}
return result;
}

}
Loading