aave-protocol-v2/test-suites/test-aave/helpers/rewards-distribution/base-maths.ts

22 lines
549 B
TypeScript

import { BigNumber } from 'ethers';
import {
BigNumberValue,
ethersValueToZDBigNumber,
valueToZDBigNumber,
} from '../utils/ray-math/bignumber';
export function getRewards(
balance: BigNumber,
assetIndex: BigNumber,
userIndex: BigNumber,
precision: number = 18
): BigNumber {
return BigNumber.from(
ethersValueToZDBigNumber(balance)
.multipliedBy(ethersValueToZDBigNumber(assetIndex).minus(ethersValueToZDBigNumber(userIndex)))
.dividedBy(valueToZDBigNumber(10).exponentiatedBy(precision))
.toString()
);
}