mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
feat: added deploy scripts
This commit is contained in:
parent
8d52a520b0
commit
53dc34abd7
|
@ -7,11 +7,12 @@ import {PercentageMath} from '../../protocol/libraries/math/PercentageMath.sol';
|
||||||
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
|
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
|
||||||
import {ILendingRateOracle} from '../../interfaces/ILendingRateOracle.sol';
|
import {ILendingRateOracle} from '../../interfaces/ILendingRateOracle.sol';
|
||||||
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
|
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
|
||||||
import {ISushiRewardsAwareAToken} from '../interfaces/sushi/ISushiRewardsAwareAToken.sol';
|
|
||||||
import {IMasterChef} from '../../adapters/interfaces/sushi/IMasterChef.sol';
|
|
||||||
import {
|
import {
|
||||||
DefaultReserveInterestRateStrategy
|
DefaultReserveInterestRateStrategy
|
||||||
} from '../../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
|
} from '../../protocol/lendingpool/DefaultReserveInterestRateStrategy.sol';
|
||||||
|
import {
|
||||||
|
CurveGaugeRewardsAwareAToken
|
||||||
|
} from '../../adapters/rewards/curve/CurveGaugeRewardsAwareAToken.sol';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @title DefaultReserveInterestRateStrategy contract
|
* @title DefaultReserveInterestRateStrategy contract
|
||||||
|
@ -22,7 +23,7 @@ import {
|
||||||
* of the LendingPoolAddressesProvider
|
* of the LendingPoolAddressesProvider
|
||||||
* @author Aave
|
* @author Aave
|
||||||
**/
|
**/
|
||||||
contract CurveLPReserveInterestRateStrategy is DefaultReserveInterestRateStrategy {
|
contract CurveGaugeReserveInterestRateStrategy is DefaultReserveInterestRateStrategy {
|
||||||
using WadRayMath for uint256;
|
using WadRayMath for uint256;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
using PercentageMath for uint256;
|
using PercentageMath for uint256;
|
||||||
|
@ -78,9 +79,10 @@ contract CurveLPReserveInterestRateStrategy is DefaultReserveInterestRateStrateg
|
||||||
uint256
|
uint256
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
uint256 poolId = ISushiRewardsAwareAToken(aToken).getMasterChefPoolId();
|
uint256 stakedBalance =
|
||||||
(uint256 stakedBalance, ) =
|
IERC20(CurveGaugeRewardsAwareAToken(aToken).getGaugeController()).balanceOf(
|
||||||
IMasterChef(ISushiRewardsAwareAToken(aToken).getMasterChef()).userInfo(poolId, aToken);
|
CurveGaugeRewardsAwareAToken(aToken).getCurveTreasury()
|
||||||
|
);
|
||||||
|
|
||||||
//avoid stack too deep
|
//avoid stack too deep
|
||||||
uint256 availableLiquidity = stakedBalance.add(liquidityAdded).sub(liquidityTaken);
|
uint256 availableLiquidity = stakedBalance.add(liquidityAdded).sub(liquidityTaken);
|
|
@ -251,5 +251,13 @@ contract CurveGaugeRewardsAwareAToken is RewardsAwareAToken {
|
||||||
function getCrvToken() external view returns (address) {
|
function getCrvToken() external view returns (address) {
|
||||||
return CRV_TOKEN;
|
return CRV_TOKEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurveTreasury() external view returns (address) {
|
||||||
|
return CURVE_TREASURY;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getGaugeController() external view returns (address) {
|
||||||
|
return _gaugeController;
|
||||||
|
}
|
||||||
/** End of External getters */
|
/** End of External getters */
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,3 +77,19 @@ export const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
|
||||||
export const CRV_TOKEN = {
|
export const CRV_TOKEN = {
|
||||||
[eEthereumNetwork.main]: '0xD533a949740bb3306d119CC777fa900bA034cd52',
|
[eEthereumNetwork.main]: '0xD533a949740bb3306d119CC777fa900bA034cd52',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const CURVE_TREASURY = {
|
||||||
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CURVE_CONFIG = {
|
||||||
|
votingEscrow: {
|
||||||
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
|
},
|
||||||
|
curveFeeDistributor: {
|
||||||
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
|
},
|
||||||
|
gaugeController: {
|
||||||
|
[eEthereumNetwork.main]: ZERO_ADDRESS,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
|
@ -52,6 +52,7 @@ import {
|
||||||
RewardsTokenFactory,
|
RewardsTokenFactory,
|
||||||
RewardsATokenMockFactory,
|
RewardsATokenMockFactory,
|
||||||
CurveGaugeRewardsAwareATokenFactory,
|
CurveGaugeRewardsAwareATokenFactory,
|
||||||
|
CurveTreasuryFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {
|
import {
|
||||||
withSaveAndVerify,
|
withSaveAndVerify,
|
||||||
|
@ -69,7 +70,7 @@ import { readArtifact as buidlerReadArtifact } from '@nomiclabs/buidler/plugins'
|
||||||
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
import { HardhatRuntimeEnvironment } from 'hardhat/types';
|
||||||
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
|
import { LendingPoolLibraryAddresses } from '../types/LendingPoolFactory';
|
||||||
import { UiPoolDataProvider } from '../types';
|
import { UiPoolDataProvider } from '../types';
|
||||||
import { CRV_TOKEN } from './constants';
|
import { CRV_TOKEN, CURVE_TREASURY } from './constants';
|
||||||
|
|
||||||
export const deployUiPoolDataProvider = async (
|
export const deployUiPoolDataProvider = async (
|
||||||
[incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress],
|
[incentivesController, aaveOracle]: [tEthereumAddress, tEthereumAddress],
|
||||||
|
@ -721,9 +722,10 @@ export const deployATokenImplementations = async (
|
||||||
|
|
||||||
export const deployCurveGaugeRewardsAwareAToken = async (
|
export const deployCurveGaugeRewardsAwareAToken = async (
|
||||||
crvToken: tEthereumAddress,
|
crvToken: tEthereumAddress,
|
||||||
|
curveTreasury: tEthereumAddress,
|
||||||
verify?: boolean
|
verify?: boolean
|
||||||
) => {
|
) => {
|
||||||
const args: [tEthereumAddress] = [crvToken];
|
const args: [tEthereumAddress, tEthereumAddress] = [crvToken, curveTreasury];
|
||||||
return withSaveAndVerify(
|
return withSaveAndVerify(
|
||||||
await new CurveGaugeRewardsAwareATokenFactory(await getFirstSigner()).deploy(...args),
|
await new CurveGaugeRewardsAwareATokenFactory(await getFirstSigner()).deploy(...args),
|
||||||
eContractid.CurveGaugeRewardsAwareAToken,
|
eContractid.CurveGaugeRewardsAwareAToken,
|
||||||
|
@ -734,5 +736,28 @@ export const deployCurveGaugeRewardsAwareAToken = async (
|
||||||
|
|
||||||
export const deployCurveGaugeRewardsAwareATokenByNetwork = async (verify?: boolean) => {
|
export const deployCurveGaugeRewardsAwareATokenByNetwork = async (verify?: boolean) => {
|
||||||
const network = DRE.network.name as eEthereumNetwork;
|
const network = DRE.network.name as eEthereumNetwork;
|
||||||
return deployCurveGaugeRewardsAwareAToken(CRV_TOKEN[network], verify);
|
return deployCurveGaugeRewardsAwareAToken(CRV_TOKEN[network], CURVE_TREASURY[network], verify);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const deployCurveTreasury = async (
|
||||||
|
votingEscrow: tEthereumAddress,
|
||||||
|
crvToken: tEthereumAddress,
|
||||||
|
curveFeeDistributor: tEthereumAddress,
|
||||||
|
gaugeController: tEthereumAddress,
|
||||||
|
aaveCollector: tEthereumAddress,
|
||||||
|
verify?: boolean
|
||||||
|
) => {
|
||||||
|
const args: [
|
||||||
|
tEthereumAddress,
|
||||||
|
tEthereumAddress,
|
||||||
|
tEthereumAddress,
|
||||||
|
tEthereumAddress,
|
||||||
|
tEthereumAddress
|
||||||
|
] = [votingEscrow, crvToken, curveFeeDistributor, gaugeController, aaveCollector];
|
||||||
|
return withSaveAndVerify(
|
||||||
|
await new CurveTreasuryFactory(await getFirstSigner()).deploy(...args),
|
||||||
|
eContractid.CurveTreasury,
|
||||||
|
args,
|
||||||
|
verify
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -90,6 +90,7 @@ export enum eContractid {
|
||||||
RewardsATokenMock = 'RewardsATokenMock',
|
RewardsATokenMock = 'RewardsATokenMock',
|
||||||
RewardsToken = 'RewardsToken',
|
RewardsToken = 'RewardsToken',
|
||||||
CurveGaugeRewardsAwareAToken = 'CurveGaugeRewardsAwareAToken',
|
CurveGaugeRewardsAwareAToken = 'CurveGaugeRewardsAwareAToken',
|
||||||
|
CurveTreasury = 'CurveTreasury',
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
40
tasks/deployments/deploy-CurveTreasury.ts
Normal file
40
tasks/deployments/deploy-CurveTreasury.ts
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import { task } from 'hardhat/config';
|
||||||
|
import { CRV_TOKEN, CURVE_CONFIG, ZERO_ADDRESS } from '../../helpers/constants';
|
||||||
|
import {
|
||||||
|
deployCurveTreasury,
|
||||||
|
deployInitializableAdminUpgradeabilityProxy,
|
||||||
|
} from '../../helpers/contracts-deployments';
|
||||||
|
import { waitForTx } from '../../helpers/misc-utils';
|
||||||
|
|
||||||
|
task(`deploy-curve-treasury`, `Deploys the CurveTreasury contract`)
|
||||||
|
.addParam('proxyAdmin')
|
||||||
|
.addParam('treasuryAdmin')
|
||||||
|
.addFlag('verify', `Verify contract via Etherscan API.`)
|
||||||
|
.setAction(async ({ verify, proxyAdmin, treasuryAdmin }, localBRE) => {
|
||||||
|
await localBRE.run('set-DRE');
|
||||||
|
|
||||||
|
const net = localBRE.network.name;
|
||||||
|
console.log(`\n- Curve Treasury deployment`);
|
||||||
|
|
||||||
|
const implementation = await deployCurveTreasury(
|
||||||
|
CURVE_CONFIG.votingEscrow[net],
|
||||||
|
CRV_TOKEN[net],
|
||||||
|
CURVE_CONFIG.curveFeeDistributor[net],
|
||||||
|
CURVE_CONFIG.gaugeController[net],
|
||||||
|
ZERO_ADDRESS,
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
||||||
|
const proxy = await deployInitializableAdminUpgradeabilityProxy(verify);
|
||||||
|
const encoded = implementation.interface.encodeFunctionData('initialize', [
|
||||||
|
treasuryAdmin,
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
]);
|
||||||
|
await waitForTx(await proxy.initialize(implementation.address, proxyAdmin, encoded));
|
||||||
|
|
||||||
|
console.log(`\tFinished CurveTreasury deployment`);
|
||||||
|
console.log(`\tProxy:`, proxy.address);
|
||||||
|
console.log(`\tImpl:`, implementation.address);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user