-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve: swap all Ovm adapters (excl. Optimism/Base) w/ generic adapter #1824
Open
bmzig
wants to merge
8
commits into
master
Choose a base branch
from
bz/swapSomeOvm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+60
−21
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
36eae9d
improve: swap all Ovm adapters (excl. Optimism/Base) w/ generic adapter
bmzig 697097c
Update src/clients/bridges/AdapterManager.ts
bmzig 4d7804e
fix object.fromEntries
bmzig 3f543c3
fix incorrect blast bridge
bmzig c6f4a5c
lint
bmzig 2d5a70a
update test
bmzig 1d23f7d
Merge branch 'master' into bz/swapSomeOvm
bmzig 3b978b5
Merge branch 'master' into bz/swapSomeOvm
bmzig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,10 +1,16 @@ | ||||||
import { utils } from "@across-protocol/sdk"; | ||||||
import { spokesThatHoldEthAndWeth, SUPPORTED_TOKENS } from "../../common/Constants"; | ||||||
import { | ||||||
spokesThatHoldEthAndWeth, | ||||||
SUPPORTED_TOKENS, | ||||||
CUSTOM_BRIDGE, | ||||||
CANONICAL_BRIDGE, | ||||||
DEFAULT_GAS_MULTIPLIER, | ||||||
} from "../../common/Constants"; | ||||||
import { InventoryConfig, OutstandingTransfers } from "../../interfaces"; | ||||||
import { BigNumber, isDefined, winston, Signer, getL2TokenAddresses, TransactionResponse, assert } from "../../utils"; | ||||||
import { SpokePoolClient, HubPoolClient } from "../"; | ||||||
import { ArbitrumAdapter, PolygonAdapter, ZKSyncAdapter, LineaAdapter, OpStackAdapter, ScrollAdapter } from "./"; | ||||||
import { CHAIN_IDs } from "@across-protocol/constants"; | ||||||
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants"; | ||||||
|
||||||
import { BaseChainAdapter } from "../../adapter"; | ||||||
|
||||||
|
@@ -40,6 +46,19 @@ export class AdapterManager { | |||||
}; | ||||||
|
||||||
const { OPTIMISM, ARBITRUM, POLYGON, ZK_SYNC, BASE, MODE, LINEA, LISK, BLAST, REDSTONE, SCROLL, ZORA } = CHAIN_IDs; | ||||||
const hubChainId = hubPoolClient.chainId; | ||||||
const l1Signer = spokePoolClients[hubChainId].spokePool.signer; | ||||||
const constructBridges = (chainId: number) => { | ||||||
return Object.fromEntries( | ||||||
SUPPORTED_TOKENS[chainId].map((symbol) => { | ||||||
const l2Signer = spokePoolClients[chainId].spokePool.signer; | ||||||
const l1Token = TOKEN_SYMBOLS_MAP[symbol].addresses[hubChainId]; | ||||||
const bridgeConstructor = CUSTOM_BRIDGE[chainId]?.[l1Token] ?? CANONICAL_BRIDGE[chainId]; | ||||||
const bridge = new bridgeConstructor(chainId, hubChainId, l1Signer, l2Signer, l1Token); | ||||||
return [l1Token, bridge]; | ||||||
}), | ||||||
); | ||||||
}; | ||||||
if (this.spokePoolClients[OPTIMISM] !== undefined) { | ||||||
this.adapters[OPTIMISM] = new OpStackAdapter( | ||||||
OPTIMISM, | ||||||
|
@@ -71,51 +90,71 @@ export class AdapterManager { | |||||
this.adapters[LINEA] = new LineaAdapter(logger, spokePoolClients, filterMonitoredAddresses(LINEA)); | ||||||
} | ||||||
if (this.spokePoolClients[MODE] !== undefined) { | ||||||
this.adapters[MODE] = new OpStackAdapter( | ||||||
const bridges = constructBridges(MODE); | ||||||
this.adapters[MODE] = new BaseChainAdapter( | ||||||
spokePoolClients, | ||||||
MODE, | ||||||
hubChainId, | ||||||
filterMonitoredAddresses(MODE), | ||||||
logger, | ||||||
SUPPORTED_TOKENS[MODE], | ||||||
spokePoolClients, | ||||||
filterMonitoredAddresses(MODE) | ||||||
bridges, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
Suggested change
|
||||||
DEFAULT_GAS_MULTIPLIER[MODE] ?? 1 | ||||||
); | ||||||
} | ||||||
if (this.spokePoolClients[REDSTONE] !== undefined) { | ||||||
this.adapters[REDSTONE] = new OpStackAdapter( | ||||||
const bridges = constructBridges(REDSTONE); | ||||||
this.adapters[REDSTONE] = new BaseChainAdapter( | ||||||
spokePoolClients, | ||||||
REDSTONE, | ||||||
hubChainId, | ||||||
filterMonitoredAddresses(REDSTONE), | ||||||
logger, | ||||||
SUPPORTED_TOKENS[REDSTONE], | ||||||
spokePoolClients, | ||||||
filterMonitoredAddresses(REDSTONE) | ||||||
bridges, | ||||||
DEFAULT_GAS_MULTIPLIER[REDSTONE] ?? 1 | ||||||
); | ||||||
} | ||||||
if (this.spokePoolClients[LISK] !== undefined) { | ||||||
this.adapters[LISK] = new OpStackAdapter( | ||||||
const bridges = constructBridges(LISK); | ||||||
this.adapters[LISK] = new BaseChainAdapter( | ||||||
spokePoolClients, | ||||||
LISK, | ||||||
hubChainId, | ||||||
filterMonitoredAddresses(LISK), | ||||||
logger, | ||||||
SUPPORTED_TOKENS[LISK], | ||||||
spokePoolClients, | ||||||
filterMonitoredAddresses(LISK) | ||||||
bridges, | ||||||
DEFAULT_GAS_MULTIPLIER[LISK] ?? 1 | ||||||
); | ||||||
} | ||||||
if (this.spokePoolClients[BLAST] !== undefined) { | ||||||
this.adapters[BLAST] = new OpStackAdapter( | ||||||
const bridges = constructBridges(BLAST); | ||||||
this.adapters[BLAST] = new BaseChainAdapter( | ||||||
spokePoolClients, | ||||||
BLAST, | ||||||
hubChainId, | ||||||
filterMonitoredAddresses(BLAST), | ||||||
logger, | ||||||
SUPPORTED_TOKENS[BLAST], | ||||||
spokePoolClients, | ||||||
filterMonitoredAddresses(BLAST) | ||||||
bridges, | ||||||
DEFAULT_GAS_MULTIPLIER[BLAST] ?? 1 | ||||||
); | ||||||
} | ||||||
if (this.spokePoolClients[SCROLL] !== undefined) { | ||||||
this.adapters[SCROLL] = new ScrollAdapter(logger, spokePoolClients, filterMonitoredAddresses(SCROLL)); | ||||||
} | ||||||
if (this.spokePoolClients[ZORA] !== undefined) { | ||||||
this.adapters[ZORA] = new OpStackAdapter( | ||||||
const bridges = constructBridges(ZORA); | ||||||
this.adapters[ZORA] = new BaseChainAdapter( | ||||||
spokePoolClients, | ||||||
ZORA, | ||||||
hubChainId, | ||||||
filterMonitoredAddresses(ZORA), | ||||||
logger, | ||||||
SUPPORTED_TOKENS[ZORA], | ||||||
spokePoolClients, | ||||||
filterMonitoredAddresses(ZORA) | ||||||
bridges, | ||||||
DEFAULT_GAS_MULTIPLIER[ZORA] ?? 1 | ||||||
); | ||||||
} | ||||||
|
||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was actually an issue where I assumed the blast bridge followed the same interface as the OpStackDefaultERC20Bridge finalization events, but actually the token address positions are swapped. I.e. the first position is the address of USDB and the second position is DAI on mainnet, not the other way around.