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

List FRAX #18

Open
wants to merge 8 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 .frax.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# DEFAULT_GAS_PRICE= 50 GWEI by default

TOKEN=0x853d955aCEf822Db058eb8505911ED77F175b99e
ATOKEN=0x6efD37b3015AeA0E19418f98661488A4D2D3C377
STABLE_DEBT_TOKEN=0x7E3Ddfceef69bEC3A38Fc9AE8D7A8c46D7788C6b
VARIABLE_DEBT_TOKEN=0x08FFf652bEF777634585707B17627c9274E3dB11
INTEREST_STRATEGY=0xb0a73aC3B10980A598685d4631c83f5348F5D32c
LTV=0
LIQUIDATION_THRESHOLD=0
LIQUIDATION_BONUS=0
RESERVE_FACTOR=2000
DECIMALS=18
ENABLE_BORROW=true
ENABLE_AS_COLLATERAL=false
ENABLE_STABLE_BORROW=false
IPFS_HASH=Qmby95BYfKszQxMPDmbyGzF6vnkpPQCjsMaJLyx9sxixUH
CHAINLINK_ORACLE_PROXY=0x14d04Fff8D21bd62987a5cE9ce543d2F1edF5D3E

# 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 @@ -12,6 +12,7 @@ if (process.env.SKIP_LOAD !== 'true') {
// eslint-disable-next-line global-require
require('./tasks/list-new-asset.ts');
require('./tasks/list-rai.ts');
require('./tasks/list-frax.ts');
require('./tasks/list-bond.ts');
}

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
"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:frax": "MAINNET_FORK=true FORKING_BLOCK=13172214 hardhat test ./test/test-listing-frax.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:frax:main": "hardhat create:proposal-new-asset:frax --network main"
},
"keywords": [],
"author": "dhadrien",
Expand Down
125 changes: 125 additions & 0 deletions tasks/list-frax.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
import { task } from 'hardhat/config';
import '@nomiclabs/hardhat-ethers';
import { getContractAt } from '@nomiclabs/hardhat-ethers/dist/src/helpers';
import { config } from 'dotenv';
import { IAaveGovernanceV2 } from '../types/IAaveGovernanceV2';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const bs58 = require('bs58');

config();

task('create:proposal-new-asset:frax', 'Get the calldata to make a proposal to list FRAX')
// eslint-disable-next-line no-empty-pattern
.setAction(async ({}, _DRE: any) => {
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
} = 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
) {
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 genericPayloadAddress = (
await _DRE.deployments.get('AssetListingProposalGenericExecutor')
).address;
console.log(genericPayloadAddress)
const executeSignature =
'execute(address,address,address,address,address,uint256,uint256,uint256,uint256,uint8,bool,bool,bool)';
const executeCallData = _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 setAssetSignature = 'setAssetSources(address[],address[])';
const setAssetCallData = _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,
[genericPayloadAddress, AAVE_PRICE_ORACLE_V2],
['0', '0'],
[executeSignature, setAssetSignature],
[executeCallData, setAssetCallData],
[true, false],
ipfsEncoded
)

console.log("Your Proposal:", tx);

await (await proposer.sendTransaction(tx)).wait()
});
Loading