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 alUSD #22

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

TOKEN=0xBC6DA0FE9aD5f3b0d58160288917AA56653660E9
ATOKEN=0x174aC37dD1db54516D00887E0E84697423Eefa9b
STABLE_DEBT_TOKEN=0x1D708aB94699717A4A8d725431d322D418A166E8
VARIABLE_DEBT_TOKEN=0xE2B3b50CF9b36C8d066e5da994B97cae6a268482
INTEREST_STRATEGY=0x0CFc9A0F66692179abCA661a610851bdf6fAE0F0
LTV=0
LIQUIDATION_THRESHOLD=0
LIQUIDATION_BONUS=0
RESERVE_FACTOR=2000
DECIMALS=18
ENABLE_BORROW=true
ENABLE_STABLE_BORROW=true
ENABLE_AS_COLLATERAL=false
CHAINLINK_ORACLE_PROXY=0xF55DB61d1e65718ac0d5A163B18CCA3645791265

TOKEN_HOLDER=0xB05136FAcE3F8c6f9e6CDb076a38Ee6D4910f6d4
FORKING_BLOCK=14367337

# IPFS hash is a placeholder until PR is merged
IPFS_HASH=QmNfU4FMdQriJVQeqQTNxgY63iSJVh8yCJf8aFDkQDjaLQ
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-alusd.ts')
}

export const BUIDLEREVM_CHAIN_ID = 31337;
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:alusd": "MAINNET_FORK=true FORKING_BLOCK=14367337 hardhat test ./test/test-listing-alusd.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:alusd:main": "hardhat create:proposal-new-asset:alusd --network main"
},
"keywords": [],
"author": "dhadrien",
Expand Down
125 changes: 125 additions & 0 deletions tasks/list-alusd.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:alusd', 'Get the calldata to make a proposal to list ALUSD')
// 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