Skip to content

Commit a5536a8

Browse files
authored
chore: remove universal swap and bridge usage in api (#2144)
1 parent 320a674 commit a5536a8

File tree

7 files changed

+18
-234
lines changed

7 files changed

+18
-234
lines changed

api/_dexes/types.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export type CrossSwapQuotes = {
177177
};
178178

179179
export type OriginSwapEntryPointContract = {
180-
name: "UniversalSwapAndBridge" | "SpokePoolPeriphery" | "SvmSpoke";
180+
name: "SpokePoolPeriphery" | "SvmSpoke";
181181
address: string;
182182
dex?: SupportedDex;
183183
};
@@ -251,14 +251,11 @@ export type QuoteFetchOpts = Partial<{
251251
splitSlippage: boolean;
252252
}>;
253253

254-
export type OriginEntryPointContractName =
255-
| "SpokePoolPeriphery"
256-
| "UniversalSwapAndBridge"
257-
| "SvmSpoke";
254+
export type OriginEntryPointContractName = "SpokePoolPeriphery" | "SvmSpoke";
258255

259256
export type OriginEntryPoints = {
260257
originSwapInitialRecipient: {
261-
name: "UniversalSwapAndBridge" | "SwapProxy" | "SvmSpoke";
258+
name: "SwapProxy" | "SvmSpoke";
262259
address: string;
263260
};
264261
swapAndBridge: OriginSwapEntryPointContract;

api/_dexes/utils.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import {
5050
TransferType,
5151
getSwapProxyAddress,
5252
} from "../_spoke-pool-periphery";
53-
import { getUniversalSwapAndBridgeAddress } from "../_swap-and-bridge";
5453
import { getFillDeadline } from "../_fill-deadline";
5554
import { encodeActionCalls } from "../swap/_utils";
5655
import { InvalidParamError } from "../_errors";
@@ -89,8 +88,8 @@ export type QuoteFetchPrioritizationMode =
8988
*
9089
* @example
9190
* {
92-
* default: [getSwapRouter02Strategy("UniversalSwapAndBridge", "trading-api")],
93-
* [CHAIN_IDs.MAINNET]: [getSwapRouter02Strategy("UniversalSwapAndBridge", "sdk")],
91+
* default: [getSwapRouter02Strategy("SpokePoolPeriphery", "trading-api")],
92+
* [CHAIN_IDs.MAINNET]: [getSwapRouter02Strategy("SpokePoolPeriphery", "sdk")],
9493
* }
9594
*/
9695
export type QuoteFetchStrategies = Partial<{
@@ -148,7 +147,7 @@ export const defaultQuoteFetchStrategies: QuoteFetchStrategies = {
148147
mode: "priority-speed",
149148
priorityChunkSize: 1,
150149
},
151-
default: [getSwapRouter02Strategy("UniversalSwapAndBridge")],
150+
default: [getSwapRouter02Strategy("SpokePoolPeriphery")],
152151
};
153152

154153
export function getPreferredBridgeTokens(
@@ -1148,22 +1147,6 @@ export function getOriginSwapEntryPoints(
11481147
address: getSpokePoolPeripheryAddress(chainId),
11491148
},
11501149
} as const;
1151-
} else if (originSwapEntryPointContractName === "UniversalSwapAndBridge") {
1152-
return {
1153-
originSwapInitialRecipient: {
1154-
name: "UniversalSwapAndBridge",
1155-
address: getUniversalSwapAndBridgeAddress(dex, chainId),
1156-
},
1157-
swapAndBridge: {
1158-
name: "UniversalSwapAndBridge",
1159-
address: getUniversalSwapAndBridgeAddress(dex, chainId),
1160-
dex,
1161-
},
1162-
deposit: {
1163-
name: "SpokePool",
1164-
address: getSpokePoolAddress(chainId),
1165-
},
1166-
} as const;
11671150
}
11681151
throw new Error(
11691152
`Unknown origin swap entry point contract '${originSwapEntryPointContractName}'`

api/_swap-and-bridge.ts

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
// NOTE: SwapAndBridge and UniverslSwapAndBridge were removed in version 4.1.3 of the contracts repo
2-
// We need version 4.1.1 until we migrate to new SpokePoolPeriphery contracts.
3-
import {
4-
SwapAndBridge__factory,
5-
UniversalSwapAndBridge__factory,
6-
} from "@across-protocol/contracts-v4.1.1";
1+
import { SwapAndBridge__factory } from "@across-protocol/contracts-v4.1.1";
72

83
import { ENABLED_ROUTES, getProvider } from "./_utils";
94

10-
type SwapAndBridgeType = "SwapAndBridge" | "UniversalSwapAndBridge";
11-
125
export class UnsupportedDex extends Error {
13-
constructor(dex: string, type: SwapAndBridgeType) {
14-
super(`DEX/Aggregator '${dex}' not supported for '${type}'`);
6+
constructor(dex: string) {
7+
super(`DEX/Aggregator '${dex}' not supported for 'SwapAndBridge'`);
158
}
169
}
1710

1811
export class UnsupportedDexOnChain extends Error {
19-
constructor(chainId: number, dex: string, type: SwapAndBridgeType) {
12+
constructor(chainId: number, dex: string) {
2013
super(
21-
`DEX/Aggregator '${dex}' not supported on chain ${chainId} for '${type}'`
14+
`DEX/Aggregator '${dex}' not supported on chain ${chainId} for 'SwapAndBridge'`
2215
);
2316
}
2417
}
@@ -41,37 +34,16 @@ export const swapAndBridgeDexes = Object.keys(
4134
ENABLED_ROUTES.swapAndBridgeAddresses
4235
);
4336

44-
export const universalSwapAndBridgeDexes = Object.keys(
45-
ENABLED_ROUTES.universalSwapAndBridgeAddresses
46-
);
47-
4837
export function getSwapAndBridgeAddress(dex: string, chainId: number) {
4938
if (!_isDexSupportedForSwapAndBridge(dex)) {
50-
throw new UnsupportedDex(dex, "SwapAndBridge");
39+
throw new UnsupportedDex(dex);
5140
}
5241

5342
const address = (
5443
ENABLED_ROUTES.swapAndBridgeAddresses[dex] as Record<string, string>
5544
)?.[chainId];
5645
if (!address) {
57-
throw new UnsupportedDexOnChain(chainId, dex, "SwapAndBridge");
58-
}
59-
return address;
60-
}
61-
62-
export function getUniversalSwapAndBridgeAddress(dex: string, chainId: number) {
63-
if (!_isDexSupportedForUniversalSwapAndBridge(dex)) {
64-
throw new UnsupportedDex(dex, "UniversalSwapAndBridge");
65-
}
66-
67-
const address = (
68-
ENABLED_ROUTES.universalSwapAndBridgeAddresses[dex] as Record<
69-
string,
70-
string
71-
>
72-
)?.[chainId];
73-
if (!address) {
74-
throw new UnsupportedDexOnChain(chainId, dex, "UniversalSwapAndBridge");
46+
throw new UnsupportedDexOnChain(chainId, dex);
7547
}
7648
return address;
7749
}
@@ -85,26 +57,8 @@ export function getSwapAndBridge(dex: string, chainId: number) {
8557
);
8658
}
8759

88-
export function getUniversalSwapAndBridge(dex: string, chainId: number) {
89-
const universalSwapAndBridgeAddress = getUniversalSwapAndBridgeAddress(
90-
dex,
91-
chainId
92-
);
93-
94-
return UniversalSwapAndBridge__factory.connect(
95-
universalSwapAndBridgeAddress,
96-
getProvider(chainId)
97-
);
98-
}
99-
10060
function _isDexSupportedForSwapAndBridge(
10161
dex: string
10262
): dex is keyof typeof ENABLED_ROUTES.swapAndBridgeAddresses {
10363
return swapAndBridgeDexes.includes(dex);
10464
}
105-
106-
function _isDexSupportedForUniversalSwapAndBridge(
107-
dex: string
108-
): dex is keyof typeof ENABLED_ROUTES.universalSwapAndBridgeAddresses {
109-
return universalSwapAndBridgeDexes.includes(dex);
110-
}

api/swap/approval/_utils.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
} from "../../_dexes/utils";
3232
import { JupiterSwapIxs } from "../../_dexes/jupiter/utils/api";
3333
import { appendJupiterIxs } from "../../_dexes/jupiter/utils/transaction-builder";
34-
import { getUniversalSwapAndBridge } from "../../_swap-and-bridge";
3534
import { getSVMRpc } from "../../_providers";
3635
import { getFillDeadlineBuffer } from "../../_fill-deadline";
3736
import { getQuoteTimestampArg } from "../../_quote-timestamp";
@@ -122,59 +121,6 @@ async function _buildDepositTxForAllowanceHolderEvm(
122121
}
123122
);
124123
toAddress = spokePoolPeriphery.address;
125-
}
126-
// NOTE: Left for backwards compatibility with the old `UniversalSwapAndBridge`
127-
// contract. Should be removed once we've migrated to the new `SpokePoolPeriphery`.
128-
else if (originSwapEntryPoint.name === "UniversalSwapAndBridge") {
129-
const universalSwapAndBridge = getUniversalSwapAndBridge(
130-
originSwapEntryPoint.dex || "unknown",
131-
originChainId
132-
);
133-
if (originSwapQuote.swapTxns.length !== 1) {
134-
throw new Error(
135-
"Expected exactly 1 swap transaction for origin swap via `UniversalSwapAndBridge`"
136-
);
137-
}
138-
const swapTxn = originSwapQuote.swapTxns[0] as EvmSwapTxn;
139-
tx = await universalSwapAndBridge.populateTransaction.swapAndBridge(
140-
originSwapQuote.tokenIn.address,
141-
originSwapQuote.tokenOut.address,
142-
swapTxn.data,
143-
originSwapQuote.maximumAmountIn,
144-
originSwapQuote.minAmountOut,
145-
{
146-
...swapAndDepositData.depositData,
147-
depositor: sdk.utils
148-
.toAddressType(
149-
swapAndDepositData.depositData.depositor,
150-
originChainId
151-
)
152-
.toEvmAddress(),
153-
recipient: sdk.utils
154-
.toAddressType(
155-
swapAndDepositData.depositData.recipient,
156-
destinationChainId
157-
)
158-
.toEvmAddress(),
159-
outputToken: sdk.utils
160-
.toAddressType(
161-
swapAndDepositData.depositData.outputToken,
162-
destinationChainId
163-
)
164-
.toEvmAddress(),
165-
exclusiveRelayer: sdk.utils
166-
.toAddressType(
167-
swapAndDepositData.depositData.exclusiveRelayer,
168-
destinationChainId
169-
)
170-
.toEvmAddress(),
171-
exclusivityDeadline:
172-
swapAndDepositData.depositData.exclusivityParameter,
173-
// Typo in the contract
174-
destinationChainid: swapAndDepositData.depositData.destinationChainId,
175-
}
176-
);
177-
toAddress = universalSwapAndBridge.address;
178124
} else {
179125
throw new Error(
180126
`Could not build 'swapAndBridge' tx for unknown entry point contract`

scripts/generate-routes.ts

Lines changed: 5 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -122,51 +122,6 @@ const enabledRoutes = {
122122
[CHAIN_IDs.ARBITRUM]: "0xF633b72A4C2Fb73b77A379bf72864A825aD35b6D",
123123
},
124124
},
125-
// Addresses of `UniversalSwapAndBridge` contracts from deployment:
126-
// https://github.com/across-protocol/contracts/pull/731/commits/6bdbfd38f50b616ac25e49687cbac6fb6bcb543b
127-
universalSwapAndBridgeAddresses: {
128-
"1inch": {
129-
[CHAIN_IDs.ARBITRUM]: "0x81C7601ac0c5825e89F967f9222B977CCD78aD77",
130-
[CHAIN_IDs.BASE]: "0x98285D11B9F7aFec2d475805E5255f26B4490167",
131-
[CHAIN_IDs.OPTIMISM]: "0x7631eA29479Ee265241F13FB48555A2C886d3Bf8",
132-
[CHAIN_IDs.POLYGON]: "0xc2dcb88873e00c9d401de2cbba4c6a28f8a6e2c2",
133-
},
134-
"uniswap-v3/swap-router-02": {
135-
[CHAIN_IDs.ARBITRUM]: "0x2414A759d4EFF700Ad81e257Ab5187d07eCeEbAb",
136-
[CHAIN_IDs.BASE]: "0xed8b9c9aE7aCEf12eb4650d26Eb876005a4752d2",
137-
[CHAIN_IDs.BLAST]: "0x57EE47829369e2EF62fBb423648bec70d0366204",
138-
[CHAIN_IDs.LENS]: "0x793Ff9Cd09819C537500dFcEB6F61861c1B80dCD",
139-
[CHAIN_IDs.MAINNET]: "0x0e84f089B0923EfeA51C6dF91581BFBa66A3484A",
140-
[CHAIN_IDs.OPTIMISM]: "0x04989eaF03547E6583f9d9e42aeD11D2b78A808b",
141-
[CHAIN_IDs.POLYGON]: "0xa55490E20057BD4775618D0FC8D51F59f602FED0",
142-
[CHAIN_IDs.WORLD_CHAIN]: "0x56e2d1b8C7dE8D11B282E1b4C924C32D91f9102B",
143-
[CHAIN_IDs.ZORA]: "0x75b84707e6Bf5bc48DbC3AD883c23192C869AAE4",
144-
[CHAIN_IDs.ZK_SYNC]: "0xdB82479e3903869fbF8B308162E332FED771D51B",
145-
},
146-
gho: {
147-
[CHAIN_IDs.MAINNET]: "0x18d0915ADA0d5969db64CA44A42dB1b51D8421aa",
148-
[CHAIN_IDs.LENS]: "0xDFD7f7AC8F2331C4E83A43E73aB7579e736AC1Bf",
149-
},
150-
"gho-multicall3": {
151-
[CHAIN_IDs.MAINNET]: "0x9736F26C6311701A984A53A0b555f8A20225173A",
152-
},
153-
lifi: {
154-
[CHAIN_IDs.MAINNET]: "0x96804f83B2f77A8F7631b284000F84e5225f8f31",
155-
[CHAIN_IDs.OPTIMISM]: "0xdce5D1a7D52C62E3246117a5657a0306894C1ee8",
156-
[CHAIN_IDs.UNICHAIN]: "0x868041C095cA2b19e462eC0BC8718262bFF1baCD",
157-
[CHAIN_IDs.POLYGON]: "0xDee13c711c91c1ae3A8a1E7b8c983f820AFFBF18",
158-
[CHAIN_IDs.LENS]: "0xD6cdAFd8C8860B664f953d2b23c52AC8c624cB1A",
159-
[CHAIN_IDs.ZK_SYNC]: "0x5a003fA0dae249A31FD4f610fbb3B84A1503a156",
160-
[CHAIN_IDs.WORLD_CHAIN]: "0x53dcB809269AE777fCA05232bb323A9e90feA6b0",
161-
[CHAIN_IDs.LISK]: "0xE0A722530d48aC27eF87596ace5b49629e7DBa5A",
162-
[CHAIN_IDs.SONEIUM]: "0xB6EA3c1a03d842A2E07C48ceF5F2DBd502428406",
163-
[CHAIN_IDs.BASE]: "0x53dcB809269AE777fCA05232bb323A9e90feA6b0",
164-
[CHAIN_IDs.MODE]: "0xBdF9357077B3ED082f0521fA6c726Deca2dcbaB4",
165-
[CHAIN_IDs.ARBITRUM]: "0x6925036403d3e1A5fB6A530f62bA53fe06018522",
166-
[CHAIN_IDs.BLAST]: "0x7593d6394947C9ef0f67575Ce66Be1D529A98886",
167-
[CHAIN_IDs.SCROLL]: "0xBdF9357077B3ED082f0521fA6c726Deca2dcbaB4",
168-
},
169-
},
170125
spokePoolPeripheryAddresses: {
171126
[CHAIN_IDs.ARBITRUM]: "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
172127
[CHAIN_IDs.BASE]: "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
@@ -243,9 +198,6 @@ const enabledRoutes = {
243198
"0x17496824Ba574A4e9De80110A91207c4c63e552a", // Mocked
244199
},
245200
},
246-
universalSwapAndBridgeAddresses: {
247-
"uniswap-v3/swap-router-02": {},
248-
},
249201
spokePoolPeripheryAddresses: {},
250202
swapProxyAddresses: {},
251203
routes: transformChainConfigs(enabledSepoliaChainConfigs, []),
@@ -432,7 +384,11 @@ function transformChainConfigs(
432384
);
433385

434386
// Handle USDC swap tokens
435-
const usdcSwapTokens = [];
387+
const usdcSwapTokens: {
388+
swapInputTokenSymbol: string;
389+
acrossInputTokenSymbol: string;
390+
acrossOutputTokenSymbol: string;
391+
}[] = [];
436392

437393
const toChain = {
438394
chainId: externalProject.intermediaryChain,
@@ -660,12 +616,6 @@ async function generateRoutes(hubPoolChainId = 1) {
660616
swapAndBridgeAddresses: checksumAddressesOfNestedMap(
661617
config.swapAndBridgeAddresses as Record<string, Record<string, string>>
662618
),
663-
universalSwapAndBridgeAddresses: checksumAddressesOfNestedMap(
664-
config.universalSwapAndBridgeAddresses as Record<
665-
string,
666-
Record<string, string>
667-
>
668-
),
669619
spokePoolPeripheryAddresses: checksumAddressOfMap(
670620
config.spokePoolPeripheryAddresses as Record<string, string>
671621
),

src/data/routes_11155111_0x14224e63716afAcE30C9a417E0542281869f7d9e.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
"11155420": "0x17496824Ba574A4e9De80110A91207c4c63e552a"
1414
}
1515
},
16-
"universalSwapAndBridgeAddresses": {
17-
"uniswap-v3/swap-router-02": {}
18-
},
1916
"spokePoolPeripheryAddresses": {},
2017
"swapProxyAddresses": {},
2118
"routes": [

src/data/routes_1_0xc186fA914353c44b2E33eBE05f21846F1048bEda.json

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,49 +20,6 @@
2020
"42161": "0xF633b72A4C2Fb73b77A379bf72864A825aD35b6D"
2121
}
2222
},
23-
"universalSwapAndBridgeAddresses": {
24-
"1inch": {
25-
"10": "0x7631eA29479Ee265241F13FB48555A2C886d3Bf8",
26-
"137": "0xC2dCB88873E00c9d401De2CBBa4C6A28f8A6e2c2",
27-
"8453": "0x98285D11B9F7aFec2d475805E5255f26B4490167",
28-
"42161": "0x81C7601ac0c5825e89F967f9222B977CCD78aD77"
29-
},
30-
"uniswap-v3/swap-router-02": {
31-
"1": "0x0e84f089B0923EfeA51C6dF91581BFBa66A3484A",
32-
"10": "0x04989eaF03547E6583f9d9e42aeD11D2b78A808b",
33-
"137": "0xa55490E20057BD4775618D0FC8D51F59f602FED0",
34-
"232": "0x793Ff9Cd09819C537500dFcEB6F61861c1B80dCD",
35-
"324": "0xdB82479e3903869fbF8B308162E332FED771D51B",
36-
"480": "0x56e2d1b8C7dE8D11B282E1b4C924C32D91f9102B",
37-
"8453": "0xed8b9c9aE7aCEf12eb4650d26Eb876005a4752d2",
38-
"42161": "0x2414A759d4EFF700Ad81e257Ab5187d07eCeEbAb",
39-
"81457": "0x57EE47829369e2EF62fBb423648bec70d0366204",
40-
"7777777": "0x75b84707e6Bf5bc48DbC3AD883c23192C869AAE4"
41-
},
42-
"gho": {
43-
"1": "0x18d0915ADA0d5969db64CA44A42dB1b51D8421aa",
44-
"232": "0xDFD7f7AC8F2331C4E83A43E73aB7579e736AC1Bf"
45-
},
46-
"gho-multicall3": {
47-
"1": "0x9736F26C6311701A984A53A0b555f8A20225173A"
48-
},
49-
"lifi": {
50-
"1": "0x96804f83B2f77A8F7631b284000F84e5225f8f31",
51-
"10": "0xdce5D1a7D52C62E3246117a5657a0306894C1ee8",
52-
"130": "0x868041C095cA2b19e462eC0BC8718262bFF1baCD",
53-
"137": "0xDee13c711c91c1ae3A8a1E7b8c983f820AFFBF18",
54-
"232": "0xD6cdAFd8C8860B664f953d2b23c52AC8c624cB1A",
55-
"324": "0x5a003fA0dae249A31FD4f610fbb3B84A1503a156",
56-
"480": "0x53dcB809269AE777fCA05232bb323A9e90feA6b0",
57-
"1135": "0xE0A722530d48aC27eF87596ace5b49629e7DBa5A",
58-
"1868": "0xB6EA3c1a03d842A2E07C48ceF5F2DBd502428406",
59-
"8453": "0x53dcB809269AE777fCA05232bb323A9e90feA6b0",
60-
"34443": "0xBdF9357077B3ED082f0521fA6c726Deca2dcbaB4",
61-
"42161": "0x6925036403d3e1A5fB6A530f62bA53fe06018522",
62-
"81457": "0x7593d6394947C9ef0f67575Ce66Be1D529A98886",
63-
"534352": "0xBdF9357077B3ED082f0521fA6c726Deca2dcbaB4"
64-
}
65-
},
6623
"spokePoolPeripheryAddresses": {
6724
"1": "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",
6825
"10": "0x89415a82d909a7238d69094C3Dd1dCC1aCbDa85C",

0 commit comments

Comments
 (0)