diff --git a/api/_cache.ts b/api/_cache.ts index 2380cbc62..213416a2e 100644 --- a/api/_cache.ts +++ b/api/_cache.ts @@ -84,10 +84,18 @@ export async function getCachedValue( ): Promise { const cachedValue = await redisCache.get(key); if (cachedValue) { + if (key.includes("latestGasPriceCache")) { + console.log( + `Cache hit for key: ${key}: ${parser ? parser(cachedValue) : cachedValue}` + ); + } return parser ? parser(cachedValue) : cachedValue; } const value = await fetcher(); + if (key.includes("latestGasPriceCache")) { + console.log(`Cache miss for key: ${key}: ${value}`); + } await redisCache.set(key, value, ttl); return value; } diff --git a/api/_utils.ts b/api/_utils.ts index 4b94d2296..2af3133ae 100644 --- a/api/_utils.ts +++ b/api/_utils.ts @@ -1982,8 +1982,8 @@ export function getCachedFillGasUsage( } ); return { + opStackL1GasCost: gasCosts.opStackL1GasCost, nativeGasCost: gasCosts.nativeGasCost, - tokenGasCost: gasCosts.tokenGasCost, }; }; @@ -1991,10 +1991,15 @@ export function getCachedFillGasUsage( cacheKey, ttl, fetchFn, - (gasCosts: { nativeGasCost: BigNumber; tokenGasCost: BigNumber }) => { + (gasCosts: { + nativeGasCost: BigNumber; + opStackL1GasCost: BigNumber | undefined; + }) => { return { nativeGasCost: BigNumber.from(gasCosts.nativeGasCost), - tokenGasCost: BigNumber.from(gasCosts.tokenGasCost), + opStackL1GasCost: gasCosts.opStackL1GasCost + ? BigNumber.from(gasCosts.opStackL1GasCost) + : undefined, }; } ); @@ -2007,7 +2012,10 @@ export function latestGasPriceCache(chainId: number) { }; return makeCacheGetterAndSetter( - buildInternalCacheKey("latestGasPriceCache", chainId), + buildInternalCacheKey( + `${process.env.CACHE_PREFIX ? process.env.CACHE_PREFIX + "-" : ""}latestGasPriceCache`, + chainId + ), ttlPerChain[chainId] || ttlPerChain.default, async () => (await getMaxFeePerGas(chainId)).maxFeePerGas, (bnFromCache) => BigNumber.from(bnFromCache) @@ -2026,6 +2034,11 @@ export function getMaxFeePerGas( baseFeeMarkup: baseFeeMultiplier, priorityFeeMarkup: priorityFeeMultiplier, } = getGasMarkup(chainId); + console.log( + "fresh query getGasPriceEstimate", + baseFeeMultiplier.toString(), + priorityFeeMultiplier.toString() + ); return sdk.gasPriceOracle.getGasPriceEstimate(getProvider(chainId), { chainId, baseFeeMultiplier, diff --git a/api/limits.ts b/api/limits.ts index fcfc29a33..e65396c81 100644 --- a/api/limits.ts +++ b/api/limits.ts @@ -180,7 +180,18 @@ const handler = async ( }), latestGasPriceCache(destinationChainId).get(), ]); + console.log( + `Got gasPrice: ${gasPrice.toString()} and gasCosts ${gasCosts?.nativeGasCost.toString()}` + ); const tokenPriceUsd = ethers.utils.parseUnits(_tokenPriceUsd.toString()); + let tokenGasCost = gasCosts?.nativeGasCost; + if (tokenGasCost !== undefined) { + tokenGasCost = tokenGasCost.mul(gasPrice); + if (gasCosts?.opStackL1GasCost) { + tokenGasCost = tokenGasCost.add(gasCosts.opStackL1GasCost); + } + } + console.log(`tokenGasCosts: ${tokenGasCost?.toString()}`); const [ relayerFeeDetails, @@ -195,7 +206,7 @@ const handler = async ( relayer, gasPrice, gasCosts?.nativeGasCost, - gasCosts?.tokenGasCost + tokenGasCost ), callViaMulticall3(provider, multiCalls, { blockTag: latestBlock.number, diff --git a/package.json b/package.json index 6ec93dc78..0a101f267 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@across-protocol/constants": "^3.1.24", "@across-protocol/contracts": "^3.0.19", "@across-protocol/contracts-v3.0.6": "npm:@across-protocol/contracts@3.0.6", - "@across-protocol/sdk": "^3.4.7", + "@across-protocol/sdk": "^3.4.8-beta.1", "@amplitude/analytics-browser": "^2.3.5", "@balancer-labs/sdk": "1.1.6-beta.16", "@emotion/react": "^11.13.0", diff --git a/yarn.lock b/yarn.lock index 9b06bf5bf..275c9cd65 100644 --- a/yarn.lock +++ b/yarn.lock @@ -83,10 +83,10 @@ yargs "^17.7.2" zksync-web3 "^0.14.3" -"@across-protocol/sdk@^3.4.7": - version "3.4.7" - resolved "https://registry.yarnpkg.com/@across-protocol/sdk/-/sdk-3.4.7.tgz#6ddf9698f918d7b7e0216327d60b54b37fe14f22" - integrity sha512-GeyzDG8EzlN8oddmjXASqND+usZPkWDLpzbdWfAfBfHT3pjIMatntZqZghfCfjy+ICf+rlYrAb8I24H4jlct8Q== +"@across-protocol/sdk@^3.4.8-beta.1": + version "3.4.8-beta.1" + resolved "https://registry.yarnpkg.com/@across-protocol/sdk/-/sdk-3.4.8-beta.1.tgz#f9366cf7a30bf44a655d25efa03dd9101cdb96ca" + integrity sha512-uVkvdrnQt2Gtdel9H4isDRB+5iTn/fj1zamQzWqvaknSHftdFm2nbiRmNkB7fm2o41XanxTcXRN3rYUNWTGb1Q== dependencies: "@across-protocol/across-token" "^1.0.0" "@across-protocol/constants" "^3.1.25"