mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
22 lines
549 B
TypeScript
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()
|
|
);
|
|
}
|