-
Notifications
You must be signed in to change notification settings - Fork 33
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
SDK: cleanup #1382
SDK: cleanup #1382
Conversation
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: 8
Files selected for processing (5)
- packages/sdk-router/src/operations/pools.ts (1 hunks)
- packages/sdk-router/src/router/synapseCCTPRouter.test.ts (1 hunks)
- packages/sdk-router/src/router/synapseCCTPRouter.ts (1 hunks)
- packages/sdk-router/src/router/synapseRouter.test.ts (1 hunks)
- packages/sdk-router/src/router/synapseRouter.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- packages/sdk-router/src/router/synapseCCTPRouter.test.ts
- packages/sdk-router/src/router/synapseRouter.test.ts
Additional comments (Suppressed): 5
packages/sdk-router/src/operations/pools.ts (5)
15-23: The function
getPoolTokens
is well implemented and follows the best practices. It uses theSynapseRouterSet
to get theSynapseRouter
for a specific chainId and then fetches the pool tokens for a given pool address.33-41: The function
getPoolInfo
is also correctly implemented. It retrieves information about a pool, including the number of tokens and LP token, using theSynapseRouterSet
andSynapseRouter
.50-55: The function
getAllPools
is properly implemented. It fetches all pools for a given chain ID using theSynapseRouterSet
andSynapseRouter
.102-117: The function
calculateRemoveLiquidity
is correctly implemented. It calculates the amounts received when removing liquidity from a pool.129-150: The function
calculateRemoveLiquidityOne
is well implemented. It calculates the amount of one token received when removing liquidity from a pool.
This reverts commit 4c33414.
This reverts commit dd9979d.
As #1397 & #579 pointed out if a module is changed and then unchanged, the needs-go-generate action is not removed (this is blocking #1382 rn). For this reason, this pr: - consolidates actions for `include_deps`=true and `include_deps`=false. This will also help with #1390 by halving api requests by git-changes-action. Further work could be done here by consolidating goreleaser into `go.yml` the future - Remove unchanged module labels. This is honestly kind of a pain and could lead to api rate limiting issues. The way we're going to deal with this is by starting an action for each label, but only running it if the event is a pull request and [this condition](https://stackoverflow.com/a/59588725) is met. Once this is done we can also add this to the needs-go-generate check to reduce the number of api calls to remove a lebl further helping w/ #1390 --------- Co-authored-by: Trajan0x <[email protected]>
This reverts commit 1883649.
* fix: packages/explorer-ui/package.json & packages/explorer-ui/yarn.lock to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-POSTCSS-5926692 * change eth rpc hotfix (#1425) * Publish - @synapsecns/[email protected] * SDK: cleanup (#1382) * yarn add ts-xor * Isolate Query types * Define Abstract Router * Implement common functions for Routers * Wrappers for SynapseRouter, SynapseCCTPRouter * Abstraction for a set of Router instances * Finding bridge routes * Add SynapseRouter-specific functions * Add router/index.ts * Constructor for new SDK class * Add pools, swaps operations to new SDK * Fix: naming * Add origin router address to BridgeRoute * Add bridge operations to SDK * Match exports with the old SDK * Nuke old SDK * Add address property to Router class * Remove ABI from Router constructor * Remove `addresses` from RouterSet constructor * Rework address map generation * Fully isolate contract interaction * Don't expose routerContract in Router class * Fix: circular dependency * Adjust synapseRouter test * Adjust CCTP router test * Fix: pass addressMap as constructor arg * Fix: pass Router constructor as argument * Basic coverage for RouterSets * Refactor constants * Add test for getBridgeTokens * Add test: getOriginQueries * Tests: getDestinationQueries * Test SDK constructor * Add ETH -> ARB bridgeQuote tests * More bridge tests * Add tests for errors * Introduce SwapQuote type * Fix: return type for `getBridgeGas()` * Add coverage for the remainder of the functions * Fix: address handling in calculateAddLiquidity * Remove deprecated code * Add coverage for deadlines * Rename new tests * Add some clarity for used classes * yarn install * add comment for vercel build * Use llama public RPCs * [DROP IN PROD] modify to local * Fix: spelling * Explicit error when Router is not present * Add coverage * Set default timeout to 30s for SDK tests * Keep the Code Rabbit happy by resolving a few issues * Revert "[DROP IN PROD] modify to local" This reverts commit 4c33414. * Revert "add comment for vercel build" This reverts commit dd9979d. * bump * Revert "bump" This reverts commit 1883649. --------- Co-authored-by: Trajan0x <[email protected]> Co-authored-by: Jonah Lin <[email protected]> * Publish - @synapsecns/[email protected] - @synapsecns/[email protected] - @synapsecns/[email protected] * cleanup stale (#1426) Co-authored-by: Trajan0x <[email protected]> * update (#1431) * Publish - @synapsecns/[email protected] * fix: lint (#1433) * Publish - @synapsecns/[email protected] * Updated charts to use v2 version of autoscaling kube API (#1428) * Updated charts to use v2 version of autoscaling kube API * Fixed explorer helm chart format * Updated config * Added port to config * Fixed hpa spec of services (#1437) * update (#1439) * Publish - @synapsecns/[email protected] * fix lint (#1441) * Publish - @synapsecns/[email protected] * Feat/input quotes (#1412) * Initialize fetchBridgeQuotes in utils, add BridgeQuoteRequest data type * Basic useBridgeQuote that continuously provides back bridge quote amount * Simple async fetchBridgeQuote function * Adjust fetchBridgeQuote function to accept synapseSDK as a param * fetchBridgeQuotes can return multiple bridge quotes via SDK in single function call * static typing * Init Bridge Updater component to allow for refreshing toTokens quotes * Bridge Updater component can access bridge quotes based on current toTokens in store * Remove test code in ToTokenListOverlay * Return token Token type in fetchBridgeQuote() call to match possibleTokens in ToTokenListOverlay * Update * Add comment * init fechAndStoreBridgeQuotes async thunk * fetchAndStoreBridgeQuotes * add fetchAndStoreBridgeQuote to use for current bridge selections * Update BridgeQuoteRequest to include originToken * ... * port getAndSetBridgeQuote logic into fetchBridgeQuote * Extend BridgeQuote type into BridgeQuoteResponse to include destinationToken to match token options by * Add typing to thunks * Add store state and reducer for fetchAndStoerBridgeQuotes * Bridge Updater to dispatch fetched bridge quotes for toTokens when avail * Update fetchBridgeQuotes to return array of objects * Pass in formatted exchangeRate string into SelectSpecificTokenButton * Add OptionDetails component that displays exchangeRate for now * Prefetch exchange rates without fromValue * Add state/reducer for fetchAndStoreBridgeQuotes status * Show exchangeRates only after fetch status is valid * Add action and reducer to resetFetchedBridgeQuotes * Reset fetched bridge quotes if fromToken is reset or is null * Reset fetched bridge quotes if no toChainId exists * calculateEstimatedTransactionTime util function * Pass in estimatedDuration prop to SelectSpecificTokenButton to populate token selection * Add comments * Add estimatedDurationInSeconds as prop in OptionDetails component, display duration in minute format * Style estimated duration in token selection * Add util function locateBestExchangeRateIndex * Add isBestExchangeRate bool prop to SelectSpecificTokenButton * ... * Create OptionTag with BestOptionType interface to create multiple options * Basic unstyled OptionTag is working * Add gradient * Style tag * Render tag only if exchangeRate available * Add destinationChainId in response for fetchBridgeQuotes * Ensure quote does not show unless destinationChainId matches, solve for case when connected chain id is default toChainId * Style OptionTag * Match bridgeQuotes based on destinationToken and not array positioning * Init getDefaultBridgeAmount util function * Create required enums to construct respective getDefaultBridgeAmount func * ... * Update locateBestExchangeRateToken to match best rate by Token * Proprogate bestExchangeRateToken changes to ToTokenListOverlay * clean * Fix NaN bug * ... * Clean * Add maxConcurrentRequests and requestDelay to limit single overload + throttle fetchBridgeQuotes call * Debounce user input in Bridge updater to prevent alternative quote fetching, initial 5000ms * updateDebouncedFromValue action * Add reducer * Lift debouncedFromValue to store * Utilize debouncedFromValue throughout bridge experience * Create orderedPossibleTokens to create ordered list based on fetched bridge quotes * Debounce 400 * Debounce 300ms * 400ms debounce works * Ensure loader activates when fromValue updates, not based on debouncedFromValue * .. * Sort Best Rate selection and place at top * Add delay on bridge loading animation * Add default case for getDefaultBridgeAmount switch statement * Ensure loader not triggered until debouncedFromValue populated * Add isLoadingExchangeRate prop to SelectSpecificTokenButton * Show loading spinner when fetching bridge quote exchange rates * ... * Update name from LoadingSpinner to LoadingDots to be more descriptive' ' ' * Update ButtonLoadingSpinner to ButtonLoadingDots * Add debouncedToTokensFromValue action and reducer * Setup debounce for alternative bridge quotes * Utilize debouncedToTokensFromValue to fetch alternate bridge quotes * Separate debouncing for primary quote and alternate quotes * Update semantic naming, add comments * Update debounce times between primary/alternative * Tweak debouncer for alternative quote * Update debounce and maxConcurrentRequests to make alternative bridge quotes more reliable * Tighten up alternative bridge quotes fetching conditions for stability * update naming * Clear quotes if user input does not exist * Allow input to be zerod * Update trigger for useEffect updating alternative bridge quotes * hasOnlyZeroes shared utils function * Add try catch around fetchBridgeQuote action * clean * clean * Example with fetching with default values * Only fetch alternative bridge quotes when user input exists and is not zero * Increase bridge qutoe fetching reliability after setting default to selections to undefined * Update loading status when fetching default exchange rates * Only show best rate if more than one option * Fix lint * .. * Disable integration tests for iniitally settting bridge origin and destination token * Test max 2 concurrent requests * Set loading to false in useEffect cleanup * Add error handling for when fetchBridgeQuote does not have request or synapseSDK avail --------- Co-authored-by: Jonah Lin <[email protected]> * Publish - @synapsecns/[email protected] * feat/bridge-housekeeping (#1422) * Add isOrigin prop to SelectSpecificNetworkButton components to determine when to display extra tokens * Propogate props * Update TokenVisualizer in FromChainList * ... * Update chain icons * Set default fromToken and toToken to null * Remove default to selections * Default originToken set to null to set to options to empty * Resolve failures * Update formatBigIntToString util function to include trailing 0 before decimal * set initial default for fromToken to null * resetBridgeInputs action * Add reducer for resetBridgeInputs * Reset bridge inputs on disconnect * Only set toToken from finite bridge machine if toChainId has been set --------- Co-authored-by: Jonah Lin <[email protected]> * Publish - @synapsecns/[email protected] * [Snyk] Security upgrade postcss from 8.4.27 to 8.4.31 (#1416) * fix: packages/synapse-interface/package.json to reduce vulnerabilities The following vulnerabilities are fixed with an upgrade: - https://snyk.io/vuln/SNYK-JS-POSTCSS-5926692 * Add disabled prop to FilterInput * Ensure search input is disabled until app successfully mounts * Add border opacity when not mounted --------- Co-authored-by: snyk-bot <[email protected]> Co-authored-by: Jonah Lin <[email protected]> * yarn install * yarn install --------- Co-authored-by: snyk-bot <[email protected]> Co-authored-by: aureliusbtc <[email protected]> Co-authored-by: aureliusbtc <[email protected]> Co-authored-by: χ² <[email protected]> Co-authored-by: Trajan0x <[email protected]> Co-authored-by: Jonah Lin <[email protected]> Co-authored-by: ChiTimesChi <[email protected]> Co-authored-by: Borislav Grigorov <[email protected]> Co-authored-by: jonah <[email protected]> Co-authored-by: bigboydiamonds <[email protected]>
Description
Major refactor of Router SDK in preparation for RouterV2 and external Router Adapters.
High level overview of the changes:
Router
class that abstracts away the contract interactions and normalizes the data structures that different contracts are using, so that the rest of SDK (and its consumers) are dealing with unified types likeQuery
.SynapseRouter
andSynapseCCTPRouter
inherit from it to add support for corresponding contracts.RouterSet
class that handles the interactions with Routers on a few chains (such as bridge quote).SynapseRouterSet
andSynapseCCTPRouterSet
inherit from it to add support for corresponding contract sets.src/operations
to increase readability:src/operations/bridge
for bridging and bridge quoting,src/operations/pool
for pool inspection,src/operations/swap
for swapping and swap quoting.src/constants/testValues.ts
The changes were done in a non-breaking way, so that the SDK consumers could update w/o adjusting their code.
Additional context
c552818cb344a049af8fc93620c4600c75042a77: synapse-interface preview link
cdc4c00b93c8b9af502651b743cf6422e5287827: synapse-interface preview link
Summary by CodeRabbit
SynapseRouterSet
andSynapseCCTPRouterSet
classes.SynapseRouter
andSynapseCCTPRouter
classes to interact with respective contracts on different chains.f6d7008a733f81ebb11fc80be3151b3516775531: synapse-interface preview link
a9b4a9d0964bcd9297eb7df25f595703aa7adbab: synapse-interface preview link