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

fix(sdk-rouder): remove cache hydration #2597

Merged
merged 2 commits into from
May 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk-router/src/rfq/api.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ global.fetch = require('node-fetch')
describe('getAllQuotes', () => {
it('Integration test', async () => {
const result = await getAllQuotes()
console.log('Current quotes: ' + JSON.stringify(result, null, 2))
// console.log('Current quotes: ' + JSON.stringify(result, null, 2))
expect(result.length).toBeGreaterThan(0)
})
})
23 changes: 12 additions & 11 deletions packages/sdk-router/src/rfq/fastBridgeRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
narrowToCCTPRouterQuery,
reduceToQuery,
} from '../module'
import { BigintIsh, HYDRATION_SUPPORTED_CHAIN_IDS } from '../constants'
import { BigintIsh } from '../constants'
import { getMatchingTxLog } from '../utils/logs'
import { adjustValueIfNative } from '../utils/handleNativeToken'
import { CACHE_TIMES, RouterCache } from '../utils/RouterCache'
Expand Down Expand Up @@ -53,18 +53,19 @@ export class FastBridgeRouter implements SynapseModule {
FastBridgeRouter.fastBridgeRouterInterface,
provider
) as FastBridgeRouterContract
this.hydrateCache()
// TODO: figure out why this breaks the tests
// this.hydrateCache()
}

private async hydrateCache() {
if (HYDRATION_SUPPORTED_CHAIN_IDS.includes(this.chainId)) {
try {
await Promise.all([this.getProtocolFeeRate()])
} catch (e) {
console.error('fastBridgeRouter: Error hydrating cache', e)
}
}
}
// private async hydrateCache() {
// if (HYDRATION_SUPPORTED_CHAIN_IDS.includes(this.chainId)) {
// try {
// await Promise.all([this.getProtocolFeeRate()])
// } catch (e) {
// console.error('fastBridgeRouter: Error hydrating cache', e)
// }
// }
// }

/**
* @inheritdoc SynapseModule.bridge
Expand Down
25 changes: 13 additions & 12 deletions packages/sdk-router/src/router/synapseCCTPRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import cctpAbi from '../abi/SynapseCCTP.json'
import { adjustValueIfNative } from '../utils/handleNativeToken'
import { getMatchingTxLog } from '../utils/logs'
import { BigintIsh, HYDRATION_SUPPORTED_CHAIN_IDS } from '../constants'
import { BigintIsh } from '../constants'
import { DestRequest } from './types'
import { CACHE_TIMES, RouterCache } from '../utils/RouterCache'
/**
Expand Down Expand Up @@ -49,19 +49,20 @@ export class SynapseCCTPRouter extends Router {
provider
) as SynapseCCTPRouterContract
this.address = address
this.hydrateCache()
// TODO: figure out why this breaks the tests
// this.hydrateCache()
}

/** fully optional but improves perf on first request */
private async hydrateCache() {
if (HYDRATION_SUPPORTED_CHAIN_IDS.includes(this.chainId)) {
try {
await Promise.all([this.chainGasAmount()])
} catch (e) {
console.error('synapseCCTPRouter: Error hydrating cache', e)
}
}
}
// /** fully optional but improves perf on first request */
// private async hydrateCache() {
// if (HYDRATION_SUPPORTED_CHAIN_IDS.includes(this.chainId)) {
// try {
// await Promise.all([this.chainGasAmount()])
// } catch (e) {
// console.error('synapseCCTPRouter: Error hydrating cache', e)
// }
// }
// }

public async getOriginAmountOut(
tokenIn: string,
Expand Down
22 changes: 11 additions & 11 deletions packages/sdk-router/src/router/synapseRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
reduceToQuery,
} from '../module'
import bridgeAbi from '../abi/SynapseBridge.json'
import { BigintIsh, HYDRATION_SUPPORTED_CHAIN_IDS } from '../constants'
import { BigintIsh } from '../constants'
import {
DestRequest,
Pool,
Expand Down Expand Up @@ -102,18 +102,18 @@ export class SynapseRouter extends Router {
provider
) as SynapseRouterContract
this.address = address
this.hydrateCache()
// this.hydrateCache()
}

private async hydrateCache() {
if (HYDRATION_SUPPORTED_CHAIN_IDS.includes(this.chainId)) {
try {
await Promise.all([this.chainGasAmount()])
} catch (e) {
console.error('synapseRouter: Error hydrating cache', e)
}
}
}
// private async hydrateCache() {
// if (HYDRATION_SUPPORTED_CHAIN_IDS.includes(this.chainId)) {
// try {
// await Promise.all([this.chainGasAmount()])
// } catch (e) {
// console.error('synapseRouter: Error hydrating cache', e)
// }
// }
// }

public async getOriginAmountOut(
tokenIn: string,
Expand Down
Loading