From c536a04df4957ac32e763bac924253756fb42a10 Mon Sep 17 00:00:00 2001 From: tjs Date: Wed, 25 May 2022 20:27:52 -0400 Subject: [PATCH] add constants for token decimals --- .../src/{constants.ts => constants/index.ts} | 0 ts/client/src/constants/tokens.ts | 15 +++++++++++++++ 2 files changed, 15 insertions(+) rename ts/client/src/{constants.ts => constants/index.ts} (100%) create mode 100644 ts/client/src/constants/tokens.ts diff --git a/ts/client/src/constants.ts b/ts/client/src/constants/index.ts similarity index 100% rename from ts/client/src/constants.ts rename to ts/client/src/constants/index.ts diff --git a/ts/client/src/constants/tokens.ts b/ts/client/src/constants/tokens.ts new file mode 100644 index 000000000..9b7cc3ee8 --- /dev/null +++ b/ts/client/src/constants/tokens.ts @@ -0,0 +1,15 @@ +export const getTokenDecimals = (symbol: string) => { + const tokenMeta = tokens.find((t) => t.symbol === symbol); + + if (!tokenMeta) throw new Error('TokenDecimalError: Token not found'); + + return tokenMeta.decimals; +}; + +const tokens = [ + { symbol: 'USDC', decimals: 6 }, + { symbol: 'SOL', decimals: 9 }, + { symbol: 'BTC', decimals: 6 }, +]; + +export default tokens;