@across-protocol/sdk 3.3.25 → 3.3.27
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/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +28 -28
- package/dist/cjs/clients/SpokePoolClient.d.ts +0 -4
- package/dist/cjs/clients/SpokePoolClient.js +1 -4
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +1 -0
- package/dist/cjs/constants.js +2 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +3 -2
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/utils/FormattingUtils.d.ts +1 -0
- package/dist/cjs/utils/FormattingUtils.js +5 -1
- package/dist/cjs/utils/FormattingUtils.js.map +1 -1
- package/dist/cjs/utils/Multicall.js +2 -0
- package/dist/cjs/utils/Multicall.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +1 -0
- package/dist/cjs/utils/SpokeUtils.js +6 -1
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +1 -51
- package/dist/cjs/utils/common.js +3 -55
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +28 -28
- package/dist/esm/clients/SpokePoolClient.d.ts +0 -19
- package/dist/esm/clients/SpokePoolClient.js +1 -19
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +3 -2
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/utils/FormattingUtils.d.ts +1 -0
- package/dist/esm/utils/FormattingUtils.js +3 -0
- package/dist/esm/utils/FormattingUtils.js.map +1 -1
- package/dist/esm/utils/Multicall.js +2 -0
- package/dist/esm/utils/Multicall.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +1 -0
- package/dist/esm/utils/SpokeUtils.js +10 -1
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/common.d.ts +1 -62
- package/dist/esm/utils/common.js +2 -63
- package/dist/esm/utils/common.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +28 -28
- package/dist/types/clients/SpokePoolClient.d.ts +0 -19
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -0
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/utils/FormattingUtils.d.ts +1 -0
- 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 +1 -0
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +1 -62
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/BundleDataClient/BundleDataClient.ts +7 -0
- package/src/clients/SpokePoolClient.ts +3 -29
- package/src/constants.ts +4 -0
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -10
- package/src/utils/FormattingUtils.ts +4 -0
- package/src/utils/Multicall.ts +2 -0
- package/src/utils/SpokeUtils.ts +11 -1
- package/src/utils/common.ts +3 -101
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { L2Provider } from "@eth-optimism/sdk/dist/interfaces/l2-provider";
|
|
2
2
|
import Decimal from "decimal.js";
|
|
3
3
|
import { ethers, PopulatedTransaction, providers } from "ethers";
|
|
4
|
-
import { TypedMessage } from "../interfaces/TypedData";
|
|
5
4
|
import { BigNumber, BigNumberish, BN } from "./BigNumberUtils";
|
|
6
5
|
import { Transport } from "viem";
|
|
7
6
|
export type Decimalish = string | number | Decimal;
|
|
@@ -130,6 +129,7 @@ export declare function retry<T>(call: () => Promise<T>, times: number, delayS:
|
|
|
130
129
|
export type TransactionCostEstimate = {
|
|
131
130
|
nativeGasCost: BigNumber;
|
|
132
131
|
tokenGasCost: BigNumber;
|
|
132
|
+
gasPrice: BigNumber;
|
|
133
133
|
};
|
|
134
134
|
/**
|
|
135
135
|
* Estimates the total gas cost required to submit an unsigned (populated) transaction on-chain.
|
|
@@ -147,66 +147,5 @@ export declare function estimateTotalGasRequiredByUnsignedTransaction(unsignedTx
|
|
|
147
147
|
gasUnits: BigNumberish;
|
|
148
148
|
transport: Transport;
|
|
149
149
|
}>): Promise<TransactionCostEstimate>;
|
|
150
|
-
export type UpdateDepositDetailsMessageType = {
|
|
151
|
-
UpdateDepositDetails: [
|
|
152
|
-
{
|
|
153
|
-
name: "depositId";
|
|
154
|
-
type: "uint32";
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
name: "originChainId";
|
|
158
|
-
type: "uint256";
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: "updatedRelayerFeePct";
|
|
162
|
-
type: "int64";
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
name: "updatedRecipient";
|
|
166
|
-
type: "address";
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
name: "updatedMessage";
|
|
170
|
-
type: "bytes";
|
|
171
|
-
}
|
|
172
|
-
];
|
|
173
|
-
};
|
|
174
|
-
export type UpdateV3DepositDetailsMessageType = {
|
|
175
|
-
UpdateDepositDetails: [
|
|
176
|
-
{
|
|
177
|
-
name: "depositId";
|
|
178
|
-
type: "uint32";
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
name: "originChainId";
|
|
182
|
-
type: "uint256";
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: "updatedOutputAmount";
|
|
186
|
-
type: "uint256";
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
name: "updatedRecipient";
|
|
190
|
-
type: "address";
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
name: "updatedMessage";
|
|
194
|
-
type: "bytes";
|
|
195
|
-
}
|
|
196
|
-
];
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Utility function to get EIP-712 compliant typed data that can be signed with the JSON-RPC method
|
|
200
|
-
* `eth_signedTypedDataV4` in MetaMask (https://docs.metamask.io/guide/signing-data.html). The resulting signature
|
|
201
|
-
* can then be used to call the method `speedUpDeposit` of a `SpokePool.sol` contract.
|
|
202
|
-
* @param depositId The deposit ID to speed up.
|
|
203
|
-
* @param originChainId The chain ID of the origin chain.
|
|
204
|
-
* @param updatedRelayerFeePct The new relayer fee percentage.
|
|
205
|
-
* @param updatedRecipient The new recipient address.
|
|
206
|
-
* @param updatedMessage The new message that should be provided to the recipient.
|
|
207
|
-
* @return EIP-712 compliant typed data.
|
|
208
|
-
*/
|
|
209
|
-
export declare function getUpdateDepositTypedData(depositId: number, originChainId: number, updatedRelayerFeePct: BigNumber, updatedRecipient: string, updatedMessage: string): TypedMessage<UpdateDepositDetailsMessageType>;
|
|
210
|
-
export declare function getUpdateV3DepositTypedData(depositId: number, originChainId: number, updatedOutputAmount: BigNumber, updatedRecipient: string, updatedMessage: string): TypedMessage<UpdateV3DepositDetailsMessageType>;
|
|
211
150
|
export declare function randomAddress(): string;
|
|
212
151
|
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAG3E,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,SAAS,E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Q,CAAC,EAC7D,OAAO,GAAE,OAAO,CAAC;IACf,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAM,GACN,OAAO,CAAC,uBAAuB,CAAC,CAgDlC;AAgBD,wBAAgB,aAAa,WAE5B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@across-protocol/sdk",
|
|
3
3
|
"author": "UMA Team",
|
|
4
|
-
"version": "3.3.
|
|
4
|
+
"version": "3.3.27",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"homepage": "https://docs.across.to/reference/sdk",
|
|
7
7
|
"files": [
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
},
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@across-protocol/across-token": "^1.0.0",
|
|
102
|
-
"@across-protocol/constants": "^3.1.
|
|
103
|
-
"@across-protocol/contracts": "^3.0.
|
|
102
|
+
"@across-protocol/constants": "^3.1.24",
|
|
103
|
+
"@across-protocol/contracts": "^3.0.19",
|
|
104
104
|
"@eth-optimism/sdk": "^3.3.1",
|
|
105
105
|
"@ethersproject/bignumber": "^5.7.0",
|
|
106
106
|
"@pinata/sdk": "^2.1.0",
|
|
@@ -899,6 +899,9 @@ export class BundleDataClient {
|
|
|
899
899
|
bundleInvalidFillsV3.push(fill);
|
|
900
900
|
return;
|
|
901
901
|
}
|
|
902
|
+
// If deposit is using the deterministic relay hash feature, then the following binary search-based
|
|
903
|
+
// algorithm will not work. However, it is impossible to emit an infinite fill deadline using
|
|
904
|
+
// the unsafeDepositV3 function so there is no need to catch the special case.
|
|
902
905
|
const historicalDeposit = await queryHistoricalDepositForFill(originClient, fill);
|
|
903
906
|
if (!historicalDeposit.found) {
|
|
904
907
|
bundleInvalidFillsV3.push(fill);
|
|
@@ -1003,6 +1006,10 @@ export class BundleDataClient {
|
|
|
1003
1006
|
// older deposit in case the spoke pool client's lookback isn't old enough to find the matching deposit.
|
|
1004
1007
|
// We can skip this step if the deposit's fill deadline is not infinite, because we can assume that the
|
|
1005
1008
|
// spoke pool clients have loaded deposits old enough to cover all fills with a non-infinite fill deadline.
|
|
1009
|
+
// We do not need to handle the case where the deposit ID is > uint32 (in which case we wouldn't
|
|
1010
|
+
// want to perform a binary search lookup for it because the deposit ID is "unsafe" and cannot be
|
|
1011
|
+
// found using such a method) because infinite fill deadlines cannot be produced from the unsafeDepositV3()
|
|
1012
|
+
// function.
|
|
1006
1013
|
if (
|
|
1007
1014
|
INFINITE_FILL_DEADLINE.eq(slowFillRequest.fillDeadline) &&
|
|
1008
1015
|
slowFillRequest.blockNumber >= destinationChainBlockRange[0]
|
|
@@ -400,33 +400,6 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
400
400
|
return `${event.depositId}-${event.originChainId}`;
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
/**
|
|
404
|
-
* Find the block range that contains the deposit ID. This is a binary search that searches for the block range
|
|
405
|
-
* that contains the deposit ID.
|
|
406
|
-
* @param targetDepositId The target deposit ID to search for.
|
|
407
|
-
* @param initLow The initial lower bound of the block range to search.
|
|
408
|
-
* @param initHigh The initial upper bound of the block range to search.
|
|
409
|
-
* @param maxSearches The maximum number of searches to perform. This is used to prevent infinite loops.
|
|
410
|
-
* @returns The block range that contains the deposit ID.
|
|
411
|
-
* @note // We want to find the block range that satisfies these conditions:
|
|
412
|
-
* // - the low block has deposit count <= targetDepositId
|
|
413
|
-
* // - the high block has a deposit count > targetDepositId.
|
|
414
|
-
* // This way the caller can search for a V3FundsDeposited event between [low, high] that will always
|
|
415
|
-
* // contain the event emitted when deposit ID was incremented to targetDepositId + 1. This is the same transaction
|
|
416
|
-
* // where the deposit with deposit ID = targetDepositId was created.
|
|
417
|
-
*/
|
|
418
|
-
public _getBlockRangeForDepositId(
|
|
419
|
-
targetDepositId: number,
|
|
420
|
-
initLow: number,
|
|
421
|
-
initHigh: number,
|
|
422
|
-
maxSearches: number
|
|
423
|
-
): Promise<{
|
|
424
|
-
low: number;
|
|
425
|
-
high: number;
|
|
426
|
-
}> {
|
|
427
|
-
return getBlockRangeForDepositId(targetDepositId, initLow, initHigh, maxSearches, this);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
403
|
/**
|
|
431
404
|
* Finds the deposit id at a specific block number.
|
|
432
405
|
* @param blockTag The block number to search for the deposit ID at.
|
|
@@ -814,11 +787,12 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
814
787
|
//
|
|
815
788
|
// @dev Limiting between 5-10 searches empirically performs best when there are ~300,000 deposits
|
|
816
789
|
// for a spoke pool and we're looking for a deposit <5 days older than HEAD.
|
|
817
|
-
const searchBounds = await
|
|
790
|
+
const searchBounds = await getBlockRangeForDepositId(
|
|
818
791
|
depositId,
|
|
819
792
|
this.deploymentBlock,
|
|
820
793
|
this.latestBlockSearched,
|
|
821
|
-
7
|
|
794
|
+
7,
|
|
795
|
+
this
|
|
822
796
|
);
|
|
823
797
|
|
|
824
798
|
const tStart = Date.now();
|
package/src/constants.ts
CHANGED
|
@@ -15,6 +15,10 @@ export const { AddressZero: ZERO_ADDRESS } = ethersConstants;
|
|
|
15
15
|
// 2^96 - 1 is a conservative erc20 max allowance.
|
|
16
16
|
export const MAX_SAFE_ALLOWANCE = "79228162514264337593543950335";
|
|
17
17
|
|
|
18
|
+
// The maximum depositId that can be emitted in a depositV3 method is the maximum uint32 value, so
|
|
19
|
+
// 2^32 - 1.
|
|
20
|
+
export const MAX_SAFE_DEPOSIT_ID = "4294967295";
|
|
21
|
+
|
|
18
22
|
export const SECONDS_PER_YEAR = 31557600; // 365.25 days per year.
|
|
19
23
|
|
|
20
24
|
/**
|
|
@@ -89,20 +89,20 @@ export class QueryBase implements QueryInterface {
|
|
|
89
89
|
const gasTotalMultiplier = toBNWei(1.0 + gasMarkup);
|
|
90
90
|
|
|
91
91
|
const tx = await populateV3Relay(this.spokePool, deposit, relayer);
|
|
92
|
-
const {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
);
|
|
92
|
+
const {
|
|
93
|
+
nativeGasCost,
|
|
94
|
+
tokenGasCost,
|
|
95
|
+
gasPrice: impliedGasPrice,
|
|
96
|
+
} = await estimateTotalGasRequiredByUnsignedTransaction(tx, relayer, this.provider, {
|
|
97
|
+
gasPrice,
|
|
98
|
+
gasUnits,
|
|
99
|
+
transport,
|
|
100
|
+
});
|
|
102
101
|
|
|
103
102
|
return {
|
|
104
103
|
nativeGasCost: nativeGasCost.mul(gasTotalMultiplier).div(fixedPointAdjustment),
|
|
105
104
|
tokenGasCost: tokenGasCost.mul(gasTotalMultiplier).div(fixedPointAdjustment),
|
|
105
|
+
gasPrice: impliedGasPrice,
|
|
106
106
|
};
|
|
107
107
|
}
|
|
108
108
|
|
|
@@ -126,6 +126,10 @@ export function convertFromWei(weiVal: string, decimals: number): string {
|
|
|
126
126
|
return formatFunction(weiVal);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
export function formatGwei(weiVal: string): string {
|
|
130
|
+
return convertFromWei(weiVal, 9);
|
|
131
|
+
}
|
|
132
|
+
|
|
129
133
|
/**
|
|
130
134
|
* Shortens a list of addresses to a shorter version with only the first 10 characters.
|
|
131
135
|
* @param addresses A list of addresses to shorten.
|
package/src/utils/Multicall.ts
CHANGED
|
@@ -25,6 +25,7 @@ const NON_DETERMINISTIC_MULTICALL_ADDRESSES = {
|
|
|
25
25
|
// Multicall3 is an OP stack predeploy, so don't specify it here.
|
|
26
26
|
const DETERMINISTIC_MULTICALL_CHAINS = [
|
|
27
27
|
CHAIN_IDs.ARBITRUM,
|
|
28
|
+
CHAIN_IDs.INK,
|
|
28
29
|
CHAIN_IDs.LINEA,
|
|
29
30
|
CHAIN_IDs.MAINNET,
|
|
30
31
|
CHAIN_IDs.POLYGON,
|
|
@@ -32,6 +33,7 @@ const DETERMINISTIC_MULTICALL_CHAINS = [
|
|
|
32
33
|
// Testnet:
|
|
33
34
|
CHAIN_IDs.BASE_SEPOLIA,
|
|
34
35
|
CHAIN_IDs.BLAST_SEPOLIA,
|
|
36
|
+
CHAIN_IDs.INK_SEPOLIA,
|
|
35
37
|
CHAIN_IDs.POLYGON_AMOY,
|
|
36
38
|
CHAIN_IDs.SCROLL_SEPOLIA,
|
|
37
39
|
CHAIN_IDs.SEPOLIA,
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { BytesLike, Contract, PopulatedTransaction, providers, utils as ethersUtils } from "ethers";
|
|
3
|
-
import { CHAIN_IDs, ZERO_ADDRESS } from "../constants";
|
|
3
|
+
import { CHAIN_IDs, MAX_SAFE_DEPOSIT_ID, 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";
|
|
@@ -244,6 +244,16 @@ export function getRelayHashFromEvent(e: Deposit | Fill | SlowFillRequest): stri
|
|
|
244
244
|
return getRelayDataHash(e, e.destinationChainId);
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
export function isUnsafeDepositId(depositId: number): boolean {
|
|
248
|
+
// SpokePool.unsafeDepositV3() produces a uint256 depositId by hashing the msg.sender, depositor and input
|
|
249
|
+
// uint256 depositNonce. There is a possibility that this resultant uint256 is less than the maxSafeDepositId (i.e.
|
|
250
|
+
// the maximum uint32 value) which makes it possible that an unsafeDepositV3's depositId can collide with a safe
|
|
251
|
+
// depositV3's depositId, but the chances of a collision are 1 in 2^(256 - 32), so we'll ignore this
|
|
252
|
+
// possibility.
|
|
253
|
+
const maxSafeDepositId = BigNumber.from(MAX_SAFE_DEPOSIT_ID);
|
|
254
|
+
return maxSafeDepositId.lt(depositId);
|
|
255
|
+
}
|
|
256
|
+
|
|
247
257
|
/**
|
|
248
258
|
* Find the amount filled for a deposit at a particular block.
|
|
249
259
|
* @param spokePool SpokePool contract instance.
|
package/src/utils/common.ts
CHANGED
|
@@ -4,7 +4,6 @@ import assert from "assert";
|
|
|
4
4
|
import Decimal from "decimal.js";
|
|
5
5
|
import { ethers, PopulatedTransaction, providers, VoidSigner } from "ethers";
|
|
6
6
|
import { getGasPriceEstimate } from "../gasPriceOracle";
|
|
7
|
-
import { TypedMessage } from "../interfaces/TypedData";
|
|
8
7
|
import { BigNumber, BigNumberish, BN, formatUnits, parseUnits, toBN } from "./BigNumberUtils";
|
|
9
8
|
import { ConvertDecimals } from "./FormattingUtils";
|
|
10
9
|
import { chainIsOPStack } from "./NetworkUtils";
|
|
@@ -236,6 +235,7 @@ export function retry<T>(call: () => Promise<T>, times: number, delayS: number):
|
|
|
236
235
|
export type TransactionCostEstimate = {
|
|
237
236
|
nativeGasCost: BigNumber; // Units: gas
|
|
238
237
|
tokenGasCost: BigNumber; // Units: wei (nativeGasCost * wei/gas)
|
|
238
|
+
gasPrice: BigNumber; // Units: wei/gas
|
|
239
239
|
};
|
|
240
240
|
|
|
241
241
|
/**
|
|
@@ -266,6 +266,7 @@ export async function estimateTotalGasRequiredByUnsignedTransaction(
|
|
|
266
266
|
|
|
267
267
|
// Estimate the Gas units required to submit this transaction.
|
|
268
268
|
const nativeGasCost = gasUnits ? BigNumber.from(gasUnits) : await voidSigner.estimateGas(unsignedTx);
|
|
269
|
+
assert(nativeGasCost.gt(0), "Gas cost should not be 0");
|
|
269
270
|
let tokenGasCost: BigNumber;
|
|
270
271
|
|
|
271
272
|
// OP stack is a special case; gas cost is computed by the SDK, without having to query price.
|
|
@@ -303,6 +304,7 @@ export async function estimateTotalGasRequiredByUnsignedTransaction(
|
|
|
303
304
|
return {
|
|
304
305
|
nativeGasCost, // Units: gas
|
|
305
306
|
tokenGasCost, // Units: wei (nativeGasCost * wei/gas)
|
|
307
|
+
gasPrice: tokenGasCost.div(nativeGasCost), // Units: wei/gas
|
|
306
308
|
};
|
|
307
309
|
}
|
|
308
310
|
|
|
@@ -320,106 +322,6 @@ async function getLineaGasFees(chainId: number, transport: Transport | undefined
|
|
|
320
322
|
};
|
|
321
323
|
}
|
|
322
324
|
|
|
323
|
-
export type UpdateDepositDetailsMessageType = {
|
|
324
|
-
UpdateDepositDetails: [
|
|
325
|
-
{
|
|
326
|
-
name: "depositId";
|
|
327
|
-
type: "uint32";
|
|
328
|
-
},
|
|
329
|
-
{ name: "originChainId"; type: "uint256" },
|
|
330
|
-
{ name: "updatedRelayerFeePct"; type: "int64" },
|
|
331
|
-
{ name: "updatedRecipient"; type: "address" },
|
|
332
|
-
{ name: "updatedMessage"; type: "bytes" },
|
|
333
|
-
];
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
export type UpdateV3DepositDetailsMessageType = {
|
|
337
|
-
UpdateDepositDetails: [
|
|
338
|
-
{ name: "depositId"; type: "uint32" },
|
|
339
|
-
{ name: "originChainId"; type: "uint256" },
|
|
340
|
-
{ name: "updatedOutputAmount"; type: "uint256" },
|
|
341
|
-
{ name: "updatedRecipient"; type: "address" },
|
|
342
|
-
{ name: "updatedMessage"; type: "bytes" },
|
|
343
|
-
];
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* Utility function to get EIP-712 compliant typed data that can be signed with the JSON-RPC method
|
|
348
|
-
* `eth_signedTypedDataV4` in MetaMask (https://docs.metamask.io/guide/signing-data.html). The resulting signature
|
|
349
|
-
* can then be used to call the method `speedUpDeposit` of a `SpokePool.sol` contract.
|
|
350
|
-
* @param depositId The deposit ID to speed up.
|
|
351
|
-
* @param originChainId The chain ID of the origin chain.
|
|
352
|
-
* @param updatedRelayerFeePct The new relayer fee percentage.
|
|
353
|
-
* @param updatedRecipient The new recipient address.
|
|
354
|
-
* @param updatedMessage The new message that should be provided to the recipient.
|
|
355
|
-
* @return EIP-712 compliant typed data.
|
|
356
|
-
*/
|
|
357
|
-
export function getUpdateDepositTypedData(
|
|
358
|
-
depositId: number,
|
|
359
|
-
originChainId: number,
|
|
360
|
-
updatedRelayerFeePct: BigNumber,
|
|
361
|
-
updatedRecipient: string,
|
|
362
|
-
updatedMessage: string
|
|
363
|
-
): TypedMessage<UpdateDepositDetailsMessageType> {
|
|
364
|
-
return {
|
|
365
|
-
types: {
|
|
366
|
-
UpdateDepositDetails: [
|
|
367
|
-
{ name: "depositId", type: "uint32" },
|
|
368
|
-
{ name: "originChainId", type: "uint256" },
|
|
369
|
-
{ name: "updatedRelayerFeePct", type: "int64" },
|
|
370
|
-
{ name: "updatedRecipient", type: "address" },
|
|
371
|
-
{ name: "updatedMessage", type: "bytes" },
|
|
372
|
-
],
|
|
373
|
-
},
|
|
374
|
-
primaryType: "UpdateDepositDetails",
|
|
375
|
-
domain: {
|
|
376
|
-
name: "ACROSS-V2",
|
|
377
|
-
version: "1.0.0",
|
|
378
|
-
chainId: originChainId,
|
|
379
|
-
},
|
|
380
|
-
message: {
|
|
381
|
-
depositId,
|
|
382
|
-
originChainId,
|
|
383
|
-
updatedRelayerFeePct,
|
|
384
|
-
updatedRecipient,
|
|
385
|
-
updatedMessage,
|
|
386
|
-
},
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
export function getUpdateV3DepositTypedData(
|
|
391
|
-
depositId: number,
|
|
392
|
-
originChainId: number,
|
|
393
|
-
updatedOutputAmount: BigNumber,
|
|
394
|
-
updatedRecipient: string,
|
|
395
|
-
updatedMessage: string
|
|
396
|
-
): TypedMessage<UpdateV3DepositDetailsMessageType> {
|
|
397
|
-
return {
|
|
398
|
-
types: {
|
|
399
|
-
UpdateDepositDetails: [
|
|
400
|
-
{ name: "depositId", type: "uint32" },
|
|
401
|
-
{ name: "originChainId", type: "uint256" },
|
|
402
|
-
{ name: "updatedOutputAmount", type: "uint256" },
|
|
403
|
-
{ name: "updatedRecipient", type: "address" },
|
|
404
|
-
{ name: "updatedMessage", type: "bytes" },
|
|
405
|
-
],
|
|
406
|
-
},
|
|
407
|
-
primaryType: "UpdateDepositDetails",
|
|
408
|
-
domain: {
|
|
409
|
-
name: "ACROSS-V2",
|
|
410
|
-
version: "1.0.0",
|
|
411
|
-
chainId: originChainId,
|
|
412
|
-
},
|
|
413
|
-
message: {
|
|
414
|
-
depositId,
|
|
415
|
-
originChainId,
|
|
416
|
-
updatedOutputAmount,
|
|
417
|
-
updatedRecipient,
|
|
418
|
-
updatedMessage,
|
|
419
|
-
},
|
|
420
|
-
};
|
|
421
|
-
}
|
|
422
|
-
|
|
423
325
|
export function randomAddress() {
|
|
424
326
|
return ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));
|
|
425
327
|
}
|