@instadapp/avocado-base 0.0.0-dev.0d5070b → 0.0.0-dev.0e696bd

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.
Files changed (93) hide show
  1. package/abi/avoFactoryProxy.json +109 -0
  2. package/abi/balanceResolver.json +110 -0
  3. package/abi/erc20.json +350 -0
  4. package/abi/forwarder.json +1435 -0
  5. package/abi/gaslessWallet.json +289 -0
  6. package/app.vue +27 -0
  7. package/assets/images/icons/arrow-left.svg +5 -0
  8. package/assets/images/icons/arrow-right.svg +5 -0
  9. package/assets/images/icons/avocado.svg +4 -0
  10. package/assets/images/icons/bridge-2.svg +3 -0
  11. package/assets/images/icons/bridge.svg +7 -0
  12. package/assets/images/icons/calendar.svg +8 -0
  13. package/assets/images/icons/change-threshold.svg +4 -0
  14. package/assets/images/icons/check-circle.svg +4 -0
  15. package/assets/images/icons/chevron-down.svg +4 -0
  16. package/assets/images/icons/clipboard.svg +7 -0
  17. package/assets/images/icons/clock-circle.svg +5 -0
  18. package/assets/images/icons/copy.svg +5 -0
  19. package/assets/images/icons/cross-transfer.svg +7 -0
  20. package/assets/images/icons/dapp.svg +4 -0
  21. package/assets/images/icons/deploy.svg +12 -0
  22. package/assets/images/icons/error-circle.svg +6 -0
  23. package/assets/images/icons/exclamation-circle.svg +13 -0
  24. package/assets/images/icons/exclamation-octagon.svg +13 -0
  25. package/assets/images/icons/exclamation-triangle.svg +5 -0
  26. package/assets/images/icons/external-link.svg +6 -0
  27. package/assets/images/icons/eye.svg +4 -0
  28. package/assets/images/icons/flowers.svg +8 -0
  29. package/assets/images/icons/gas-emoji.svg +193 -0
  30. package/assets/images/icons/gas.svg +14 -0
  31. package/assets/images/icons/gift.svg +153 -0
  32. package/assets/images/icons/globe.svg +110 -0
  33. package/assets/images/icons/hamburger.svg +6 -0
  34. package/assets/images/icons/instadapp-pro.svg +4 -0
  35. package/assets/images/icons/logout.svg +3 -0
  36. package/assets/images/icons/moon.svg +3 -0
  37. package/assets/images/icons/multi-send.svg +7 -0
  38. package/assets/images/icons/network.svg +13 -0
  39. package/assets/images/icons/options.svg +5 -0
  40. package/assets/images/icons/permit-sign.svg +11 -0
  41. package/assets/images/icons/plus-circle.svg +6 -0
  42. package/assets/images/icons/plus.svg +5 -0
  43. package/assets/images/icons/power-off-bg.svg +24 -0
  44. package/assets/images/icons/power-off.svg +19 -0
  45. package/assets/images/icons/power-on.svg +19 -0
  46. package/assets/images/icons/qr.svg +20 -0
  47. package/assets/images/icons/question-circle.svg +14 -0
  48. package/assets/images/icons/refresh.svg +6 -0
  49. package/assets/images/icons/reject-proposal.svg +6 -0
  50. package/assets/images/icons/search.svg +12 -0
  51. package/assets/images/icons/sun.svg +3 -0
  52. package/assets/images/icons/transfer.svg +5 -0
  53. package/assets/images/icons/trash-2.svg +8 -0
  54. package/assets/images/icons/upgrade.svg +4 -0
  55. package/assets/images/icons/wave.svg +214 -0
  56. package/assets/images/icons/x.svg +5 -0
  57. package/components/ActionLogo.vue +38 -0
  58. package/components/ActionMetadata.vue +72 -0
  59. package/components/AuthorityAvatar.vue +26 -0
  60. package/components/ChainLogo.vue +125 -328
  61. package/components/CopyClipboard.vue +64 -0
  62. package/components/metadata/Bridge.vue +59 -0
  63. package/components/metadata/CrossTransfer.vue +71 -0
  64. package/components/metadata/GasTopup.vue +39 -0
  65. package/components/metadata/Permit2.vue +42 -0
  66. package/components/metadata/Signers.vue +45 -0
  67. package/components/metadata/Swap.vue +74 -0
  68. package/components/metadata/Transfer.vue +50 -0
  69. package/components.d.ts +13 -0
  70. package/contracts/AvoFactoryProxy.ts +302 -0
  71. package/contracts/BalanceResolver.ts +321 -0
  72. package/contracts/Erc20.ts +526 -0
  73. package/contracts/Forwarder.ts +1644 -0
  74. package/contracts/GaslessWallet.ts +660 -0
  75. package/contracts/common.ts +46 -0
  76. package/contracts/factories/AvoFactoryProxy__factory.ts +181 -0
  77. package/contracts/factories/BalanceResolver__factory.ts +212 -0
  78. package/contracts/factories/Erc20__factory.ts +368 -0
  79. package/contracts/factories/Forwarder__factory.ts +1456 -0
  80. package/contracts/factories/GaslessWallet__factory.ts +499 -0
  81. package/contracts/factories/index.ts +8 -0
  82. package/contracts/index.ts +14 -0
  83. package/nuxt.config.ts +18 -2
  84. package/package.json +18 -6
  85. package/server/utils/index.ts +2 -0
  86. package/utils/avocado.ts +2 -0
  87. package/utils/bignumber.ts +51 -0
  88. package/utils/formatter.ts +94 -0
  89. package/utils/helper.ts +73 -0
  90. package/utils/metadata.ts +536 -0
  91. package/utils/network.ts +221 -47
  92. package/utils/services.ts +21 -0
  93. package/utils/utils.d.ts +129 -14
@@ -0,0 +1,499 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+
5
+ import { Contract, Signer, utils } from "ethers";
6
+ import type { Provider } from "@ethersproject/providers";
7
+ import type { GaslessWallet, GaslessWalletInterface } from "../GaslessWallet";
8
+
9
+ const _abi = [
10
+ {
11
+ inputs: [
12
+ {
13
+ internalType: "contract IGSWVersionsRegistry",
14
+ name: "gswVersionsRegistry_",
15
+ type: "address",
16
+ },
17
+ {
18
+ internalType: "address",
19
+ name: "gswForwarder_",
20
+ type: "address",
21
+ },
22
+ ],
23
+ stateMutability: "nonpayable",
24
+ type: "constructor",
25
+ },
26
+ {
27
+ inputs: [],
28
+ name: "GaslessSmartWallet__Expired",
29
+ type: "error",
30
+ },
31
+ {
32
+ inputs: [],
33
+ name: "GaslessSmartWallet__InvalidParams",
34
+ type: "error",
35
+ },
36
+ {
37
+ inputs: [],
38
+ name: "GaslessSmartWallet__InvalidSignature",
39
+ type: "error",
40
+ },
41
+ {
42
+ inputs: [],
43
+ name: "GaslessSmartWallet__Unauthorized",
44
+ type: "error",
45
+ },
46
+ {
47
+ inputs: [],
48
+ name: "SelfUpgradeable__Unauthorized",
49
+ type: "error",
50
+ },
51
+ {
52
+ anonymous: false,
53
+ inputs: [
54
+ {
55
+ indexed: true,
56
+ internalType: "address",
57
+ name: "source",
58
+ type: "address",
59
+ },
60
+ {
61
+ indexed: true,
62
+ internalType: "address",
63
+ name: "caller",
64
+ type: "address",
65
+ },
66
+ {
67
+ indexed: false,
68
+ internalType: "bytes",
69
+ name: "metadata",
70
+ type: "bytes",
71
+ },
72
+ ],
73
+ name: "CastExecuted",
74
+ type: "event",
75
+ },
76
+ {
77
+ anonymous: false,
78
+ inputs: [
79
+ {
80
+ indexed: true,
81
+ internalType: "address",
82
+ name: "source",
83
+ type: "address",
84
+ },
85
+ {
86
+ indexed: true,
87
+ internalType: "address",
88
+ name: "caller",
89
+ type: "address",
90
+ },
91
+ {
92
+ indexed: false,
93
+ internalType: "string",
94
+ name: "reason",
95
+ type: "string",
96
+ },
97
+ {
98
+ indexed: false,
99
+ internalType: "bytes",
100
+ name: "metadata",
101
+ type: "bytes",
102
+ },
103
+ ],
104
+ name: "CastFailed",
105
+ type: "event",
106
+ },
107
+ {
108
+ anonymous: false,
109
+ inputs: [
110
+ {
111
+ indexed: false,
112
+ internalType: "uint8",
113
+ name: "version",
114
+ type: "uint8",
115
+ },
116
+ ],
117
+ name: "Initialized",
118
+ type: "event",
119
+ },
120
+ {
121
+ anonymous: false,
122
+ inputs: [
123
+ {
124
+ indexed: true,
125
+ internalType: "address",
126
+ name: "gswImpl",
127
+ type: "address",
128
+ },
129
+ ],
130
+ name: "Upgraded",
131
+ type: "event",
132
+ },
133
+ {
134
+ inputs: [],
135
+ name: "ACTION_TYPE_HASH",
136
+ outputs: [
137
+ {
138
+ internalType: "bytes32",
139
+ name: "",
140
+ type: "bytes32",
141
+ },
142
+ ],
143
+ stateMutability: "view",
144
+ type: "function",
145
+ },
146
+ {
147
+ inputs: [],
148
+ name: "CAST_TYPE_HASH",
149
+ outputs: [
150
+ {
151
+ internalType: "bytes32",
152
+ name: "",
153
+ type: "bytes32",
154
+ },
155
+ ],
156
+ stateMutability: "view",
157
+ type: "function",
158
+ },
159
+ {
160
+ inputs: [],
161
+ name: "DEFAULT_CHAIN_ID",
162
+ outputs: [
163
+ {
164
+ internalType: "uint256",
165
+ name: "",
166
+ type: "uint256",
167
+ },
168
+ ],
169
+ stateMutability: "view",
170
+ type: "function",
171
+ },
172
+ {
173
+ inputs: [],
174
+ name: "DOMAIN_SEPARATOR_NAME",
175
+ outputs: [
176
+ {
177
+ internalType: "string",
178
+ name: "",
179
+ type: "string",
180
+ },
181
+ ],
182
+ stateMutability: "view",
183
+ type: "function",
184
+ },
185
+ {
186
+ inputs: [],
187
+ name: "DOMAIN_SEPARATOR_VERSION",
188
+ outputs: [
189
+ {
190
+ internalType: "string",
191
+ name: "",
192
+ type: "string",
193
+ },
194
+ ],
195
+ stateMutability: "view",
196
+ type: "function",
197
+ },
198
+ {
199
+ inputs: [],
200
+ name: "TYPE_HASH",
201
+ outputs: [
202
+ {
203
+ internalType: "bytes32",
204
+ name: "",
205
+ type: "bytes32",
206
+ },
207
+ ],
208
+ stateMutability: "view",
209
+ type: "function",
210
+ },
211
+ {
212
+ inputs: [
213
+ {
214
+ components: [
215
+ {
216
+ internalType: "address",
217
+ name: "target",
218
+ type: "address",
219
+ },
220
+ {
221
+ internalType: "bytes",
222
+ name: "data",
223
+ type: "bytes",
224
+ },
225
+ {
226
+ internalType: "uint256",
227
+ name: "value",
228
+ type: "uint256",
229
+ },
230
+ ],
231
+ internalType: "struct IGaslessSmartWallet.Action[]",
232
+ name: "actions_",
233
+ type: "tuple[]",
234
+ },
235
+ ],
236
+ name: "_callTargets",
237
+ outputs: [],
238
+ stateMutability: "payable",
239
+ type: "function",
240
+ },
241
+ {
242
+ inputs: [
243
+ {
244
+ components: [
245
+ {
246
+ internalType: "address",
247
+ name: "target",
248
+ type: "address",
249
+ },
250
+ {
251
+ internalType: "bytes",
252
+ name: "data",
253
+ type: "bytes",
254
+ },
255
+ {
256
+ internalType: "uint256",
257
+ name: "value",
258
+ type: "uint256",
259
+ },
260
+ ],
261
+ internalType: "struct IGaslessSmartWallet.Action[]",
262
+ name: "actions_",
263
+ type: "tuple[]",
264
+ },
265
+ {
266
+ internalType: "uint256",
267
+ name: "validUntil_",
268
+ type: "uint256",
269
+ },
270
+ {
271
+ internalType: "uint256",
272
+ name: "gas_",
273
+ type: "uint256",
274
+ },
275
+ {
276
+ internalType: "address",
277
+ name: "source_",
278
+ type: "address",
279
+ },
280
+ {
281
+ internalType: "bytes",
282
+ name: "metadata_",
283
+ type: "bytes",
284
+ },
285
+ {
286
+ internalType: "bytes",
287
+ name: "signature_",
288
+ type: "bytes",
289
+ },
290
+ ],
291
+ name: "cast",
292
+ outputs: [
293
+ {
294
+ internalType: "bool",
295
+ name: "success_",
296
+ type: "bool",
297
+ },
298
+ {
299
+ internalType: "string",
300
+ name: "revertReason_",
301
+ type: "string",
302
+ },
303
+ ],
304
+ stateMutability: "payable",
305
+ type: "function",
306
+ },
307
+ {
308
+ inputs: [],
309
+ name: "domainSeparatorV4",
310
+ outputs: [
311
+ {
312
+ internalType: "bytes32",
313
+ name: "",
314
+ type: "bytes32",
315
+ },
316
+ ],
317
+ stateMutability: "view",
318
+ type: "function",
319
+ },
320
+ {
321
+ inputs: [],
322
+ name: "gswForwarder",
323
+ outputs: [
324
+ {
325
+ internalType: "address",
326
+ name: "",
327
+ type: "address",
328
+ },
329
+ ],
330
+ stateMutability: "view",
331
+ type: "function",
332
+ },
333
+ {
334
+ inputs: [],
335
+ name: "gswNonce",
336
+ outputs: [
337
+ {
338
+ internalType: "uint256",
339
+ name: "",
340
+ type: "uint256",
341
+ },
342
+ ],
343
+ stateMutability: "view",
344
+ type: "function",
345
+ },
346
+ {
347
+ inputs: [],
348
+ name: "gswVersionsRegistry",
349
+ outputs: [
350
+ {
351
+ internalType: "contract IGSWVersionsRegistry",
352
+ name: "",
353
+ type: "address",
354
+ },
355
+ ],
356
+ stateMutability: "view",
357
+ type: "function",
358
+ },
359
+ {
360
+ inputs: [
361
+ {
362
+ internalType: "address",
363
+ name: "owner_",
364
+ type: "address",
365
+ },
366
+ ],
367
+ name: "initialize",
368
+ outputs: [],
369
+ stateMutability: "nonpayable",
370
+ type: "function",
371
+ },
372
+ {
373
+ inputs: [],
374
+ name: "owner",
375
+ outputs: [
376
+ {
377
+ internalType: "address",
378
+ name: "",
379
+ type: "address",
380
+ },
381
+ ],
382
+ stateMutability: "view",
383
+ type: "function",
384
+ },
385
+ {
386
+ inputs: [
387
+ {
388
+ internalType: "address",
389
+ name: "gswImpl_",
390
+ type: "address",
391
+ },
392
+ ],
393
+ name: "upgradeTo",
394
+ outputs: [],
395
+ stateMutability: "nonpayable",
396
+ type: "function",
397
+ },
398
+ {
399
+ inputs: [
400
+ {
401
+ internalType: "address",
402
+ name: "gswImpl_",
403
+ type: "address",
404
+ },
405
+ {
406
+ internalType: "bytes",
407
+ name: "data_",
408
+ type: "bytes",
409
+ },
410
+ {
411
+ internalType: "bool",
412
+ name: "forceCall_",
413
+ type: "bool",
414
+ },
415
+ ],
416
+ name: "upgradeToAndCall",
417
+ outputs: [],
418
+ stateMutability: "payable",
419
+ type: "function",
420
+ },
421
+ {
422
+ inputs: [
423
+ {
424
+ components: [
425
+ {
426
+ internalType: "address",
427
+ name: "target",
428
+ type: "address",
429
+ },
430
+ {
431
+ internalType: "bytes",
432
+ name: "data",
433
+ type: "bytes",
434
+ },
435
+ {
436
+ internalType: "uint256",
437
+ name: "value",
438
+ type: "uint256",
439
+ },
440
+ ],
441
+ internalType: "struct IGaslessSmartWallet.Action[]",
442
+ name: "actions_",
443
+ type: "tuple[]",
444
+ },
445
+ {
446
+ internalType: "uint256",
447
+ name: "validUntil_",
448
+ type: "uint256",
449
+ },
450
+ {
451
+ internalType: "uint256",
452
+ name: "gas_",
453
+ type: "uint256",
454
+ },
455
+ {
456
+ internalType: "address",
457
+ name: "source_",
458
+ type: "address",
459
+ },
460
+ {
461
+ internalType: "bytes",
462
+ name: "metadata_",
463
+ type: "bytes",
464
+ },
465
+ {
466
+ internalType: "bytes",
467
+ name: "signature_",
468
+ type: "bytes",
469
+ },
470
+ ],
471
+ name: "verify",
472
+ outputs: [
473
+ {
474
+ internalType: "bool",
475
+ name: "",
476
+ type: "bool",
477
+ },
478
+ ],
479
+ stateMutability: "view",
480
+ type: "function",
481
+ },
482
+ {
483
+ stateMutability: "payable",
484
+ type: "receive",
485
+ },
486
+ ] as const;
487
+
488
+ export class GaslessWallet__factory {
489
+ static readonly abi = _abi;
490
+ static createInterface(): GaslessWalletInterface {
491
+ return new utils.Interface(_abi) as GaslessWalletInterface;
492
+ }
493
+ static connect(
494
+ address: string,
495
+ signerOrProvider: Signer | Provider
496
+ ): GaslessWallet {
497
+ return new Contract(address, _abi, signerOrProvider) as GaslessWallet;
498
+ }
499
+ }
@@ -0,0 +1,8 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export { AvoFactoryProxy__factory } from "./AvoFactoryProxy__factory";
5
+ export { BalanceResolver__factory } from "./BalanceResolver__factory";
6
+ export { Erc20__factory } from "./Erc20__factory";
7
+ export { Forwarder__factory } from "./Forwarder__factory";
8
+ export { GaslessWallet__factory } from "./GaslessWallet__factory";
@@ -0,0 +1,14 @@
1
+ /* Autogenerated file. Do not edit manually. */
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ export type { AvoFactoryProxy } from "./AvoFactoryProxy";
5
+ export type { BalanceResolver } from "./BalanceResolver";
6
+ export type { Erc20 } from "./Erc20";
7
+ export type { Forwarder } from "./Forwarder";
8
+ export type { GaslessWallet } from "./GaslessWallet";
9
+ export * as factories from "./factories";
10
+ export { AvoFactoryProxy__factory } from "./factories/AvoFactoryProxy__factory";
11
+ export { BalanceResolver__factory } from "./factories/BalanceResolver__factory";
12
+ export { Erc20__factory } from "./factories/Erc20__factory";
13
+ export { Forwarder__factory } from "./factories/Forwarder__factory";
14
+ export { GaslessWallet__factory } from "./factories/GaslessWallet__factory";
package/nuxt.config.ts CHANGED
@@ -1,4 +1,20 @@
1
1
  // https://nuxt.com/docs/api/configuration/nuxt-config
2
- export default defineNuxtConfig({
2
+ import ViteComponents from "unplugin-vue-components/vite";
3
3
 
4
- })
4
+ export default defineNuxtConfig({
5
+ modules: ["@nuxtjs/tailwindcss", "nuxt-svgo", "@vueuse/nuxt"],
6
+ svgo: {
7
+ defaultImport: "component",
8
+ autoImportPath: "./assets/images/icons",
9
+ svgoConfig: {
10
+ plugins: ["prefixIds"],
11
+ },
12
+ },
13
+ vite: {
14
+ plugins: [
15
+ ViteComponents({
16
+ dts: true,
17
+ }),
18
+ ],
19
+ },
20
+ });
package/package.json CHANGED
@@ -1,20 +1,32 @@
1
1
  {
2
2
  "name": "@instadapp/avocado-base",
3
- "version": "0.0.0-dev.0d5070b",
3
+ "version": "0.0.0-dev.0e696bd",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
+ "types": "global.d.ts",
6
7
  "scripts": {
7
8
  "build": "nuxt build",
8
9
  "dev": "nuxt dev",
9
10
  "generate": "nuxt generate",
10
- "preview": "nuxt preview"
11
+ "preview": "nuxt preview",
12
+ "generate:contracts": "rimraf contracts && typechain --target=ethers-v5 'abi/*.json' --out-dir 'contracts'"
11
13
  },
12
14
  "devDependencies": {
13
- "nuxt": "^3.3.3",
14
- "@instadapp/avocado": "^0.1.9",
15
- "@instadapp/avocado-dev": "npm:@instadapp/avocado@dev"
15
+ "@instadapp/avocado": "^0.1.10",
16
+ "@instadapp/avocado-dev": "npm:@instadapp/avocado@dev",
17
+ "@nuxtjs/tailwindcss": "^6.6.5",
18
+ "@typechain/ethers-v5": "^10.2.0",
19
+ "nuxt": "^3.6.1",
20
+ "nuxt-svgo": "^3.1.0",
21
+ "rimraf": "^3.0.2",
22
+ "typechain": "^8.1.1",
23
+ "unplugin-vue-components": "^0.25.1",
24
+ "vue-tippy": "^6.0.0"
16
25
  },
17
26
  "dependencies": {
18
- "ethers": "^5.7.2"
27
+ "@vueuse/nuxt": "^10.2.0",
28
+ "bignumber.js": "^9.1.1",
29
+ "ethers": "^5.7.2",
30
+ "xxhashjs": "^0.2.2"
19
31
  }
20
32
  }
@@ -1,2 +1,4 @@
1
1
  export * from "../../utils/avocado";
2
2
  export * from "../../utils/network";
3
+ export * from "../../utils/bignumber";
4
+ export * from "../../utils/formatter";
package/utils/avocado.ts CHANGED
@@ -20,3 +20,5 @@ export const AVO_STAGING_DEPOSIT_ADDRESS =
20
20
  export const AVO_PROD_RPC_URL = "https://rpc.avocado.instadapp.io";
21
21
 
22
22
  export const AVO_STAGING_RPC_URL = "https://rpc.avocado.instad.app";
23
+
24
+ export const blockQueryURL = "https://blockquery.instadapp.io";
@@ -0,0 +1,51 @@
1
+ import { BigNumber } from "bignumber.js";
2
+ import { BigNumber as BN } from "ethers";
3
+
4
+ type CombinedBigNumber = BigNumber | string | number;
5
+
6
+ export const toBN = (value: BigNumber.Value | BN) =>
7
+ new BigNumber(BN.isBigNumber(value) ? value.toString() : value);
8
+ export const isZero = (value: BigNumber.Value | BN) => toBN(value).isZero();
9
+ export const times = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
10
+ toBN(a).times(toBN(b));
11
+ export const minus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
12
+ toBN(a).minus(toBN(b));
13
+ export const plus = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
14
+ toBN(a).plus(toBN(b));
15
+ export const lte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
16
+ toBN(a).lte(toBN(b));
17
+ export const gte = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
18
+ toBN(a).gte(toBN(b));
19
+ export const div = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
20
+ toBN(a).div(toBN(b));
21
+ export const lt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
22
+ toBN(a).lt(toBN(b));
23
+ export const gt = (a: BigNumber.Value | BN, b: BigNumber.Value | BN) =>
24
+ toBN(a).gt(toBN(b));
25
+ export const ensureValue = (value: any) => {
26
+ if (!value) return toBN("0");
27
+ if (toBN(value).isNaN()) return toBN("0");
28
+
29
+ return toBN(value);
30
+ };
31
+ export const max = (...args: BigNumber.Value[]) => {
32
+ return BigNumber.max(...args);
33
+ };
34
+
35
+ export function pow(value: CombinedBigNumber, exponent: string | number) {
36
+ return toBN(value).pow(toBN(exponent));
37
+ }
38
+
39
+ export function toWei(val: CombinedBigNumber, decimals: number): string {
40
+ const num = toBN(val);
41
+ const multiplier = pow(10, decimals);
42
+ return times(num, multiplier).toFixed(0);
43
+ }
44
+
45
+ export function fromWei(val: CombinedBigNumber, decimal = 18) {
46
+ return toBN(val).div(new BigNumber(10).pow(decimal));
47
+ }
48
+
49
+ export function abs(value: CombinedBigNumber) {
50
+ return toBN(value).abs();
51
+ }