Uniswap / sdk-core

⚙️ Code shared across TypeScript Uniswap SDK versions
MIT License
121 stars 355 forks source link

feat: move shared contract addresses to shared repo #58

Closed cbachmeier closed 1 year ago

cbachmeier commented 1 year ago

We want to consolidate much of the repeated code in the UX and BE involved with launching on a new chain. This PR is to centralize a lot of the Uni contract addresses across chains in one place.

I've also restructured how these contracts are stored, so instead of a series of repeated strings such as SEPOLIA_V3_CORE_FACTORY_ADDRESSES without any programmatic method to enforce consistency, there is a new datatype ChainAddresses whose fields correspond to the related contract. There is a map CHAIN_TO_ADDRESSES_MAP which will return all the ChainAddresses for a given ChainId. This helps simplify a lot of the helper consts such as V3_CORE_FACTORY_ADDRESSES which is now simply a reduce function across all SUPPORTED_CHAINS.

Last change primarily affecting UX is I've swapped SupportedChainId for ChainId and now SUPPORTED_CHAINS is an array which is the subset of all available Chains where Uni addresses have been deployed. This is the format used by the BE and is more robust than the previous sole SupportedChainId. This will change will likely require some small refactoring on the UX but will have us closer aligned to the BE.

cbachmeier commented 1 year ago

Take a look at #59 to see how a new chain's addresses (Avalanche) are added