diff --git a/liquidity/cypress/package.json b/liquidity/cypress/package.json index f682f1ed..1cb59032 100644 --- a/liquidity/cypress/package.json +++ b/liquidity/cypress/package.json @@ -5,15 +5,19 @@ "version": "0.0.9", "scripts": { "anvil:arbitrum": "anvil --auto-impersonate --chain-id 42161 --fork-url wss://arbitrum-mainnet.infura.io/ws/v3/$INFURA_KEY --timeout 5000 --retries 0 --no-rate-limit --steps-tracing --fork-block-number 269244293", + "anvil:arbitrum-sepolia": "anvil --auto-impersonate --chain-id 421614 --fork-url wss://arbitrum-sepolia.infura.io/ws/v3/$INFURA_KEY --timeout 5000 --retries 0 --no-rate-limit --steps-tracing", "anvil:sepolia": "anvil --auto-impersonate --chain-id 11155111 --fork-url wss://sepolia.infura.io/ws/v3/$INFURA_KEY --timeout 5000 --retries 0 --no-rate-limit --steps-tracing", "anvil:base": "anvil --auto-impersonate --chain-id 8453 --fork-url wss://base-mainnet.infura.io/ws/v3/$INFURA_KEY --timeout 5000 --retries 0 --no-rate-limit --steps-tracing --fork-block-number 21781780", + "anvil:base-sepolia": "anvil --auto-impersonate --chain-id 84532 --fork-url wss://base-sepolia.infura.io/ws/v3/$INFURA_KEY --timeout 5000 --retries 0 --no-rate-limit --steps-tracing", "cy": "NODE_ENV=test cypress open --component --browser chrome", "e2e:arbitrum": "NODE_ENV=test CYPRESS_CHAIN_ID=42161 CYPRESS_PRESET=main cypress open --e2e --browser chrome --config specPattern='./cypress/e2e/42161-main/*.e2e.js'", "e2e:base": "NODE_ENV=test CYPRESS_CHAIN_ID=8453 CYPRESS_PRESET=andromeda cypress open --e2e --browser chrome --config specPattern='./cypress/e2e/8453-andromeda/*.e2e.js'", "sync-time": "ts-node bin/syncTime.ts", "update-prices": "ts-node bin/doAllPriceUpdates.ts 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", "update-prices:arbitrum": "NODE_ENV=test CYPRESS_CHAIN_ID=42161 CYPRESS_PRESET=main yarn update-prices", - "update-prices:base": "NODE_ENV=test CYPRESS_CHAIN_ID=8453 CYPRESS_PRESET=andromeda yarn update-prices" + "update-prices:arbitrum-sepolia": "NODE_ENV=test CYPRESS_CHAIN_ID=421614 CYPRESS_PRESET=main yarn update-prices", + "update-prices:base": "NODE_ENV=test CYPRESS_CHAIN_ID=8453 CYPRESS_PRESET=andromeda yarn update-prices", + "update-prices:base-sepolia": "NODE_ENV=test CYPRESS_CHAIN_ID=84532 CYPRESS_PRESET=andromeda yarn update-prices" }, "devDependencies": { "@chakra-ui/react": "^2.8.2", diff --git a/liquidity/lib/useAccountCollateral/useAccountCollateral.ts b/liquidity/lib/useAccountCollateral/useAccountCollateral.ts index 81cbea26..404d8909 100644 --- a/liquidity/lib/useAccountCollateral/useAccountCollateral.ts +++ b/liquidity/lib/useAccountCollateral/useAccountCollateral.ts @@ -122,9 +122,13 @@ export function useAccountCollateral({ }); const allCalls = [...calls]; - allCalls.unshift( - (await getPriceUpdates((await getPythFeedIds(network)) as string[], network)) as any - ); + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(network)) as string[], + network + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } const data = await erc7412Call(network, provider, allCalls, decoder, 'useAccountCollateral'); @@ -173,9 +177,13 @@ export function useAccountSpecificCollateral(accountId?: string, collateralAddre }); const allCalls = [...calls]; - allCalls.unshift( - (await getPriceUpdates((await getPythFeedIds(network)) as string[], network)) as any - ); + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(network)) as string[], + network + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } const data = await erc7412Call( network, diff --git a/liquidity/lib/useBlockchain/magic.ts b/liquidity/lib/useBlockchain/magic.ts index 1fe58c0f..7a6f6c29 100644 --- a/liquidity/lib/useBlockchain/magic.ts +++ b/liquidity/lib/useBlockchain/magic.ts @@ -37,6 +37,15 @@ export class MagicProvider extends ethers.providers.JsonRpcProvider { if (method === 'eth_accounts') { return [this.magicWallet]; } - return super.send(method, params); + try { + const result = await super.send(method, params); + // eslint-disable-next-line no-console + console.log('MAGIC.send', { method, params, result }); + return result; + } catch (error) { + // eslint-disable-next-line no-console + console.log('MAGIC.send ERROR', { method, params, error }); + throw error; + } } } diff --git a/liquidity/lib/useBorrow/useBorrow.tsx b/liquidity/lib/useBorrow/useBorrow.tsx index 68653166..08144b69 100644 --- a/liquidity/lib/useBorrow/useBorrow.tsx +++ b/liquidity/lib/useBorrow/useBorrow.tsx @@ -69,10 +69,15 @@ export const useBorrow = ({ } const walletAddress = await signer.getAddress(); - const erc7412Tx = await withERC7412(network, calls, 'useBorrow', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useBorrow', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useClaimAllRewards/useClaimAllRewards.tsx b/liquidity/lib/useClaimAllRewards/useClaimAllRewards.tsx index e1eade6d..62b5800b 100644 --- a/liquidity/lib/useClaimAllRewards/useClaimAllRewards.tsx +++ b/liquidity/lib/useClaimAllRewards/useClaimAllRewards.tsx @@ -96,10 +96,15 @@ export function useClaimAllRewards( calls.unshift(priceUpdateTx as any); } - const erc7412Tx = await withERC7412(network, calls, 'useClaimAllRewards', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useClaimAllRewards', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useClearDebt/useClearDebt.tsx b/liquidity/lib/useClearDebt/useClearDebt.tsx index 05aef9cf..76d968cb 100644 --- a/liquidity/lib/useClearDebt/useClearDebt.tsx +++ b/liquidity/lib/useClearDebt/useClearDebt.tsx @@ -92,10 +92,15 @@ export const useClearDebt = ({ calls.unshift(priceUpdateTx as any); } const walletAddress = await signer.getAddress(); - const erc7412Tx = await withERC7412(network, calls, 'useRepay', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useRepay', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts b/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts index 26429d6b..678ea619 100644 --- a/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts +++ b/liquidity/lib/useCollateralPriceUpdates/useCollateralPriceUpdates.ts @@ -227,10 +227,15 @@ export const useCollateralPriceUpdates = (customNetwork?: Network) => { } if (outdatedPriceIds.length) { - return { - ...(await getPriceUpdates(outdatedPriceIds, network)), - from: walletAddress, - }; + const priceUpdateTx = (await getPriceUpdates(outdatedPriceIds, network).catch( + () => undefined + )) as any; + if (priceUpdateTx) { + return { + ...priceUpdateTx, + from: walletAddress, + }; + } } return null; diff --git a/liquidity/lib/useCollateralPrices/useCollateralPrices.ts b/liquidity/lib/useCollateralPrices/useCollateralPrices.ts index 42113757..12b3fa6b 100644 --- a/liquidity/lib/useCollateralPrices/useCollateralPrices.ts +++ b/liquidity/lib/useCollateralPrices/useCollateralPrices.ts @@ -96,12 +96,14 @@ export const useCollateralPrices = (customNetwork?: Network) => { const { calls, decoder } = await loadPrices({ CoreProxy, collateralAddresses }); const allCalls = [...calls]; - allCalls.unshift( - (await getPriceUpdates( - (await getPythFeedIds(targetNetwork)) as string[], - targetNetwork - )) as any - ); + + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(targetNetwork)) as string[], + targetNetwork + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } const prices = await erc7412Call( targetNetwork, diff --git a/liquidity/lib/useDeposit/useDeposit.tsx b/liquidity/lib/useDeposit/useDeposit.tsx index 9d3f84c1..5449b479 100644 --- a/liquidity/lib/useDeposit/useDeposit.tsx +++ b/liquidity/lib/useDeposit/useDeposit.tsx @@ -101,10 +101,15 @@ export const useDeposit = ({ calls.unshift(priceUpdateTx as any); } - const erc7412Tx = await withERC7412(network, calls, 'useDeposit', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useDeposit', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useDepositBaseAndromeda/useDepositBaseAndromeda.tsx b/liquidity/lib/useDepositBaseAndromeda/useDepositBaseAndromeda.tsx index dac9c0db..032e24e9 100644 --- a/liquidity/lib/useDepositBaseAndromeda/useDepositBaseAndromeda.tsx +++ b/liquidity/lib/useDepositBaseAndromeda/useDepositBaseAndromeda.tsx @@ -139,7 +139,7 @@ export const useDepositBaseAndromeda = ({ const walletAddress = await signer.getAddress(); - const erc7412Tx = await withERC7412( + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( network, calls, 'useDepositBaseAndromeda', @@ -147,7 +147,7 @@ export const useDepositBaseAndromeda = ({ ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts b/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts index fe0217c7..0ea97b76 100644 --- a/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts +++ b/liquidity/lib/useLiquidityPosition/useLiquidityPosition.ts @@ -126,9 +126,13 @@ export const useLiquidityPosition = ({ const allCalls = priceCalls.concat(positionCalls).concat(accountCollateralCalls); - allCalls.unshift( - (await getPriceUpdates((await getPythFeedIds(network)) as string[], network)) as any - ); + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(network)) as string[], + network + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } return await erc7412Call( network, diff --git a/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts b/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts index 17e9416c..08a55f0f 100644 --- a/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts +++ b/liquidity/lib/useLiquidityPositions/useLiquidityPositions.ts @@ -101,9 +101,13 @@ export const useLiquidityPositions = ({ accountId }: { accountId?: string }) => const allCalls = priceCalls.concat(positionCalls).concat(availableCollateralCalls); const singlePositionDecoder = positionCallsAndData.at(0)?.decoder; - allCalls.unshift( - (await getPriceUpdates((await getPythFeedIds(network)) as string[], network)) as any - ); + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(network)) as string[], + network + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } return await erc7412Call( network, diff --git a/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts b/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts index a8c2093f..a27d3721 100644 --- a/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts +++ b/liquidity/lib/usePoolConfiguration/usePoolConfiguration.ts @@ -45,18 +45,22 @@ export const usePoolConfiguration = (poolId?: string) => { maxDebtShareValue: weightD18, })); - const calls = await Promise.all( + const allCalls = await Promise.all( markets.map((m) => CoreProxy.populateTransaction.isMarketCapacityLocked(m.id)) ); - calls.unshift( - (await getPriceUpdates((await getPythFeedIds(network)) as string[], network)) as any - ); + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(network)) as string[], + network + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } const decoded = await erc7412Call( network, provider, - calls, + allCalls, (encoded) => { const result = Array.isArray(encoded) ? encoded : [encoded]; return result.map((x) => diff --git a/liquidity/lib/usePoolsList/usePoolsList.ts b/liquidity/lib/usePoolsList/usePoolsList.ts index f7b570d7..9aed0d41 100644 --- a/liquidity/lib/usePoolsList/usePoolsList.ts +++ b/liquidity/lib/usePoolsList/usePoolsList.ts @@ -26,14 +26,14 @@ export function usePoolsList() { } export function usePool(networkId: number, poolId: string) { - const { data, isLoading } = usePoolsList(); + const { data, isPending } = usePoolsList(); // TODO: In the future if we have multiple pools per network filter by poolId also return { data: data?.synthetixPools.find( - (p) => p.network.id === networkId && p?.poolInfo?.[0]?.pool?.id === poolId + (p) => p?.network?.id === networkId && p?.poolInfo?.[0]?.pool?.id === poolId ), - isLoading, + isLoading: isPending, }; } diff --git a/liquidity/lib/useRepay/useRepay.tsx b/liquidity/lib/useRepay/useRepay.tsx index 0a324691..78d2d6bf 100644 --- a/liquidity/lib/useRepay/useRepay.tsx +++ b/liquidity/lib/useRepay/useRepay.tsx @@ -79,10 +79,15 @@ export const useRepay = ({ calls.unshift(priceUpdateTx as any); } - const erc7412Tx = await withERC7412(network, calls, 'useRepay', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useRepay', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useRepayBaseAndromeda/useRepayBaseAndromeda.tsx b/liquidity/lib/useRepayBaseAndromeda/useRepayBaseAndromeda.tsx index 504c26ba..573a8c38 100644 --- a/liquidity/lib/useRepayBaseAndromeda/useRepayBaseAndromeda.tsx +++ b/liquidity/lib/useRepayBaseAndromeda/useRepayBaseAndromeda.tsx @@ -131,10 +131,15 @@ export const useRepayBaseAndromeda = ({ } const walletAddress = await signer.getAddress(); - const erc7412Tx = await withERC7412(network, calls, 'useRepay', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useRepay', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useUndelegate/useUndelegate.tsx b/liquidity/lib/useUndelegate/useUndelegate.tsx index 823a156e..6f6b707b 100644 --- a/liquidity/lib/useUndelegate/useUndelegate.tsx +++ b/liquidity/lib/useUndelegate/useUndelegate.tsx @@ -57,10 +57,15 @@ export const useUndelegate = ({ calls.unshift(priceUpdateTx as any); } - const erc7412Tx = await withERC7412(network, calls, 'useUndelegate', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useUndelegate', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useUndelegateBaseAndromeda/useUndelegateBaseAndromeda.tsx b/liquidity/lib/useUndelegateBaseAndromeda/useUndelegateBaseAndromeda.tsx index e87f4ba6..868e3c7d 100644 --- a/liquidity/lib/useUndelegateBaseAndromeda/useUndelegateBaseAndromeda.tsx +++ b/liquidity/lib/useUndelegateBaseAndromeda/useUndelegateBaseAndromeda.tsx @@ -112,10 +112,15 @@ export const useUndelegateBaseAndromeda = ({ const walletAddress = await signer.getAddress(); - const erc7412Tx = await withERC7412(network, calls, 'useUndelegateBase', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useUndelegateBase', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useVaultsData/useVaultsData.ts b/liquidity/lib/useVaultsData/useVaultsData.ts index a39b019e..b75dfe2c 100644 --- a/liquidity/lib/useVaultsData/useVaultsData.ts +++ b/liquidity/lib/useVaultsData/useVaultsData.ts @@ -49,19 +49,20 @@ export const useVaultsData = (poolId?: number, customNetwork?: Network) => { ) ); - const calls = await Promise.all([collateralCallsP, debtCallsP]); + const allCalls = await Promise.all([collateralCallsP, debtCallsP]); - calls.unshift( - (await getPriceUpdates( - (await getPythFeedIds(targetNetwork)) as string[], - targetNetwork - )) as any - ); + const priceUpdateTx = (await getPriceUpdates( + (await getPythFeedIds(targetNetwork)) as string[], + targetNetwork + ).catch(() => undefined)) as any; + if (priceUpdateTx) { + allCalls.unshift(priceUpdateTx); + } return await erc7412Call( targetNetwork, provider, - calls.flat(), + allCalls.flat(), (multicallResult) => { if (!Array.isArray(multicallResult)) throw Error('Expected array'); diff --git a/liquidity/lib/useWithdraw/useWithdraw.tsx b/liquidity/lib/useWithdraw/useWithdraw.tsx index 02139456..f609f97a 100644 --- a/liquidity/lib/useWithdraw/useWithdraw.tsx +++ b/liquidity/lib/useWithdraw/useWithdraw.tsx @@ -70,10 +70,15 @@ export const useWithdraw = ({ calls.unshift(priceUpdateTx as any); } - const erc7412Tx = await withERC7412(network, calls, 'useWithdraw', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + calls, + 'useWithdraw', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/useWithdrawBaseAndromeda/useWithdrawBaseAndromeda.tsx b/liquidity/lib/useWithdrawBaseAndromeda/useWithdrawBaseAndromeda.tsx index cac430da..0cb0bdf7 100644 --- a/liquidity/lib/useWithdrawBaseAndromeda/useWithdrawBaseAndromeda.tsx +++ b/liquidity/lib/useWithdrawBaseAndromeda/useWithdrawBaseAndromeda.tsx @@ -144,10 +144,15 @@ export const useWithdrawBaseAndromeda = ({ } const walletAddress = await signer.getAddress(); - const erc7412Tx = await withERC7412(network, allCalls, 'useWithdrawBase', walletAddress); + const { multicallTxn: erc7412Tx, gasLimit } = await withERC7412( + network, + allCalls, + 'useWithdrawBase', + walletAddress + ); const gasOptionsForTransaction = formatGasPriceForTransaction({ - gasLimit: erc7412Tx.gasLimit, + gasLimit, gasPrices, gasSpeed, }); diff --git a/liquidity/lib/withERC7412/withERC7412.ts b/liquidity/lib/withERC7412/withERC7412.ts index 78da40d3..7358333b 100644 --- a/liquidity/lib/withERC7412/withERC7412.ts +++ b/liquidity/lib/withERC7412/withERC7412.ts @@ -12,6 +12,8 @@ import { notNil } from '@snx-v3/tsHelpers'; import { Network, deploymentHasERC7412, getMagicProvider } from '@snx-v3/useBlockchain'; import { ethers } from 'ethers'; +const IS_DEBUG = window.localStorage.getItem('DEBUG') === 'true'; + export const ERC7412_ABI = [ 'error OracleDataRequired(address oracleContract, bytes oracleQuery)', 'error OracleDataRequired(address oracleContract, bytes oracleQuery, uint256 feeRequired)', @@ -223,7 +225,7 @@ async function getMulticallTransaction( ), }; const gasLimit = await provider.estimateGas(multicallTxn); - return { ...multicallTxn, gasLimit }; + return { multicallTxn, gasLimit, _calls: calls }; } /** @@ -234,7 +236,7 @@ export const withERC7412 = async ( calls: (ethers.PopulatedTransaction & { requireSuccess?: boolean })[], label: string, from: string -): Promise => { +) => { // Make sure we're always using JSONRpcProvider, the web3 provider coming from the signer might have bugs causing errors to miss revert data const jsonRpcProvider = getMagicProvider() ?? new ethers.providers.JsonRpcProvider(network.rpcUrl()); @@ -248,7 +250,7 @@ export const withERC7412 = async ( while (true) { try { - if (window.localStorage.getItem('DEBUG') === 'true') { + if (IS_DEBUG) { await logMulticall({ network, calls, label }); } return await getMulticallTransaction(network, calls, from, jsonRpcProvider); @@ -342,28 +344,51 @@ export async function erc7412Call( const Multicall3Contract = await importMulticall3(network.id, network.preset); const from = getDefaultFromAddress(network.name); - const newCall = await withERC7412( + const { + _calls: newCalls, + gasLimit, + multicallTxn, + } = await withERC7412( network, calls.filter(notNil).map((call) => (call.from ? call : { ...call, from })), // fill missing "from" label, from ); - const res = await provider.call(newCall); + const res = await provider.call({ ...multicallTxn, gasLimit }); + if (res === '0x') { + throw new Error(`[${label}] Call returned 0x`); + } - if (newCall.to?.toLowerCase() === Multicall3Contract.address.toLowerCase()) { + if (multicallTxn.to?.toLowerCase() === Multicall3Contract.address.toLowerCase()) { // If this was a multicall, decode and remove price updates. const decodedMultiCall: { returnData: string }[] = new ethers.utils.Interface( Multicall3Contract.abi ).decodeFunctionResult('aggregate3Value', res)[0]; + if (IS_DEBUG) { + console.log(`[${label}] multicall`, decodedMultiCall); + } + // Remove the price updates - const responseWithoutPriceUpdates = decodedMultiCall.filter( - ({ returnData }) => returnData !== '0x' // price updates have 0x as return data - ); + const responseWithoutPriceUpdates: string[] = []; + const PythVerfier = await importPythVerfier(network.id, network.preset); + decodedMultiCall.forEach(({ returnData }, i) => { + if (newCalls?.[i]?.to !== PythVerfier.address) { + responseWithoutPriceUpdates.push(returnData); + } + }); - return decode(responseWithoutPriceUpdates.map(({ returnData }) => returnData)); + const decoded = decode(responseWithoutPriceUpdates); + if (IS_DEBUG) { + console.log(`[${label}] result`, decoded); + } + return decoded; } - return decode(res); + const decoded = decode(res); + if (IS_DEBUG) { + console.log(`[${label}] result`, decoded); + } + return decoded; } diff --git a/package.json b/package.json index 28e12490..9f3add70 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,15 @@ "start": "yarn workspace @snx-v3/liquidity start", "build": "yarn workspace @snx-v3/liquidity build", "update-prices:arbitrum": "yarn workspace @snx-v3/liquidity-cypress update-prices:arbitrum", + "update-prices:arbitrum-sepolia": "yarn workspace @snx-v3/liquidity-cypress update-prices:arbitrum-sepolia", "update-prices:base": "yarn workspace @snx-v3/liquidity-cypress update-prices:base", + "update-prices:base-sepolia": "yarn workspace @snx-v3/liquidity-cypress update-prices:base-sepolia", "sync-time": "yarn workspace @snx-v3/liquidity-cypress sync-time", "anvil:arbitrum": "yarn workspace @snx-v3/liquidity-cypress anvil:arbitrum", + "anvil:arbitrum-sepolia": "yarn workspace @snx-v3/liquidity-cypress anvil:arbitrum-sepolia", "anvil:sepolia": "yarn workspace @snx-v3/liquidity-cypress anvil:sepolia", "anvil:base": "yarn workspace @snx-v3/liquidity-cypress anvil:base", + "anvil:base-sepolia": "yarn workspace @snx-v3/liquidity-cypress anvil:base-sepolia", "cy": "yarn workspace @snx-v3/liquidity-cypress cy", "e2e:arbitrum": "yarn workspace @snx-v3/liquidity-cypress e2e:arbitrum", "e2e:base": "yarn workspace @snx-v3/liquidity-cypress e2e:base",