mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Updated PercentageMath to support two decimals of precision
This commit is contained in:
parent
11e06e2e92
commit
692cc87f62
|
@ -13,7 +13,7 @@ import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol';
|
|||
library PercentageMath {
|
||||
using SafeMath for uint256;
|
||||
|
||||
uint256 constant PERCENTAGE_FACTOR = 1e2; //percentage plus two decimals
|
||||
uint256 constant PERCENTAGE_FACTOR = 1e4; //percentage plus two decimals
|
||||
uint256 constant HALF_PERCENT = PERCENTAGE_FACTOR / 2;
|
||||
|
||||
function percentMul(uint256 value, uint256 percentage) internal pure returns (uint256) {
|
||||
|
|
|
@ -170,9 +170,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '75',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
baseLTVAsCollateral: '7500',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -183,9 +183,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '75',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
baseLTVAsCollateral: '7500',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -196,9 +196,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '75',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
baseLTVAsCollateral: '7500',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '6',
|
||||
|
@ -210,8 +210,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '6',
|
||||
|
@ -223,8 +223,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -235,9 +235,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '115',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -248,9 +248,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -261,9 +261,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '75',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
baseLTVAsCollateral: '7500',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -274,9 +274,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '65',
|
||||
liquidationThreshold: '70',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6500',
|
||||
liquidationThreshold: '7000',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -287,9 +287,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '115',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '8',
|
||||
|
@ -300,9 +300,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -313,9 +313,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -326,9 +326,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -339,9 +339,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -352,9 +352,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '60',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6000',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: true,
|
||||
reserveDecimals: '18',
|
||||
|
@ -366,8 +366,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '65',
|
||||
liquidationBonus: '110',
|
||||
liquidationThreshold: '6500',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -379,8 +379,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.14).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '110',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -394,8 +394,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.1).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -407,8 +407,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.06).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -420,8 +420,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.06).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '6',
|
||||
|
@ -433,8 +433,8 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
stableRateSlope1: new BigNumber(0.06).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '-1',
|
||||
liquidationThreshold: '80',
|
||||
liquidationBonus: '105',
|
||||
liquidationThreshold: '8000',
|
||||
liquidationBonus: '10500',
|
||||
borrowingEnabled: true,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '6',
|
||||
|
@ -445,9 +445,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '68',
|
||||
liquidationThreshold: '73',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6800',
|
||||
liquidationThreshold: '7300',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -458,9 +458,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '68',
|
||||
liquidationThreshold: '73',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6800',
|
||||
liquidationThreshold: '7300',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -471,9 +471,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '48',
|
||||
liquidationThreshold: '66',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '4800',
|
||||
liquidationThreshold: '6600',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -484,9 +484,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '51',
|
||||
liquidationThreshold: '66',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '5100',
|
||||
liquidationThreshold: '6600',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -497,9 +497,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '63',
|
||||
liquidationThreshold: '68',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '6300',
|
||||
liquidationThreshold: '6800',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
@ -510,9 +510,9 @@ export const getReservesConfigByPool = (pool: AavePools): iMultiPoolsAssets<IRes
|
|||
variableRateSlope2: new BigNumber(0.5).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope1: new BigNumber(0.16).multipliedBy(oneRay).toFixed(),
|
||||
stableRateSlope2: new BigNumber(0.6).multipliedBy(oneRay).toFixed(),
|
||||
baseLTVAsCollateral: '48',
|
||||
liquidationThreshold: '66',
|
||||
liquidationBonus: '110',
|
||||
baseLTVAsCollateral: '4800',
|
||||
liquidationThreshold: '6600',
|
||||
liquidationBonus: '11000',
|
||||
borrowingEnabled: false,
|
||||
stableBorrowRateEnabled: false,
|
||||
reserveDecimals: '18',
|
||||
|
|
|
@ -64,7 +64,7 @@ makeSuite('LendingPool liquidation - liquidator receiving aToken', (testEnv) =>
|
|||
const userGlobalDataAfter = await pool.getUserAccountData(borrower.address);
|
||||
|
||||
expect(userGlobalDataAfter.currentLiquidationThreshold).to.be.bignumber.equal(
|
||||
'80',
|
||||
'8000',
|
||||
'Invalid liquidation threshold'
|
||||
);
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ makeSuite('LendingPool liquidation - liquidator receiving the underlying asset',
|
|||
const userGlobalDataAfter: any = await pool.getUserAccountData(borrower.address);
|
||||
|
||||
expect(userGlobalDataAfter.currentLiquidationThreshold.toString()).to.be.bignumber.equal(
|
||||
'80',
|
||||
'8000',
|
||||
'Invalid liquidation threshold'
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user