Skip to content

Commit 02128c2

Browse files
committed
Merge branch 'epic/svm-client' into pablo/slow-fill
2 parents 8e87c64 + 4c1d608 commit 02128c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1430
-950
lines changed

e2e/queries.e2e.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ describe("Queries", function () {
2828
undefined,
2929
process.env.COINGECKO_PRO_API_KEY
3030
);
31-
await Promise.all([
32-
arbitrumQueries.getGasCosts(),
33-
arbitrumQueries.getTokenDecimals("USDC"),
34-
arbitrumQueries.getTokenPrice("USDC"),
35-
]);
31+
await Promise.all([arbitrumQueries.getGasCosts(), arbitrumQueries.getTokenPrice("USDC")]);
3632
});
3733
it("Boba", async function () {
3834
const provider = new providers.JsonRpcProvider(process.env.NODE_URL_288);
@@ -44,11 +40,7 @@ describe("Queries", function () {
4440
undefined,
4541
process.env.COINGECKO_PRO_API_KEY
4642
);
47-
await Promise.all([
48-
bobaQueries.getGasCosts(),
49-
bobaQueries.getTokenDecimals("USDC"),
50-
bobaQueries.getTokenPrice("USDC"),
51-
]);
43+
await Promise.all([bobaQueries.getGasCosts(), bobaQueries.getTokenPrice("USDC")]);
5244
});
5345
it("Ethereum", async function () {
5446
const provider = new providers.JsonRpcProvider(process.env.NODE_URL_1);
@@ -60,11 +52,7 @@ describe("Queries", function () {
6052
undefined,
6153
process.env.COINGECKO_PRO_API_KEY
6254
);
63-
await Promise.all([
64-
ethereumQueries.getGasCosts(),
65-
ethereumQueries.getTokenDecimals("USDC"),
66-
ethereumQueries.getTokenPrice("USDC"),
67-
]);
55+
await Promise.all([ethereumQueries.getGasCosts(), ethereumQueries.getTokenPrice("USDC")]);
6856
});
6957
it("Optimism", async function () {
7058
const provider = new providers.JsonRpcProvider(process.env.NODE_URL_10);
@@ -76,11 +64,7 @@ describe("Queries", function () {
7664
undefined,
7765
process.env.COINGECKO_PRO_API_KEY
7866
);
79-
await Promise.all([
80-
optimismQueries.getGasCosts(),
81-
optimismQueries.getTokenDecimals("USDC"),
82-
optimismQueries.getTokenPrice("USDC"),
83-
]);
67+
await Promise.all([optimismQueries.getGasCosts(), optimismQueries.getTokenPrice("USDC")]);
8468
});
8569
it("Polygon", async function () {
8670
const provider = new providers.JsonRpcProvider(process.env.NODE_URL_137);
@@ -92,10 +76,6 @@ describe("Queries", function () {
9276
undefined,
9377
process.env.COINGECKO_PRO_API_KEY
9478
);
95-
await Promise.all([
96-
polygonQueries.getGasCosts(),
97-
polygonQueries.getTokenDecimals("USDC"),
98-
polygonQueries.getTokenPrice("USDC"),
99-
]);
79+
await Promise.all([polygonQueries.getGasCosts(), polygonQueries.getTokenPrice("USDC")]);
10080
});
10181
});

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@across-protocol/sdk",
33
"author": "UMA Team",
4-
"version": "4.1.44",
4+
"version": "4.1.62",
55
"license": "AGPL-3.0",
66
"homepage": "https://docs.across.to/reference/sdk",
77
"files": [
@@ -104,8 +104,8 @@
104104
},
105105
"dependencies": {
106106
"@across-protocol/across-token": "^1.0.0",
107-
"@across-protocol/constants": "^3.1.51",
108-
"@across-protocol/contracts": "^4.0.5",
107+
"@across-protocol/constants": "^3.1.64",
108+
"@across-protocol/contracts": "^4.0.9",
109109
"@coral-xyz/anchor": "^0.30.1",
110110
"@eth-optimism/sdk": "^3.3.1",
111111
"@ethersproject/bignumber": "^5.7.0",

src/arch/svm/SpokeUtils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import {
2121
import assert from "assert";
2222
import { arrayify, hexZeroPad, hexlify } from "ethers/lib/utils";
2323
import { Logger } from "winston";
24+
import { CHAIN_IDs } from "../../constants";
2425
import { Deposit, FillStatus, FillWithBlock, RelayData } from "../../interfaces";
2526
import {
2627
BigNumber,
2728
SvmAddress,
2829
chainIsSvm,
2930
chunk,
30-
getTokenInformationFromAddress,
31+
getTokenInfo,
3132
isDefined,
3233
isUnsafeDepositId,
3334
keccak256,
@@ -386,7 +387,7 @@ export async function createApproveInstruction(
386387

387388
// If no mint decimals were supplied, then assign it to whatever value we have in TOKEN_SYMBOLS_MAP.
388389
// If this token is not in TOKEN_SYMBOLS_MAP, then throw an error.
389-
mintDecimals ??= getTokenInformationFromAddress(mint.toBase58())?.decimals;
390+
mintDecimals ??= getTokenInfo(mint.toBase58(), CHAIN_IDs.SOLANA)?.decimals;
390391
if (!isDefined(mintDecimals)) {
391392
throw new Error(`No mint decimals found for token ${mint.toBase58()}`);
392393
}

src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import {
2424
DisabledChainsUpdate,
2525
GlobalConfigUpdate,
2626
LiteChainsIdListUpdate,
27-
Log,
2827
ParsedTokenConfig,
2928
RateModelUpdate,
3029
RouteRateModelUpdate,
@@ -43,8 +42,8 @@ type ConfigStoreUpdateSuccess = {
4342
chainId: number;
4443
searchEndBlock: number;
4544
events: {
46-
updatedTokenConfigEvents: Log[];
47-
updatedGlobalConfigEvents: Log[];
45+
updatedTokenConfigEvents: SortableEvent[];
46+
updatedGlobalConfigEvents: SortableEvent[];
4847
globalConfigUpdateTimes: number[];
4948
};
5049
};
@@ -341,8 +340,13 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
341340
paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedGlobalConfig(), searchConfig),
342341
]);
343342

343+
const updatedTokenConfigSortableEvents = updatedTokenConfigEvents.map(spreadEventWithBlockNumber);
344+
const updatedGlobalConfigSortableEvents = updatedGlobalConfigEvents.map(spreadEventWithBlockNumber);
345+
344346
// Events *should* normally be received in ascending order, but explicitly enforce the ordering.
345-
[updatedTokenConfigEvents, updatedGlobalConfigEvents].forEach((events) => sortEventsAscendingInPlace(events));
347+
[updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents].forEach((events) =>
348+
sortEventsAscendingInPlace(events)
349+
);
346350

347351
const globalConfigUpdateTimes = (
348352
await Promise.all(updatedGlobalConfigEvents.map((event) => this.configStore.provider.getBlock(event.blockNumber)))
@@ -353,8 +357,8 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
353357
chainId,
354358
searchEndBlock: searchConfig.to,
355359
events: {
356-
updatedTokenConfigEvents,
357-
updatedGlobalConfigEvents,
360+
updatedTokenConfigEvents: updatedTokenConfigSortableEvents,
361+
updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
358362
globalConfigUpdateTimes,
359363
},
360364
};
@@ -380,13 +384,11 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
380384
// Save new TokenConfig updates.
381385
for (const event of updatedTokenConfigEvents) {
382386
// If transaction hash is known to be invalid, skip it immediately to avoid creating extra logs.
383-
if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.transactionHash.toLowerCase())) {
387+
if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.txnRef.toLowerCase())) {
384388
continue;
385389
}
386390

387-
const args = {
388-
...(spreadEventWithBlockNumber(event) as TokenConfig),
389-
};
391+
const args = event as TokenConfig;
390392

391393
try {
392394
const { rateModel, routeRateModel, spokeTargetBalances } = this.validateTokenConfigUpdate(args);
@@ -418,7 +420,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
418420
this.logger.debug({
419421
at: "ConfigStoreClient::update",
420422
message: `Skipping invalid historical update at block ${event.blockNumber}`,
421-
transactionHash: event.transactionHash,
423+
txnRef: event.txnRef,
422424
});
423425
}
424426
continue;
@@ -427,7 +429,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
427429

428430
// Save new Global config updates.
429431
for (let i = 0; i < updatedGlobalConfigEvents.length; i++) {
430-
const args = spreadEventWithBlockNumber(updatedGlobalConfigEvents[i]) as SortableEvent & {
432+
const args = updatedGlobalConfigEvents[i] as SortableEvent & {
431433
key: string;
432434
// eslint-disable-next-line @typescript-eslint/no-explicit-any
433435
value: any;
@@ -562,7 +564,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
562564
rateModel: string | undefined;
563565
routeRateModel: RouteRateModelUpdate["routeRateModel"];
564566
} {
565-
const { value, key, transactionHash } = args;
567+
const { value, key, txnRef } = args;
566568
const parsedValue = parseJSONWithNumericString(value) as ParsedTokenConfig;
567569
const l1Token = key;
568570

@@ -578,7 +580,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
578580
const rateModel = parsedValue.rateModel;
579581
assert(
580582
this.isValidRateModel(rateModel),
581-
`Invalid rateModel UBar for ${l1Token} at transaction ${transactionHash}, ${JSON.stringify(rateModel)}`
583+
`Invalid rateModel UBar for ${l1Token} at transaction ${txnRef}, ${JSON.stringify(rateModel)}`
582584
);
583585
rateModelForToken = JSON.stringify(rateModel);
584586

@@ -601,7 +603,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
601603
Object.entries(parsedValue.routeRateModel).map(([path, routeRateModel]) => {
602604
assert(
603605
this.isValidRateModel(routeRateModel) &&
604-
`Invalid routeRateModel UBar for ${path} for ${l1Token} at transaction ${transactionHash}, ${JSON.stringify(
606+
`Invalid routeRateModel UBar for ${path} for ${l1Token} at transaction ${txnRef}, ${JSON.stringify(
605607
routeRateModel
606608
)}`
607609
);

0 commit comments

Comments
 (0)