Skip to content

Commit

Permalink
Merge branch 'carousel-factory-epoch-creation'
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnyxos committed Mar 13, 2024
2 parents e95c0c1 + 81b8b39 commit ab9e592
Show file tree
Hide file tree
Showing 22 changed files with 1,290 additions and 233 deletions.
594 changes: 476 additions & 118 deletions configJSON-V2.json

Large diffs are not rendered by default.

60 changes: 60 additions & 0 deletions script/DeployLockRewards.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-License-Identifier;
pragma solidity ^0.8.15;

import "../src/lock-rewards/LockRewards.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";

// forge script LockRewardsScript --rpc-url $ARBITRUM_RPC_URL --private-key $PRIVATE_KEY --broadcast --skip-simulation --slow --verify -vv

contract LockRewardsScript is Script {
using stdJson for string;

function run() public {

vm.startBroadcast();

console.log("Broadcast sender", msg.sender);


LockRewards lockContract16Weeks = new LockRewards(
0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e, // lockToken
0x5D59e5837F7e5d0F710178Eda34d9eCF069B36D2, // rewardToken1 GOV
0x6BE37a65E46048B1D12C0E08d9722402A5247Ff1, // rewardToken2 WETH
16,
16
);

lockContract16Weeks.changeRecoverWhitelist(0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e, true);

LockRewards lockContract32Weeks = new LockRewards(
0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e, // lockToken
0x5D59e5837F7e5d0F710178Eda34d9eCF069B36D2, // rewardToken1 GOV
0x6BE37a65E46048B1D12C0E08d9722402A5247Ff1, // rewardToken2 WETH
32,
32
);

lockContract32Weeks.changeRecoverWhitelist(0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e, true);

console.log("LockRewards 16 weeks", address(lockContract16Weeks));
console.log("LockRewards 32 weeks", address(lockContract32Weeks));

// approve lockContract16Weeks to transfer lockToken
IERC20(0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e).approve(address(lockContract16Weeks), type(uint256).max);
lockContract16Weeks.deposit(100 ether, 16);


// approve lockContract32Weeks to transfer lockToken
IERC20(0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e).approve(address(lockContract32Weeks), type(uint256).max);
lockContract32Weeks.deposit(100 ether, 32);

// log balance
console.log("LockRewards 16 weeks balance", IERC20(0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e).balanceOf(address(lockContract16Weeks)));
console.log("LockRewards 32 weeks balance", IERC20(0xE3d9514f1485e3A26789B4a0a2A874D270EFE37e).balanceOf(address(lockContract32Weeks)));
//transfer ownership
//vaultFactory.transferOwnership(addresses.admin);
vm.stopBroadcast();

}
}
6 changes: 3 additions & 3 deletions script/configs/configAddresses-V2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"admin": "0x45aA9d8B9D567489be9DeFcd085C6bA72BBf344F",
"arb": "0x912CE59144191C1204E64559FE8253a0e49E6548",
"arbitrum_sequencer": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"carouselFactory": "0xC3179AC01b7D68aeD4f27a19510ffe2bfb78Ab3e",
"controller": "0xC0655f3dace795cc48ea1E2e7BC012c1eec912dC",
"controllerGeneric" : "0xDff5d76A5EcD9E3190FE8974c920775c987c442e",
"carouselFactory": "0x442Fd67F2CcF92eD73E7B7E4ff435835EcA890C9",
"controller": "0xe386e6A5238C32E3FC6f2202f42158cdd15Eb514",
"controllerGeneric" : "0xDdFD1f17a80F088B9AcF1aEf0a86FBD181F361f3",
"controllerGenericPausable" : "0xEe7bE0f184372103C5d6766118B6307a00b16962",
"gelatoOpsV2": "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
"gelatoTaskTreasury": "0xB2f34fd4C16e656163dADFeEaE4Ae0c1F13b140A",
Expand Down
8 changes: 4 additions & 4 deletions script/configs/configTestEnv-V2.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{"configAddresses":
{
"admin": "0x16cBaDA408F7523452fF91c8387b1784d00d10D8",
"admin": "0x6bD6948ef89c43dc3e188c1Fa0D145cA75A46074",
"arb": "0x12e0a97aC4410a79d5cb61343AA160dF33C67F75",
"arbitrum_sequencer": "0xFdB631F5EE196F0ed6FAa767959853A9F217697D",
"carouselFactory": "0x820877E5b1Ee55123c6c6AC2b197fD0A3697A6aB",
"controller": "0x5F8142A6d172B05bceA26115D7B07a5512314201",
"controllerGeneric" : "0xc85F29F4E1636FD70d458C9897D60b4d28906a93",
"carouselFactory": "0x470aCEDb80ee4BDfacB246BaA6d9BFdD829f5B5F",
"controller": "0x4b197C8DcC53846CFC4570F64Ac8009D5ddCe221",
"controllerGeneric" : "0x5C008833E56583eBe25FC6aBcD632a7cb9335722",
"controllerGenericPausable" : "0xde6DB47347764BEd9Cd85dDE1e30eA8F04a9FA90",
"gelatoOpsV2": "0xB3f5503f93d5Ef84b06993a1975B9D21B962892F",
"gelatoTaskTreasury": "0xB2f34fd4C16e656163dADFeEaE4Ae0c1F13b140A",
Expand Down
77 changes: 53 additions & 24 deletions script/v2/V2DeployConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ contract V2DeployConfig is HelperV2 {
);
console.log("Address Factory", configAddresses.carouselFactory);
contractToAddresses(configAddresses);
// console log y2k approval for factory
console2.log(
"Y2K allowance for factory",
IERC20(y2k).allowance(configAddresses.policy, configAddresses.carouselFactory)
);
}

function run() public {
Expand Down Expand Up @@ -85,7 +90,7 @@ contract V2DeployConfig is HelperV2 {
market.uri,
controller,
stringToUint(market.relayFee),
market.depositFee,
stringToUint(market.depositFee),
stringToUint(market.minQueueDeposit)
)
);
Expand All @@ -98,6 +103,17 @@ contract V2DeployConfig is HelperV2 {
"-----------------------NEXT MARKETS----------------------"
);
}
// if controller is generic, set depeg condition (depeg 2, repeg 1)
if (market.isGenericController) {
if(!market.isGenericController && !market.isDepegCondition) {
revert("Depeg only supported for generic controller");
}
// setDepegCondition(
// market.oracle,
// marketId,
// market.isDepeg
// );
}
console2.log("\n");
}
}
Expand Down Expand Up @@ -142,9 +158,9 @@ contract V2DeployConfig is HelperV2 {
}

if (market.isGenericController) {
if (market.isDepeg && strikePrice % 2 ** 1 != 0)
if (market.isDepegCondition && strikePrice % 2 ** 1 != 0)
revert("Strike price must be even");
else if (!market.isDepeg && strikePrice % 2 ** 1 != 1)
else if (!market.isDepegCondition && strikePrice % 2 ** 1 != 1)
revert("Strike price must be odd");
}
}
Expand Down Expand Up @@ -200,7 +216,7 @@ contract V2DeployConfig is HelperV2 {
console2.log("epochId: ", epochId);
console2.log("marketId: ", marketId);

deployKeeper(marketId, epochId, vaults, epoch);
// deployKeeper(marketId, epochId, vaults, epoch);

console2.log("\n");
}
Expand Down Expand Up @@ -310,39 +326,52 @@ contract V2DeployConfig is HelperV2 {
}

// deploy rollover and resolve keeper
startKeepers(marketId, epochId, epoch.isGenericController);
// startKeepers(marketId, epochId, false);

console2.log(
"------------------------------------------------------------"
);
}

uint256[] public marketIds = [
102062669946436220800282965814418861703520361600036198831171353773735437582898,
19463494430787374236800916328272982194211552759358049028102840161626064590799,
43365822659564324551460842388001340228617494417519860688859686053122333904688,
2331975465739044783693470748756652505041645629776698023032314532662570347594
// 115677642346820381438193910536175683699063892721242791603421532303838012181085, // TUSD
93601944593345476072344843193813093085647514424424373919377230374357655731143, // TUSD
// 76701967050000321875042703061334997609004364812794785217276595646824090547563, // LUSD
57766427650726088851311587414883446645212442377811572965298655496781476287628 // CRVUSD
// 44285020224447742577916715973830335667697821344158427036525354635037016830837 // USDD
];

function deployNullEpoch() public {

// loop thwourh marketIds
for (uint256 i = 0; i < marketIds.length; ++i) {
uint256 marketId = marketIds[i];
(uint256 epochId, address[2] memory vaults) = factory
.createEpochWithEmissions(
marketId,
uint40(block.timestamp + uint256(10 minutes)),
uint40(block.timestamp + uint256(15 minutes)),
1,
0,
0
);
Carousel(vaults[0]).getDepositQueueLength() > 0
? Carousel(vaults[0]).mintDepositInQueue(epochId, 100)
: console2.log("No deposit in queue");
Carousel(vaults[1]).getDepositQueueLength() > 0
? Carousel(vaults[1]).mintDepositInQueue(epochId, 100)
: console2.log("No deposit in queue");
// (address[2] memory vaults) = factory.marketIdToVaults(marketId, 0);
address premiumVault = factory.marketIdToVaults(marketId, 0);
address collateralVault = factory.marketIdToVaults(marketId, 1);
// (uint256 epochId, address[2] memory vaults) = factory
// .createEpochWithEmissions(
// marketId,
// uint40(block.timestamp + uint256(3 minutes)),
// uint40(block.timestamp + uint256(6 minutes)),
// 1,
// 0,
// 0
// );
// mintQueues Premium
console.log("queues length, premium", Carousel(premiumVault).getDepositQueueLength());
// Carousel(vaults[0]).getDepositQueueLength() > 0
// ? Carousel(vaults[0]).mintDepositInQueue(epochId, 100)
// : console2.log("No deposit in queue");

// mintQueues Collateral
console.log("queues length, collateral", Carousel(collateralVault).getDepositQueueLength());

// Carousel(vaults[1]).getDepositQueueLength() > 0
// ? Carousel(vaults[1]).mintDepositInQueue(epochId, 100)
// : console2.log("No deposit in queue");

console.log("--Next Market--");
}
}
}
Loading

0 comments on commit ab9e592

Please sign in to comment.