Coder Social home page Coder Social logo

"Failed to get gas constants data from the optimism gas oracle" when quoting swaps on Base and Optimism about smart-order-router HOT 11 CLOSED

pedroyan avatar pedroyan commented on August 13, 2024 5
"Failed to get gas constants data from the optimism gas oracle" when quoting swaps on Base and Optimism

from smart-order-router.

Comments (11)

Akhilesh-solutelabs avatar Akhilesh-solutelabs commented on August 13, 2024 1

we were able to get rid of the error of Failed to get gas constants data from the optimism gas oracle by upgrading to :

    "@uniswap/sdk-core": "^4.2.0",
    "@uniswap/smart-order-router": "^3.26.0",
    "@uniswap/v3-periphery": "^1.4.4",
    "@uniswap/v3-sdk": "^3.11.0",

which caused Browser is not defined - solution : Adding fallback script as mentioned in comments in #484

after which we ran into -
image
so we moved the L:6 variables - _SEPOLIA of github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/functions/get-candidate-pools.ts i.e.
USDC_ARBITRUM_SEPOLIA, DAI_OPTIMISM_SEPOLIA, USDC_OPTIMISM_SEPOLIA, USDT_OPTIMISM_SEPOLIA, WBTC_OPTIMISM_SEPOLIA to already existing import on L:16
import { USDC_ARBITRUM_SEPOLIA, DAI_OPTIMISM_SEPOLIA, USDC_OPTIMISM_SEPOLIA, USDT_OPTIMISM_SEPOLIA, WBTC_OPTIMISM_SEPOLIA, CELO,
CELO_ALFAJORES, ...} from '../../../providers/token-provider';

It seems to have worked for me. I was able to get a quote for ETH/ other tokens .. on Optimism chain using Alpha router & do a successful swap. So I would request uniswap team @jsy1218 to update the imports perhaps? not sure why there are two different imports when they use the same token-provider file.

from smart-order-router.

jsy1218 avatar jsy1218 commented on August 13, 2024 1

Sorry for the trouble. The original issue happened after OP Ecotone upgrade, same day as Dencun. Proper fix was in since 3.26.0.

For the minor import issue in #518 (comment), will find a time to fix.

from smart-order-router.

pedroyan avatar pedroyan commented on August 13, 2024

Let me know if we can provide any more information that can be useful in the investigation here!

from smart-order-router.

 avatar commented on August 13, 2024

I'm getting the same symptom. Using version @uniswap/[email protected] in a browser. (tried to upgrade to latest but couldn't get it to work in the browser, but that's a different issue)

The point of failure for me is in OptimismGasDataProvider.getGasData, where it's making making these calls:

'l1BaseFee', 'scalar', 'decimals', 'overhead'

The tx.results show failures for 'scalar' and 'overhead'

[
    {
        "success": true,
        "result": [
            {
                "type": "BigNumber",
                "hex": "0x05b619715f"
            }
        ]
    },
    {
        "success": false,
        "returnData": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002647617350726963654f7261636c653a207363616c6172282920697320646570726563617465640000000000000000000000000000000000000000000000000000"
    },
    {
        "success": true,
        "result": [
            {
                "type": "BigNumber",
                "hex": "0x06"
            }
        ]
    },
    {
        "success": false,
        "returnData": "0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002847617350726963654f7261636c653a206f7665726865616428292069732064657072656361746564000000000000000000000000000000000000000000000000"
    }
]

from smart-order-router.

nirtusbro avatar nirtusbro commented on August 13, 2024

I'm seeing this same thing, is there a way around this?

from smart-order-router.

julien51 avatar julien51 commented on August 13, 2024

Confirmed for us as well!

from smart-order-router.

ccarfi avatar ccarfi commented on August 13, 2024

also confirming seeing this too

from smart-order-router.

nirtusbro avatar nirtusbro commented on August 13, 2024

I solved this by using the v2 version of swap router: 0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45
Found here: https://docs.uniswap.org/contracts/v3/reference/deployments under SwapRouter02

from smart-order-router.

stephancill avatar stephancill commented on August 13, 2024

i believe the error is related to the deprecation of L1 calldata fees and transition to blob fees. the data returned by the errors decoded are revert messages: "GasPriceOracle: scalar() is deprecated" and "GasPriceOracle: overhead() is deprecated"

i'm not sure what the equivalent of overhead is in blobspace, but the patch below fixes the issue. it replaces the L1 fee variables with blob equivalents where available (everything except overhead) and updates the gas oracle ABI with the one from the latest deployment https://optimistic.etherscan.io/address/0xb528d11cc114e026f138fe568744c6d45ce6da7a#code

diff --git a/node_modules/@uniswap/smart-order-router/build/module/providers/v3/gas-data-provider.js b/node_modules/@uniswap/smart-order-router/build/module/providers/v3/gas-data-provider.js
index 700e514..939c775 100644
--- a/node_modules/@uniswap/smart-order-router/build/module/providers/v3/gas-data-provider.js
+++ b/node_modules/@uniswap/smart-order-router/build/module/providers/v3/gas-data-provider.js
@@ -2,6 +2,7 @@ import { ChainId } from '@uniswap/sdk-core';
 import { GasDataArbitrum__factory } from '../../types/other/factories/GasDataArbitrum__factory';
 import { GasPriceOracle__factory } from '../../types/other/factories/GasPriceOracle__factory';
 import { ARB_GASINFO_ADDRESS, log, OVM_GASPRICE_ADDRESS } from '../../util';
+import { BigNumber } from 'ethers';
 export class OptimismGasDataProvider {
     constructor(chainId, multicall2Provider, gasPriceAddress) {
         this.chainId = chainId;
@@ -18,23 +19,25 @@ export class OptimismGasDataProvider {
      */
     async getGasData() {
         var _a, _b, _c, _d;
-        const funcNames = ['l1BaseFee', 'scalar', 'decimals', 'overhead'];
+        const funcNames = ['blobBaseFee', 'blobBaseFeeScalar', 'decimals', 'overhead'];
         const tx = await this.multicall2Provider.callMultipleFunctionsOnSameContract({
             address: this.gasOracleAddress,
             contractInterface: GasPriceOracle__factory.createInterface(),
             functionNames: funcNames,
         });
+
         if (!((_a = tx.results[0]) === null || _a === void 0 ? void 0 : _a.success) ||
             !((_b = tx.results[1]) === null || _b === void 0 ? void 0 : _b.success) ||
-            !((_c = tx.results[2]) === null || _c === void 0 ? void 0 : _c.success) ||
-            !((_d = tx.results[3]) === null || _d === void 0 ? void 0 : _d.success)) {
+            !((_c = tx.results[2]) === null || _c === void 0 ? void 0 : _c.success) 
+            // || !((_d = tx.results[3]) === null || _d === void 0 ? void 0 : _d.success)
+            ) {
             log.info({ results: tx.results }, 'Failed to get gas constants data from the optimism gas oracle');
             throw new Error('Failed to get gas constants data from the optimism gas oracle');
         }
         const { result: l1BaseFee } = tx.results[0];
         const { result: scalar } = tx.results[1];
         const { result: decimals } = tx.results[2];
-        const { result: overhead } = tx.results[3];
+        const { result: overhead } = tx.results[3].success ? tx.results[3] : {result: [BigNumber.from(0)]};
         return {
             l1BaseFee: l1BaseFee[0],
             scalar: scalar[0],
diff --git a/node_modules/@uniswap/smart-order-router/build/module/types/other/factories/GasPriceOracle__factory.js b/node_modules/@uniswap/smart-order-router/build/module/types/other/factories/GasPriceOracle__factory.js
index a893e46..c41f77e 100644
--- a/node_modules/@uniswap/smart-order-router/build/module/types/other/factories/GasPriceOracle__factory.js
+++ b/node_modules/@uniswap/smart-order-router/build/module/types/other/factories/GasPriceOracle__factory.js
@@ -4,302 +4,207 @@
 import { Contract, utils } from "ethers";
 const _abi = [
     {
-        inputs: [
-            {
-                internalType: "address",
-                name: "_owner",
-                type: "address",
-            },
-        ],
-        stateMutability: "nonpayable",
-        type: "constructor",
-    },
-    {
-        anonymous: false,
-        inputs: [
-            {
-                indexed: false,
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        name: "DecimalsUpdated",
-        type: "event",
-    },
-    {
-        anonymous: false,
-        inputs: [
-            {
-                indexed: false,
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        name: "GasPriceUpdated",
-        type: "event",
-    },
-    {
-        anonymous: false,
-        inputs: [
-            {
-                indexed: false,
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        name: "L1BaseFeeUpdated",
-        type: "event",
-    },
-    {
-        anonymous: false,
-        inputs: [
-            {
-                indexed: false,
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        name: "OverheadUpdated",
-        type: "event",
-    },
-    {
-        anonymous: false,
-        inputs: [
-            {
-                indexed: true,
-                internalType: "address",
-                name: "previousOwner",
-                type: "address",
-            },
-            {
-                indexed: true,
-                internalType: "address",
-                name: "newOwner",
-                type: "address",
-            },
-        ],
-        name: "OwnershipTransferred",
-        type: "event",
-    },
-    {
-        anonymous: false,
-        inputs: [
-            {
-                indexed: false,
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        name: "ScalarUpdated",
-        type: "event",
-    },
-    {
-        inputs: [],
-        name: "decimals",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [],
-        name: "gasPrice",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "bytes",
-                name: "_data",
-                type: "bytes",
-            },
-        ],
-        name: "getL1Fee",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "bytes",
-                name: "_data",
-                type: "bytes",
-            },
-        ],
-        name: "getL1GasUsed",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [],
-        name: "l1BaseFee",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [],
-        name: "overhead",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [],
-        name: "owner",
-        outputs: [
-            {
-                internalType: "address",
-                name: "",
-                type: "address",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [],
-        name: "renounceOwnership",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-    {
-        inputs: [],
-        name: "scalar",
-        outputs: [
-            {
-                internalType: "uint256",
-                name: "",
-                type: "uint256",
-            },
-        ],
-        stateMutability: "view",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "uint256",
-                name: "_decimals",
-                type: "uint256",
-            },
-        ],
-        name: "setDecimals",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "uint256",
-                name: "_gasPrice",
-                type: "uint256",
-            },
-        ],
-        name: "setGasPrice",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "uint256",
-                name: "_baseFee",
-                type: "uint256",
-            },
-        ],
-        name: "setL1BaseFee",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "uint256",
-                name: "_overhead",
-                type: "uint256",
-            },
-        ],
-        name: "setOverhead",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "uint256",
-                name: "_scalar",
-                type: "uint256",
-            },
-        ],
-        name: "setScalar",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-    {
-        inputs: [
-            {
-                internalType: "address",
-                name: "newOwner",
-                type: "address",
-            },
-        ],
-        name: "transferOwnership",
-        outputs: [],
-        stateMutability: "nonpayable",
-        type: "function",
-    },
-];
+        "inputs": [],
+        "name": "DECIMALS",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "baseFee",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "baseFeeScalar",
+        "outputs": [
+        {
+            "internalType": "uint32",
+            "name": "",
+            "type": "uint32"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "blobBaseFee",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "blobBaseFeeScalar",
+        "outputs": [
+        {
+            "internalType": "uint32",
+            "name": "",
+            "type": "uint32"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "decimals",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "pure",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "gasPrice",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+        {
+            "internalType": "bytes",
+            "name": "_data",
+            "type": "bytes"
+        }
+        ],
+        "name": "getL1Fee",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [
+        {
+            "internalType": "bytes",
+            "name": "_data",
+            "type": "bytes"
+        }
+        ],
+        "name": "getL1GasUsed",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "isEcotone",
+        "outputs": [
+        {
+            "internalType": "bool",
+            "name": "",
+            "type": "bool"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "l1BaseFee",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "overhead",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "scalar",
+        "outputs": [
+        {
+            "internalType": "uint256",
+            "name": "",
+            "type": "uint256"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "setEcotone",
+        "outputs": [],
+        "stateMutability": "nonpayable",
+        "type": "function"
+    },
+    {
+        "inputs": [],
+        "name": "version",
+        "outputs": [
+        {
+            "internalType": "string",
+            "name": "",
+            "type": "string"
+        }
+        ],
+        "stateMutability": "view",
+        "type": "function"
+    }
+    ];
 export class GasPriceOracle__factory {
     static createInterface() {
         return new utils.Interface(_abi);

from smart-order-router.

Aiden0801 avatar Aiden0801 commented on August 13, 2024

Same here. Can anyone please help me?

from smart-order-router.

pietro-bertarini avatar pietro-bertarini commented on August 13, 2024

I was facing the same problem and it was resolved after I update to 3.26.1!!
Screenshot 2024-04-02 at 18 02 47

from smart-order-router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.