Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

First pass on adding Set market migration scripts. Still some general… #1

Open
wants to merge 5 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
8 changes: 5 additions & 3 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number
? `https://eth-${
networkName === 'main' ? 'mainnet' : networkName
}.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://${networkName}.infura.io/v3/${INFURA_KEY}`,
: `https://${
networkName === 'main' ? 'mainnet' : networkName
}.infura.io/v3/${INFURA_KEY}`,
hardfork: HARDFORK,
blockGasLimit: DEFAULT_BLOCK_GAS_LIMIT,
gasMultiplier: DEFAULT_GAS_MUL,
Expand All @@ -62,10 +64,10 @@ const getCommonNetworkConfig = (networkName: eEthereumNetwork, networkId: number

const mainnetFork = MAINNET_FORK
? {
blockNumber: 11366117,
blockNumber: 11583338,
url: ALCHEMY_KEY
? `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`
: `https://main.infura.io/v3/${INFURA_KEY}`,
: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
}
: undefined;

Expand Down
8 changes: 6 additions & 2 deletions helpers/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './types';
import { getParamPerPool } from './contracts-helpers';
import AaveConfig from '../markets/aave';
import SetConfig from '../markets/set';
import { CommonsConfig } from '../markets/aave/commons';
import { DRE, filterMapBy } from './misc-utils';
import { tEthereumAddress } from './types';
Expand All @@ -18,12 +19,15 @@ export enum ConfigNames {
Commons = 'Commons',
Aave = 'Aave',
Uniswap = 'Uniswap',
Set = 'Set'
}

export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
switch (configName) {
case ConfigNames.Aave:
return AaveConfig;
case ConfigNames.Set:
return SetConfig;
case ConfigNames.Commons:
return CommonsConfig;
default:
Expand All @@ -35,11 +39,11 @@ export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
// PROTOCOL PARAMS PER POOL
// ----------------

export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IReserveParams> =>
export const getReservesConfigByPool = (pool: AavePools, config: PoolConfiguration): iMultiPoolsAssets<IReserveParams> =>
getParamPerPool<iMultiPoolsAssets<IReserveParams>>(
{
[AavePools.proto]: {
...AaveConfig.ReservesConfig,
...config.ReservesConfig,
},
},
pool
Expand Down
6 changes: 2 additions & 4 deletions helpers/contracts-deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,9 @@ export const deployDelegationAwareAToken = async (
);
};

export const deployAllMockTokens = async (verify?: boolean) => {
export const deployAllMockTokens = async (config: PoolConfiguration, verify?: boolean) => {
const tokens: { [symbol: string]: MockContract | MintableERC20 } = {};

const protoConfigData = getReservesConfigByPool(AavePools.proto);

const protoConfigData = getReservesConfigByPool(AavePools.proto, config);
for (const tokenSymbol of Object.keys(TokenContractId)) {
let decimals = '18';

Expand Down
2 changes: 1 addition & 1 deletion helpers/contracts-getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export const getPairsTokenAggregator = (
},
aggregatorsAddresses: { [tokenSymbol: string]: tEthereumAddress }
): [string[], string[]] => {
const { ETH, USD, WETH, ...assetsAddressesWithoutEth } = allAssetsAddresses;
const { ETH, USD, WETH, SetWETH, ...assetsAddressesWithoutEth } = allAssetsAddresses;

const pairs = Object.entries(assetsAddressesWithoutEth).map(([tokenSymbol, tokenAddress]) => {
if (tokenSymbol !== 'WETH' && tokenSymbol !== 'ETH') {
Expand Down
19 changes: 19 additions & 0 deletions helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export enum EthereumNetworkNames {

export enum AavePools {
proto = 'proto',
set = 'set'
}

export enum eContractid {
Expand Down Expand Up @@ -200,6 +201,11 @@ export interface iAssetBase<T> {
USD: T;
REN: T;
ENJ: T;
DPI: T;
SetDAI: T;
SetUSDC: T;
SetUSDT: T;
SetWETH: T;
}

export type iAssetsWithoutETH<T> = Omit<iAssetBase<T>, 'ETH'>;
Expand Down Expand Up @@ -230,6 +236,15 @@ export type iAavePoolAssets<T> = Pick<
| 'ENJ'
>;

export type iSetPoolAssets<T> = Pick<
iAssetsWithoutUSD<T>,
| 'SetDAI'
| 'SetUSDC'
| 'SetUSDT'
| 'SetWETH'
| 'DPI'
>;

export type iMultiPoolsAssets<T> = iAssetCommon<T> | iAavePoolAssets<T>;

export type iAavePoolTokens<T> = Omit<iAavePoolAssets<T>, 'ETH'>;
Expand Down Expand Up @@ -258,6 +273,7 @@ export enum TokenContractId {
YFI = 'YFI',
UNI = 'UNI',
ENJ = 'ENJ',
DPI = 'DPI',
}

export interface IReserveParams extends IReserveBorrowParams, IReserveCollateralParams {
Expand Down Expand Up @@ -372,6 +388,9 @@ export interface ICommonConfiguration {
export interface IAaveConfiguration extends ICommonConfiguration {
ReservesConfig: iAavePoolAssets<IReserveParams>;
}
export interface ISetConfiguration extends ICommonConfiguration {
ReservesConfig: iSetPoolAssets<IReserveParams>;
}
export interface ITokenAddress {
[token: string]: tEthereumAddress;
}
Expand Down
26 changes: 26 additions & 0 deletions markets/aave/commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ const MOCK_CHAINLINK_AGGREGATORS_PRICES = {
BAT: oneEther.multipliedBy('0.00137893825230').toFixed(),
BUSD: oneEther.multipliedBy('0.00736484').toFixed(),
DAI: oneEther.multipliedBy('0.00369068412860').toFixed(),
DPI: oneEther.multipliedBy('0.15694444444444').toFixed(),
ENJ: oneEther.multipliedBy('0.00029560').toFixed(),
KNC: oneEther.multipliedBy('0.001072').toFixed(),
LINK: oneEther.multipliedBy('0.009955').toFixed(),
MANA: oneEther.multipliedBy('0.000158').toFixed(),
MKR: oneEther.multipliedBy('2.508581').toFixed(),
REN: oneEther.multipliedBy('0.00065133').toFixed(),
SetDAI: oneEther.multipliedBy('0.00369068412860').toFixed(),
SetUSDC: oneEther.multipliedBy('0.00369068412860').toFixed(),
SetUSDT: oneEther.multipliedBy('0.00369068412860').toFixed(),
SetWETH: oneEther.toFixed(),
SNX: oneEther.multipliedBy('0.00442616').toFixed(),
SUSD: oneEther.multipliedBy('0.00364714136416').toFixed(),
TUSD: oneEther.multipliedBy('0.00364714136416').toFixed(),
Expand Down Expand Up @@ -109,6 +114,15 @@ export const CommonsConfig: ICommonConfiguration = {
BUSD: {
borrowRate: oneRay.multipliedBy(0.05).toFixed(),
},
SetDAI: {
borrowRate: oneRay.multipliedBy(0.039).toFixed(),
},
SetUSDC: {
borrowRate: oneRay.multipliedBy(0.039).toFixed(),
},
SetUSDT: {
borrowRate: oneRay.multipliedBy(0.035).toFixed(),
},
},
// ----------------
// COMMON PROTOCOL ADDRESSES ACROSS POOLS
Expand Down Expand Up @@ -205,6 +219,9 @@ export const CommonsConfig: ICommonConfiguration = {
MANA: '0x1b93D8E109cfeDcBb3Cc74eD761DE286d5771511',
MKR: '0x0B156192e04bAD92B6C1C13cf8739d14D78D5701',
REN: '0xF1939BECE7708382b5fb5e559f630CB8B39a10ee',
SetDAI: '0x22B58f1EbEDfCA50feF632bD73368b2FdA96D541',
SetUSDC: '0x64EaC61A2DFda2c3Fa04eED49AA33D021AeC8838',
SetUSDT: '0x0bF499444525a23E7Bb61997539725cA2e928138',
SNX: '0xF9A76ae7a1075Fe7d646b06fF05Bd48b9FA5582e',
SUSD: '0xb343e7a1aF578FA35632435243D814e7497622f7',
TUSD: '0x7aeCF1c19661d12E962b69eBC8f6b2E63a55C660',
Expand All @@ -227,6 +244,9 @@ export const CommonsConfig: ICommonConfiguration = {
MANA: '0xDab909dedB72573c626481fC98CEE1152b81DEC2',
MKR: '0x811B1f727F8F4aE899774B568d2e72916D91F392',
REN: ZERO_ADDRESS,
SetDAI: '0x64b8e49baded7bfb2fd5a9235b2440c0ee02971b',
SetUSDC: '0xe1480303dde539e2c241bdc527649f37c9cbef7d',
SetUSDT: '0xc08fe0c4d97ccda6b40649c6da621761b628c288',
SNX: '0xA95674a8Ed9aa9D2E445eb0024a9aa05ab44f6bf',
SUSD: '0xe054b4aee7ac7645642dd52f1c892ff0128c98f0',
TUSD: '0x523ac85618df56e940534443125ef16daf785620',
Expand All @@ -249,6 +269,9 @@ export const CommonsConfig: ICommonConfiguration = {
MANA: '0x82A44D92D6c329826dc557c5E1Be6ebeC5D5FeB9',
MKR: '0x24551a8Fb2A7211A25a17B1481f043A8a8adC7f2',
REN: '0x3147D7203354Dc06D9fd350c7a2437bcA92387a4',
SetDAI: '0x773616E4d11A78F511299002da57A0a94577F1f4',
SetUSDC: '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4',
SetUSDT: '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46',
SNX: '0x79291A9d692Df95334B1a0B3B4AE6bC606782f8c',
SUSD: '0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757',
TUSD: '0x3886BA987236181D98F2401c507Fb8BeA7871dF2',
Expand All @@ -271,6 +294,9 @@ export const CommonsConfig: ICommonConfiguration = {
MANA: '0x82A44D92D6c329826dc557c5E1Be6ebeC5D5FeB9',
MKR: '0x24551a8Fb2A7211A25a17B1481f043A8a8adC7f2',
REN: '0x3147D7203354Dc06D9fd350c7a2437bcA92387a4',
SetDAI: '0x773616E4d11A78F511299002da57A0a94577F1f4',
SetUSDC: '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4',
SetUSDT: '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46',
SNX: '0x79291A9d692Df95334B1a0B3B4AE6bC606782f8c',
SUSD: '0x8e0b7e6062272B5eF4524250bFFF8e5Bd3497757',
TUSD: '0x3886BA987236181D98F2401c507Fb8BeA7871dF2',
Expand Down
Loading