@across-protocol/sdk 4.3.69 → 4.3.71
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/arch/evm/MessageUtils.d.ts +3 -0
- package/dist/cjs/arch/evm/MessageUtils.js +8 -0
- package/dist/cjs/arch/evm/MessageUtils.js.map +1 -0
- package/dist/cjs/arch/evm/index.d.ts +1 -0
- package/dist/cjs/arch/evm/index.js +1 -0
- package/dist/cjs/arch/evm/index.js.map +1 -1
- package/dist/cjs/arch/svm/MessageUtils.d.ts +3 -0
- package/dist/cjs/arch/svm/MessageUtils.js +9 -0
- package/dist/cjs/arch/svm/MessageUtils.js.map +1 -0
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +21 -49
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/index.d.ts +1 -0
- package/dist/cjs/arch/svm/index.js +1 -0
- package/dist/cjs/arch/svm/index.js.map +1 -1
- package/dist/cjs/gasPriceOracle/oracle.js +1 -0
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +2 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/arch/evm/MessageUtils.d.ts +9 -0
- package/dist/esm/arch/evm/MessageUtils.js +11 -0
- package/dist/esm/arch/evm/MessageUtils.js.map +1 -0
- package/dist/esm/arch/evm/index.d.ts +1 -0
- package/dist/esm/arch/evm/index.js +1 -0
- package/dist/esm/arch/evm/index.js.map +1 -1
- package/dist/esm/arch/svm/MessageUtils.d.ts +9 -0
- package/dist/esm/arch/svm/MessageUtils.js +15 -0
- package/dist/esm/arch/svm/MessageUtils.js.map +1 -0
- package/dist/esm/arch/svm/SpokeUtils.d.ts +4 -1
- package/dist/esm/arch/svm/SpokeUtils.js +25 -50
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/index.d.ts +1 -0
- package/dist/esm/arch/svm/index.js +1 -0
- package/dist/esm/arch/svm/index.js.map +1 -1
- package/dist/esm/gasPriceOracle/oracle.js +1 -1
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +4 -6
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/types/arch/evm/MessageUtils.d.ts +10 -0
- package/dist/types/arch/evm/MessageUtils.d.ts.map +1 -0
- package/dist/types/arch/evm/index.d.ts +1 -0
- package/dist/types/arch/evm/index.d.ts.map +1 -1
- package/dist/types/arch/svm/MessageUtils.d.ts +10 -0
- package/dist/types/arch/svm/MessageUtils.d.ts.map +1 -0
- package/dist/types/arch/svm/SpokeUtils.d.ts +4 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/index.d.ts +1 -0
- package/dist/types/arch/svm/index.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/arch/evm/MessageUtils.ts +12 -0
- package/src/arch/evm/index.ts +1 -0
- package/src/arch/svm/MessageUtils.ts +16 -0
- package/src/arch/svm/SpokeUtils.ts +6 -23
- package/src/arch/svm/index.ts +1 -0
- package/src/gasPriceOracle/oracle.ts +1 -1
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +2 -1
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +4 -22
package/src/arch/evm/index.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { deserializeMessage } from ".";
|
|
2
|
+
import { RelayData } from "../../interfaces";
|
|
3
|
+
import { BigNumber, bnZero, isMessageEmpty } from "../../utils";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @notice Return the native token cost of filling a deposit beyond gas cost. We're not using msg.value in our fills,
|
|
7
|
+
* so return zero for EVM side
|
|
8
|
+
* @param deposit RelayData associated with Deposit we're estimating for
|
|
9
|
+
* @returns Native token cost
|
|
10
|
+
*/
|
|
11
|
+
export function getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber {
|
|
12
|
+
// Notice. We return `message.value_amount` here instead of simulating the Transaction. The reason is, we choose to
|
|
13
|
+
// rely hard on Solana program to protect us from not taking more than `value_amount` rather than relying on
|
|
14
|
+
// simulation. Chain state may change between simulation and execution, so simulation alone is unreliable
|
|
15
|
+
return isMessageEmpty(deposit.message) ? bnZero : BigNumber.from(deserializeMessage(deposit.message).value_amount);
|
|
16
|
+
}
|
|
@@ -58,7 +58,6 @@ import {
|
|
|
58
58
|
chainIsProd,
|
|
59
59
|
chainIsSvm,
|
|
60
60
|
chunk,
|
|
61
|
-
delay,
|
|
62
61
|
getMessageHash,
|
|
63
62
|
isDefined,
|
|
64
63
|
isUnsafeDepositId,
|
|
@@ -1261,21 +1260,17 @@ export async function getFillRelayDelegatePda(
|
|
|
1261
1260
|
* @param nonce The nonce to check.
|
|
1262
1261
|
* @param sourceDomain The source domain.
|
|
1263
1262
|
* @returns True if the message has been processed, false otherwise.
|
|
1263
|
+
* @dev This function intentionally does not have error handling for `getCCTPNoncePda` nor `simulateAndDecode` since
|
|
1264
|
+
* the error handling would have to account for the asynchronous opening/closing of PDAs, which is better handled downstream,
|
|
1265
|
+
* where the caller of this function has more context.
|
|
1264
1266
|
*/
|
|
1265
1267
|
export const hasCCTPV1MessageBeenProcessed = async (
|
|
1266
1268
|
solanaClient: SVMProvider,
|
|
1267
1269
|
signer: KeyPairSigner,
|
|
1268
1270
|
nonce: number,
|
|
1269
|
-
sourceDomain: number
|
|
1270
|
-
nRetries: number = 0,
|
|
1271
|
-
maxRetries: number = 2
|
|
1271
|
+
sourceDomain: number
|
|
1272
1272
|
): Promise<boolean> => {
|
|
1273
|
-
|
|
1274
|
-
try {
|
|
1275
|
-
noncePda = await getCCTPNoncePda(solanaClient, signer, nonce, sourceDomain);
|
|
1276
|
-
} catch (e) {
|
|
1277
|
-
return false;
|
|
1278
|
-
}
|
|
1273
|
+
const noncePda = await getCCTPNoncePda(solanaClient, signer, nonce, sourceDomain);
|
|
1279
1274
|
const isNonceUsedIx = MessageTransmitterClient.getIsNonceUsedInstruction({
|
|
1280
1275
|
nonce: nonce,
|
|
1281
1276
|
usedNonces: noncePda,
|
|
@@ -1286,19 +1281,7 @@ export const hasCCTPV1MessageBeenProcessed = async (
|
|
|
1286
1281
|
}
|
|
1287
1282
|
return Boolean(buf[0]);
|
|
1288
1283
|
};
|
|
1289
|
-
|
|
1290
|
-
// and retry, and throw if the error persists.
|
|
1291
|
-
try {
|
|
1292
|
-
return await simulateAndDecode(solanaClient, isNonceUsedIx, signer, parserFunction);
|
|
1293
|
-
} catch (e) {
|
|
1294
|
-
if (nRetries < maxRetries) {
|
|
1295
|
-
const delaySeconds = 2 ** nRetries + Math.random();
|
|
1296
|
-
await delay(delaySeconds);
|
|
1297
|
-
|
|
1298
|
-
return hasCCTPV1MessageBeenProcessed(solanaClient, signer, nonce, sourceDomain, ++nRetries);
|
|
1299
|
-
}
|
|
1300
|
-
throw e;
|
|
1301
|
-
}
|
|
1284
|
+
return await simulateAndDecode(solanaClient, isNonceUsedIx, signer, parserFunction);
|
|
1302
1285
|
};
|
|
1303
1286
|
|
|
1304
1287
|
/**
|
package/src/arch/svm/index.ts
CHANGED
|
@@ -108,7 +108,7 @@ function _getEthersGasPriceEstimate(
|
|
|
108
108
|
[CHAIN_IDs.ARBITRUM]: arbitrum.eip1559,
|
|
109
109
|
[CHAIN_IDs.BSC]: ethereum.legacy,
|
|
110
110
|
[CHAIN_IDs.MAINNET]: ethereum.eip1559,
|
|
111
|
-
|
|
111
|
+
[CHAIN_IDs.PLASMA]: ethereum.eip1559,
|
|
112
112
|
[CHAIN_IDs.POLYGON]: polygon.gasStation,
|
|
113
113
|
[CHAIN_IDs.SCROLL]: ethereum.legacy,
|
|
114
114
|
[CHAIN_IDs.ZK_SYNC]: ethereum.legacy,
|
|
@@ -22,6 +22,7 @@ import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator
|
|
|
22
22
|
import { Transport } from "viem";
|
|
23
23
|
import { getGasPriceEstimate } from "../../gasPriceOracle";
|
|
24
24
|
import { EvmProvider } from "../../arch/evm/types";
|
|
25
|
+
import { arch } from "../..";
|
|
25
26
|
|
|
26
27
|
export type SymbolMappingType = Record<
|
|
27
28
|
string,
|
|
@@ -167,7 +168,7 @@ export class QueryBase implements QueryInterface {
|
|
|
167
168
|
* @returns Native token cost
|
|
168
169
|
*/
|
|
169
170
|
getAuxiliaryNativeTokenCost(_deposit: RelayData): BigNumber {
|
|
170
|
-
return
|
|
171
|
+
return arch.evm.getAuxiliaryNativeTokenCost(_deposit);
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
/**
|
|
@@ -5,32 +5,17 @@ import {
|
|
|
5
5
|
fetchEncodedAccount,
|
|
6
6
|
isSome,
|
|
7
7
|
} from "@solana/kit";
|
|
8
|
-
import {
|
|
9
|
-
SVMProvider,
|
|
10
|
-
SolanaVoidSigner,
|
|
11
|
-
getFillRelayTx,
|
|
12
|
-
toAddress,
|
|
13
|
-
getAssociatedTokenAddress,
|
|
14
|
-
deserializeMessage,
|
|
15
|
-
} from "../../arch/svm";
|
|
8
|
+
import { SVMProvider, SolanaVoidSigner, getFillRelayTx, toAddress, getAssociatedTokenAddress } from "../../arch/svm";
|
|
16
9
|
import { Coingecko } from "../../coingecko";
|
|
17
10
|
import { CHAIN_IDs } from "../../constants";
|
|
18
11
|
import { getGasPriceEstimate } from "../../gasPriceOracle";
|
|
19
12
|
import { RelayData } from "../../interfaces";
|
|
20
|
-
import {
|
|
21
|
-
Address,
|
|
22
|
-
BigNumber,
|
|
23
|
-
BigNumberish,
|
|
24
|
-
SvmAddress,
|
|
25
|
-
TransactionCostEstimate,
|
|
26
|
-
bnZero,
|
|
27
|
-
isMessageEmpty,
|
|
28
|
-
toBN,
|
|
29
|
-
} from "../../utils";
|
|
13
|
+
import { Address, BigNumber, BigNumberish, SvmAddress, TransactionCostEstimate, toBN } from "../../utils";
|
|
30
14
|
import { Logger, QueryInterface, getDefaultRelayer } from "../relayFeeCalculator";
|
|
31
15
|
import { SymbolMappingType } from "./";
|
|
32
16
|
import { TOKEN_PROGRAM_ADDRESS } from "@solana-program/token";
|
|
33
17
|
import { TOKEN_2022_PROGRAM_ADDRESS, getTokenSize, fetchMint, Extension } from "@solana-program/token-2022";
|
|
18
|
+
import { arch } from "../..";
|
|
34
19
|
|
|
35
20
|
/**
|
|
36
21
|
* A special QueryBase implementation for SVM used for querying gas costs, token prices, and decimals of various tokens
|
|
@@ -180,10 +165,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
180
165
|
* @returns Native token cost
|
|
181
166
|
*/
|
|
182
167
|
getAuxiliaryNativeTokenCost(deposit: RelayData): BigNumber {
|
|
183
|
-
|
|
184
|
-
// rely hard on Solana program to protect us from not taking more than `value_amount` rather than relying on
|
|
185
|
-
// simulation. Chain state may change between simulation and execution, so simulation alone is unreliable
|
|
186
|
-
return isMessageEmpty(deposit.message) ? bnZero : BigNumber.from(deserializeMessage(deposit.message).value_amount);
|
|
168
|
+
return arch.svm.getAuxiliaryNativeTokenCost(deposit);
|
|
187
169
|
}
|
|
188
170
|
|
|
189
171
|
/**
|