Skip to content

Commit

Permalink
Deploy branch (#93)
Browse files Browse the repository at this point in the history
* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* unused local var

* 66 audit timelock in admin functions of vault (#67)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* 41 audit getlatestprice when calling endepoch with sequencer down does not end and epoch (#68)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* audit: getLatestPrice in event of triggerEndEpoch

* epochHasEnded

* goerli deployment

* natspec comments

* add quick fix to test before PR refactoring

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* erased dup test

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* dup of trigger null epoch

Co-authored-by: 0xnexusflip <[email protected]>

* missing address

* 69 audit depeg event can happen at incorrect price (#70)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* audit: getLatestPrice in event of triggerEndEpoch

* audit: Change the isDisaster modifier to revert when price of a pegged asset is equal to the strike price of a Vault

* epochHasEnded

* goerli deployment

* natspec comments

* add quick fix to test before PR refactoring

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* unused local var

* 66 audit timelock in admin functions of vault (#67)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* 41 audit getlatestprice when calling endepoch with sequencer down does not end and epoch (#68)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* audit: getLatestPrice in event of triggerEndEpoch

* epochHasEnded

* goerli deployment

* natspec comments

* add quick fix to test before PR refactoring

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* erased dup test

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* dup of trigger null epoch

Co-authored-by: 0xnexusflip <[email protected]>

* missing address

Co-authored-by: 0xnexusflip <[email protected]>

* audit: #383

* audit: #379

* audit #118

* remove hashed index

* change treasure address 0

* deposit event with useless param

* audit deposit evnt

* audit: fee cannot be 0

* add timelock, strk price, null epoch tests

* add testFeeCannotBe0

* add testControllerNotSet

* timelock assert test

* test fail for timelockers

* tests of epochnull and withdraw without fee

* test epoch already finished

* EpochFinishedAlready and epochNull tests

* testing suite update on reverts

* comment out test testVaultAddressZero

* Revert 81 71 audit missing assert verification on transfer of tokens (#82)

* 71 audit missing assert verification on transfer of tokens (#81)

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* unused local var

* 66 audit timelock in admin functions of vault (#67)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* 41 audit getlatestprice when calling endepoch with sequencer down does not end and epoch (#68)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* audit: getLatestPrice in event of triggerEndEpoch

* epochHasEnded

* goerli deployment

* natspec comments

* add quick fix to test before PR refactoring

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* erased dup test

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* dup of trigger null epoch

Co-authored-by: 0xnexusflip <[email protected]>

* missing address

* 69 audit depeg event can happen at incorrect price (#70)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* audit: getLatestPrice in event of triggerEndEpoch

* audit: Change the isDisaster modifier to revert when price of a pegged asset is equal to the strike price of a Vault

* epochHasEnded

* goerli deployment

* natspec comments

* add quick fix to test before PR refactoring

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* unused local var

* 66 audit timelock in admin functions of vault (#67)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* 41 audit getlatestprice when calling endepoch with sequencer down does not end and epoch (#68)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* audit: timelock in admin functions of vault #66

* audit: getLatestPrice in event of triggerEndEpoch

* epochHasEnded

* goerli deployment

* natspec comments

* add quick fix to test before PR refactoring

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* removed admin

* add assert to testOwnerAuthorize

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* erased dup test

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* 46 audit oracle outdated issues (#63)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* 39 audit controllersol needs to implement tvl cant be zero (#64)

* audit: remove approving of WETH when Depositing Eth

* audit: Vault.sol mapping to epochs is over

* natspec example

* synthax errors on compile

* useless onlyAdmin

* audit: Controller.sol needs to implement TVL cant be zero

* total supply and modifier

* allow rest only after epoch begins

* dup of trigger null epoch

Co-authored-by: 0xnexusflip <[email protected]>

* missing address

Co-authored-by: 0xnexusflip <[email protected]>

* audit: #383

* audit: #379

* audit #118

* remove hashed index

* change treasure address 0

* deposit event with useless param

* audit deposit evnt

* audit: fee cannot be 0

* add timelock, strk price, null epoch tests

* add testFeeCannotBe0

* add testControllerNotSet

* timelock assert test

* test fail for timelockers

* tests of epochnull and withdraw without fee

* test epoch already finished

* EpochFinishedAlready and epochNull tests

* testing suite update on reverts

* comment out test testVaultAddressZero

* assert on all asset.transfers

Co-authored-by: 0xnexusflip <[email protected]>

* Revert "71 audit missing assert verification on transfer of tokens (#81)"

This reverts commit 79d913a.

Co-authored-by: 0xnexusflip <[email protected]>

* assert on all asset.transfers (#84)

* add author to contracts

* audit marketExists on controller functs (#85)

* remove getNextEpoch

* audit: Vault receiver != address(0)

* audit: oracle for more than 18 and for less than 18 decimals

* audit: multiply before dividing #77

* test out lowest fee possible

* audit: #79

* timelock for factory instead of vault

* onlyAdmin to onlyOwner Ownable

* fix overflow on previewWithdraw

* fee calculation on premium

* fix testWithdrawDepeg() and WithdrawEndEpoch()

* revert event naming in RewardsFactory

* removed hashed index

* add testOracleDecimals() template

* change strike on deploy script

* qa for oracle decimals

* timelocker contract with queue and execute

* policy role

* policy == owner

* remove rewards duration and rewards rate

* useless rewardsDuration and rewardRate

* config json

* json parser

* deploy with json config

* deploy more assets script

* add fake weth

* fakeweth mint

* /out => abi/

* abi ignore

* commands to work

* deploy more markets

* deploy more scripts

* _index

* remove redundant epoch end

* commands

* pausable staking rewards

Co-authored-by: 0xnexusflip <[email protected]>
Co-authored-by: mcruzvas <[email protected]>
  • Loading branch information
3 people authored Oct 19, 2022
1 parent 598b56f commit 698af2a
Show file tree
Hide file tree
Showing 14 changed files with 635 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ node_modules
.vscode
.env
out/
abi/
broadcast/
7 changes: 4 additions & 3 deletions configAddresses.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{"configAddresses":
[{
"treasury": "0xFB0a3A93e9acd461747e7D613eb3722d53B96613",
"admin": "0xFB0a3A93e9acd461747e7D613eb3722d53B96613",
"policy": "0xFB0a3A93e9acd461747e7D613eb3722d53B96613",
"treasury": "0xaC0D2cF77a8F8869069fc45821483701A264933B",
"admin": "0xaC0D2cF77a8F8869069fc45821483701A264933B",
"policy": "0xaC0D2cF77a8F8869069fc45821483701A264933B",

"weth": "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
"arbitrum_sequencer": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",

Expand Down
12 changes: 0 additions & 12 deletions configFarms.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
{
"1":[{
"epochEnd":1665802423,
"rewardsAmount": 10000000000000000000

}],

"2":[{
"epochEnd":1665802423,
"rewardsAmount": 10000000000000000000
}],

"3":[{
"epochEnd":1665802423,
"rewardsAmount": 10000000000000000000
}]
}
Expand Down
8 changes: 4 additions & 4 deletions configMarkets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"2":[{
"name":"y2kFRAX_97*",
"strikePrice": 975555555555555555,
"epochBegin":1665543223,
"epochEnd":1665802423,
"epochBegin":1665871200,
"epochEnd":1666130400,
"epochFee":55,
"token": "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
"oracle": "0x0809E3d38d1B4214958faf06D8b1B1a2b73f2ab8"
Expand All @@ -22,8 +22,8 @@
"3":[{
"name":"y2kFRAX_95*",
"strikePrice": 955555555555555555,
"epochBegin":1665543223,
"epochEnd":1665802423,
"epochBegin":1665871200,
"epochEnd":1666130400,
"epochFee":55,
"token": "0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F",
"oracle": "0x0809E3d38d1B4214958faf06D8b1B1a2b73f2ab8"
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[profile.default]
src = 'src'
out = 'out'
out = 'abi'
libs = ['lib']

remappings = ["@openzeppelin/=lib/openzeppelin-contracts/","@chainlink=lib/chainlink/contracts/src/v0.8","@solmate=lib/solmate/src"]
Expand Down
19 changes: 11 additions & 8 deletions script/DeployConfigured.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "../src/VaultFactory.sol";
import "../src/Controller.sol";
import "../src/rewards/RewardsFactory.sol";
import "../test/Y2Ktest.sol";
import "../src/rewards/PausableRewardsFactory.sol";
import "../src/tokens/Y2K.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/// @author MiguelBits

//forge script ConfigScript --rpc-url $ARBITRUM_RPC_URL --private-key $PRIVATE_KEY --etherscan-api-key $arbiscanApiKey --verify --broadcast -vv
//forge script ConfigScript --rpc-url $ARBITRUM_RPC_URL --private-key $PRIVATE_KEY --broadcast --etherscan-api-key $arbiscanApiKey --verify --skip-simulation --gas-estimate-multiplier 200 --slow -vv

contract ConfigScript is Script {
using stdJson for string;

Expand Down Expand Up @@ -46,7 +47,6 @@ contract ConfigScript is Script {
}

struct ConfigFarm {
uint256 epochEnd;
uint256 rewardsAmount;
}

Expand Down Expand Up @@ -78,16 +78,18 @@ contract ConfigScript is Script {
console2.log("\n");

vm.startBroadcast();

console2.log("Broadcast sender", msg.sender);
console2.log("Broadcast admin ", addresses.admin);
console2.log("Broadcast policy", addresses.policy);
//start setUp();

vaultFactory = new VaultFactory(addresses.treasury, addresses.weth, addresses.policy);
controller = new Controller(address(vaultFactory), addresses.arbitrum_sequencer);

vaultFactory.setController(address(controller));

y2k = new Y2K(500 ether, msg.sender);
y2k = new Y2K(5000 ether, msg.sender);

rewardsFactory = new RewardsFactory(address(y2k), address(vaultFactory));
//stop setUp();
Expand Down Expand Up @@ -117,15 +119,16 @@ contract ConfigScript is Script {
console2.log("\n");
// create market
vaultFactory.createNewMarket(markets.epochFee, markets.token, markets.strikePrice, markets.epochBegin, markets.epochEnd, markets.oracle, markets.name);
(address rHedge, address rRisk) = rewardsFactory.createStakingRewards(index, farms.epochEnd);
(address rHedge, address rRisk) = rewardsFactory.createStakingRewards(index, markets.epochEnd);
//sending gov tokens to farms
y2k.approve(address(rHedge), farms.rewardsAmount);
y2k.transfer(rHedge, farms.rewardsAmount);
y2k.approve(address(rRisk), farms.rewardsAmount);
y2k.transfer(rRisk, farms.rewardsAmount);
//start rewards for farms
StakingRewards(rHedge).notifyRewardAmount(y2k.balanceOf(rHedge));
StakingRewards(rRisk).notifyRewardAmount(y2k.balanceOf(rRisk));

// stop create market

//pause getRewards
StakingRewards(rHedge).pause();
StakingRewards(rRisk).pause();
Expand Down
126 changes: 126 additions & 0 deletions script/DeployEpochsConfigured.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// SPDX-License-Identifier;
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "../src/VaultFactory.sol";
import "../src/Controller.sol";
import "../src/rewards/RewardsFactory.sol";
import "../test/Y2Ktest.sol";
import "../test/fakeWeth.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/// @author MiguelBits
//forge script ConfigEpochsScript --rpc-url $ARBITRUM_RPC_URL --private-key $PRIVATE_KEY --broadcast --skip-simulation --gas-estimate-multiplier 200 --slow -vv
contract ConfigEpochsScript is Script {
using stdJson for string;

struct ConfigAddresses {
address admin;
address arbitrum_sequencer;
address oracleDAI;
address oracleFEI;
address oracleFRAX;
address oracleMIM;
address oracleUSDC;
address oracleUSDT;
address policy;
address tokenDAI;
address tokenFEI;
address tokenFRAX;
address tokenMIM;
address tokenUSDC;
address tokenUSDT;
address treasury;
address weth;
}

struct ConfigMarket {
uint256 epochBegin;
uint256 epochEnd;
uint256 epochFee;
string name;
address oracle;
int256 strikePrice;
address token;
}

struct ConfigFarm {
uint256 rewardsAmount;
}

VaultFactory vaultFactory = VaultFactory(0x3DcF49D27388E4BCF7AE74D75AFA987034Bd7ce0);
Controller controller = Controller(0x77fe110716E6B5D1904C7E3d1C49aB3C58Ef678B);
RewardsFactory rewardsFactory = RewardsFactory(0x9dC6821AE74FaAE71Dfd1016f14eAdcA7823Faf4);
Y2K y2k = Y2K(0x4070a276F99A4A38E0b3046183fEc8F33923716e);

uint index = 2;

function run() public {
vm.startBroadcast();

ConfigAddresses memory addresses = getConfigAddresses();
ConfigMarket memory markets = getConfigMarket(index);
ConfigFarm memory farms = getConfigFarm(index);

//INDEX
//get markets config
console2.log("Market name", markets.name);
console2.log("Adress token", addresses.tokenFRAX);
console2.log("Market token", markets.token);
console2.log("Adress oracle", addresses.oracleFRAX);
console2.log("Market oracle", markets.oracle);
console2.log("Market strike price", uint256(markets.strikePrice));
console2.log("Market epoch begin", markets.epochBegin);
console2.log("Market epoch end", markets.epochEnd);
console2.log("Market epoch fee", markets.epochFee);
console2.log("Farm epoch end", farms.epochEnd);
console2.log("Farm rewards amount", farms.rewardsAmount);
//console2.log("Sender balance amnt", y2k.balanceOf(msg.sender));
console2.log("\n");
// create market
vaultFactory.deployMoreAssets(index, markets.epochBegin, markets.epochEnd, markets.epochFee);
(address rHedge, address rRisk) = rewardsFactory.createStakingRewards(index, markets.epochEnd);
//sending gov tokens to farms
y2k.transfer(rHedge, farms.rewardsAmount);
y2k.transfer(rRisk, farms.rewardsAmount);
//start rewards for farms
StakingRewards(rHedge).notifyRewardAmount(y2k.balanceOf(rHedge));
StakingRewards(rRisk).notifyRewardAmount(y2k.balanceOf(rRisk));
// stop create market

vm.stopBroadcast();
}

function getConfigAddresses() public returns (ConfigAddresses memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configAddresses.json");
string memory json = vm.readFile(path);
bytes memory transactionDetails = json.parseRaw(".configAddresses[0]");
ConfigAddresses memory rawConstants = abi.decode(transactionDetails, (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, "/configMarkets.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".",Strings.toString(_index), "[0]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigMarket memory rawConstants = abi.decode(transactionDetails, (ConfigMarket));
//console2.log("ConfigMarkets ", rawConstants.name);
return rawConstants;
}

function getConfigFarm(uint256 _index) public returns (ConfigFarm memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configFarms.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".",Strings.toString(_index), "[0]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigFarm memory rawConstants = abi.decode(transactionDetails, (ConfigFarm));
//console2.log("ConfigFarms ", rawConstants.rewardsAmount);
return rawConstants;
}
}
127 changes: 127 additions & 0 deletions script/DeployMarketsConfigured.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// SPDX-License-Identifier;
pragma solidity ^0.8.13;

import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "../src/VaultFactory.sol";
import "../src/Controller.sol";
import "../src/rewards/RewardsFactory.sol";
import "../test/Y2Ktest.sol";
import "../test/fakeWeth.sol";
import "@openzeppelin/contracts/utils/Strings.sol";

/// @author MiguelBits
//forge script ConfigScript --rpc-url $ARBITRUM_RPC_URL --private-key $PRIVATE_KEY --broadcast --skip-simulation --gas-estimate-multiplier 200 --slow -vv
contract ConfigMarketsScript is Script {
using stdJson for string;

struct ConfigAddresses {
address admin;
address arbitrum_sequencer;
address oracleDAI;
address oracleFEI;
address oracleFRAX;
address oracleMIM;
address oracleUSDC;
address oracleUSDT;
address policy;
address tokenDAI;
address tokenFEI;
address tokenFRAX;
address tokenMIM;
address tokenUSDC;
address tokenUSDT;
address treasury;
address weth;
}

struct ConfigMarket {
uint256 epochBegin;
uint256 epochEnd;
uint256 epochFee;
string name;
address oracle;
int256 strikePrice;
address token;
}

struct ConfigFarm {
uint256 rewardsAmount;
}

VaultFactory vaultFactory = VaultFactory(0x3DcF49D27388E4BCF7AE74D75AFA987034Bd7ce0);
Controller controller = Controller(0x77fe110716E6B5D1904C7E3d1C49aB3C58Ef678B);
RewardsFactory rewardsFactory = RewardsFactory(0x9dC6821AE74FaAE71Dfd1016f14eAdcA7823Faf4);
Y2K y2k = Y2K(0x4070a276F99A4A38E0b3046183fEc8F33923716e);

uint index = 3;

function run() public {
vm.startBroadcast();

ConfigAddresses memory addresses = getConfigAddresses();
ConfigMarket memory markets = getConfigMarket(index);
ConfigFarm memory farms = getConfigFarm(index);

//INDEX
//get markets config
console2.log("Market index", index);
console2.log("Market name", markets.name);
console2.log("Adress token", addresses.tokenFRAX);
console2.log("Market token", markets.token);
console2.log("Adress oracle", addresses.oracleFRAX);
console2.log("Market oracle", markets.oracle);
console2.log("Market strike price", uint256(markets.strikePrice));
console2.log("Market epoch begin", markets.epochBegin);
console2.log("Market epoch end", markets.epochEnd);
console2.log("Market epoch fee", markets.epochFee);
console2.log("Farm epoch end", farms.epochEnd);
console2.log("Farm rewards amount", farms.rewardsAmount);
//console2.log("Sender balance amnt", y2k.balanceOf(msg.sender));
console2.log("\n");
// create market
vaultFactory.createNewMarket(markets.epochFee, markets.token, markets.strikePrice, markets.epochBegin, markets.epochEnd, markets.oracle, markets.name);
(address rHedge, address rRisk) = rewardsFactory.createStakingRewards(index, markets.epochEnd);
//sending gov tokens to farms
y2k.transfer(rHedge, farms.rewardsAmount);
y2k.transfer(rRisk, farms.rewardsAmount);
//start rewards for farms
StakingRewards(rHedge).notifyRewardAmount(y2k.balanceOf(rHedge));
StakingRewards(rRisk).notifyRewardAmount(y2k.balanceOf(rRisk));
// stop create market

vm.stopBroadcast();
}

function getConfigAddresses() public returns (ConfigAddresses memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configAddresses.json");
string memory json = vm.readFile(path);
bytes memory transactionDetails = json.parseRaw(".configAddresses[0]");
ConfigAddresses memory rawConstants = abi.decode(transactionDetails, (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, "/configMarkets.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".",Strings.toString(_index), "[0]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigMarket memory rawConstants = abi.decode(transactionDetails, (ConfigMarket));
//console2.log("ConfigMarkets ", rawConstants.name);
return rawConstants;
}

function getConfigFarm(uint256 _index) public returns (ConfigFarm memory) {
string memory root = vm.projectRoot();
string memory path = string.concat(root, "/configFarms.json");
string memory json = vm.readFile(path);
string memory indexString = string.concat(".",Strings.toString(_index), "[0]");
bytes memory transactionDetails = json.parseRaw(indexString);
ConfigFarm memory rawConstants = abi.decode(transactionDetails, (ConfigFarm));
//console2.log("ConfigFarms ", rawConstants.rewardsAmount);
return rawConstants;
}
}
Loading

0 comments on commit 698af2a

Please sign in to comment.