@instadapp/avocado-base 0.0.0-dev.9807f71 → 0.0.0-dev.9e8d2fb

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/nuxt.config.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  // https://nuxt.com/docs/api/configuration/nuxt-config
2
2
  export default defineNuxtConfig({
3
- modules: ["@nuxtjs/tailwindcss"],
4
- });
3
+
4
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.0-dev.9807f71",
3
+ "version": "0.0.0-dev.9e8d2fb",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "types": "global.d.ts",
@@ -14,7 +14,6 @@
14
14
  "devDependencies": {
15
15
  "@instadapp/avocado": "^0.1.10",
16
16
  "@instadapp/avocado-dev": "npm:@instadapp/avocado@dev",
17
- "@nuxtjs/tailwindcss": "^6.6.5",
18
17
  "@typechain/ethers-v5": "^10.2.0",
19
18
  "nuxt": "^3.3.3",
20
19
  "rimraf": "^3.0.2",
@@ -1,4 +1,2 @@
1
1
  export * from "../../utils/avocado";
2
2
  export * from "../../utils/network";
3
- export * from "../../utils/bignumber";
4
- export * from "../../utils/formatter";
package/utils/helper.ts CHANGED
@@ -26,29 +26,3 @@ export function sortByMany<T>(
26
26
  return result;
27
27
  });
28
28
  }
29
-
30
- export function cloneDeep<T>(value: T): T {
31
- return JSON.parse(JSON.stringify(value));
32
- }
33
-
34
- export function filterArray(array: any, filters: any) {
35
- const filterKeys = Object.keys(filters);
36
- return array.filter((item: any) => {
37
- // validates all filter criteria
38
- return filterKeys.every((key) => {
39
- // ignores non-function predicates
40
- if (typeof filters[key] !== "function") return true;
41
- return filters[key](item[key], item);
42
- });
43
- });
44
- }
45
-
46
- export function onImageError(this: HTMLImageElement) {
47
- const parentElement = this.parentElement;
48
- this.onerror = null;
49
- this.remove();
50
-
51
- if (parentElement) {
52
- parentElement.classList.add("bg-gray-300");
53
- }
54
- }
package/utils/index.ts ADDED
@@ -0,0 +1,93 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { BigNumber as BN } from "ethers";
3
+
4
+ export function shortenHash(hash: string, length: number = 4) {
5
+ if (!hash) return;
6
+ if (hash.length < 12) return hash;
7
+ const beginningChars = hash.startsWith("0x") ? length + 2 : length;
8
+ const shortened =
9
+ hash.substr(0, beginningChars) + "..." + hash.substr(-length);
10
+ return shortened;
11
+ }
12
+
13
+ export const toBN = (value: BigNumber.Value | BN) =>
14
+ new BigNumber(BN.isBigNumber(value) ? value.toString() : value);
15
+ export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero();
16
+ export const times = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
17
+ toBN(a).times(toBN(b));
18
+ export const minus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
19
+ toBN(a).minus(toBN(b));
20
+ export const plus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
21
+ toBN(a).plus(toBN(b));
22
+ export const lte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
23
+ toBN(a).lte(toBN(b));
24
+ export const gte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
25
+ toBN(a).gte(toBN(b));
26
+ export const div = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
27
+ toBN(a).div(toBN(b));
28
+ export const lt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
29
+ toBN(a).lt(toBN(b));
30
+ export const gt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
31
+ toBN(a).gt(toBN(b));
32
+ export const ensureValue = (value: any) => {
33
+ if (!value) return toBN("0");
34
+ if (toBN(value).isNaN()) return toBN("0");
35
+
36
+ return toBN(value);
37
+ };
38
+ export const max = (...args: BigNumber.Value[]) => {
39
+ return BigNumber.max(...args);
40
+ };
41
+
42
+ export function onImageError(this: HTMLImageElement) {
43
+ const parentElement = this.parentElement;
44
+ this.onerror = null;
45
+ this.remove();
46
+
47
+ if (parentElement) {
48
+ parentElement.classList.add("bg-gray-300");
49
+ }
50
+ }
51
+
52
+ const locale = "en-US";
53
+
54
+ export function formatUsd(value: any, fractionDigits = 2) {
55
+ const formatter = new Intl.NumberFormat(locale, {
56
+ style: "currency",
57
+ currency: "USD",
58
+ minimumFractionDigits: fractionDigits,
59
+ maximumFractionDigits: fractionDigits,
60
+ });
61
+
62
+ return formatter.format(value);
63
+ }
64
+
65
+ export function cloneDeep<T>(value: T): T {
66
+ return JSON.parse(JSON.stringify(value));
67
+ }
68
+
69
+ export function signedNumber(numb: string | number) {
70
+ return new Intl.NumberFormat("en-US", {
71
+ signDisplay: "exceptZero",
72
+ }).format(toBN(numb).toNumber());
73
+ }
74
+
75
+ export function formatDecimal(value: string | number, decimalPlaces = 5) {
76
+ if (!value) {
77
+ value = "0";
78
+ }
79
+
80
+ return toBN(value).decimalPlaces(decimalPlaces).toFormat();
81
+ }
82
+
83
+ export function filterArray(array: any, filters: any) {
84
+ const filterKeys = Object.keys(filters);
85
+ return array.filter((item: any) => {
86
+ // validates all filter criteria
87
+ return filterKeys.every((key) => {
88
+ // ignores non-function predicates
89
+ if (typeof filters[key] !== "function") return true;
90
+ return filters[key](item[key], item);
91
+ });
92
+ });
93
+ }
package/utils/metadata.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ethers, utils } from "ethers";
2
2
  import { Forwarder__factory } from "@/contracts";
3
+ import { toBN } from "./index";
3
4
 
4
5
  const multiMetadataTypes = ["bytes[]"];
5
6
 
package/utils/network.ts CHANGED
@@ -8,14 +8,14 @@ export const networks: Network[] = [
8
8
  debankName: "eth",
9
9
  ankrName: "eth",
10
10
  chainId: 1,
11
- explorerUrl: "https://etherscan.io",
12
- get serverRpcUrl() {
13
- return process.env?.MAINNET_RPC_URL || this.params.rpcUrls[0];
14
- },
15
- balanceResolverAddress: "0x5b7D61b389D12e1f5873d0cCEe7E675915AB5F43",
16
- usdcAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
17
11
  params: {
18
12
  rpcUrls: ["https://rpc.ankr.com/eth"],
13
+ explorerUrl: "https://etherscan.io",
14
+ get serverRpcUrl() {
15
+ return process.env?.MAINNET_RPC_URL || this.rpcUrls[0];
16
+ },
17
+ balanceResolverAddress: "0x5b7D61b389D12e1f5873d0cCEe7E675915AB5F43",
18
+ usdcAddress: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
19
19
  nativeCurrency: {
20
20
  name: "Ethereum",
21
21
  symbol: "ETH",
@@ -28,12 +28,6 @@ export const networks: Network[] = [
28
28
  debankName: "matic",
29
29
  ankrName: "polygon",
30
30
  chainId: 137,
31
- balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
32
- usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
33
- explorerUrl: "https://polygonscan.com",
34
- get serverRpcUrl() {
35
- return process.env?.POLYGON_RPC_URL || this.params.rpcUrls[0];
36
- },
37
31
  params: {
38
32
  chainName: "Matic(Polygon) Mainnet",
39
33
  nativeCurrency: {
@@ -41,7 +35,13 @@ export const networks: Network[] = [
41
35
  symbol: "MATIC",
42
36
  decimals: 18,
43
37
  },
38
+ balanceResolverAddress: "0x58632D23120b20650262b8A629a14e4F4043E0D9",
39
+ usdcAddress: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
44
40
  rpcUrls: ["https://polygon-rpc.com"],
41
+ get serverRpcUrl() {
42
+ return process.env?.POLYGON_RPC_URL || this.rpcUrls[0];
43
+ },
44
+ explorerUrl: "https://polygonscan.com",
45
45
  },
46
46
  },
47
47
  {
@@ -49,12 +49,6 @@ export const networks: Network[] = [
49
49
  debankName: "arb",
50
50
  ankrName: "arbitrum",
51
51
  chainId: 42161,
52
- usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
53
- balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
54
- explorerUrl: "https://arbiscan.io",
55
- get serverRpcUrl() {
56
- return process.env?.ARBITRUM_RPC_URL || this.params.rpcUrls[0];
57
- },
58
52
  params: {
59
53
  chainName: "Arbitrum One",
60
54
  nativeCurrency: {
@@ -62,7 +56,13 @@ export const networks: Network[] = [
62
56
  symbol: "ETH",
63
57
  decimals: 18,
64
58
  },
59
+ usdcAddress: "0xff970a61a04b1ca14834a43f5de4533ebddb5cc8",
60
+ balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
61
+ get serverRpcUrl() {
62
+ return process.env?.ARBITRUM_RPC_URL || this.rpcUrls[0];
63
+ },
65
64
  rpcUrls: ["https://arb1.arbitrum.io/rpc"],
65
+ explorerUrl: "https://arbiscan.io",
66
66
  },
67
67
  },
68
68
  {
@@ -70,12 +70,6 @@ export const networks: Network[] = [
70
70
  debankName: "op",
71
71
  ankrName: "optimism",
72
72
  chainId: 10,
73
- usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
74
- balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
75
- explorerUrl: "https://optimistic.etherscan.io",
76
- get serverRpcUrl() {
77
- return process.env?.OPTIMISM_RPC_URL || this.params.rpcUrls[0];
78
- },
79
73
  params: {
80
74
  chainName: "Optimistic Ethereum",
81
75
  nativeCurrency: {
@@ -83,7 +77,13 @@ export const networks: Network[] = [
83
77
  symbol: "ETH",
84
78
  decimals: 18,
85
79
  },
80
+ usdcAddress: "0x7f5c764cbc14f9669b88837ca1490cca17c31607",
81
+ balanceResolverAddress: "0xca5f37e6D8bB24c5A7958d5eccE7Bd9Aacc944f2",
82
+ get serverRpcUrl() {
83
+ return process.env?.OPTIMISM_RPC_URL || this.rpcUrls[0];
84
+ },
86
85
  rpcUrls: ["https://mainnet.optimism.io"],
86
+ explorerUrl: "https://optimistic.etherscan.io",
87
87
  },
88
88
  },
89
89
  {
@@ -91,20 +91,20 @@ export const networks: Network[] = [
91
91
  debankName: "avax",
92
92
  ankrName: "avalanche",
93
93
  chainId: 43114,
94
- usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
95
- balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
96
- explorerUrl: "https://snowtrace.io",
97
- get serverRpcUrl() {
98
- return process.env?.AVALANCHE_RPC_URL || this.params.rpcUrls[0];
99
- },
100
94
  params: {
101
95
  chainName: "Avalanche Network",
96
+ get serverRpcUrl() {
97
+ return process.env?.AVALANCHE_RPC_URL || this.rpcUrls[0];
98
+ },
102
99
  nativeCurrency: {
103
100
  name: "Avalanche",
104
101
  symbol: "AVAX",
105
102
  decimals: 18,
106
103
  },
104
+ usdcAddress: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
105
+ balanceResolverAddress: "0x63009f31D054E0ac9F321Cf0D642375236A4Bf1E",
107
106
  rpcUrls: ["https://api.avax.network/ext/bc/C/rpc"],
107
+ explorerUrl: "https://snowtrace.io",
108
108
  },
109
109
  },
110
110
  {
@@ -112,15 +112,15 @@ export const networks: Network[] = [
112
112
  debankName: "bsc",
113
113
  ankrName: "bsc",
114
114
  chainId: 56,
115
- explorerUrl: "https://bscscan.com",
116
- usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
117
- balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
118
- get serverRpcUrl() {
119
- return process.env?.BSC_RPC_URL || this.params.rpcUrls[0];
120
- },
121
115
  params: {
122
116
  chainName: "Binance Smart Chain",
117
+ explorerUrl: "https://bscscan.com",
123
118
  rpcUrls: ["https://rpc.ankr.com/bsc"],
119
+ get serverRpcUrl() {
120
+ return process.env?.BSC_RPC_URL || this.rpcUrls[0];
121
+ },
122
+ usdcAddress: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
123
+ balanceResolverAddress: "0xb808cff38706e267067b0af427726aa099f69f89",
124
124
  nativeCurrency: {
125
125
  name: "Binance Coin",
126
126
  symbol: "BNB",
@@ -133,15 +133,15 @@ export const networks: Network[] = [
133
133
  debankName: "xdai",
134
134
  ankrName: "gnosis",
135
135
  chainId: 100,
136
- balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
137
- explorerUrl: "https://gnosisscan.io",
138
- usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
139
- get serverRpcUrl() {
140
- return process.env?.GNOSIS_RPC_URL || this.params.rpcUrls[0];
141
- },
142
136
  params: {
143
137
  chainName: "Gnosis Safe",
138
+ explorerUrl: "https://gnosisscan.io",
144
139
  rpcUrls: ["https://rpc.ankr.com/gnosis"],
140
+ get serverRpcUrl() {
141
+ return process.env?.GNOSIS_RPC_URL || this.rpcUrls[0];
142
+ },
143
+ balanceResolverAddress: "0xfaa244e276b1597f663975ed007ee4ff70d27849",
144
+ usdcAddress: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
145
145
  nativeCurrency: {
146
146
  name: "xdaistable",
147
147
  symbol: "xDAI",
@@ -152,16 +152,15 @@ export const networks: Network[] = [
152
152
  {
153
153
  name: "Polygon zkEVM",
154
154
  chainId: 1101,
155
- explorerUrl: "https://zkevm.polygonscan.com",
156
- balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
157
- usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
158
- get serverRpcUrl() {
159
- return process.env?.POLYGON_ZKEVM_RPC_URL || this.params.rpcUrls[0];
160
- },
161
155
  params: {
162
156
  chainName: "polygon zkEVM",
157
+ explorerUrl: "https://zkevm.polygonscan.com",
163
158
  rpcUrls: ["https://rpc.ankr.com/polygon_zkevm"],
164
-
159
+ get serverRpcUrl() {
160
+ return process.env?.POLYGON_ZKEVM_RPC_URL || this.rpcUrls[0];
161
+ },
162
+ balanceResolverAddress: "0x48D1Fa5Ee6691a1E0B45d2B515650997BEA27a01",
163
+ usdcAddress: "0xa8ce8aee21bc2a48a5ef670afcc9274c7bbbc035",
165
164
  nativeCurrency: {
166
165
  name: "Ethereum",
167
166
  symbol: "ETH",
@@ -173,10 +172,6 @@ export const networks: Network[] = [
173
172
  name: AVO_PROD_CHAIN_NAME,
174
173
  chainId: AVO_PROD_CHAIN_ID,
175
174
  isAvocado: true,
176
- balanceResolverAddress: "",
177
- usdcAddress: "",
178
- serverRpcUrl: AVO_PROD_RPC_URL,
179
- explorerUrl: AVO_PROD_EXPLORER_URL,
180
175
  params: {
181
176
  chainName: AVO_PROD_CHAIN_NAME,
182
177
  nativeCurrency: {
@@ -185,17 +180,17 @@ export const networks: Network[] = [
185
180
  decimals: 18,
186
181
  },
187
182
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
183
+ balanceResolverAddress: "",
184
+ usdcAddress: "",
185
+ serverRpcUrl: AVO_PROD_RPC_URL,
188
186
  rpcUrls: [AVO_PROD_RPC_URL],
187
+ explorerUrl: AVO_PROD_EXPLORER_URL,
189
188
  },
190
189
  },
191
190
  {
192
191
  name: AVO_STAGING_CHAIN_NAME,
193
192
  chainId: AVO_STAGING_CHAIN_ID,
194
- serverRpcUrl: AVO_STAGING_RPC_URL,
195
- explorerUrl: AVO_STAGING_EXPLORER_URL,
196
193
  isAvocado: true,
197
- balanceResolverAddress: "",
198
- usdcAddress: "",
199
194
  params: {
200
195
  chainName: AVO_STAGING_CHAIN_NAME,
201
196
  nativeCurrency: {
@@ -203,8 +198,12 @@ export const networks: Network[] = [
203
198
  symbol: "USDC",
204
199
  decimals: 18,
205
200
  },
201
+ serverRpcUrl: AVO_STAGING_RPC_URL,
202
+ balanceResolverAddress: "",
203
+ usdcAddress: "",
206
204
  iconUrls: ["https://avocado.instadapp.io/logo.svg"],
207
205
  rpcUrls: [AVO_STAGING_RPC_URL],
206
+ explorerUrl: AVO_STAGING_EXPLORER_URL,
208
207
  },
209
208
  },
210
209
  ];
@@ -243,7 +242,7 @@ export const getServerRpcProvider = (chainId: number | string) => {
243
242
  if (!rpcInstances[chainId]) {
244
243
  const network = networks.find((n) => n.chainId == chainId);
245
244
  serverRpcInstances[chainId] = new ethers.providers.JsonRpcProvider(
246
- network?.serverRpcUrl
245
+ network?.params.serverRpcUrl
247
246
  );
248
247
  }
249
248
 
@@ -265,5 +264,5 @@ export const getExplorerUrl = (
265
264
  suffix: `/${string}` = "/"
266
265
  ) => {
267
266
  const network = getNetworkByChainId(chainId);
268
- return `${network.explorerUrl}${suffix}`;
267
+ return `${network.params.explorerUrl}${suffix}`;
269
268
  };
package/utils/utils.d.ts CHANGED
@@ -8,14 +8,14 @@ interface Network {
8
8
  ankrName?: string;
9
9
  chainId: ChainId;
10
10
  isAvocado?: boolean;
11
- serverRpcUrl: string | undefined;
12
- balanceResolverAddress?: string;
13
- usdcAddress: string;
14
- explorerUrl: string;
15
11
  params: {
16
12
  chainName?: string;
17
- iconUrls?: string[];
18
13
  rpcUrls: string[];
14
+ serverRpcUrl: string | undefined;
15
+ balanceResolverAddress?: string;
16
+ usdcAddress: string;
17
+ explorerUrl: string;
18
+ iconUrls?: string[];
19
19
  nativeCurrency?: {
20
20
  name: string;
21
21
  symbol: string;
package/app.vue DELETED
@@ -1,20 +0,0 @@
1
- <template>
2
- <div class="container mx-auto">
3
- Networks:
4
- <ul class="grid grid-cols-5 gap-5">
5
- <li class="w-fit" v-for="network in networks">
6
- <p>
7
- {{ network.name }}
8
- </p>
9
- <p>
10
- {{ network.chainId }}
11
- </p>
12
- <div class="flex items-center gap-2">
13
- <ChainLogo class="w-8 h-8" :chain="network.chainId" />
14
- <ChainLogo stroke class="w-8 h-8" :chain="network.chainId" />
15
- </div>
16
- </li>
17
- </ul>
18
- </div>
19
- <ul></ul>
20
- </template>
@@ -1,31 +0,0 @@
1
- import { BigNumber } from "bignumber.js";
2
- import { BigNumber as BN } from "ethers";
3
-
4
- export const toBN = (value: BigNumber.Value | BN) =>
5
- new BigNumber(BN.isBigNumber(value) ? value.toString() : value);
6
- export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero();
7
- export const times = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
8
- toBN(a).times(toBN(b));
9
- export const minus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
10
- toBN(a).minus(toBN(b));
11
- export const plus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
12
- toBN(a).plus(toBN(b));
13
- export const lte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
14
- toBN(a).lte(toBN(b));
15
- export const gte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
16
- toBN(a).gte(toBN(b));
17
- export const div = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
18
- toBN(a).div(toBN(b));
19
- export const lt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
20
- toBN(a).lt(toBN(b));
21
- export const gt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
22
- toBN(a).gt(toBN(b));
23
- export const ensureValue = (value: any) => {
24
- if (!value) return toBN("0");
25
- if (toBN(value).isNaN()) return toBN("0");
26
-
27
- return toBN(value);
28
- };
29
- export const max = (...args: BigNumber.Value[]) => {
30
- return BigNumber.max(...args);
31
- };
@@ -1,51 +0,0 @@
1
- export function formatPercent(
2
- value: number,
3
- fractionDigits = 2,
4
- maxValue = null
5
- ) {
6
- if (isZero(value)) return "0.00%";
7
-
8
- if (maxValue && gt(times(value, "100"), maxValue)) return `>${maxValue}%`;
9
-
10
- const formatter = new Intl.NumberFormat("en-US", {
11
- style: "percent",
12
- minimumFractionDigits: fractionDigits,
13
- maximumFractionDigits: fractionDigits,
14
- });
15
-
16
- return formatter.format(value);
17
- }
18
-
19
- export function shortenHash(hash: string, length: number = 4) {
20
- if (!hash) return;
21
- if (hash.length < 12) return hash;
22
- const beginningChars = hash.startsWith("0x") ? length + 2 : length;
23
- const shortened =
24
- hash.substr(0, beginningChars) + "..." + hash.substr(-length);
25
- return shortened;
26
- }
27
-
28
- export function formatUsd(value: any, fractionDigits = 2) {
29
- const formatter = new Intl.NumberFormat("en-US", {
30
- style: "currency",
31
- currency: "USD",
32
- minimumFractionDigits: fractionDigits,
33
- maximumFractionDigits: fractionDigits,
34
- });
35
-
36
- return formatter.format(value);
37
- }
38
-
39
- export function signedNumber(numb: string | number) {
40
- return new Intl.NumberFormat("en-US", {
41
- signDisplay: "exceptZero",
42
- }).format(toBN(numb).toNumber());
43
- }
44
-
45
- export function formatDecimal(value: string | number, decimalPlaces = 5) {
46
- if (!value) {
47
- value = "0";
48
- }
49
-
50
- return toBN(value).decimalPlaces(decimalPlaces).toFormat();
51
- }