@across-protocol/sdk 3.1.34 → 3.1.35
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/dist/cjs/apiClient/abstractClient.d.ts +2 -2
- package/dist/cjs/apiClient/mockedClient.d.ts +2 -2
- package/dist/cjs/apiClient/mockedClient.js +13 -12
- package/dist/cjs/apiClient/mockedClient.js.map +1 -1
- package/dist/cjs/apiClient/productionClient.d.ts +2 -2
- package/dist/cjs/apiClient/productionClient.js +10 -10
- package/dist/cjs/apiClient/productionClient.js.map +1 -1
- package/dist/cjs/apiClient/types.d.ts +10 -10
- package/dist/cjs/caching/Arweave/ArweaveClient.d.ts +2 -2
- package/dist/cjs/caching/Arweave/ArweaveClient.js +3 -4
- package/dist/cjs/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +2 -3
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +2 -2
- package/dist/cjs/clients/HubPoolClient.js +1 -2
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient.js +2 -3
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +2 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +2 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +0 -3
- package/dist/cjs/constants.js +1 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/contracts/utils.d.ts +2 -1
- package/dist/cjs/contracts/utils.js +2 -3
- package/dist/cjs/contracts/utils.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js +4 -3
- package/dist/cjs/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js +2 -3
- package/dist/cjs/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/polygon.js +3 -4
- package/dist/cjs/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.d.ts +2 -1
- package/dist/cjs/gasPriceOracle/util.d.ts +2 -1
- package/dist/cjs/gasPriceOracle/util.js.map +1 -1
- package/dist/cjs/interfaces/Bridge.d.ts +1 -1
- package/dist/cjs/interfaces/BundleData.d.ts +2 -1
- package/dist/cjs/interfaces/Common.d.ts +1 -1
- package/dist/cjs/interfaces/ConfigStore.d.ts +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +1 -1
- package/dist/cjs/pool/poolClient.d.ts +2 -2
- package/dist/cjs/pool/poolClient.js +14 -14
- package/dist/cjs/pool/poolClient.js.map +1 -1
- package/dist/cjs/providers/retryProvider.js +34 -24
- package/dist/cjs/providers/retryProvider.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +3 -3
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +1 -2
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.js +3 -2
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/BigNumberUtils.d.ts +9 -5
- package/dist/cjs/utils/BigNumberUtils.js +13 -8
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
- package/dist/cjs/utils/FormattingUtils.d.ts +3 -4
- package/dist/cjs/utils/FormattingUtils.js +5 -5
- package/dist/cjs/utils/FormattingUtils.js.map +1 -1
- package/dist/cjs/utils/JSONUtils.js +5 -5
- package/dist/cjs/utils/JSONUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +1 -1
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +2 -1
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/cjs/utils/ValidatorUtils.js +4 -3
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +4 -4
- package/dist/cjs/utils/common.js +5 -7
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/apiClient/abstractClient.d.ts +2 -2
- package/dist/esm/apiClient/mockedClient.d.ts +2 -2
- package/dist/esm/apiClient/mockedClient.js +13 -12
- package/dist/esm/apiClient/mockedClient.js.map +1 -1
- package/dist/esm/apiClient/productionClient.d.ts +2 -2
- package/dist/esm/apiClient/productionClient.js +10 -10
- package/dist/esm/apiClient/productionClient.js.map +1 -1
- package/dist/esm/apiClient/types.d.ts +10 -10
- package/dist/esm/caching/Arweave/ArweaveClient.d.ts +2 -2
- package/dist/esm/caching/Arweave/ArweaveClient.js +2 -3
- package/dist/esm/caching/Arweave/ArweaveClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1 -2
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +2 -2
- package/dist/esm/clients/HubPoolClient.js +1 -2
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient.js +1 -2
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +2 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +2 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +0 -3
- package/dist/esm/constants.js +1 -3
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/contracts/utils.d.ts +2 -1
- package/dist/esm/contracts/utils.js +1 -2
- package/dist/esm/contracts/utils.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js +5 -4
- package/dist/esm/gasPriceOracle/adapters/arbitrum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/ethereum.js +1 -2
- package/dist/esm/gasPriceOracle/adapters/ethereum.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/polygon.js +4 -5
- package/dist/esm/gasPriceOracle/adapters/polygon.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.d.ts +2 -1
- package/dist/esm/gasPriceOracle/util.d.ts +2 -1
- package/dist/esm/gasPriceOracle/util.js.map +1 -1
- package/dist/esm/interfaces/Bridge.d.ts +1 -1
- package/dist/esm/interfaces/BundleData.d.ts +2 -1
- package/dist/esm/interfaces/Common.d.ts +1 -1
- package/dist/esm/interfaces/ConfigStore.d.ts +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +1 -1
- package/dist/esm/pool/poolClient.d.ts +2 -2
- package/dist/esm/pool/poolClient.js +8 -8
- package/dist/esm/pool/poolClient.js.map +1 -1
- package/dist/esm/providers/retryProvider.js +34 -24
- package/dist/esm/providers/retryProvider.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +3 -3
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +1 -2
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.js +2 -1
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/BigNumberUtils.d.ts +9 -5
- package/dist/esm/utils/BigNumberUtils.js +11 -5
- package/dist/esm/utils/BigNumberUtils.js.map +1 -1
- package/dist/esm/utils/FormattingUtils.d.ts +3 -4
- package/dist/esm/utils/FormattingUtils.js +7 -7
- package/dist/esm/utils/FormattingUtils.js.map +1 -1
- package/dist/esm/utils/JSONUtils.js +1 -1
- package/dist/esm/utils/JSONUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +2 -2
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +34 -33
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/esm/utils/ValidatorUtils.js +5 -4
- package/dist/esm/utils/ValidatorUtils.js.map +1 -1
- package/dist/esm/utils/common.d.ts +4 -4
- package/dist/esm/utils/common.js +4 -6
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/apiClient/abstractClient.d.ts +2 -2
- package/dist/types/apiClient/abstractClient.d.ts.map +1 -1
- package/dist/types/apiClient/mockedClient.d.ts +2 -2
- package/dist/types/apiClient/mockedClient.d.ts.map +1 -1
- package/dist/types/apiClient/productionClient.d.ts +2 -2
- package/dist/types/apiClient/productionClient.d.ts.map +1 -1
- package/dist/types/apiClient/types.d.ts +10 -10
- package/dist/types/apiClient/types.d.ts.map +1 -1
- package/dist/types/caching/Arweave/ArweaveClient.d.ts +2 -2
- package/dist/types/caching/Arweave/ArweaveClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +2 -2
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +2 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +2 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +0 -3
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/contracts/utils.d.ts +2 -1
- package/dist/types/contracts/utils.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/arbitrum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/ethereum.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/polygon.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/types.d.ts +2 -1
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/util.d.ts +2 -1
- package/dist/types/gasPriceOracle/util.d.ts.map +1 -1
- package/dist/types/interfaces/Bridge.d.ts +1 -1
- package/dist/types/interfaces/Bridge.d.ts.map +1 -1
- package/dist/types/interfaces/BundleData.d.ts +2 -1
- package/dist/types/interfaces/BundleData.d.ts.map +1 -1
- package/dist/types/interfaces/Common.d.ts +1 -1
- package/dist/types/interfaces/Common.d.ts.map +1 -1
- package/dist/types/interfaces/ConfigStore.d.ts +1 -1
- package/dist/types/interfaces/ConfigStore.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +1 -1
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +1 -1
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/pool/poolClient.d.ts +2 -2
- package/dist/types/pool/poolClient.d.ts.map +1 -1
- package/dist/types/providers/retryProvider.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +3 -3
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +1 -2
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/BigNumberUtils.d.ts +9 -5
- package/dist/types/utils/BigNumberUtils.d.ts.map +1 -1
- package/dist/types/utils/FormattingUtils.d.ts +3 -4
- package/dist/types/utils/FormattingUtils.d.ts.map +1 -1
- package/dist/types/utils/Multicall.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +34 -33
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/dist/types/utils/ValidatorUtils.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +4 -4
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/apiClient/abstractClient.ts +2 -2
- package/src/apiClient/mockedClient.ts +14 -13
- package/src/apiClient/productionClient.ts +11 -12
- package/src/apiClient/types.ts +10 -10
- package/src/caching/Arweave/ArweaveClient.ts +3 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +1 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +1 -2
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +1 -1
- package/src/clients/HubPoolClient.ts +2 -1
- package/src/clients/SpokePoolClient.ts +2 -1
- package/src/clients/mocks/MockHubPoolClient.ts +2 -2
- package/src/clients/mocks/MockSpokePoolClient.ts +2 -2
- package/src/constants.ts +1 -4
- package/src/contracts/utils.ts +2 -2
- package/src/gasPriceOracle/adapters/arbitrum.ts +4 -3
- package/src/gasPriceOracle/adapters/ethereum.ts +2 -2
- package/src/gasPriceOracle/adapters/polygon.ts +5 -5
- package/src/gasPriceOracle/types.ts +2 -1
- package/src/gasPriceOracle/util.ts +2 -1
- package/src/interfaces/Bridge.ts +1 -1
- package/src/interfaces/BundleData.ts +2 -1
- package/src/interfaces/Common.ts +1 -1
- package/src/interfaces/ConfigStore.ts +1 -1
- package/src/interfaces/HubPool.ts +1 -1
- package/src/interfaces/SpokePool.ts +1 -1
- package/src/pool/poolClient.ts +19 -10
- package/src/providers/retryProvider.ts +35 -17
- package/src/relayFeeCalculator/relayFeeCalculator.ts +1 -1
- package/src/utils/AddressUtils.ts +2 -1
- package/src/utils/BigNumberUtils.ts +12 -6
- package/src/utils/FormattingUtils.ts +9 -9
- package/src/utils/JSONUtils.ts +1 -1
- package/src/utils/Multicall.ts +2 -1
- package/src/utils/SpokeUtils.ts +2 -2
- package/src/utils/TokenUtils.ts +2 -1
- package/src/utils/ValidatorUtils.ts +5 -4
- package/src/utils/common.ts +4 -5
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
boolean,
|
|
12
12
|
defaulted,
|
|
13
13
|
} from "superstruct";
|
|
14
|
-
import { BigNumber } from "
|
|
14
|
+
import { BigNumber } from "../../../utils";
|
|
15
15
|
|
|
16
16
|
const PositiveIntegerStringSS = pattern(string(), /\d+/);
|
|
17
17
|
const Web3AddressSS = pattern(string(), /^0x[a-fA-F0-9]{40}$/);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
-
import {
|
|
2
|
+
import { Contract, Event, EventFilter } from "ethers";
|
|
3
3
|
import _ from "lodash";
|
|
4
4
|
import winston from "winston";
|
|
5
5
|
import { DEFAULT_CACHING_SAFE_LAG, DEFAULT_CACHING_TTL } from "../constants";
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from "../interfaces";
|
|
23
23
|
import * as lpFeeCalculator from "../lpFeeCalculator";
|
|
24
24
|
import {
|
|
25
|
+
BigNumber,
|
|
25
26
|
BlockFinder,
|
|
26
27
|
bnZero,
|
|
27
28
|
dedupArray,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
|
-
import {
|
|
3
|
-
import { randomAddress, assign, bnZero } from "../../utils";
|
|
2
|
+
import { Contract, Event } from "ethers";
|
|
3
|
+
import { BigNumber, randomAddress, assign, bnZero } from "../../utils";
|
|
4
4
|
import { L1Token, PendingRootBundle, RealizedLpFee } from "../../interfaces";
|
|
5
5
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
6
6
|
import { HubPoolClient, HubPoolUpdate, LpFeeRequest } from "../HubPoolClient";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
-
import {
|
|
2
|
+
import { Contract, Event, providers } from "ethers";
|
|
3
3
|
import { random } from "lodash";
|
|
4
4
|
import winston from "winston";
|
|
5
5
|
import { ZERO_ADDRESS } from "../../constants";
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
SlowFillLeaf,
|
|
16
16
|
SpeedUp,
|
|
17
17
|
} from "../../interfaces";
|
|
18
|
-
import { bnZero, toBN, toBNWei, forEachAsync, getCurrentTime, randomAddress } from "../../utils";
|
|
18
|
+
import { BigNumber, bnZero, toBN, toBNWei, forEachAsync, getCurrentTime, randomAddress } from "../../utils";
|
|
19
19
|
import { SpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
20
20
|
import { HubPoolClient } from "../HubPoolClient";
|
|
21
21
|
import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
|
package/src/constants.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { constants as ethersConstants
|
|
1
|
+
import { constants as ethersConstants } from "ethers";
|
|
2
2
|
import { TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
|
|
3
3
|
|
|
4
4
|
export {
|
|
@@ -44,9 +44,6 @@ export const PROTOCOL_DEFAULT_CHAIN_ID_INDICES = [1, 10, 137, 288, 42161];
|
|
|
44
44
|
export const DEFAULT_CACHING_TTL = 60 * 60 * 24 * 7 * 2; // 2 Weeks
|
|
45
45
|
export const DEFAULT_CACHING_SAFE_LAG = 60 * 60; // 1 hour
|
|
46
46
|
|
|
47
|
-
export const UBA_BOUNDS_RANGE_MAX = BigNumber.from(String(Number.MAX_SAFE_INTEGER)).mul(utils.parseEther("1.0"));
|
|
48
|
-
export const UBA_BOUNDS_RANGE_MIN = UBA_BOUNDS_RANGE_MAX.mul(-1);
|
|
49
|
-
|
|
50
47
|
export const DEFAULT_SIMULATED_RELAYER_ADDRESS = "0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67";
|
|
51
48
|
export const DEFAULT_SIMULATED_RELAYER_ADDRESS_TEST = "0x9A8f92a830A5cB89a3816e3D267CB7791c16b04D"; // Görli, ...
|
|
52
49
|
|
package/src/contracts/utils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
-
import {
|
|
3
|
-
import { isDefined } from "../utils";
|
|
2
|
+
import { Event } from "ethers";
|
|
3
|
+
import { BigNumber, BigNumberish, isDefined } from "../utils";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @dev Originally imported from @uma/sdk.
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { providers
|
|
2
|
-
import { bnOne } from "../../utils";
|
|
1
|
+
import { providers } from "ethers";
|
|
2
|
+
import { BigNumber, bnOne, parseUnits } from "../../utils";
|
|
3
3
|
import { GasPriceEstimate } from "../types";
|
|
4
4
|
import * as ethereum from "./ethereum";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
let DEFAULT_PRIORITY_FEE: BigNumber | undefined = undefined;
|
|
7
7
|
|
|
8
8
|
// Arbitrum Nitro implements EIP-1559 pricing, but the priority fee is always refunded to the caller. Further,
|
|
9
9
|
// ethers typically hardcodes the priority fee to 1.5 Gwei. So, confirm that the priority fee supplied was 1.5
|
|
10
10
|
// Gwei, and then drop it to 1 Wei. Reference: https://developer.arbitrum.io/faqs/gas-faqs#q-priority
|
|
11
11
|
export async function eip1559(provider: providers.Provider, chainId: number): Promise<GasPriceEstimate> {
|
|
12
|
+
DEFAULT_PRIORITY_FEE ??= parseUnits("1.5", 9);
|
|
12
13
|
const { maxFeePerGas: _maxFeePerGas, maxPriorityFeePerGas } = await ethereum.eip1559(provider, chainId);
|
|
13
14
|
|
|
14
15
|
// If this throws, ethers default behaviour has changed, or Arbitrum RPCs are returning something more sensible.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { providers
|
|
1
|
+
import { providers } from "ethers";
|
|
2
2
|
import { BaseHTTPAdapter, BaseHTTPAdapterArgs } from "../../priceClient/adapters/baseAdapter";
|
|
3
|
-
import { bnZero, isDefined } from "../../utils";
|
|
3
|
+
import { bnZero, isDefined, parseUnits } from "../../utils";
|
|
4
4
|
import { CHAIN_IDs } from "../../constants";
|
|
5
5
|
import { GasPriceEstimate } from "../types";
|
|
6
6
|
import { gasPriceError } from "../util";
|
|
@@ -50,12 +50,12 @@ class PolygonGasStation extends BaseHTTPAdapter {
|
|
|
50
50
|
|
|
51
51
|
[gasPrice.maxFee, gasPrice.maxPriorityFee].forEach((gasPrice) => {
|
|
52
52
|
if (Number(gasPrice) < 0) {
|
|
53
|
-
gasPriceError("getFeeData()", this.chainId,
|
|
53
|
+
gasPriceError("getFeeData()", this.chainId, parseUnits(gasPrice.toString(), 9));
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
const maxPriorityFeePerGas =
|
|
58
|
-
const maxFeePerGas =
|
|
57
|
+
const maxPriorityFeePerGas = parseUnits(gasPrice.maxPriorityFee.toString(), 9);
|
|
58
|
+
const maxFeePerGas = parseUnits(gasPrice.maxFee.toString(), 9);
|
|
59
59
|
|
|
60
60
|
return { maxPriorityFeePerGas, maxFeePerGas };
|
|
61
61
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { providers } from "ethers";
|
|
2
|
+
import { BigNumber } from "../utils";
|
|
2
3
|
|
|
3
4
|
export function gasPriceError(method: string, chainId: number, data: providers.FeeData | BigNumber): void {
|
|
4
5
|
throw new Error(`Malformed ${method} response on chain ID ${chainId} (${JSON.stringify(data)})`);
|
package/src/interfaces/Bridge.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Signer } from "ethers";
|
|
2
2
|
import { DepositWithBlock, FillWithBlock, Refund } from "./SpokePool";
|
|
3
3
|
import { HubPoolClient } from "../clients/HubPoolClient";
|
|
4
4
|
import { AcrossConfigStoreClient } from "../clients";
|
|
5
5
|
import { ArweaveClient } from "../caching";
|
|
6
|
+
import { BigNumber } from "../utils";
|
|
6
7
|
|
|
7
8
|
export type ExpiredDepositsToRefundV3 = {
|
|
8
9
|
[originChainId: number]: {
|
package/src/interfaces/Common.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { BigNumber } from "ethers";
|
|
2
1
|
import { SortableEvent } from "./Common";
|
|
3
2
|
import { FilledRelayEvent, FilledV3RelayEvent, FundsDepositedEvent, V3FundsDepositedEvent } from "../typechain";
|
|
4
3
|
import { SpokePoolClient } from "../clients";
|
|
4
|
+
import { BigNumber } from "../utils";
|
|
5
5
|
import { RelayerRefundLeaf } from "./HubPool";
|
|
6
6
|
|
|
7
7
|
export type { FilledRelayEvent, FilledV3RelayEvent, FundsDepositedEvent, V3FundsDepositedEvent };
|
package/src/pool/poolClient.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import * as uma from "@uma/sdk";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
bnZero,
|
|
5
|
+
toBNWei,
|
|
6
|
+
fixedPointAdjustment,
|
|
7
|
+
calcPeriodicCompoundInterest,
|
|
8
|
+
calcApr,
|
|
9
|
+
BigNumber,
|
|
10
|
+
BigNumberish,
|
|
11
|
+
fromWei,
|
|
12
|
+
} from "../utils";
|
|
13
|
+
import { ethers, Signer } from "ethers";
|
|
5
14
|
import type { Overrides } from "@ethersproject/contracts";
|
|
6
15
|
import { TransactionRequest, TransactionReceipt, Log } from "@ethersproject/abstract-provider";
|
|
7
16
|
import { Provider, Block } from "@ethersproject/providers";
|
|
@@ -256,10 +265,10 @@ class UserState {
|
|
|
256
265
|
if (endBlock <= this.startBlock) return [];
|
|
257
266
|
const { userAddress } = this;
|
|
258
267
|
const events: TypedEvent<
|
|
259
|
-
[string, string,
|
|
268
|
+
[string, string, BigNumber] & {
|
|
260
269
|
from: string;
|
|
261
270
|
to: string;
|
|
262
|
-
value:
|
|
271
|
+
value: BigNumber;
|
|
263
272
|
}
|
|
264
273
|
>[] = (
|
|
265
274
|
await Promise.all([
|
|
@@ -352,9 +361,9 @@ function joinUserState(
|
|
|
352
361
|
poolState: Pool,
|
|
353
362
|
tokenEventState: hubPool.TokenEventState,
|
|
354
363
|
userState: Awaited<ReturnType<UserState["read"]>>,
|
|
355
|
-
transferValue
|
|
356
|
-
cumulativeStakeBalance
|
|
357
|
-
cumulativeStakeClaimBalance
|
|
364
|
+
transferValue = bnZero,
|
|
365
|
+
cumulativeStakeBalance = bnZero,
|
|
366
|
+
cumulativeStakeClaimBalance = bnZero
|
|
358
367
|
): User {
|
|
359
368
|
const positionValue = BigNumber.from(poolState.exchangeRateCurrent)
|
|
360
369
|
.mul(userState.balanceOf.add(cumulativeStakeBalance))
|
|
@@ -534,7 +543,7 @@ export class Client {
|
|
|
534
543
|
)
|
|
535
544
|
)
|
|
536
545
|
)
|
|
537
|
-
).reduce((prev, acc) => acc.add(prev),
|
|
546
|
+
).reduce((prev, acc) => acc.add(prev), bnZero);
|
|
538
547
|
|
|
539
548
|
// Get the cumulative balance of the user from the accelerating distributor contract.
|
|
540
549
|
const { cumulativeBalance } = await acceleratingDistributorContract.getUserStake(lpToken, userState.address);
|
|
@@ -578,7 +587,7 @@ export class Client {
|
|
|
578
587
|
}
|
|
579
588
|
// we make sure to filter out any transfers where to/from is the same user
|
|
580
589
|
return result;
|
|
581
|
-
},
|
|
590
|
+
}, bnZero);
|
|
582
591
|
}
|
|
583
592
|
private getOrCreateTransactionManager(signer: Signer, address: string) {
|
|
584
593
|
if (this.transactionManagers[address]) return this.transactionManagers[address];
|
|
@@ -744,7 +753,7 @@ export class Client {
|
|
|
744
753
|
const { address: userAddress } = userState;
|
|
745
754
|
const transferValue = this.config.hasArchive
|
|
746
755
|
? await this.calculateLpTransferValue(l1TokenAddress, userState)
|
|
747
|
-
:
|
|
756
|
+
: bnZero;
|
|
748
757
|
const stakeData = await this.resolveStakingData(lpToken, l1TokenAddress, userState);
|
|
749
758
|
const tokenEventState = poolEventState[l1TokenAddress];
|
|
750
759
|
const newUserState = this.setUserState(
|
|
@@ -53,6 +53,8 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
this.pollingInterval = 1000;
|
|
57
|
+
|
|
56
58
|
if (this.nodeQuorumThreshold < 1 || !Number.isInteger(this.nodeQuorumThreshold)) {
|
|
57
59
|
throw new Error(
|
|
58
60
|
`nodeQuorum,Threshold cannot be < 1 and must be an integer. Currently set to ${this.nodeQuorumThreshold}`
|
|
@@ -125,9 +127,38 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
|
|
|
125
127
|
return values[0][1];
|
|
126
128
|
}
|
|
127
129
|
|
|
128
|
-
const
|
|
130
|
+
const getMismatchedProviders = (values: [ethers.providers.StaticJsonRpcProvider, unknown][]) => {
|
|
131
|
+
return Object.fromEntries(
|
|
132
|
+
values
|
|
133
|
+
.filter(([, result]) => !compareRpcResults(method, result, quorumResult))
|
|
134
|
+
.map(([provider, result]) => [provider.connection.url, result])
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const logQuorumMismatchOrFailureDetails = (
|
|
139
|
+
method: string,
|
|
140
|
+
params: Array<unknown>,
|
|
141
|
+
quorumProviders: string[],
|
|
142
|
+
mismatchedProviders: { [k: string]: unknown },
|
|
143
|
+
errors: [ethers.providers.StaticJsonRpcProvider, string][]
|
|
144
|
+
) => {
|
|
145
|
+
logger.warn({
|
|
146
|
+
at: "ProviderUtils",
|
|
147
|
+
message: "Some providers mismatched with the quorum result or failed 🚸",
|
|
148
|
+
notificationPath: "across-warn",
|
|
149
|
+
method,
|
|
150
|
+
params: JSON.stringify(params),
|
|
151
|
+
quorumProviders,
|
|
152
|
+
mismatchedProviders: JSON.stringify(mismatchedProviders),
|
|
153
|
+
erroringProviders: errors.map(([provider, errorText]) => formatProviderError(provider, errorText)),
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const throwQuorumError = (fallbackValues?: [ethers.providers.StaticJsonRpcProvider, unknown][]) => {
|
|
129
158
|
const errorTexts = errors.map(([provider, errorText]) => formatProviderError(provider, errorText));
|
|
130
159
|
const successfulProviderUrls = values.map(([provider]) => provider.connection.url);
|
|
160
|
+
const mismatchedProviders = getMismatchedProviders([...values, ...(fallbackValues || [])]);
|
|
161
|
+
logQuorumMismatchOrFailureDetails(method, params, successfulProviderUrls, mismatchedProviders, errors);
|
|
131
162
|
throw new Error(
|
|
132
163
|
"Not enough providers agreed to meet quorum.\n" +
|
|
133
164
|
"Providers that errored:\n" +
|
|
@@ -186,29 +217,16 @@ export class RetryProvider extends ethers.providers.StaticJsonRpcProvider {
|
|
|
186
217
|
|
|
187
218
|
// If this count is less than we need for quorum, throw the quorum error.
|
|
188
219
|
if (count < quorumThreshold) {
|
|
189
|
-
throwQuorumError();
|
|
220
|
+
throwQuorumError(fallbackValues);
|
|
190
221
|
}
|
|
191
222
|
|
|
192
223
|
// If we've achieved quorum, then we should still log the providers that mismatched with the quorum result.
|
|
193
|
-
const mismatchedProviders =
|
|
194
|
-
[...values, ...fallbackValues]
|
|
195
|
-
.filter(([, result]) => !compareRpcResults(method, result, quorumResult))
|
|
196
|
-
.map(([provider, result]) => [provider.connection.url, result])
|
|
197
|
-
);
|
|
224
|
+
const mismatchedProviders = getMismatchedProviders([...values, ...fallbackValues]);
|
|
198
225
|
const quorumProviders = [...values, ...fallbackValues]
|
|
199
226
|
.filter(([, result]) => compareRpcResults(method, result, quorumResult))
|
|
200
227
|
.map(([provider]) => provider.connection.url);
|
|
201
228
|
if (Object.keys(mismatchedProviders).length > 0 || errors.length > 0) {
|
|
202
|
-
|
|
203
|
-
at: "ProviderUtils",
|
|
204
|
-
message: "Some providers mismatched with the quorum result or failed 🚸",
|
|
205
|
-
notificationPath: "across-warn",
|
|
206
|
-
method,
|
|
207
|
-
params,
|
|
208
|
-
quorumProviders,
|
|
209
|
-
mismatchedProviders,
|
|
210
|
-
erroringProviders: errors.map(([provider, errorText]) => formatProviderError(provider, errorText)),
|
|
211
|
-
});
|
|
229
|
+
logQuorumMismatchOrFailureDetails(method, params, quorumProviders, mismatchedProviders, errors);
|
|
212
230
|
}
|
|
213
231
|
|
|
214
232
|
return quorumResult;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
-
import { BigNumber } from "ethers";
|
|
3
2
|
import { DEFAULT_SIMULATED_RELAYER_ADDRESS, TOKEN_SYMBOLS_MAP } from "../constants";
|
|
4
3
|
import { Deposit } from "../interfaces";
|
|
5
4
|
import {
|
|
5
|
+
BigNumber,
|
|
6
6
|
BigNumberish,
|
|
7
7
|
MAX_BIG_INT,
|
|
8
8
|
TransactionCostEstimate,
|
|
@@ -4,14 +4,20 @@
|
|
|
4
4
|
* @author Across Protocol
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { utils as ethersUtils } from "ethers";
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
// eslint-disable-next-line no-restricted-imports
|
|
10
|
+
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// eslint-disable-next-line no-restricted-imports
|
|
13
|
+
export * from "@ethersproject/bignumber";
|
|
14
|
+
export type BN = BigNumber;
|
|
13
15
|
|
|
16
|
+
export const { formatEther, formatUnits, parseEther, parseUnits } = ethersUtils;
|
|
17
|
+
export const bnZero = BigNumber.from("0");
|
|
18
|
+
export const bnOne = BigNumber.from("1");
|
|
14
19
|
export const bnUint32Max = BigNumber.from("0xffffffff");
|
|
20
|
+
export const bnUint256Max = BigNumber.from("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
15
21
|
|
|
16
22
|
/**
|
|
17
23
|
* Converts a stringified number into a BigNumber with 18 decimal places.
|
|
@@ -19,7 +25,7 @@ export const bnUint32Max = BigNumber.from("0xffffffff");
|
|
|
19
25
|
* @returns The parsed BigNumber.
|
|
20
26
|
*/
|
|
21
27
|
export function toWei(num: BigNumberish): BN {
|
|
22
|
-
return
|
|
28
|
+
return ethersUtils.parseEther(num.toString());
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
/**
|
|
@@ -28,7 +34,7 @@ export function toWei(num: BigNumberish): BN {
|
|
|
28
34
|
* @returns The parsed BigNumber.
|
|
29
35
|
*/
|
|
30
36
|
export function toGWei(num: BigNumberish): BN {
|
|
31
|
-
return
|
|
37
|
+
return ethersUtils.parseUnits(num.toString(), 9);
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BN, toBN } from "./BigNumberUtils";
|
|
1
|
+
import { utils as ethersUtils } from "ethers";
|
|
2
|
+
import { formatUnits, BigNumber as ethersBigNumber, BN, parseUnits, toBN } from "./BigNumberUtils";
|
|
3
3
|
import { fromWei } from "./common";
|
|
4
4
|
import assert from "assert";
|
|
5
5
|
import { BigNumber } from "bignumber.js";
|
|
@@ -93,7 +93,7 @@ export function createShortHexString(hex: string, maxLength = 8, delimiter = "..
|
|
|
93
93
|
* @returns The hex string.
|
|
94
94
|
*/
|
|
95
95
|
export function utf8ToHex(input: string): string {
|
|
96
|
-
return
|
|
96
|
+
return ethersUtils.formatBytes32String(input);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/**
|
|
@@ -102,7 +102,7 @@ export function utf8ToHex(input: string): string {
|
|
|
102
102
|
* @returns The utf8 string.
|
|
103
103
|
*/
|
|
104
104
|
export function hexToUtf8(input: string): string {
|
|
105
|
-
return
|
|
105
|
+
return ethersUtils.toUtf8String(input);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
/**
|
|
@@ -112,7 +112,7 @@ export function hexToUtf8(input: string): string {
|
|
|
112
112
|
* @returns The 32-byte hexadecimal string representation of the input.
|
|
113
113
|
*/
|
|
114
114
|
export function bnToHex(input: BN): string {
|
|
115
|
-
return
|
|
115
|
+
return ethersUtils.hexZeroPad(ethersUtils.hexlify(toBN(input)), 32);
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
/**
|
|
@@ -172,8 +172,8 @@ export const ConvertDecimals = (fromDecimals: number, toDecimals: number): ((amo
|
|
|
172
172
|
* @param numericString The numeric string to convert
|
|
173
173
|
* @returns The winston representation of the numeric string as a BigNumber
|
|
174
174
|
*/
|
|
175
|
-
export function parseWinston(numericString: string):
|
|
176
|
-
return
|
|
175
|
+
export function parseWinston(numericString: string): ethersBigNumber {
|
|
176
|
+
return parseUnits(numericString, 12);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
/**
|
|
@@ -181,6 +181,6 @@ export function parseWinston(numericString: string): ethers.BigNumber {
|
|
|
181
181
|
* @param winstonValue The winston value to convert
|
|
182
182
|
* @returns The numeric string representation of the winston value
|
|
183
183
|
*/
|
|
184
|
-
export function formatWinston(winstonValue:
|
|
185
|
-
return
|
|
184
|
+
export function formatWinston(winstonValue: ethersBigNumber): string {
|
|
185
|
+
return formatUnits(winstonValue, 12);
|
|
186
186
|
}
|
package/src/utils/JSONUtils.ts
CHANGED
package/src/utils/Multicall.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Contract, providers, Signer, utils as ethersUtils } from "ethers";
|
|
2
2
|
import { CHAIN_IDs } from "@across-protocol/constants";
|
|
3
|
+
import { BigNumber } from "./BigNumberUtils";
|
|
3
4
|
import { Multicall3, Multicall3__factory } from "./abi/typechain";
|
|
4
5
|
|
|
5
6
|
type Provider = providers.Provider;
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
-
import {
|
|
2
|
+
import { BytesLike, Contract, PopulatedTransaction, providers, utils as ethersUtils } from "ethers";
|
|
3
3
|
import { CHAIN_IDs, ZERO_ADDRESS } from "../constants";
|
|
4
4
|
import { Deposit, Fill, FillStatus, RelayData, SlowFillRequest } from "../interfaces";
|
|
5
5
|
import { SpokePoolClient } from "../clients";
|
|
6
6
|
import { chunk } from "./ArrayUtils";
|
|
7
|
-
import { toBN } from "./BigNumberUtils";
|
|
7
|
+
import { BigNumber, toBN } from "./BigNumberUtils";
|
|
8
8
|
import { isDefined } from "./TypeGuards";
|
|
9
9
|
import { getNetworkName } from "./NetworkUtils";
|
|
10
10
|
|
package/src/utils/TokenUtils.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { BlockTag } from "@ethersproject/abstract-provider";
|
|
2
|
-
import {
|
|
2
|
+
import { Contract, providers, Signer } from "ethers";
|
|
3
3
|
import * as constants from "../constants";
|
|
4
4
|
import { L1Token } from "../interfaces";
|
|
5
5
|
import { ERC20__factory } from "../typechain";
|
|
6
|
+
import { BigNumber } from "./BigNumberUtils";
|
|
6
7
|
import { getNetworkName } from "./NetworkUtils";
|
|
7
8
|
import { isDefined } from "./TypeGuards";
|
|
8
9
|
import { compareAddressesSimple } from "./AddressUtils";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { utils as ethersUtils } from "ethers";
|
|
2
2
|
import { object, min as Min, define, optional, string, integer, boolean } from "superstruct";
|
|
3
3
|
import { DepositWithBlock } from "../interfaces";
|
|
4
|
+
import { BigNumber } from "../utils";
|
|
4
5
|
|
|
5
|
-
const AddressValidator = define<string>("AddressValidator", (v) =>
|
|
6
|
-
const HexValidator = define<string>("HexValidator", (v) =>
|
|
7
|
-
const BigNumberValidator = define<BigNumber>("BigNumberValidator", (v) =>
|
|
6
|
+
const AddressValidator = define<string>("AddressValidator", (v) => ethersUtils.isAddress(String(v)));
|
|
7
|
+
const HexValidator = define<string>("HexValidator", (v) => ethersUtils.isHexString(String(v)));
|
|
8
|
+
const BigNumberValidator = define<BigNumber>("BigNumberValidator", (v) => BigNumber.isBigNumber(v));
|
|
8
9
|
|
|
9
10
|
const V3DepositSchema = object({
|
|
10
11
|
depositId: Min(integer(), 0),
|
package/src/utils/common.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
|
2
2
|
import { isL2Provider as isOptimismL2Provider } from "@eth-optimism/sdk/dist/l2-provider";
|
|
3
3
|
import assert from "assert";
|
|
4
4
|
import Decimal from "decimal.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ethers, PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
6
6
|
import { getGasPriceEstimate } from "../gasPriceOracle";
|
|
7
7
|
import { TypedMessage } from "../interfaces/TypedData";
|
|
8
|
-
import { BigNumberish, BN, toBN } from "./BigNumberUtils";
|
|
8
|
+
import { BigNumber, BigNumberish, BN, formatUnits, parseUnits, toBN } from "./BigNumberUtils";
|
|
9
9
|
import { ConvertDecimals } from "./FormattingUtils";
|
|
10
10
|
import { chainIsOPStack } from "./NetworkUtils";
|
|
11
11
|
|
|
@@ -20,7 +20,7 @@ export const MAX_BIG_INT = BigNumber.from(Number.MAX_SAFE_INTEGER.toString());
|
|
|
20
20
|
* @param {number} decimals
|
|
21
21
|
* @returns {BN}
|
|
22
22
|
*/
|
|
23
|
-
export const toBNWei = (num: BigNumberish, decimals?: number): BN =>
|
|
23
|
+
export const toBNWei = (num: BigNumberish, decimals?: number): BN => parseUnits(num.toString(), decimals);
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* fromWei.
|
|
@@ -29,8 +29,7 @@ export const toBNWei = (num: BigNumberish, decimals?: number): BN => ethers.util
|
|
|
29
29
|
* @param {number} decimals
|
|
30
30
|
* @returns {string}
|
|
31
31
|
*/
|
|
32
|
-
export const fromWei = (num: BigNumberish, decimals?: number): string =>
|
|
33
|
-
ethers.utils.formatUnits(num.toString(), decimals);
|
|
32
|
+
export const fromWei = (num: BigNumberish, decimals?: number): string => formatUnits(num.toString(), decimals);
|
|
34
33
|
|
|
35
34
|
/**
|
|
36
35
|
* min.
|