Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DPI #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .dpi.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
INFURA_KEY=
ALCHEMY_KEY=
MNEMONIC=

# DEFAULT_GAS_PRICE= 50 GWEI by default

TOKEN=0x1494ca1f11d487c2bbe4543e90080aeba4ba3c2b
ATOKEN=0x5A910454dE8FDe39df264b23f03C72Eca1ba4345
VARIABLE_DEBT_TOKEN=0x174Cb5DEa424f96836F507665C4522dB55e43eD2
STABLE_DEBT_TOKEN=0x0f2d35d52a65c4CC98e345C3B478E75f7E4B9c2a
INTEREST_STRATEGY=0x9440aEc0795D7485e58bCF26622c2f4A681A9671
LTV=6000
LIQUIDATION_THRESHOLD=7000
LIQUIDATION_BONUS=11000
RESERVE_FACTOR=2000
DECIMALS=18
ENABLE_BORROW=true
ENABLE_AS_COLLATERAL=true
ENABLE_STABLE_BORROW=false
IPFS_HASH=Qme2d9yZ81j3JkQ4ecr7BSZv4Rvh5NyU36um48f5S75CQG
CHAINLINK_ORACLE_PROXY=0x029849bbc0b1d93b85a8b6190e979fd38F5760E2

# By default executor and governance addresses set to mainnet addresses
# Uncomment the following for kovan
#AAVE_SHORT_EXECUTOR=0x2012b02574f32a96b9cfb8ba7fdfd589d5c70f50
#AAVE_GOVERNANCE_V2=0xc2ebab3bac8f2f5028f5c7317027a41ebfca31d2
1 change: 1 addition & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (process.env.SKIP_LOAD !== 'true') {
require('./tasks/list-new-asset.ts');
require('./tasks/list-rai.ts');
require('./tasks/list-bond.ts');
require('./tasks/list-dpi.ts');
}

export const BUIDLEREVM_CHAIN_ID = 31337;
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
"test:crv": "MAINNET_FORK=true FORKING_BLOCK=11538355 hardhat test ./test/test-listing-crv.spec.ts",
"test:bal": "MAINNET_FORK=true FORKING_BLOCK=11743368 hardhat test ./test/test-listing-bal.spec.ts",
"test:bond": "MAINNET_FORK=true FORKING_BLOCK=12767300 hardhat test ./test/test-listing-bond.spec.ts",
"test:dpi": "MAINNET_FORK=true FORKING_BLOCK=12966176 hardhat test ./test/test-listing-dpi.spec.ts",
"test:xsushi": "MAINNET_FORK=true FORKING_BLOCK=11829845 hardhat test ./test/test-listing-xsushi.spec.ts",
"test:rai": "MAINNET_FORK=true FORKING_BLOCK=12593370 hardhat test ./test/test-listing-rai.spec.ts",
"run-env": "npm i && tail -f /dev/null",
"propose-new-asset:kovan": "hardhat create:proposal-new-asset --network kovan",
"propose-new-asset:main": "hardhat create:proposal-new-asset --network main",
"propose-new-asset:bond:main": "hardhat create:proposal-new-asset:bond --network main",
"propose-new-asset:dpi:main": "hardhat create:proposal-new-asset:dpi --network main",
"propose-new-asset:rai:main": "hardhat create:proposal-new-asset:rai --network main"
},
"keywords": [],
Expand Down
129 changes: 129 additions & 0 deletions tasks/list-dpi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import path from 'path';
import { config } from 'dotenv';
import '@nomiclabs/hardhat-ethers';
import { task } from 'hardhat/config';
import { getContractAt } from '@nomiclabs/hardhat-ethers/dist/src/helpers';
import { IAaveGovernanceV2 } from '../types/IAaveGovernanceV2';
import { HardhatRuntimeEnvironment, TaskArguments } from 'hardhat/types';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const bs58 = require('bs58');

config({ path: path.resolve(process.cwd(), '.dpi.env') });

task('create:proposal-new-asset:dpi', 'Get the calldata to make a proposal to list DPI')
.addFlag('testrun', 'if provided, only generates the transaction without submitting it onchain')
// eslint-disable-next-line no-empty-pattern
.setAction(async (args: TaskArguments, _DRE: HardhatRuntimeEnvironment) => {
const {
TOKEN,
ATOKEN,
STABLE_DEBT_TOKEN,
VARIABLE_DEBT_TOKEN,
INTEREST_STRATEGY,
LTV,
LIQUIDATION_THRESHOLD,
LIQUIDATION_BONUS,
RESERVE_FACTOR,
DECIMALS,
ENABLE_BORROW,
ENABLE_AS_COLLATERAL,
ENABLE_STABLE_BORROW,
IPFS_HASH,
CHAINLINK_ORACLE_PROXY,
AAVE_GOVERNANCE_V2 = '0xEC568fffba86c094cf06b22134B23074DFE2252c', // mainnet
AAVE_SHORT_EXECUTOR = '0xee56e2b3d491590b5b31738cc34d5232f378a8d5', // mainnet
AAVE_PRICE_ORACLE_V2 = '0xA50ba011c48153De246E5192C8f9258A2ba79Ca9', // mainnet
ASSET_LISTING_EXECUTOR = '0xe775A3A0A1cdc50bD48d5F47c442A0a4F5F24473', // mainnet AssetListingProposalGenericExecutor
} = process.env;
if (
!TOKEN ||
!ATOKEN ||
!STABLE_DEBT_TOKEN ||
!VARIABLE_DEBT_TOKEN ||
!INTEREST_STRATEGY ||
!LTV ||
!LIQUIDATION_BONUS ||
!LIQUIDATION_THRESHOLD ||
!DECIMALS ||
(ENABLE_BORROW !== 'true' && ENABLE_BORROW !== 'false') ||
(ENABLE_AS_COLLATERAL !== 'true' && ENABLE_AS_COLLATERAL !== 'false') ||
(ENABLE_STABLE_BORROW !== 'true' && ENABLE_STABLE_BORROW !== 'false') ||
!IPFS_HASH ||
!CHAINLINK_ORACLE_PROXY ||
!AAVE_GOVERNANCE_V2 ||
!AAVE_SHORT_EXECUTOR ||
!AAVE_PRICE_ORACLE_V2 ||
!RESERVE_FACTOR ||
!ASSET_LISTING_EXECUTOR
) {
throw new Error('You have not set correctly the .env file, make sure to read the README.md');
}
const proposer = (await _DRE.ethers.getSigners())[0];

const executeListingSign =
'execute(address,address,address,address,address,uint256,uint256,uint256,uint256,uint8,bool,bool,bool)';
const executeListingData = _DRE.ethers.utils.defaultAbiCoder.encode(
[
'address',
'address',
'address',
'address',
'address',
'uint',
'uint',
'uint',
'uint',
'uint8',
'bool',
'bool',
'bool',
],
[
TOKEN,
ATOKEN,
STABLE_DEBT_TOKEN,
VARIABLE_DEBT_TOKEN,
INTEREST_STRATEGY,
LTV,
LIQUIDATION_THRESHOLD,
LIQUIDATION_BONUS,
RESERVE_FACTOR,
DECIMALS,
ENABLE_BORROW === 'true',
ENABLE_STABLE_BORROW === 'true',
ENABLE_AS_COLLATERAL === 'true',
]
);

// Set the Chainlink oracle address
const setAssetSign = 'setAssetSources(address[],address[])';
const setAssetData = _DRE.ethers.utils.defaultAbiCoder.encode(
['address[]', 'address[]'],
[[TOKEN], [CHAINLINK_ORACLE_PROXY]]
);

const gov = (await getContractAt(
_DRE,
'IAaveGovernanceV2',
AAVE_GOVERNANCE_V2 || ''
)) as IAaveGovernanceV2;
const ipfsEncoded = `0x${bs58.decode(IPFS_HASH).slice(2).toString('hex')}`;
const tx = await gov
.connect(proposer)
.populateTransaction.create(
AAVE_SHORT_EXECUTOR,
[ASSET_LISTING_EXECUTOR, AAVE_PRICE_ORACLE_V2],
['0', '0'],
[executeListingSign, setAssetSign],
[executeListingData, setAssetData],
[true, false],
ipfsEncoded
);

console.log('Proposal transaction:', tx);

if (!args.testrun) {
const receipt = await (await proposer.sendTransaction(tx)).wait();
console.log('Proposal submitted in:', receipt.transactionHash);
}
});
Loading