@across-protocol/sdk 4.2.16-alpha.2 → 4.2.16-alpha.4
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/SpokeUtils.d.ts +2 -6
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +10 -9
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +2 -2
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.js +2 -2
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +3 -3
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +9 -8
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +2 -0
- package/dist/cjs/utils/AddressUtils.js +8 -2
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +2 -2
- package/dist/esm/arch/evm/SpokeUtils.d.ts +2 -6
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +10 -9
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +2 -2
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.js +2 -2
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +3 -3
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +9 -8
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +2 -0
- package/dist/esm/utils/AddressUtils.js +10 -2
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +2 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts +2 -6
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +2 -2
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +3 -3
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +2 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +2 -2
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/arch/evm/SpokeUtils.ts +1 -6
- package/src/arch/svm/SpokeUtils.ts +6 -5
- package/src/arch/svm/utils.ts +2 -2
- package/src/clients/BundleDataClient/BundleDataClient.ts +1 -1
- package/src/clients/HubPoolClient.ts +3 -3
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +1 -1
- package/src/clients/mocks/MockHubPoolClient.ts +3 -3
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +10 -2
- package/src/utils/AddressUtils.ts +12 -0
- package/src/utils/TokenUtils.ts +2 -2
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
BigNumber,
|
|
38
38
|
EvmAddress,
|
|
39
39
|
SvmAddress,
|
|
40
|
+
Address as SdkAddress,
|
|
40
41
|
chainIsSvm,
|
|
41
42
|
chunk,
|
|
42
43
|
isUnsafeDepositId,
|
|
@@ -405,6 +406,7 @@ export async function fillRelayInstruction(
|
|
|
405
406
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
406
407
|
|
|
407
408
|
const relayer = SvmAddress.from(signer.address);
|
|
409
|
+
|
|
408
410
|
// Create ATA for the relayer and recipient token accounts
|
|
409
411
|
const relayerTokenAccount = await getAssociatedTokenAddress(relayer, deposit.outputToken);
|
|
410
412
|
|
|
@@ -425,13 +427,12 @@ export async function fillRelayInstruction(
|
|
|
425
427
|
program
|
|
426
428
|
);
|
|
427
429
|
|
|
428
|
-
|
|
429
|
-
// from an EVM Spoke pool. Once we migrate to `Address` types, this can be modified/removed.
|
|
430
|
-
const [depositor, inputToken] = [deposit.depositor, deposit.inputToken].map(toAddress);
|
|
431
|
-
const [recipient, outputToken, exclusiveRelayer] = [
|
|
430
|
+
const [recipient, outputToken, exclusiveRelayer, depositor, inputToken] = [
|
|
432
431
|
deposit.recipient,
|
|
433
432
|
deposit.outputToken,
|
|
434
433
|
deposit.exclusiveRelayer,
|
|
434
|
+
deposit.depositor,
|
|
435
|
+
deposit.inputToken,
|
|
435
436
|
].map(toAddress);
|
|
436
437
|
|
|
437
438
|
return SvmSpokeClient.getFillRelayInstruction({
|
|
@@ -639,7 +640,7 @@ export function getRelayDataHash(relayData: RelayData, destinationChainId: numbe
|
|
|
639
640
|
const uint32Encoder = getU32Encoder();
|
|
640
641
|
|
|
641
642
|
assert(relayData.message.startsWith("0x"), "Message must be a hex string");
|
|
642
|
-
const encodeAddress = (data:
|
|
643
|
+
const encodeAddress = (data: SdkAddress) => Uint8Array.from(addressEncoder.encode(toAddress(data)));
|
|
643
644
|
|
|
644
645
|
const contentToHash = Buffer.concat([
|
|
645
646
|
encodeAddress(relayData.depositor),
|
package/src/arch/svm/utils.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@solana/kit";
|
|
18
18
|
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
19
19
|
import { FillType, RelayData } from "../../interfaces";
|
|
20
|
-
import { BigNumber,
|
|
20
|
+
import { BigNumber, SvmAddress, getRelayDataHash, isUint8Array, Address as SdkAddress } from "../../utils";
|
|
21
21
|
import { EventName, SVMEventNames, SVMProvider } from "./types";
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -45,7 +45,7 @@ export async function isDevnet(rpc: SVMProvider): Promise<boolean> {
|
|
|
45
45
|
/**
|
|
46
46
|
* Small utility to convert an Address to a Solana Kit branded type.
|
|
47
47
|
*/
|
|
48
|
-
export function toAddress(address:
|
|
48
|
+
export function toAddress(address: SdkAddress): Address<string> {
|
|
49
49
|
return address.toBase58() as Address<string>;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -92,7 +92,7 @@ function updateBundleFillsV3(
|
|
|
92
92
|
repaymentAddress: Address
|
|
93
93
|
): void {
|
|
94
94
|
// We shouldn't pass any unrepayable fills into this function, so we perform an extra safety check.
|
|
95
|
-
if (fill.relayer.isValidOn(repaymentChainId)) {
|
|
95
|
+
if (!fill.relayer.isValidOn(repaymentChainId)) {
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
|
|
@@ -1010,7 +1010,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1010
1010
|
const [tokenInfo, lpTokenInfo] = await Promise.all([
|
|
1011
1011
|
Promise.all(
|
|
1012
1012
|
uniqueL1Tokens.map(async (l1Token: string) => {
|
|
1013
|
-
const tokenInfo
|
|
1013
|
+
const tokenInfo = await fetchTokenInfo(l1Token, this.hubPool.provider);
|
|
1014
1014
|
return {
|
|
1015
1015
|
...tokenInfo,
|
|
1016
1016
|
address: EvmAddress.from(l1Token),
|
|
@@ -1049,7 +1049,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1049
1049
|
const args = spreadEventWithBlockNumber(_event) as ProposedRootBundle & { proposer: string };
|
|
1050
1050
|
return {
|
|
1051
1051
|
...args,
|
|
1052
|
-
proposer:
|
|
1052
|
+
proposer: EvmAddress.from(args.proposer),
|
|
1053
1053
|
};
|
|
1054
1054
|
})
|
|
1055
1055
|
);
|
|
@@ -1088,7 +1088,7 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
1088
1088
|
executedRootBundle.runningBalances = runningBalances.slice(0, nTokens);
|
|
1089
1089
|
const executedRootBundleWithL1Tokens = {
|
|
1090
1090
|
...executedRootBundle,
|
|
1091
|
-
l1Tokens:
|
|
1091
|
+
l1Tokens: l1Tokens.map((l1Token) => EvmAddress.from(String(l1Token))),
|
|
1092
1092
|
};
|
|
1093
1093
|
this.executedRootBundles.push(executedRootBundleWithL1Tokens);
|
|
1094
1094
|
}
|
|
@@ -594,7 +594,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
594
594
|
|
|
595
595
|
return {
|
|
596
596
|
...event,
|
|
597
|
-
depositor:
|
|
597
|
+
depositor: EvmAddress.from(event.depositor),
|
|
598
598
|
updatedRecipient: EvmAddress.from(event.updatedRecipient),
|
|
599
599
|
} as SpeedUpWithBlock;
|
|
600
600
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
2
|
import { Contract } from "ethers";
|
|
3
3
|
import { BigNumber, randomAddress, assign, bnZero, toAddressType, EvmAddress, Address, isDefined } from "../../utils";
|
|
4
|
-
import {
|
|
4
|
+
import { Log, PendingRootBundle, RealizedLpFee, L1TokenInfo } from "../../interfaces";
|
|
5
5
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
6
6
|
import { HubPoolClient, HubPoolUpdate, LpFeeRequest } from "../HubPoolClient";
|
|
7
7
|
import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
|
|
@@ -83,7 +83,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
83
83
|
this.latestHeightSearched = blockNumber;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
addL1Token(l1Token:
|
|
86
|
+
addL1Token(l1Token: L1TokenInfo) {
|
|
87
87
|
this.l1TokensMock.push(l1Token);
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -132,7 +132,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
132
132
|
return l2Token ?? super.getL2TokenForL1TokenAtBlock(l1Token, chainId, blockNumber);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
getTokenInfoForL1Token(l1Token: EvmAddress):
|
|
135
|
+
getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined {
|
|
136
136
|
return this.l1TokensMock.find((token) => token.address.eq(l1Token));
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -136,7 +136,14 @@ export class SvmQuery implements QueryInterface {
|
|
|
136
136
|
deposit.destinationChainId
|
|
137
137
|
)
|
|
138
138
|
) {
|
|
139
|
-
const {
|
|
139
|
+
const {
|
|
140
|
+
depositor,
|
|
141
|
+
recipient: _recipient,
|
|
142
|
+
inputToken,
|
|
143
|
+
outputToken: _outputToken,
|
|
144
|
+
exclusiveRelayer,
|
|
145
|
+
destinationChainId,
|
|
146
|
+
} = deposit;
|
|
140
147
|
|
|
141
148
|
const program = toAddress(this.spokePool);
|
|
142
149
|
const _relayDataHash = getRelayDataHash(deposit, destinationChainId);
|
|
@@ -147,11 +154,12 @@ export class SvmQuery implements QueryInterface {
|
|
|
147
154
|
getFillRelayDelegatePda(relayDataHash, BigInt(repaymentChainId), toAddress(repaymentAddress), program),
|
|
148
155
|
]);
|
|
149
156
|
|
|
157
|
+
const [recipient, outputToken] = [_recipient.forceSvmAddress(), _outputToken.forceSvmAddress()];
|
|
150
158
|
const mint = toAddress(outputToken);
|
|
151
159
|
const mintInfo = await fetchMint(this.provider, mint);
|
|
152
160
|
|
|
153
161
|
const [recipientAta, relayerAta, fillStatus, eventAuthority] = await Promise.all([
|
|
154
|
-
getAssociatedTokenAddress(
|
|
162
|
+
getAssociatedTokenAddress(recipient, outputToken, mintInfo.programAddress),
|
|
155
163
|
getAssociatedTokenAddress(SvmAddress.from(relayer.toBase58()), outputToken, mintInfo.programAddress),
|
|
156
164
|
getFillStatusPda(program, deposit, destinationChainId),
|
|
157
165
|
getEventAuthority(program),
|
|
@@ -218,6 +218,10 @@ export class Address {
|
|
|
218
218
|
|
|
219
219
|
// Subclass of address which strictly deals with 20-byte addresses. These addresses are guaranteed to be valid EVM addresses, so `toAddress` will always succeed.
|
|
220
220
|
export class EvmAddress extends Address {
|
|
221
|
+
// @dev This property is required for Typescript typechecker to know to distinguish between `Address`, `SvmAddress` and `EvmAddress`.
|
|
222
|
+
// Otherwise it lets any of these to use in place where other is expected.
|
|
223
|
+
private readonly _brandEvmAddress!: void;
|
|
224
|
+
|
|
221
225
|
// On construction, validate that the address can indeed be coerced into an EVM address. Throw immediately if it cannot.
|
|
222
226
|
constructor(rawAddress: Uint8Array) {
|
|
223
227
|
if (!EvmAddress.validate(rawAddress)) {
|
|
@@ -225,6 +229,8 @@ export class EvmAddress extends Address {
|
|
|
225
229
|
}
|
|
226
230
|
|
|
227
231
|
super(rawAddress);
|
|
232
|
+
// @dev required for TS to compile with `noUnusedLocals` rule
|
|
233
|
+
this._brandEvmAddress;
|
|
228
234
|
}
|
|
229
235
|
|
|
230
236
|
static validate(rawAddress: Uint8Array): boolean {
|
|
@@ -258,6 +264,10 @@ export class EvmAddress extends Address {
|
|
|
258
264
|
|
|
259
265
|
// Subclass of address which strictly deals SVM addresses. These addresses are guaranteed to be valid SVM addresses, so `toBase58` will always produce a valid Solana address.
|
|
260
266
|
export class SvmAddress extends Address {
|
|
267
|
+
// @dev This property is required for Typescript typechecker to know to distinguish between `Address`, `SvmAddress` and `EvmAddress`.
|
|
268
|
+
// Otherwise it lets any of these to use in place where other is expected.
|
|
269
|
+
private readonly _brandSvmAddress!: void;
|
|
270
|
+
|
|
261
271
|
// On construction, validate that the address is a point on Curve25519. Throw immediately if it is not.
|
|
262
272
|
constructor(rawAddress: Uint8Array) {
|
|
263
273
|
if (!SvmAddress.validate(rawAddress)) {
|
|
@@ -265,6 +275,8 @@ export class SvmAddress extends Address {
|
|
|
265
275
|
}
|
|
266
276
|
|
|
267
277
|
super(rawAddress);
|
|
278
|
+
// @dev required for TS to compile with `noUnusedLocals` rule
|
|
279
|
+
this._brandSvmAddress;
|
|
268
280
|
}
|
|
269
281
|
|
|
270
282
|
static validate(rawAddress: Uint8Array): boolean {
|
package/src/utils/TokenUtils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BlockTag } from "@ethersproject/abstract-provider";
|
|
2
2
|
import { Contract, providers, Signer } from "ethers";
|
|
3
3
|
import * as constants from "../constants";
|
|
4
|
-
import {
|
|
4
|
+
import { TokenInfo } from "../interfaces";
|
|
5
5
|
import { ERC20__factory } from "../typechain";
|
|
6
6
|
import { BigNumber } from "./BigNumberUtils";
|
|
7
7
|
import { getNetworkName, chainIsL1, chainIsProd } from "./NetworkUtils";
|
|
@@ -111,7 +111,7 @@ export function isStablecoin(tokenSymbol: string): boolean {
|
|
|
111
111
|
* @param tokenMapping
|
|
112
112
|
* @returns
|
|
113
113
|
*/
|
|
114
|
-
export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMapping = TOKEN_SYMBOLS_MAP):
|
|
114
|
+
export function getTokenInfo(l2TokenAddress: string, chainId: number, tokenMapping = TOKEN_SYMBOLS_MAP): TokenInfo {
|
|
115
115
|
const parsedAddress = toAddressType(l2TokenAddress, chainId).toNative();
|
|
116
116
|
|
|
117
117
|
// @dev This might give false positives if tokens on different networks have the same address. I'm not sure how
|