2020-08-25 12:15:35 +00:00
|
|
|
import {
|
|
|
|
AavePools,
|
|
|
|
iMultiPoolsAssets,
|
|
|
|
IReserveParams,
|
2020-08-25 15:15:27 +00:00
|
|
|
PoolConfiguration,
|
2020-08-25 12:15:35 +00:00
|
|
|
tEthereumAddress,
|
|
|
|
iBasicDistributionParams,
|
|
|
|
} from './types';
|
|
|
|
import {getParamPerPool} from './contracts-helpers';
|
|
|
|
import {AaveConfig} from '../config/aave';
|
|
|
|
import {UniswapConfig} from '../config/uniswap';
|
|
|
|
import {ZERO_ADDRESS} from './constants';
|
|
|
|
|
2020-08-25 15:15:27 +00:00
|
|
|
export enum ConfigNames {
|
|
|
|
Commons = 'Commons',
|
|
|
|
Aave = 'Aave',
|
|
|
|
Uniswap = 'Uniswap',
|
|
|
|
}
|
2020-08-25 12:15:35 +00:00
|
|
|
|
2020-08-25 15:15:27 +00:00
|
|
|
export const loadPoolConfig = (configName: ConfigNames): PoolConfiguration => {
|
|
|
|
switch (configName) {
|
|
|
|
case ConfigNames.Aave:
|
|
|
|
return AaveConfig;
|
|
|
|
case ConfigNames.Uniswap:
|
|
|
|
return UniswapConfig;
|
|
|
|
default:
|
|
|
|
throw new Error(`Unsupported pool configuration: ${Object.values(ConfigNames)}`);
|
|
|
|
}
|
|
|
|
};
|
2020-08-25 12:15:35 +00:00
|
|
|
|
|
|
|
// ----------------
|
|
|
|
// PROTOCOL PARAMS PER POOL
|
|
|
|
// ----------------
|
|
|
|
|
|
|
|
export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IReserveParams> =>
|
|
|
|
getParamPerPool<iMultiPoolsAssets<IReserveParams>>(
|
|
|
|
{
|
|
|
|
[AavePools.proto]: {
|
|
|
|
...AaveConfig.ReservesConfig,
|
|
|
|
},
|
|
|
|
[AavePools.secondary]: {
|
|
|
|
...UniswapConfig.ReservesConfig,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
pool
|
|
|
|
);
|
|
|
|
|
|
|
|
export const getFeeDistributionParamsCommon = (
|
|
|
|
receiver: tEthereumAddress
|
|
|
|
): iBasicDistributionParams => {
|
|
|
|
const receivers = [receiver, ZERO_ADDRESS];
|
|
|
|
const percentages = ['2000', '8000'];
|
|
|
|
return {
|
|
|
|
receivers,
|
|
|
|
percentages,
|
|
|
|
};
|
|
|
|
};
|