-
Notifications
You must be signed in to change notification settings - Fork 28
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
Deploy: SwapQuoterV2
on Arbitrum/Avalanche
#266
Conversation
Pull Request Test Coverage Report for Build 6865200911
💛 - Coveralls |
The existing sections are already well-structured and provide a clear overview of the changes. I will proceed with crafting a whimsical poem to celebrate the changes:
The poem captures the spirit of change and progression, aligning with the evolving nature of the codebase. TipsChat with CodeRabbit Bot (
|
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.
Review Status
Actionable comments generated: 13
Files ignored due to filter (13)
- deployments/arbitrum/SwapQuoterV2.json
- deployments/avalanche/DefaultPoolCalc.json
- deployments/avalanche/SwapQuoterV2.json
- deployments/mainnet/DefaultPoolCalc.json
- deployments/mainnet/SwapQuoterV2.json
- deployments/optimism/DefaultPoolCalc.json
- deployments/optimism/SwapQuoterV2.json
- script/configs/SwapQuoterV2.ignored.json
- script/configs/arbitrum/SwapQuoterV2.dc.json
- script/configs/avalanche/SwapQuoterV2.dc.json
- script/configs/mainnet/SwapQuoterV2.dc.json
- script/configs/optimism/SwapQuoterV2.dc.json
- script/networks.json
Files selected for processing (11)
- script/interfaces/IBridgeConfigV3.sol (1 hunks)
- script/interfaces/IMulticall3.sol (1 hunks)
- script/interfaces/IOwnable.sol (1 hunks)
- script/interfaces/ISynapseRouter.sol (1 hunks)
- script/router/ActivateRouterV1sQuoter.s.sol (1 hunks)
- script/router/BasicRouter.s.sol (1 hunks)
- script/router/TransferOwnership.s.sol (1 hunks)
- script/router/quoter/ConfigureQuoterV2.s.sol (1 hunks)
- script/router/quoter/DeployQuoterV2.s.sol (1 hunks)
- script/router/quoter/SaveConfigQuoterV2.s.sol (1 hunks)
- script/router/quoter/helpers/BridgeConfigLens.sol (1 hunks)
Files skipped from review due to trivial changes (2)
- script/interfaces/IOwnable.sol
- script/router/quoter/helpers/BridgeConfigLens.sol
Additional comments (Suppressed): 18
script/interfaces/ISynapseRouter.sol (1)
- 1-8: The
ISynapseRouter
interface is well defined with functions to set and get theswapQuoter
address. Ensure that thesetSwapQuoter
function is properly secured to prevent unauthorized access. This could be done by adding a modifier in the implementation to allow only the contract owner or authorized addresses to call this function.script/interfaces/IMulticall3.sol (1)
- 1-17: The
IMulticall3
interface is well defined with clear function signatures and data structures. Theaggregate3
function takes an array ofCall3
structs and returns an array ofResult
structs. This function is marked aspayable
, which means it can receive Ether. Ensure that this is the intended behavior and that the function properly handles any Ether sent to it. Also, verify that theallowFailure
field in theCall3
struct is used correctly in the implementation to allow or disallow failures as intended.script/interfaces/IBridgeConfigV3.sol (2)
1-35: The new interface
IBridgeConfigV3
introduces two new structsToken
andPool
to represent token and pool configurations respectively. It also introduces three new functionsgetAllTokenIDs
,getTokenByID
, andgetPoolConfig
to retrieve these configurations. Ensure that these new data structures and functions are correctly used in the rest of the codebase.25-35: The functions
getAllTokenIDs
,getTokenByID
, andgetPoolConfig
are declared to return memory arrays or structs. Ensure that these are handled correctly in the calling code to avoid potential memory-related issues.script/router/TransferOwnership.s.sol (1)
- 1-4: The
IOwnable
interface is imported but the newtransferOwnership
function is not reflected in the interface. Ensure that theIOwnable
interface has been updated to include this function.script/router/ActivateRouterV1sQuoter.s.sol (1)
- 9-26: The function
run
does not have any access control. This means that any address can call this function and potentially change theswapQuoter
of theSynapseRouter
. This could be a serious security issue if not intended. Please verify if this is the desired behavior. If not, consider adding appropriate access control, such asonlyOwner
oronlyAdmin
.script/router/quoter/DeployQuoterV2.s.sol (3)
1-35: The contract
DeployQuoterV2
is well-structured and follows the best practices of Solidity. It deploys theSwapQuoterV2
contract and saves its address for future use. The contract uses environment variables to get the owner's address, which is a good practice for security reasons. However, ensure that the environment variables are properly set and secured. Also, make sure that theOWNER_ADDR
is a trusted address, as it will have ownership of the deployed contract.14-20: The
run
function sets up the script, starts broadcasting, deploys theSwapQuoterV2
contract, and then stops broadcasting. This is a good practice as it encapsulates the entire process in a single function. However, ensure that thesetUp
function and thevm.startBroadcast
andvm.stopBroadcast
functions are working as expected and handle any potential errors.26-33: The
deployQuoterV2
function deploys theSwapQuoterV2
contract with the necessary parameters. It retrieves the latest router deployment, the default pool calculator, the wrapped Ether (or equivalent on other chains), and the owner's address. It then deploys theSwapQuoterV2
contract and returns its address and the constructor arguments. This function is well-structured and follows best practices. However, ensure that thegetLatestRouterDeployment
,getDeploymentAddress
, andvm.envAddress
functions are working as expected and handle any potential errors.script/router/quoter/ConfigureQuoterV2.s.sol (9)
34-44: The
run
function is the main entry point for this contract. It sets up theBasicSynapseScript
, checks if the sender is the owner, reads the configuration, starts broadcasting, sets theSynapseRouter
, sets the pools, and then stops broadcasting. This function is well-structured and follows a logical sequence of operations. However, it's important to ensure that thesetUp
,readConfig
,setSynapseRouter
, andsetPools
functions are implemented correctly and handle errors appropriately.46-71: The
readConfig
function reads the configuration for theSwapQuoterV2
contract from the deployment configuration. It then parses this configuration and stores it in theconfigBridgePools
,bridgeTokenToSymbol
, andsymbolToBridgeToken
data structures. This function also checks for duplicate symbols and bridge tokens, which is a good practice to prevent configuration errors. However, it's important to ensure that the configuration is formatted correctly and contains all the necessary information.73-79: The
setSynapseRouter
function sets thesynapseRouter
of theSwapQuoterV2
contract to the latest router deployment. This function checks if the currentsynapseRouter
is different from the latest router deployment before setting it, which is a good practice to prevent unnecessary operations. However, it's important to ensure that thegetLatestRouterDeployment
function returns the correct address.81-87: The
setPools
function updates the pools of theSwapQuoterV2
contract based on the configuration. It first removes all bridge pools that are not in the configuration, and then adds all pools from the configuration that are not in the bridge pools. This function is well-structured and follows a logical sequence of operations. However, it's important to ensure that theremoveMissingPools
andaddMissingPools
functions are implemented correctly and handle errors appropriately.89-115: The
getAllPools
function retrieves all pools from theSwapQuoterV2
contract and combines them into a single array. This function is well-structured and follows a logical sequence of operations. However, it's important to ensure that thegetOriginDefaultPools
,getOriginLinkedPools
, andgetBridgePools
functions return the correct addresses.117-134: The
removeMissingPools
function removes all pools from theSwapQuoterV2
contract that are not in the configuration. This function uses thegetMissingPools
function to find the pools to remove, and then calls theremovePools
function of theSwapQuoterV2
contract to remove them. This function is well-structured and follows a logical sequence of operations. However, it's important to ensure that thegetMissingPools
andremovePools
functions are implemented correctly and handle errors appropriately.136-159: The
addMissingPools
function adds all pools from the configuration to theSwapQuoterV2
contract that are not already in the bridge pools. This function uses thegetMissingPools
function to find the pools to add, and then calls theaddPools
function of theSwapQuoterV2
contract to add them. This function is well-structured and follows a logical sequence of operations. However, it's important to ensure that thegetMissingPools
andaddPools
functions are implemented correctly and handle errors appropriately.163-178: The
equalBridgeToken
andequalFully
functions are used to compare two pools. TheequalBridgeToken
function checks if thebridgeToken
field in the two pools is equal, and theequalFully
function checks if all fields in the two pools are equal. These functions are well-implemented and follow good practices for comparing data structures.182-213: The
getMissingPools
function returns a list of pools that are inpoolsToFilter
but not inexistingPools
. This function uses acomparePools
function to compare the pools, which allows for flexible comparison logic. This function is well-structured and follows a logical sequence of operations. However, it's important to ensure that thecomparePools
function is implemented correctly and handles errors appropriately.
…ly and cctp pools
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.
Review Status
Actionable comments generated: 11
Configuration used: CodeRabbit UI
Files ignored due to filter (9)
- deployments/base/DefaultPoolCalc.json
- deployments/base/SwapQuoterV2.json
- script/configs/SwapQuoterV2.originOnly.json
- script/configs/arbitrum/SwapQuoterV2.dc.json
- script/configs/avalanche/SwapQuoterV2.dc.json
- script/configs/base/SwapQuoterV2.dc.json
- script/configs/mainnet/SwapQuoterV2.dc.json
- script/configs/optimism/SwapQuoterV2.dc.json
- script/networks.json
Files selected for processing (3)
- script/router/quoter/ConfigureQuoterV2.s.sol (1 hunks)
- script/router/quoter/SaveConfigQuoterV2.s.sol (1 hunks)
- script/templates/BasicSynapse.s.sol (1 hunks)
Additional comments: 5
script/templates/BasicSynapse.s.sol (1)
- 189-199: The
loadDeploymentSalt
function has been updated to check if a key exists in theallSalts
JSON string using thekeyExists
function. If the key exists, it decodes the corresponding salt entry and verifies theinitCodeHash
. If the key doesn't exist, it returns 0. This change seems to be logically correct and should improve the function's robustness by handling the case where the key doesn't exist in theallSalts
JSON string.script/router/quoter/SaveConfigQuoterV2.s.sol (2)
31-49: The
run
function is the main entry point for this contract. It checks if a configuration file already exists for theSwapQuoterV2
contract. If it does, it loads the configuration from the file and returns. If not, it loads the ignored pools, saves the origin-only pools, saves the SynapseCCTP pools, saves the BridgeConfigV3 pools, and then serializes and writes the configuration to a file. This function is well-structured and follows a clear sequence of steps.164-166: The
getPoolType
function uses theisLinkedPool
function to determine the type of a pool. It returnsSwapQuoterV2.PoolType.Linked
if the pool is aLinkedPool
andSwapQuoterV2.PoolType.Default
otherwise. This function is straightforward and correctly uses theisLinkedPool
function.script/router/quoter/ConfigureQuoterV2.s.sol (2)
1-4: Ensure that the correct version of Solidity is being used and that the imported contracts are compatible with this version.
34-45: The
run
function is the main entry point for this contract. It sets up the contract, checks if the sender is the owner, reads the configuration, and then sets the Synapse router and pools. It's important to ensure that the owner check is robust and secure.
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.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- script/configs/mainnet/SwapQuoterV2.dc.json
Files selected for processing (1)
- script/router/quoter/SaveConfigQuoterV2.s.sol (1 hunks)
LGTM |
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.
LGTM
Description
SwapQuoterV2
configuration from Ethereum's BridgeConfigV3 contract.SwapQuoterV2
deployment.SynapseRouter
contract.TODO:
SynapseCCTP
contract and save them to the config.Checklist
Summary by CodeRabbit
IBridgeConfigV3
andIMulticall3
interfaces to enhance token and pool configurations and streamline multicall processes.transferOwnership
function toIOwnable
interface, enabling ownership transfers.ISynapseRouter
interface with functions to manage swap quoters.ActivateRouterV1sQuoter
,BasicRouterScript
,TransferOwnership
,ConfigureQuoterV2
,DeployQuoterV2
, andSaveConfigQuoterV2
to improve router and quoter management.BridgeConfigLens
contract to provide easy access to token and pool configurations.