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 stETH #21

Open
wants to merge 6 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
22 changes: 22 additions & 0 deletions .steth.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# DEFAULT_GAS_PRICE= 50 GWEI by default

TOKEN=0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84
ATOKEN=0xbd233D4ffdAA9B7d1d3E6b18CCcb8D091142893a
STABLE_DEBT_TOKEN=0x8180949ac41EF18e844ff8dafE604a195d86Aea9
VARIABLE_DEBT_TOKEN=0xDe2c414b671d2DB93617D1592f0490c13674de24
INTEREST_STRATEGY=0xff04ed5f7a6C3a0F1e5Ea20617F8C6f513D5A77c
LTV=7000
LIQUIDATION_THRESHOLD=7500
LIQUIDATION_BONUS=10750
RESERVE_FACTOR=1000
DECIMALS=18
ENABLE_BORROW=false
ENABLE_AS_COLLATERAL=true
ENABLE_STABLE_BORROW=false

# The below IPFS hash is invalid. Replace it with the correct value after uploading AIP to the IPFS
IPFS_HASH=QmVKuMiNYg8NpLii5EiqTnqixqQanhvjgpDy9e46NX2P3T
CHAINLINK_ORACLE_PROXY=0x86392dC19c0b719886221c78AB11eb8Cf5c52812

# For mainnet fork test: add an EOA that holds tokens
TOKEN_HOLDER=0x3e40D73EB977Dc6a537aF587D48316feE66E9C8c
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-steth.ts');
}

export const BUIDLEREVM_CHAIN_ID = 31337;
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
"test:bond": "MAINNET_FORK=true FORKING_BLOCK=12767300 hardhat test ./test/test-listing-bond.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",
"test:steth": "MAINNET_FORK=true FORKING_BLOCK=14126327 hardhat test ./test/test-listing-steth.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:rai:main": "hardhat create:proposal-new-asset:rai --network main"
"propose-new-asset:rai:main": "hardhat create:proposal-new-asset:rai --network main",
"propose-new-asset:steth:main": "PROMPT=true hardhat create:proposal-new-asset:steth --network main",
"propose-new-asset:steth:fork": "PROMPT=true MAINNET_FORK=true FORKING_BLOCK=14126327 hardhat create:proposal-new-asset:steth --network hardhat"
},
"keywords": [],
"author": "dhadrien",
Expand Down
153 changes: 153 additions & 0 deletions tasks/list-steth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import readline from 'readline';
import { getContractAt } from '@nomiclabs/hardhat-ethers/dist/src/helpers';
import { config } from 'dotenv';
import { task } from 'hardhat/config';
import { HardhatRuntimeEnvironment, TaskArguments } from 'hardhat/types';
import bs58 from 'bs58';

config();

task('create:proposal-new-asset:steth', 'Creates a proposal to list stETH')
.addFlag('dryrun', 'if provided, only generates the transaction without submitting it onchain')
.setAction(async (args: TaskArguments, _DRE: HardhatRuntimeEnvironment) => {
if (args['dryrun']) {
console.log('The script is running in dry run mode. Transactions will not be sent.');
}
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();
const executeSignature =
'execute(address,address,address,address,address,uint256,uint256,uint256,uint256,uint8,bool,bool,bool)';
const assetListingProposalGenericExecutorExecuteCallData = _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',
]
);
const setAssetSourcesSignature = 'setAssetSources(address[],address[])';
const setAssetSourceSignatureCallData = _DRE.ethers.utils.defaultAbiCoder.encode(
['address[]', 'address[]'],
[[TOKEN], [CHAINLINK_ORACLE_PROXY]]
);
const gov = await getContractAt(_DRE, 'IAaveGovernanceV2', AAVE_GOVERNANCE_V2);
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'],
[executeSignature, setAssetSourcesSignature],
[assetListingProposalGenericExecutorExecuteCallData, setAssetSourceSignatureCallData],
[true, false],
ipfsEncoded
);
console.log('Proposal Transaction:', tx);

// if the transaction is running in dry run mode, tries to call it locally to check
// that it will pass in the "battle" run
if (args['dryrun']) {
try {
console.log('Running transaction locally...');
await proposer.call(tx);
console.log('Transaction passed!');
} catch (error) {
console.error('Transaction seems to be failed!');
if (error instanceof Error) {
console.error('Next error occurred on transaction call: ', error.message);
}
}
return;
}

if (process.env.PROMPT === 'true') {
await promptToProceed();
}

console.log('Sending transaction...');
const receipt = await proposer.sendTransaction(tx).then((tx) => tx.wait());
console.log('Proposal submitted in:', receipt.transactionHash);
});

const promptToProceed = () => {
const rdl = readline.createInterface(process.stdin, process.stdout);
return new Promise<void>((resolve) => {
rdl.question('Proceed? y/n:\n', (answer) => {
rdl.close();
if (['y', 'yes'].includes(answer)) {
return resolve();
} else if (!['n', 'no'].includes(answer)) {
console.log("Please respond with 'yes' or 'no'");
}
process.exit();
});
});
};
Loading