Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
defi-dev committed May 7, 2022
1 parent ca4110a commit 4f949e6
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 112 deletions.
2 changes: 1 addition & 1 deletion contracts/PowerIndexVaultRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ contract PowerIndexVaultRouter is AbstractPowerIndexRouter, PowerIndexVaultRoute
WrappedPiErc20Interface(_piToken).enableRouterCallback(_enable);
}

function piTokenCallback(address, uint256 _withdrawAmount) external override payable virtual {
function piTokenCallback(address, uint256 _withdrawAmount) external payable virtual override {
PokeFromState memory state = PokeFromState(0, 0, 0, _withdrawAmount, false, true);
_rebalance(state, false, false);
}
Expand Down
7 changes: 1 addition & 6 deletions contracts/connectors/AbstractStakeRedeemConnector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ abstract contract AbstractStakeRedeemConnector is AbstractProfitDistributionConn
PowerIndexRouterInterface.StakeStatus _status,
DistributeData memory _distributeData,
bytes memory
)
external
virtual
override
returns (bytes memory stakeData)
{
) external virtual override returns (bytes memory stakeData) {
if (_status == PowerIndexRouterInterface.StakeStatus.EQUILIBRIUM) {
uint256 tokenBefore = UNDERLYING.balanceOf(address(PI_TOKEN));
_claimImpl();
Expand Down
44 changes: 14 additions & 30 deletions contracts/connectors/BalPowerIndexConnector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,32 +119,27 @@ contract BalPowerIndexConnector is AbstractBalancerVaultConnector {
}
IVault.FundManagement memory fundManagment = IVault.FundManagement(ASSET_MANAGER, false, ASSET_MANAGER, false);

IVault(VAULT).batchSwap(IVault.SwapKind.GIVEN_IN, swaps, assets, fundManagment, limits, uint(-1));
IVault(VAULT).batchSwap(IVault.SwapKind.GIVEN_IN, swaps, assets, fundManagment, limits, uint256(-1));
}

function stake(uint256 _amount, DistributeData memory _distributeData)
public
override
returns (bytes memory result, bool claimed)
{
function stake(uint256 _amount, DistributeData memory) public override returns (bytes memory result, bool claimed) {
uint256 underlyingStaked = getUnderlyingStaked();
_capitalOut(underlyingStaked, _amount);
_stakeImpl(_amount);
emit Stake(msg.sender, STAKING, address(UNDERLYING), _amount);
}

function redeem(uint256 _amount, DistributeData memory _distributeData)
external
override
returns (bytes memory result, bool claimed)
function redeem(uint256 _amount, DistributeData memory)
external
override
returns (bytes memory result, bool claimed)
{
uint256 underlyingStaked = getUnderlyingStaked();
// redeem amount will be converted to shares
_redeemImpl(_amount);
// capital in amount without fee
_capitalIn(underlyingStaked, _amount);
emit Redeem(msg.sender, STAKING, address(UNDERLYING), _amount);
claimed = true;
}

function initRouter(bytes calldata) external override {
Expand Down Expand Up @@ -173,9 +168,9 @@ contract BalPowerIndexConnector is AbstractBalancerVaultConnector {
}

function unpackStakeData(bytes memory _stakeData)
public
pure
returns (uint256 lastAssetsPerShare, uint256 underlyingEarned)
public
pure
returns (uint256 lastAssetsPerShare, uint256 underlyingEarned)
{
if (_stakeData.length == 0 || keccak256(_stakeData) == keccak256("")) {
return (0, 0);
Expand Down Expand Up @@ -211,9 +206,9 @@ contract BalPowerIndexConnector is AbstractBalancerVaultConnector {
* @notice Unpack claim params from bytes to variables.
*/
function unpackStakeParams(bytes memory _stakeParams)
public
pure
returns (uint256 maxETHOnStaking, uint256 minLUSDToDistribute)
public
pure
returns (uint256 maxETHOnStaking, uint256 minLUSDToDistribute)
{
if (_stakeParams.length == 0 || keccak256(_stakeParams) == keccak256("")) {
return (0, 0);
Expand Down Expand Up @@ -248,20 +243,9 @@ contract BalPowerIndexConnector is AbstractBalancerVaultConnector {
}

/**
* @dev This function should be manually changed to "view" in the ABI
*/
* @dev This function should be manually changed to "view" in the ABI
*/
function getPendingRewards() public returns (uint256) {
return REWARDS_MINTER.mintFor(STAKING, ASSET_MANAGER);
}
}











26 changes: 17 additions & 9 deletions contracts/interfaces/ILiquidityGauge.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

//pragma experimental ABIEncoderV2;

interface ILiquidityGauge {
Expand All @@ -13,7 +14,11 @@ interface ILiquidityGauge {
uint256 integral;
}

function deposit(uint256 _value, address _addr, bool _claim_rewards) external;
function deposit(
uint256 _value,
address _addr,
bool _claim_rewards
) external;

function withdraw(uint256 _value, bool _claim_rewards) external;

Expand All @@ -23,12 +28,15 @@ interface ILiquidityGauge {

function user_checkpoint(address user) external returns (bool);

function reward_data(address user) external view returns (
address token,
address distributor,
uint256 period_finish,
uint256 rate,
uint256 last_update,
uint256 integral
);
function reward_data(address user)
external
view
returns (
address token,
address distributor,
uint256 period_finish,
uint256 rate,
uint256 last_update,
uint256 integral
);
}
4 changes: 1 addition & 3 deletions contracts/interfaces/IRouterConnector.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,5 @@ interface IRouterConnector {
PowerIndexRouterInterface.StakeStatus _status,
DistributeData calldata _distributeData,
bytes calldata _claimParams
)
external
returns (bytes calldata);
) external returns (bytes calldata);
}
6 changes: 4 additions & 2 deletions contracts/interfaces/balancerV3/IBalancerMinter.sol
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pragma solidity ^0.7.0;

interface IBalancerMinter {
event MinterApprovalSet(address indexed user, address indexed minter, bool approval);

Expand All @@ -16,7 +18,7 @@ interface IBalancerMinter {
function mintFor(address gauge, address user) external returns (uint256);

/**
* @notice Set whether `minter` is approved to mint tokens on your behalf
*/
* @notice Set whether `minter` is approved to mint tokens on your behalf
*/
function setMinterApproval(address minter, bool approval) external;
}
5 changes: 2 additions & 3 deletions contracts/test/crv/BalancerMinterMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ contract BalancerMinterMock is ReentrancyGuard, EIP712 {
mapping(address => uint256) internal _nextNonce;

// solhint-disable-next-line var-name-mixedcase
bytes32 private immutable _SET_MINTER_APPROVAL_TYPEHASH = keccak256(
"SetMinterApproval(address minter,bool approval,uint256 nonce,uint256 deadline)"
);
bytes32 private immutable _SET_MINTER_APPROVAL_TYPEHASH =
keccak256("SetMinterApproval(address minter,bool approval,uint256 nonce,uint256 deadline)");

event MinterApprovalSet(address indexed user, address indexed minter, bool approval);

Expand Down
16 changes: 13 additions & 3 deletions contracts/test/crv/LiquidityGaugeMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ contract LiquidityGaugeMock is ILiquidityGauge {
IERC20 public rewardsTokens;
uint256 public rewardsPerSecond;

constructor(IERC20 _stakeToken, IERC20 _rewardsTokens, uint256 _rewardsPerSecond) public {
constructor(
IERC20 _stakeToken,
IERC20 _rewardsTokens,
uint256 _rewardsPerSecond
) public {
stakeToken = _stakeToken;
rewardsTokens = _rewardsTokens;
rewardsPerSecond = _rewardsPerSecond;
}

function deposit(uint256 _amount, address _depositFor, bool _claim) external override {
function deposit(
uint256 _amount,
address _depositFor,
bool _claim
) external override {
console.log("stakeToken.balanceOf", stakeToken.balanceOf(msg.sender));
stakeToken.transferFrom(msg.sender, address(this), _amount);
balanceOf[_depositFor] = balanceOf[_depositFor].add(_amount);
Expand All @@ -43,7 +51,9 @@ contract LiquidityGaugeMock is ILiquidityGauge {
function _updateAccumulated(address _user) internal {
accumulated = accumulated.add(rewardsPerSecond.mul(block.timestamp.sub(lastAccumulatedAt)));
if (reward_data[_user].rate != 0) {
totalRewards[_user] = totalRewards[_user].add(accumulated.sub(reward_data[_user].rate).mul(balanceOf[_user]).div(totalSupply));
totalRewards[_user] = totalRewards[_user].add(
accumulated.sub(reward_data[_user].rate).mul(balanceOf[_user]).div(totalSupply)
);
}
reward_data[_user].rate = accumulated;
lastAccumulatedAt = block.timestamp;
Expand Down
49 changes: 24 additions & 25 deletions tasks/deployLUSDAssetManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ require('@nomiclabs/hardhat-truffle5');
require('@nomiclabs/hardhat-ethers');

task('deploy-lusd-asset-manager', 'Deploy LUSD Asset Manager').setAction(async (__, { ethers, network }) => {
const { ether, zeroAddress, impersonateAccount, gwei, increaseTime, maxUint256 } = require('../test/helpers');
const { ether, impersonateAccount, gwei, increaseTime, maxUint256 } = require('../test/helpers');
const IERC20 = await artifacts.require('@openzeppelin/contracts/token/ERC20/IERC20.sol:IERC20');
const IVault = await artifacts.require('contracts/interfaces/balancerV3/IVault.sol:IVault');
const ILiquidityGauge = await artifacts.require('ILiquidityGauge');
const AssetManager = await artifacts.require('AssetManager');
const PowerPoke = await artifacts.require('IPowerPoke');
const IBalancerMinter = await artifacts.require('IBalancerMinter');
const IBasePool = await artifacts.require('contracts/interfaces/balancerV3/IBasePool.sol:IBasePool');
const BAMM = await artifacts.require('BAMM');
const StabilityPool = await artifacts.require('StabilityPool');
// const BAMM = await artifacts.require('BAMM');
const BProtocolPowerIndexConnector = await artifacts.require('BProtocolPowerIndexConnector');
const BalPowerIndexConnector = await artifacts.require('BalPowerIndexConnector');
const StablePoolFactory = await artifacts.require('@powerpool/balancer-v2-pool-stable/contracts/StablePoolFactory');
Expand Down Expand Up @@ -181,7 +180,7 @@ task('deploy-lusd-asset-manager', 'Deploy LUSD Asset Manager').setAction(async (
{ to: pokerReporter, compensateInETH: true },
);

const bamm = await BAMM.at(bammAddress);
// const bamm = await BAMM.at(bammAddress);
const gauge = await ILiquidityGauge.at(liquidityGaugeAddress);
const balancerMinter = await IBalancerMinter.at(balancerMinterAddress);

Expand Down Expand Up @@ -247,27 +246,27 @@ task('deploy-lusd-asset-manager', 'Deploy LUSD Asset Manager').setAction(async (
console.log(prefix, printsNumber + ' assetManagerRewards ', await lqty.balanceOf(lusdAssetManager.address).then(r => r.toString()));
}

async function showBammInitInfo() {
console.log('stability pool', await bamm.SP());
const stabilityPool = await StabilityPool.at(await bamm.SP());
console.log(
'getCompoundedLUSDDeposit',
await stabilityPool.getCompoundedLUSDDeposit(bammAddress).then(r => r.toString()),
);
console.log('getDepositorETHGain', await stabilityPool.getDepositorETHGain(bammAddress).then(r => r.toString()));
console.log('fetchPrice', await bamm.fetchPrice().then(r => r.toString()));
}

async function showBammStakeInfo(number) {
const c = await lusdAssetManager.connectors('0');
console.log('stake ' + number, await bamm.stake(lusdAssetManager.address).then(a => a.toString()));
console.log('isClaimAvailable', await lusdConnector.isClaimAvailable(c.claimParams));
console.log('claimRewardsIntervalReached', await lusdAssetManager.claimRewardsIntervalReached(c.lastClaimRewardsAt));
console.log(
'getStakeAndClaimStatusByConnectorIndex',
await lusdAssetManager.getStakeAndClaimStatusByConnectorIndex('0', true),
);
}
// async function showBammInitInfo() {
// console.log('stability pool', await bamm.SP());
// const stabilityPool = await StabilityPool.at(await bamm.SP());
// console.log(
// 'getCompoundedLUSDDeposit',
// await stabilityPool.getCompoundedLUSDDeposit(bammAddress).then(r => r.toString()),
// );
// console.log('getDepositorETHGain', await stabilityPool.getDepositorETHGain(bammAddress).then(r => r.toString()));
// console.log('fetchPrice', await bamm.fetchPrice().then(r => r.toString()));
// }
//
// async function showBammStakeInfo(number) {
// const c = await lusdAssetManager.connectors('0');
// console.log('stake ' + number, await bamm.stake(lusdAssetManager.address).then(a => a.toString()));
// console.log('isClaimAvailable', await lusdConnector.isClaimAvailable(c.claimParams));
// console.log('claimRewardsIntervalReached', await lusdAssetManager.claimRewardsIntervalReached(c.lastClaimRewardsAt));
// console.log(
// 'getStakeAndClaimStatusByConnectorIndex',
// await lusdAssetManager.getStakeAndClaimStatusByConnectorIndex('0', true),
// );
// }

async function addPokeClient(assetManagerAddress) {
const BONUS_NUMERATOR = '7610350076';
Expand Down
26 changes: 13 additions & 13 deletions test/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,19 +215,19 @@ async function impersonateAccount(ethers, adminAddress) {
await ethers.provider.send('hardhat_impersonateAccount', [adminAddress]);
}

async function forkPrepareBalancerAutorizer(ethers, network, deployer) {
const IAuthorizer = await artifacts.require('contracts/interfaces/balancerV3/IAuthorizer.sol:IAuthorizer');

await network.provider.request({
method: 'hardhat_reset',
params: [{ forking: { jsonRpcUrl: process.env.RPC } }],
});
const daoMultisigAddress = '0x10a19e7ee7d7f8a52822f6817de8ea18204f2e4f';
const roles = ['0x38850d48acdf7da1f77e6b4a1991447eb2c439554ba14cdfec945500fdc714a1'];
const authorizer = await IAuthorizer.at('0xa331d84ec860bf466b4cdccfb4ac09a1b43f3ae6');
await impersonateAccount(ethers, daoMultisigAddress);
await authorizer.grantRoles(roles, deployer, { from: daoMultisigAddress });
}
// async function forkPrepareBalancerAutorizer(ethers, network, deployer) {
// const IAuthorizer = await artifacts.require('contracts/interfaces/balancerV3/IAuthorizer.sol:IAuthorizer');
//
// await network.provider.request({
// method: 'hardhat_reset',
// params: [{ forking: { jsonRpcUrl: process.env.RPC } }],
// });
// const daoMultisigAddress = '0x10a19e7ee7d7f8a52822f6817de8ea18204f2e4f';
// const roles = ['0x38850d48acdf7da1f77e6b4a1991447eb2c439554ba14cdfec945500fdc714a1'];
// const authorizer = await IAuthorizer.at('0xa331d84ec860bf466b4cdccfb4ac09a1b43f3ae6');
// await impersonateAccount(ethers, daoMultisigAddress);
// await authorizer.grantRoles(roles, deployer, { from: daoMultisigAddress });
// }

async function forkContractUpgrade(ethers, adminAddress, proxyAdminAddress, proxyAddress, implAddress) {
const iface = new ethers.utils.Interface(['function upgrade(address proxy, address impl)']);
Expand Down
Loading

0 comments on commit 4f949e6

Please sign in to comment.