-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dylan DesRosier
committed
Feb 17, 2022
1 parent
5b75598
commit 6efd57f
Showing
5 changed files
with
21 additions
and
17 deletions.
There are no files selected for viewing
26 changes: 14 additions & 12 deletions
26
src/calculate/calculateNormalizedUserBalancesFromTotalSupply.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
import { BigNumber } from "@ethersproject/bignumber" | ||
import { NormalizedUserBalance, UserBalance } from "../types" | ||
import { BigNumber } from '@ethersproject/bignumber'; | ||
|
||
import { NormalizedUserBalance, UserBalance } from '../types'; | ||
|
||
function calculateNormalizedUserBalancesFromTotalSupply( | ||
userBalances: UserBalance[], | ||
totalSupply: BigNumber, | ||
): NormalizedUserBalance[] { | ||
totalSupply: BigNumber | ||
): NormalizedUserBalance[] { | ||
return userBalances.map(userBalance => { | ||
return { | ||
address: userBalance.address, | ||
normalizedBalance: userBalance.balance.mul('1000000000000000000').div(totalSupply), | ||
} | ||
}) | ||
} | ||
|
||
return { | ||
address: userBalance.address, | ||
normalizedBalance: userBalance.balance | ||
.mul('1000000000000000000') | ||
.div(totalSupply), | ||
}; | ||
}); | ||
} | ||
|
||
export default calculateNormalizedUserBalancesFromTotalSupply; | ||
export default calculateNormalizedUserBalancesFromTotalSupply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function filterUndefinedValues<T>(ts: (T | undefined)[]): T[] { | ||
return ts.filter((t: T | undefined): t is T => Boolean(t)) | ||
} | ||
export default filterUndefinedValues; | ||
return ts.filter((t: T | undefined): t is T => Boolean(t)); | ||
} | ||
|
||
export default filterUndefinedValues; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters