Skip to content
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

Feat/input quotes #1412

Merged
merged 108 commits into from
Oct 10, 2023
Merged

Feat/input quotes #1412

merged 108 commits into from
Oct 10, 2023

Conversation

bigboydiamonds
Copy link
Collaborator

@bigboydiamonds bigboydiamonds commented Sep 30, 2023

e674003513818af13fc5add8b568eb6d396afc9c: synapse-interface preview link

29274af0d3209cced8f4bdbea685a75333c5fe3b: synapse-interface preview link
4fa5271058dad9c692b2dede54ad4854c3f20154: synapse-interface preview link

0530277507e644cb895d6ca6e9b929f166a90e82: synapse-interface preview link

e9b556b68511e061a6e07e53c4dfc1b657f3602e: synapse-interface preview link

0ab0cb504dcf00ea88ff11cc723d5a26bcde4a2d: synapse-interface preview link

b8d7ea4a63984308ca9450a421ed05e9d435999f: synapse-interface preview link

2ecfa660c4ba9fe6844d3de3e52e864671dfede3: synapse-interface preview link

bc99d95365f162096daa676152cad1a9053f5663: synapse-interface preview link

2f6c4592d3f55388aae21cb95c4228e1d4846083: synapse-interface preview link
2584b8ab084781608f5747397e8fdabac24fdf50: synapse-interface preview link
1f6dd5271b944d549f9c34b844c321fe7794df04: synapse-interface preview link
67ffad244dcb5763edf79919abb313f576df2144: synapse-interface preview link

f0812a3fe1020eddd34be00e1cb76d4ced71d3d8: synapse-interface preview link

95b5fe53ecbadd7b5722d8611de3140d7bdee7f8: synapse-interface preview link

7d6ee4c5907b28bf040743814d6215e9584c6b4f: synapse-interface preview link

cd5172a1190b0b562779e61aedb498e73a7931a2: synapse-interface preview link

800d16b81bab73754dff1f9d3af507fe15fe9bdd: synapse-interface preview link

ac01b090e11fb8794cf6b037694f5ebf1689c7ff: synapse-interface preview link

a13b493bb9413256ee47445268b89a3da9a260af: synapse-interface preview link

2bb29231d7130c9b018872238fc08b73ed6f9007: synapse-interface preview link

e56bb2ab24bd889ff61c6c773ebd91ebf2d7581d: synapse-interface preview link
2bf2a6623f10e4b0952dd004cba8308ed9399ab8: synapse-interface preview link

c880474f2b0cf55833b838ff69f011ba38535b01: synapse-interface preview link
f85a92f2db00cb985eb15328db2815063bf52c5c: synapse-interface preview link
46a01d57a20215a6051a0f83740d9ae620c03d29: synapse-interface preview link
bd09d98a43fc1ef72fee065bba388cbbc24469b3: synapse-interface preview link

47df20647d9b89f0d3deb228a28aef703758e79c: synapse-interface preview link
4dc6ef611dc96eb0c0bd45d48f3dffebfee1271b: synapse-interface preview link
09df24e1393925e5331b1b60a9136bdde42f8466: synapse-interface preview link

9f02b2458ba31ceb024cfa6d0e7f13e8bc98e0a8: synapse-interface preview link
07a4dc67b433c126d16b94727eaa656c59f5a434: synapse-interface preview link

f38c4da67ce9dffe259eb0f80b142d3dc86c55fb: synapse-interface preview link
9bdb325c49947534239e7be1f61363c480d5cd77: synapse-interface preview link
4c20041b1cbcdde3429dc509a63d46e5667557f1: synapse-interface preview link
5556ac5912b8f3cda4117f209c102cdddaa5e0d0: synapse-interface preview link

0be35ab38f784a110a38a0a516a012310c548436: synapse-interface preview link

b14d4a016a647d20f14b2c9acbc047c08722e0c5: synapse-interface preview link
059fb03035b1f864c60a772330827c0de0ee2ad4: synapse-interface preview link

Summary by CodeRabbit

New Features:

  • Added functionality to fetch and display multiple bridge quotes concurrently, allowing users to select the token with the best exchange rate.
  • Introduced a new Updater component to handle the debouncing of user input and trigger the fetching of bridge quotes.
  • Implemented a new loading UI using the LoadingDots component to enhance user experience during loading states.

Refactor:

  • Refactored the hasOnlyZeros function to hasOnlyZeroes and moved it to a separate file for better code organization.
  • Updated the ToTokenListOverlay and SelectSpecificTokenButton components to handle bridge quotes and exchange rates.

Chore:

  • Commented out code blocks in the Landing (/) test suite related to checking the initial loading of default origin and destination tokens.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits Files that changed from the base of the PR and between 5c3ecc7 and 2599ed4.
Files selected for processing (1)
  • packages/synapse-interface/slices/bridge/updater.tsx (1 hunks)
Additional comments (Suppressed): 2
packages/synapse-interface/slices/bridge/updater.tsx (2)
  • 1-6: The import statements are well organized and follow a logical order. Good use of named imports for clarity.

  • 110-137: The use of enums for defining swappable types and default bridge amounts improves readability and maintainability. The getDefaultBridgeAmount function is straightforward and easy to understand.

packages/synapse-interface/slices/bridge/updater.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 0

Commits Files that changed from the base of the PR and between 2599ed4 and 1f342be.
Files selected for processing (1)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/components/StateManagedBridge/InputContainer.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 4

Commits Files that changed from the base of the PR and between 1f342be and 73256d5.
Files selected for processing (3)
  • packages/synapse-interface/components/Portfolio/PortfolioContent/components/PortfolioTokenAsset.tsx (2 hunks)
  • packages/synapse-interface/slices/bridge/updater.tsx (1 hunks)
  • packages/synapse-interface/utils/hasOnlyZeroes.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/components/Portfolio/PortfolioContent/components/PortfolioTokenAsset.tsx
Additional comments (Suppressed): 2
packages/synapse-interface/utils/hasOnlyZeroes.ts (1)
  • 1-3: The function hasOnlyZeroes checks if the input string consists only of zeroes, possibly with a decimal point followed by more zeroes. This is done using a regular expression test. The implementation seems correct and efficient.
packages/synapse-interface/slices/bridge/updater.tsx (1)
  • 1-141: The Updater component is well structured and follows best practices for using React hooks. It uses debouncing to handle user input, which can improve performance by reducing the number of API calls. However, there are a few areas that could be improved.

packages/synapse-interface/slices/bridge/updater.tsx Outdated Show resolved Hide resolved
packages/synapse-interface/slices/bridge/updater.tsx Outdated Show resolved Hide resolved
packages/synapse-interface/slices/bridge/updater.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 7

Commits Files that changed from the base of the PR and between 73256d5 and b6d1578.
Files selected for processing (3)
  • packages/synapse-interface/components/Portfolio/PortfolioContent/components/PortfolioTokenAsset.tsx (3 hunks)
  • packages/synapse-interface/slices/bridge/updater.tsx (1 hunks)
  • packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/components/Portfolio/PortfolioContent/components/PortfolioTokenAsset.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 3

Commits Files that changed from the base of the PR and between b6d1578 and b292e40.
Files selected for processing (2)
  • packages/synapse-interface/slices/bridge/reducer.ts (6 hunks)
  • packages/synapse-interface/slices/bridge/updater.tsx (1 hunks)
Additional comments (Suppressed): 7
packages/synapse-interface/slices/bridge/updater.tsx (1)
  • 1-6: The import statements are well organized and follow a logical order. Good use of absolute imports for clarity.
packages/synapse-interface/slices/bridge/reducer.ts (6)
  • 18-29: The new hunk introduces several new imports from ./actions and ./hooks, as well as a new import for BridgeQuoteResponse from @/utils/actions/fetchBridgeQuotes. Ensure that these newly imported functions, actions, and types are correctly defined and exported in their respective modules.

  • 40-50: The state of the bridge has been extended with three new properties: debouncedFromValue, debouncedToTokensFromValue, and toTokensBridgeQuotesStatus. Make sure that these new properties are used appropriately throughout the codebase and that their initial values are set correctly.

  • 63-69: The function getRoutePossibilities is now called with different arguments. The fromToken and toToken parameters are now null, and the toChainId parameter is also omitted. This could potentially affect the return value of the function and therefore the initial state of the bridge. Please verify that this change does not introduce any unexpected behavior.

  • 79-89: The initial state of the bridge has been updated to include the new properties introduced in the state. The debouncedFromValue and debouncedToTokensFromValue properties are initialized as empty strings, while toTokensBridgeQuotesStatus is set to FetchState.IDLE. These initial values seem appropriate given the expected types of these properties.

  • 472-486: Two new cases have been added to the reducer to handle the updateDebouncedFromValue and updateDebouncedToTokensFromValue actions. These actions update the debouncedFromValue and debouncedToTokensFromValue properties in the state, respectively. Ensure that these actions are dispatched at the correct times to keep the state up-to-date.

  • 535-555: The reducer has been extended with several new cases to handle the fetchAndStoreBridgeQuotes async thunk and the resetFetchedBridgeQuotes action. These actions update the toTokensBridgeQuotes and toTokensBridgeQuotesStatus properties in the state. Make sure that these actions are dispatched correctly and that error handling is in place for the async thunk.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 0

Commits Files that changed from the base of the PR and between b292e40 and e4e69ba.
Files selected for processing (2)
  • packages/synapse-interface/components/StateManagedBridge/ToTokenListOverlay.tsx (4 hunks)
  • packages/synapse-interface/slices/bridge/reducer.ts (7 hunks)
Additional comments (Suppressed): 15
packages/synapse-interface/slices/bridge/reducer.ts (7)
  • 1-8: The import of ETH as ETHEREUM from @/constants/chains/master is new. Ensure that this change does not affect the rest of the codebase where ETH was previously used.

  • 17-25: New actions have been imported: resetFetchedBridgeQuotes, updateDebouncedFromValue, and updateDebouncedToTokensFromValue. Make sure these actions are implemented correctly in the corresponding action file.

  • 39-49: New state properties have been added: debouncedFromValue, debouncedToTokensFromValue, toTokensBridgeQuotes, and toTokensBridgeQuotesStatus. Ensure that these properties are updated appropriately throughout the application.

  • 62-68: The initial values for fromToken, toChainId, and toToken have been changed to null. Verify that this doesn't break any functionality where these values were expected to be non-null.

  • 78-88: The initial state has been updated with the new properties. This looks good.

  • 471-485: Reducers for the new actions updateDebouncedFromValue and updateDebouncedToTokensFromValue have been added. These look fine, but ensure that they are dispatched at the appropriate places in the application.

  • 534-554: Reducers for the new async thunk fetchAndStoreBridgeQuotes and the new action resetFetchedBridgeQuotes have been added. The reducers handle all possible states (pending, fulfilled, rejected) of the async thunk which is a good practice.

packages/synapse-interface/components/StateManagedBridge/ToTokenListOverlay.tsx (8)
  • 2-13: The useMemo hook and the Address from 'viem' have been added to the import statements. Ensure that these new dependencies are installed and compatible with the existing codebase.

  • 26-28: A new interface TokenWithExchangeRate has been introduced which extends the Token interface by adding an exchangeRate property. This is a good practice as it enhances the modularity of the code.

  • 32-39: New properties fromToken, toTokensBridgeQuotes, and toTokensBridgeQuotesStatus have been added to the destructuring assignment from useBridgeState(). Make sure these properties exist in the BridgeState interface and are being updated correctly elsewhere in the application.

  • 170-179: The isLoadingExchangeRate constant uses the useMemo hook to determine if the exchange rate is currently loading. This is a good use of memoization to avoid unnecessary re-computations.

  • 181-186: The bridgeQuotesMatchDestination constant checks if the first bridge quote's destination chain ID matches the current toChainId. This is a good check to ensure data consistency.

  • 188-225: The orderedPossibleTokens constant uses the useMemo hook to sort tokens based on their exchange rates. This is a good use of memoization and sorting to improve user experience by showing tokens with better exchange rates first.

  • 227-229: The totalPossibleTokens constant calculates the total number of possible tokens. This is a good use of memoization to avoid unnecessary re-computations.

  • 253-290: The SelectSpecificTokenButton component now receives additional props: isLoadingExchangeRate, isBestExchangeRate, exchangeRate, and estimatedDurationInSeconds. Ensure that these props are being handled correctly in the SelectSpecificTokenButton component.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 3

Commits Files that changed from the base of the PR and between e4e69ba and 8754335.
Files selected for processing (2)
  • packages/synapse-interface/cypress/e2e/landing.cy.ts (1 hunks)
  • packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/synapse-interface/cypress/e2e/landing.cy.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 3

Commits Files that changed from the base of the PR and between 8754335 and b77650f.
Files selected for processing (1)
  • packages/synapse-interface/slices/bridge/updater.tsx (1 hunks)
Additional comments (Suppressed): 3
packages/synapse-interface/slices/bridge/updater.tsx (3)
  • 1-6: The import statements are well organized and follow a logical order. Good use of absolute imports for clarity and maintainability.

  • 57-68: The use of setTimeout and clearTimeout within useEffect is a good practice for debouncing alternative destination token bridge quotes. The code is clear and well-structured.

  • 112-139: The use of enums for SwappableTypes and DefaultBridgeAmount is a good practice for maintaining a set of constants. The getDefaultBridgeAmount function is well implemented and uses a switch statement for clarity.

@bigboydiamonds bigboydiamonds merged commit 1db681a into master Oct 10, 2023
42 checks passed
@bigboydiamonds bigboydiamonds deleted the feat/input-quotes branch October 10, 2023 21:36
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 3

Commits Files that changed from the base of the PR and between b77650f and 2d35210.
Files selected for processing (1)
  • packages/synapse-interface/utils/actions/fetchBridgeQuotes.tsx (1 hunks)

Comment on lines +26 to +106
export async function fetchBridgeQuote(
request: BridgeQuoteRequest,
synapseSDK: any
): Promise<BridgeQuoteResponse> {
if (request && synapseSDK) {
try {
const {
originChainId,
originToken,
destinationChainId,
destinationTokenAddress,
destinationToken,
amount,
}: BridgeQuoteRequest = request
const { feeAmount, routerAddress, maxAmountOut, originQuery, destQuery } =
await synapseSDK.bridgeQuote(
originChainId,
destinationChainId,
originToken.addresses[originChainId],
destinationTokenAddress,
amount
)

const toValueBigInt: bigint = BigInt(maxAmountOut.toString()) ?? 0n
const originTokenDecimals: number = originToken.decimals[originChainId]
const adjustedFeeAmount: bigint =
BigInt(feeAmount) < amount
? BigInt(feeAmount)
: BigInt(feeAmount) / powBigInt(10n, BigInt(18 - originTokenDecimals))

const originMinWithSlippage = subtractSlippage(
originQuery?.minAmountOut ?? 0n,
'ONE_TENTH',
null
)
const destMinWithSlippage = subtractSlippage(
destQuery?.minAmountOut ?? 0n,
'ONE_TENTH',
null
)

let newOriginQuery = { ...originQuery }
newOriginQuery.minAmountOut = originMinWithSlippage

let newDestQuery = { ...destQuery }
newDestQuery.minAmountOut = destMinWithSlippage

return {
outputAmount: toValueBigInt,
outputAmountString: commify(
formatBigIntToString(
toValueBigInt,
destinationToken.decimals[destinationChainId],
8
)
),
routerAddress,
allowance: null, // update for allowances
exchangeRate: calculateExchangeRate(
amount - adjustedFeeAmount,
originToken.decimals[originChainId],
toValueBigInt,
destinationToken.decimals[destinationChainId]
),
feeAmount,
delta: BigInt(maxAmountOut.toString()),
quotes: {
originQuery: newOriginQuery,
destQuery: newDestQuery,
},
destinationToken: request.destinationToken,
destinationChainId: destinationChainId,
}
} catch (error) {
console.error('Error fetching bridge quote:', error)
throw error
}
} else {
console.error('Missing request or synapse SDK')
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetchBridgeQuote function does not handle the case where synapseSDK.bridgeQuote returns null or undefined. This could lead to a runtime error when trying to destructure the result. Consider adding a check for this case.

      const { feeAmount, routerAddress, maxAmountOut, originQuery, destQuery } =
        await synapseSDK.bridgeQuote(
          originChainId,
          destinationChainId,
          originToken.addresses[originChainId],
          destinationTokenAddress,
          amount
        )
+       if (!feeAmount || !routerAddress || !maxAmountOut || !originQuery || !destQuery) {
+         throw new Error('Invalid response from synapseSDK.bridgeQuote')
+       }

Comment on lines +108 to +143
export async function fetchBridgeQuotes(
requests: BridgeQuoteRequest[],
synapseSDK: any,
maxConcurrentRequests: number = 2, // Set the maximum number of concurrent requests
requestDelay: number = 1000 // Set the delay between requests in milliseconds (adjust as needed)
): Promise<BridgeQuoteResponse[]> {
try {
const bridgeQuotes: BridgeQuoteResponse[] = []

for (let i = 0; i < requests.length; i += maxConcurrentRequests) {
const batchRequests = requests.slice(i, i + maxConcurrentRequests)
const bridgeQuotesPromises: Promise<BridgeQuoteResponse>[] =
batchRequests.map(async (request: BridgeQuoteRequest) => {
const results: BridgeQuoteResponse = await fetchBridgeQuote(
request,
synapseSDK
)

return results
})

const batchBridgeQuotes = await Promise.all(bridgeQuotesPromises)
bridgeQuotes.push(...batchBridgeQuotes)

// Add a delay between batches of requests to avoid overloading the server
if (i + maxConcurrentRequests < requests.length) {
await new Promise((resolve) => setTimeout(resolve, requestDelay))
}
}

return bridgeQuotes
} catch (error) {
console.error('Error fetching bridge quotes: ', error)
return []
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetchBridgeQuotes function uses a for loop to manage concurrent requests. This could be simplified and made more efficient by using Promise.allSettled or Promise.all with array chunks. This would allow all requests in a chunk to be sent concurrently, rather than sequentially.

Comment on lines +145 to +161
export function locateBestExchangeRateToken(
quotes: BridgeQuoteResponse[]
): Token | null {
if (quotes?.length === 0) {
return null
}

let bestQuote: BridgeQuoteResponse | null = null

quotes.forEach((quote) => {
if (!bestQuote || quote.exchangeRate > bestQuote.exchangeRate) {
bestQuote = quote
}
})

return bestQuote ? bestQuote.destinationToken : null
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locateBestExchangeRateToken function iterates over the quotes array to find the quote with the best exchange rate. This could be optimized by using the reduce function to find the best quote in a single pass.

  quotes.forEach((quote) => {
    if (!bestQuote || quote.exchangeRate > bestQuote.exchangeRate) {
      bestQuote = quote
    }
  })
+   bestQuote = quotes.reduce((best, quote) => {
+     return (!best || quote.exchangeRate > best.exchangeRate) ? quote : best;
+   }, null);

bigboydiamonds added a commit that referenced this pull request Oct 10, 2023
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant