Skip to content

Commit 078ee23

Browse files
authored
fix(smart-router): multicall chunk config types (pancakeswap#6712)
<!-- Before opening a pull request, please read the [contributing guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md) first --> <!-- copilot:all --> ### <samp>🤖 Generated by Copilot at ff0746e</samp> ### Summary 🐛🚀🚚 <!-- 1. 🐛 - This emoji represents a bug fix, which is what the changes in the `tsup.config.ts` files are, since they fix the issue of the process exiting when there is an error in the compilation. 2. 🚀 - This emoji represents a new feature or improvement, which is what the changes in the `onChainQuoteProviderFactory` function are, since they add support for different multicall configurations for different chains. 3. 🚚 - This emoji represents a file rename or move, which is what the change in the `onChainQuoteProvider.ts` file is, since it renames the file and updates its config interface. --> This pull request adds support for different multicall configurations for different chains in the `onChainQuoteProviderFactory` function, which creates a provider for on-chain quotes. It also renames a file that exports a quote provider function for on-chain calls, and updates its config interface. Additionally, it modifies the `tsup.config.ts` files in several packages to improve the developer experience and productivity when working on the `smart-router` package and its dependencies. > _Sing, O Muse, of the skillful developers who changed the code_ > _Of the `tsup` command, that swift and powerful tool of compilation_ > _Which they made more resilient and graceful in the face of error_ > _By adding a watchful condition to the `exec` callback invocation_ ### Walkthrough * Rename `quoteProviders.ts` to `onChainQuoteProvider.ts` and update imports ([link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-4048276923cd03ee6d8a16e5d98b690dce94d9fff751d6c112f14b3a7c98c3bdL2-R2)) * Add `ChainMap` type and use it for `multicallConfigs` property of `ProviderConfig` interface ([link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-9ee18cb7fa7b08aada0e9a3c92dede9202fb872ba10bd8f230843faef707f463L14-R14), [link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-9ee18cb7fa7b08aada0e9a3c92dede9202fb872ba10bd8f230843faef707f463L42-R42), [link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-4048276923cd03ee6d8a16e5d98b690dce94d9fff751d6c112f14b3a7c98c3bdL10-R10)) * Use `multicallConfigsOverride` as a map of chain IDs to batch multicall configs in `onChainQuoteProviderFactory` function ([link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-9ee18cb7fa7b08aada0e9a3c92dede9202fb872ba10bd8f230843faef707f463L128-R130)) * Add condition to check `options.watch` before exiting process on error in `tsup.config.ts` files of `smart-router`, `swap-sdk-core`, `swap-sdk`, `tokens`, and `v3-sdk` packages ([link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-4e4ec7ede28a42687cfc6d7e9eecca9af029374e2b99c5b8032d2984c11e6d43L19-R21), [link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-62bd18f32e2ec0b5a7277f9d977e7bc9abfb260ff7b80d4a308c3260274fb6efL17-R19), [link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-24710ccfa763b4572357fec6eb436b9bf64c7be09efaf367f2695b484cb7b48aL17-R19), [link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-894ba18cb369d579fe478c18d8d150c1e929449266d7a7a38716d8febdd22c49L18-R20), [link](https://github.com/pancakeswap/pancake-frontend/pull/6712/files?diff=unified&w=0#diff-2a7ead6c2f71fb04919684ef6909599d89df52ddbb16f882a93ce8e4c07e93cfL17-R19))
1 parent 238f873 commit 078ee23

File tree

8 files changed

+27
-10
lines changed

8 files changed

+27
-10
lines changed

.changeset/fair-pots-happen.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@pancakeswap/smart-router': patch
3+
---
4+
5+
Fix multicall chunk config types

packages/smart-router/evm/v3-router/providers/onChainQuoteProvider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { encodeMixedRouteToPath, getQuoteCurrency, isStablePool, isV2Pool, isV3P
1111
import { Result } from './multicallProvider'
1212
import { PancakeMulticallProvider } from './multicallSwapProvider'
1313
import { MIXED_ROUTE_QUOTER_ADDRESSES, V3_QUOTER_ADDRESSES } from '../../constants'
14-
import { BatchMulticallConfigs } from '../../types'
14+
import { BatchMulticallConfigs, ChainMap } from '../../types'
1515
import { BATCH_MULTICALL_CONFIGS } from '../../constants/multicall'
1616
import { flatMap } from '../../utils/flatMap'
1717
import { uniq } from '../../utils/uniq'
@@ -39,7 +39,7 @@ interface FactoryConfig {
3939

4040
interface ProviderConfig {
4141
onChainProvider: OnChainProvider
42-
multicallConfigs?: BatchMulticallConfigs
42+
multicallConfigs?: ChainMap<BatchMulticallConfigs>
4343
}
4444

4545
type QuoteBatchSuccess = {
@@ -125,7 +125,9 @@ function onChainQuoteProviderFactory({ getQuoteFunctionName, getQuoterAddress, a
125125

126126
const chainId: ChainId = routes[0].amount.currency.chainId
127127
const multicallConfigs =
128-
multicallConfigsOverride || BATCH_MULTICALL_CONFIGS[chainId] || BATCH_MULTICALL_CONFIGS[ChainId.ETHEREUM]
128+
multicallConfigsOverride?.[chainId] ||
129+
BATCH_MULTICALL_CONFIGS[chainId] ||
130+
BATCH_MULTICALL_CONFIGS[ChainId.ETHEREUM]
129131
const chainProvider = onChainProvider({ chainId })
130132
let { multicallChunk, gasLimitOverride } = multicallConfigs.defaultConfig
131133
const { gasErrorFailureOverride, successRateFailureOverrides } = multicallConfigs

packages/smart-router/evm/v3-router/providers/quoteProviders.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/* eslint-disable no-console */
2-
import { BatchMulticallConfigs } from '../../types'
2+
import { BatchMulticallConfigs, ChainMap } from '../../types'
33
import { QuoteProvider, OnChainProvider, RouteWithoutQuote, RouteWithQuote, RouteType, QuoterOptions } from '../types'
44
import { isV3Pool } from '../utils'
55
import { createOffChainQuoteProvider } from './offChainQuoteProvider'
66
import { createMixedRouteOnChainQuoteProvider, createV3OnChainQuoteProvider } from './onChainQuoteProvider'
77

88
interface Config {
99
onChainProvider: OnChainProvider
10-
multicallConfigs?: BatchMulticallConfigs
10+
multicallConfigs?: ChainMap<BatchMulticallConfigs>
1111
}
1212

1313
// For evm

packages/smart-router/tsup.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export default defineConfig((options) => ({
1616
exec('tsc --emitDeclarationOnly --declaration', (err, stdout) => {
1717
if (err) {
1818
console.error(stdout)
19-
process.exit(1)
19+
if (!options.watch) {
20+
process.exit(1)
21+
}
2022
}
2123
})
2224
},

packages/swap-sdk-core/tsup.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default defineConfig((options) => ({
1414
exec('tsc --emitDeclarationOnly --declaration', (err, stdout) => {
1515
if (err) {
1616
console.error(stdout)
17-
process.exit(1)
17+
if (!options.watch) {
18+
process.exit(1)
19+
}
1820
}
1921
})
2022
},

packages/swap-sdk/tsup.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default defineConfig((options) => ({
1414
exec('tsc --emitDeclarationOnly --declaration', (err, stdout) => {
1515
if (err) {
1616
console.error(stdout)
17-
process.exit(1)
17+
if (!options.watch) {
18+
process.exit(1)
19+
}
1820
}
1921
})
2022
},

packages/tokens/tsup.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export default defineConfig((options) => {
1515
exec('tsc --emitDeclarationOnly --declaration', (err, stdout) => {
1616
if (err) {
1717
console.error(stdout)
18-
process.exit(1)
18+
if (!options.watch) {
19+
process.exit(1)
20+
}
1921
}
2022
})
2123
},

packages/v3-sdk/tsup.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default defineConfig((options) => ({
1414
exec('tsc --emitDeclarationOnly --declaration', (err, stdout) => {
1515
if (err) {
1616
console.error(stdout)
17-
process.exit(1)
17+
if (!options.watch) {
18+
process.exit(1)
19+
}
1820
}
1921
})
2022
},

0 commit comments

Comments
 (0)