-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dashboard: move CollapsibleSection into component
cloud_functions: use bignumber to handle bigint Signed-off-by: bingyuyap <bingyu.yap.21@gmail.com>
- Loading branch information
Showing
11 changed files
with
170 additions
and
132 deletions.
There are no files selected for viewing
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
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
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,18 +1,44 @@ | ||
import { ChainId } from '@wormhole-foundation/sdk-base'; | ||
|
||
export type TokenAmount = { | ||
amount: string; | ||
decimals: number; | ||
}; | ||
|
||
export function normalizeToDecimals(tokenAmount: TokenAmount, targetDecimals: number): bigint { | ||
const { amount, decimals } = tokenAmount; | ||
const bigIntAmount = BigInt(amount); | ||
let normalizedAmount: bigint; | ||
|
||
if (decimals < targetDecimals) { | ||
// If less decimals, multiply to shift the decimal point to the right | ||
const factor = BigInt(10 ** (targetDecimals - decimals)); | ||
normalizedAmount = bigIntAmount * factor; | ||
} else if (decimals > targetDecimals) { | ||
// If more decimals, divide to shift the decimal point to the left | ||
const factor = BigInt(10 ** (decimals - targetDecimals)); | ||
normalizedAmount = bigIntAmount / factor; | ||
} else { | ||
normalizedAmount = bigIntAmount; | ||
} | ||
|
||
return normalizedAmount; | ||
} | ||
|
||
export type NTTTotalSupplyAndLockedData = { | ||
tokenName: string; | ||
chain: ChainId; | ||
amountLocked?: Number; | ||
totalSupply: Number; | ||
// this is bigint but for the sake of precision we are using string | ||
amountLocked?: TokenAmount; | ||
totalSupply?: TokenAmount; | ||
evmTotalSupply?: NTTTotalSupplyAndLockedData[]; | ||
}; | ||
|
||
export type NTTRateLimit = { | ||
tokenName: string; | ||
srcChain?: ChainId; | ||
destChain?: ChainId; | ||
amount?: string; | ||
totalInboundCapacity?: string; | ||
amount?: TokenAmount; | ||
totalInboundCapacity?: TokenAmount; | ||
inboundCapacity?: NTTRateLimit[]; | ||
}; |
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
Oops, something went wrong.