Skip to content

Commit

Permalink
just before to deployment (#63)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeNervoXS authored Feb 10, 2023
1 parent 3d3985b commit d6f01f3
Show file tree
Hide file tree
Showing 48 changed files with 7,758 additions and 82 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ gasReporterOutput.json
addresses.json
blockchain_db
yarn-error.log
broadcast

# deployments
deployments/localhost
Expand Down
130 changes: 130 additions & 0 deletions broadcast/MigrationOptimizerAPRDAI.s.sol/1/run-1675949226.json

Large diffs are not rendered by default.

1,075 changes: 1,075 additions & 0 deletions broadcast/MigrationOptimizerAPRDAI.s.sol/1/run-1675949233.json

Large diffs are not rendered by default.

1,075 changes: 1,075 additions & 0 deletions broadcast/MigrationOptimizerAPRDAI.s.sol/1/run-1675949322.json

Large diffs are not rendered by default.

1,075 changes: 1,075 additions & 0 deletions broadcast/MigrationOptimizerAPRDAI.s.sol/1/run-latest.json

Large diffs are not rendered by default.

190 changes: 190 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675863870.json

Large diffs are not rendered by default.

1,210 changes: 1,210 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675863884.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675931510.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675931550.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675944261.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675944268.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675944454.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675944461.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-1675944479.json

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/1/run-latest.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/137/run-1675932828.json

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/137/run-1675932835.json

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/137/run-1675942376.json

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/137/run-1675942389.json

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/137/run-1675942414.json

Large diffs are not rendered by default.

66 changes: 66 additions & 0 deletions broadcast/MigrationOptimizerAPRUSDC.s.sol/137/run-latest.json

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions contracts/interfaces/IAngleHelper.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

struct PerpetualManagerFeeData {
uint64[] xHAFeesDeposit;
uint64[] yHAFeesDeposit;
uint64[] xHAFeesWithdraw;
uint64[] yHAFeesWithdraw;
uint64 haBonusMalusDeposit;
uint64 haBonusMalusWithdraw;
}

struct PerpetualManagerParamData {
uint64 maintenanceMargin;
uint64 maxLeverage;
uint64 targetHAHedge;
uint64 limitHAHedge;
uint64 lockTime;
}

struct CollateralAddresses {
address stableMaster;
address poolManager;
address perpetualManager;
address sanToken;
address oracle;
address gauge;
address feeManager;
address[] strategies;
}

interface IAngleHelper {
function getCollateralAddresses(address agToken, address collateral)
external
view
returns (CollateralAddresses memory addresses);

function getStablecoinAddresses() external view returns (address[] memory, address[] memory);

function getPoolManager(address agToken, address collateral) external view returns (address poolManager);
}
19 changes: 6 additions & 13 deletions contracts/strategies/BaseStrategyUpgradeable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,12 @@ abstract contract BaseStrategyUpgradeable is BaseStrategyEvents, AccessControlAn
uint256 public constant BASE = 10**18;
uint256 public constant SECONDS_PER_YEAR = 31556952;

// /// @notice Role for `PoolManager` only - keccak256("POOLMANAGER_ROLE")
// bytes32 public constant POOLMANAGER_ROLE = 0x5916f72c85af4ac6f7e34636ecc97619c4b2085da099a5d28f3e58436cfbe562;
// /// @notice Role for guardians and governors - keccak256("GUARDIAN_ROLE")
// bytes32 public constant GUARDIAN_ROLE = 0x55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041;
// /// @notice Role for keepers - keccak256("KEEPER_ROLE")
// bytes32 public constant KEEPER_ROLE = 0xfc8737ab85eb45125971625a9ebdb75cc78e01d5c1fa80c4c6e5203f47bc4fab;

/// @notice Role for `PoolManager` only
bytes32 public constant POOLMANAGER_ROLE = keccak256("POOLMANAGER_ROLE");
/// @notice Role for guardians and governors
bytes32 public constant GUARDIAN_ROLE = keccak256("GUARDIAN_ROLE");
/// @notice Role for keepers
bytes32 public constant KEEPER_ROLE = keccak256("KEEPER_ROLE");
/// @notice Role for `PoolManager` only - keccak256("POOLMANAGER_ROLE")
bytes32 public constant POOLMANAGER_ROLE = 0x5916f72c85af4ac6f7e34636ecc97619c4b2085da099a5d28f3e58436cfbe562;
/// @notice Role for guardians and governors - keccak256("GUARDIAN_ROLE")
bytes32 public constant GUARDIAN_ROLE = 0x55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a5041;
/// @notice Role for keepers - keccak256("KEEPER_ROLE")
bytes32 public constant KEEPER_ROLE = 0xfc8737ab85eb45125971625a9ebdb75cc78e01d5c1fa80c4c6e5203f47bc4fab;

// ================================= REFERENCES ================================

Expand Down
7 changes: 3 additions & 4 deletions contracts/strategies/OptimizerAPR/OptimizerAPRStrategy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,9 @@ contract OptimizerAPRStrategy is BaseStrategyUpgradeable {
uint256 highestLenderNav;
uint256 totalNav = looseAssets;
uint256[] memory weightedAprs = new uint256[](lendersList.length);
uint256 lendersListLength = lendersList.length;
{
uint256 lowestApr = type(uint256).max;
for (uint256 i; i < lendersListLength; ++i) {
for (uint256 i; i < lendersList.length; ++i) {
uint256 aprAfterDeposit = lendersList[i].aprAfterDeposit(int256(looseAssets));
uint256 nav = lendersList[i].nav();
totalNav += nav;
Expand Down Expand Up @@ -192,10 +191,10 @@ contract OptimizerAPRStrategy is BaseStrategyUpgradeable {
uint256 weightedApr1;
// Case where funds are divested from the strategy with the lowest APR to be invested in the one with the highest APR
uint256 weightedApr2;
for (uint256 i; i < lendersListLength; ++i) {
for (uint256 i; i < lendersList.length; ++i) {
if (i == _highest) {
weightedApr1 += (highestLenderNav + looseAssets) * highestApr;
if (lowestNav != 0 && lendersListLength > 1)
if (lowestNav != 0 && lendersList.length > 1)
weightedApr2 +=
(highestLenderNav + looseAssets + lowestNav) *
lendersList[_highest].aprAfterDeposit(int256(lowestNav + looseAssets));
Expand Down
24 changes: 24 additions & 0 deletions deploy/OptimizerAPRStrategy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { DeployFunction } from 'hardhat-deploy/types';
import yargs from 'yargs';
const argv = yargs.env('').boolean('ci').parseSync();

const func: DeployFunction = async ({ deployments, ethers }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();

console.log('Now deploying the implementation for OptimizerAPRStrategy');
await deploy('OptimizerAPRStrategy_Implementation', {
contract: 'OptimizerAPRStrategy',
from: deployer.address,
args: [],
log: !argv.ci,
});

const optimizerAPRStrategyImplementation = (await ethers.getContract('OptimizerAPRStrategy_Implementation')).address;

console.log(`Successfully deployed the implementation for OptimizerAPR at ${optimizerAPRStrategyImplementation}`);
console.log('');
};

func.tags = ['optimizerAPRImplementation'];
export default func;
1 change: 1 addition & 0 deletions deployments/polygon/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
137
Loading

0 comments on commit d6f01f3

Please sign in to comment.