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(routing-api): support routing on unichain mainnet #919

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 7 additions & 3 deletions bin/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export class RoutingAPIPipeline extends Stack {
// Load RPC provider URLs from AWS secret
let jsonRpcProviders = {} as { [chainId: string]: string }
SUPPORTED_CHAINS.forEach((chainId: ChainId) => {
if (chainId !== ChainId.WORLDCHAIN && chainId !== ChainId.ASTROCHAIN_SEPOLIA) {
if (chainId !== ChainId.WORLDCHAIN && chainId !== ChainId.UNICHAIN_SEPOLIA) {
const key = `WEB3_RPC_${chainId}`
jsonRpcProviders[key] = jsonRpcProvidersSecret.secretValueFromJson(key).toString()
new CfnOutput(this, key, {
Expand Down Expand Up @@ -234,7 +234,9 @@ export class RoutingAPIPipeline extends Stack {
'ALCHEMY_324',
// WorldChain,
'QUICKNODE_480',
// AstroChain Sepolia,
// Unichain
'QUICKNODE_130',
// Unichain Sepolia,
'QUICKNODE_1301',
// unirpc - serves all chains
'UNIRPC_0',
Expand Down Expand Up @@ -410,7 +412,9 @@ const jsonRpcProviders = {
ALCHEMY_324: process.env.ALCHEMY_324!,
// WorldChain,
QUICKNODE_480: process.env.QUICKNODE_480!,
// AstroChain Sepolia,
// Unichain
QUICKNODE_130: process.env.QUICKNODE_130!,
// Unichain Sepolia,
QUICKNODE_1301: process.env.QUICKNODE_1301!,
// unirpc - serves all chains
UNIRPC_0: process.env.UNIRPC_0!,
Expand Down
4 changes: 2 additions & 2 deletions bin/stacks/routing-lambda-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {

description: 'Caching Routing Lambda',
environment: {
VERSION: '1',
VERSION: '2',
NODE_OPTIONS: '--enable-source-maps',
POOL_CACHE_BUCKET: poolCacheBucket.bucketName,
POOL_CACHE_BUCKET_3: poolCacheBucket3.bucketName,
Expand Down Expand Up @@ -186,7 +186,7 @@ export class RoutingLambdaStack extends cdk.NestedStack {

description: 'Routing Lambda',
environment: {
VERSION: '28',
VERSION: '29',
NODE_OPTIONS: '--enable-source-maps',
POOL_CACHE_BUCKET: poolCacheBucket.bucketName,
POOL_CACHE_BUCKET_3: poolCacheBucket3.bucketName,
Expand Down
15 changes: 12 additions & 3 deletions lib/config/rpcProviderProdConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,17 @@
"useMultiProviderProb": 1,
"latencyEvaluationSampleProb": 0,
"healthCheckSampleProb": 0,
"providerInitialWeights": [1],
"providerUrls": ["QUICKNODE_1301"],
"providerNames": ["QUICKNODE"]
"providerInitialWeights": [0, 1],
"providerUrls": ["QUICKNODE_1301", "UNIRPC_0"],
"providerNames": ["QUICKNODE", "UNIRPC"]
},
{
"chainId": 130,
"useMultiProviderProb": 1,
"latencyEvaluationSampleProb": 0,
"healthCheckSampleProb": 0,
"providerInitialWeights": [0, 1],
"providerUrls": ["QUICKNODE_130", "UNIRPC_0"],
"providerNames": ["QUICKNODE", "UNIRPC"]
}
]
8 changes: 6 additions & 2 deletions lib/cron/cache-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export const v3SubgraphUrlOverride = (chainId: ChainId) => {
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v3-celo/api`
case ChainId.WORLDCHAIN:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v3-worldchain/api`
case ChainId.ASTROCHAIN_SEPOLIA:
case ChainId.UNICHAIN_SEPOLIA:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v3-astrochain-sepolia/api`
case ChainId.UNICHAIN:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v3-unichain/api`
default:
return undefined
}
Expand All @@ -64,8 +66,10 @@ export const v2SubgraphUrlOverride = (chainId: ChainId) => {
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v2-base/api`
case ChainId.WORLDCHAIN:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v2-worldchain/api`
case ChainId.ASTROCHAIN_SEPOLIA:
case ChainId.UNICHAIN_SEPOLIA:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v2-astrochain-sepolia/api`
case ChainId.UNICHAIN:
return `https://subgraph.satsuma-prod.com/${process.env.ALCHEMY_QUERY_KEY}/uniswap/uniswap-v2-unichain/api`
default:
return undefined
}
Expand Down
3 changes: 2 additions & 1 deletion lib/dashboards/rpc-providers-widgets-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const ID_TO_PROVIDER = (id: ChainId): string => {
case ChainId.CELO:
case ChainId.BNB:
case ChainId.BASE:
case ChainId.ASTROCHAIN_SEPOLIA:
case ChainId.UNICHAIN_SEPOLIA:
case ChainId.UNICHAIN:
return ProviderName.QUIKNODE
case ChainId.CELO_ALFAJORES:
return ProviderName.FORNO
Expand Down
6 changes: 4 additions & 2 deletions lib/graphql/graphql-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export class UniGraphQLProvider implements IUniGraphQLProvider {
return 'ZKSYNC'
case ChainId.WORLDCHAIN:
return 'WORLDCHAIN'
case ChainId.ASTROCHAIN_SEPOLIA:
return 'ASTROCHAIN'
case ChainId.UNICHAIN_SEPOLIA:
return 'UNICHAIN_SEPOLIA'
case ChainId.UNICHAIN:
return 'UNICHAIN'
default:
throw new Error(`UniGraphQLProvider._chainIdToGraphQLChainName unsupported ChainId: ${chainId}`)
}
Expand Down
7 changes: 5 additions & 2 deletions lib/handlers/injector-sor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ export const SUPPORTED_CHAINS: ChainId[] = [
ChainId.ZORA,
ChainId.ZKSYNC,
ChainId.WORLDCHAIN,
ChainId.ASTROCHAIN_SEPOLIA,
ChainId.UNICHAIN_SEPOLIA,
ChainId.UNICHAIN,
]
const DEFAULT_TOKEN_LIST = 'https://gateway.ipfs.io/ipns/tokens.uniswap.org'

Expand Down Expand Up @@ -366,7 +367,8 @@ export abstract class InjectorSOR<Router, QueryParams> extends Injector<
case ChainId.ZORA:
case ChainId.ZKSYNC:
case ChainId.WORLDCHAIN:
case ChainId.ASTROCHAIN_SEPOLIA:
case ChainId.UNICHAIN_SEPOLIA:
case ChainId.UNICHAIN:
const currentQuoteProvider = new OnChainQuoteProvider(
chainId,
provider,
Expand Down Expand Up @@ -498,6 +500,7 @@ export abstract class InjectorSOR<Router, QueryParams> extends Injector<
ChainId.AVALANCHE,
ChainId.BLAST,
ChainId.WORLDCHAIN,
//ChainId.UNICHAIN, // Supported?
]

const v4Supported = [ChainId.SEPOLIA]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,10 @@ export const QUOTE_PROVIDER_TRAFFIC_SWITCH_CONFIGURATION = (
samplingExactOutPercentage: 0,
} as QuoteProviderTrafficSwitchConfiguration
}
// worldchain and astrochain sepolia don't have the view-only quoter yet, so we can shadow sample 0.1% of traffic
// worldchain and unichain sepolia don't have the view-only quoter yet, so we can shadow sample 0.1% of traffic
case ChainId.WORLDCHAIN:
case ChainId.ASTROCHAIN_SEPOLIA:
case ChainId.UNICHAIN_SEPOLIA:
case ChainId.UNICHAIN:
switch (protocol) {
case Protocol.MIXED:
case Protocol.V4:
Expand Down
3 changes: 2 additions & 1 deletion lib/handlers/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const DEFAULT_ROUTING_CONFIG_BY_CHAIN = (chainId: ChainId): AlphaRouterCo
case ChainId.BASE:
case ChainId.OPTIMISM:
case ChainId.WORLDCHAIN:
case ChainId.ASTROCHAIN_SEPOLIA:
case ChainId.UNICHAIN_SEPOLIA:
case ChainId.UNICHAIN:
return {
v2PoolSelection: {
topN: 3,
Expand Down
9 changes: 7 additions & 2 deletions lib/rpc/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ export function chainIdToNetworkName(networkId: ChainId): string {
return 'base'
case ChainId.WORLDCHAIN:
return 'worldchain'
case ChainId.ASTROCHAIN_SEPOLIA:
return 'astrochain-sepolia'
case ChainId.UNICHAIN_SEPOLIA:
return 'unichain-sepolia'
case ChainId.UNICHAIN:
return 'unichain'
default:
return 'ethereum'
}
Expand Down Expand Up @@ -102,6 +104,9 @@ export function generateProviderUrl(key: string, value: string, chainId: number)
// URL contains unichain-sepolia.quiknode.pro, we had to not disclose prior to the unichain annouce
return `${tokens[0]}`
}
case 'QUICKNODE_130': {
return `https://${tokens[0]}.unichain-mainnet.quiknode.pro/${tokens[1]}`
}
case 'QUICKNODE_480': {
return `https://${tokens[0]}.worldchain-mainnet.quiknode.pro/${tokens[1]}`
}
Expand Down
3 changes: 2 additions & 1 deletion lib/util/defaultBlocksToLiveRoutesDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export const DEFAULT_BLOCKS_TO_LIVE_ROUTES_DB: { [chain in ChainId]: number } =
[ChainId.BLAST]: 1800,
[ChainId.WORLDCHAIN]: 1800,
// (60 minutes) / (1 seconds) = 3600
[ChainId.ASTROCHAIN_SEPOLIA]: 3600,
[ChainId.UNICHAIN_SEPOLIA]: 3600,
[ChainId.UNICHAIN]: 3600,
// (60 minutes) / (250 milliseconds) = 14400
[ChainId.ARBITRUM_ONE]: 14400,
[ChainId.ARBITRUM_GOERLI]: 14400,
Expand Down
3 changes: 2 additions & 1 deletion lib/util/extraV4FeeTiersTickSpacingsHookAddresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ export const EXTRA_V4_FEE_TICK_SPACINGS_HOOK_ADDRESSES: { [chain in ChainId]: Ar
[ChainId.BLAST]: emptyV4FeeTickSpacingsHookAddresses,
[ChainId.ZKSYNC]: emptyV4FeeTickSpacingsHookAddresses,
[ChainId.WORLDCHAIN]: emptyV4FeeTickSpacingsHookAddresses,
[ChainId.ASTROCHAIN_SEPOLIA]: emptyV4FeeTickSpacingsHookAddresses,
[ChainId.UNICHAIN]: emptyV4FeeTickSpacingsHookAddresses,
[ChainId.UNICHAIN_SEPOLIA]: emptyV4FeeTickSpacingsHookAddresses,
}
4 changes: 2 additions & 2 deletions lib/util/gasLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ export const CELO_UPPER_SWAP_GAS_LIMIT = BigNumber.from(5000000)
// https://github.com/Uniswap/routing-api/blob/fe410751985995cb2904837e24f22da7dca1f518/lib/util/onChainQuoteProviderConfigs.ts#L340 divivde by 10
export const WORLDCHAIN_UPPER_SWAP_GAS_LIMIT = BigNumber.from(300000)
// https://github.com/Uniswap/routing-api/blob/fe410751985995cb2904837e24f22da7dca1f518/lib/util/onChainQuoteProviderConfigs.ts#L344 divivde by 10
export const ASTROCHAIN_SEPOLIA_UPPER_SWAP_GAS_LIMIT = BigNumber.from(300000)
export const UNICHAIN_SEPOLIA_UPPER_SWAP_GAS_LIMIT = BigNumber.from(300000)

export const CHAIN_TO_GAS_LIMIT_MAP: { [chainId: number]: BigNumber } = {
[ChainId.ZKSYNC]: ZKSYNC_UPPER_SWAP_GAS_LIMIT,
[ChainId.CELO]: CELO_UPPER_SWAP_GAS_LIMIT,
[ChainId.CELO_ALFAJORES]: CELO_UPPER_SWAP_GAS_LIMIT,
[ChainId.ASTROCHAIN_SEPOLIA]: ASTROCHAIN_SEPOLIA_UPPER_SWAP_GAS_LIMIT,
[ChainId.UNICHAIN_SEPOLIA]: UNICHAIN_SEPOLIA_UPPER_SWAP_GAS_LIMIT,
}
3 changes: 2 additions & 1 deletion lib/util/hooksAddressesAllowlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ export const HOOKS_ADDRESSES_ALLOWLIST: { [chain in ChainId]: Array<string> } =
[ChainId.BLAST]: [ADDRESS_ZERO],
[ChainId.ZKSYNC]: [ADDRESS_ZERO],
[ChainId.WORLDCHAIN]: [ADDRESS_ZERO],
[ChainId.ASTROCHAIN_SEPOLIA]: [ADDRESS_ZERO],
[ChainId.UNICHAIN]: [ADDRESS_ZERO],
[ChainId.UNICHAIN_SEPOLIA]: [ADDRESS_ZERO],
}
3 changes: 2 additions & 1 deletion lib/util/newCachedRoutesRolloutPercent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ export const NEW_CACHED_ROUTES_ROLLOUT_PERCENT: { [chain in ChainId]: number } =
[ChainId.BLAST]: 100,
[ChainId.ZKSYNC]: 100,
[ChainId.WORLDCHAIN]: 100,
[ChainId.ASTROCHAIN_SEPOLIA]: 100,
[ChainId.UNICHAIN]: 100,
[ChainId.UNICHAIN_SEPOLIA]: 100,
}
Loading
Loading