Skip to content

Commit

Permalink
chore(wallet)_: use proxy instead of OVM_GasPriceOracle contract for …
Browse files Browse the repository at this point in the history
…estimating l1 fee

- A new contract is used for estimating L1 fee.
- New contract's addresses are known only for Optimims and Sepolia Optimimsm.
- Old contract and addresses per chain are kept so far, but not in use anymore.

Comparing to other wallets, seems L1 fee is added to the total fee only for the Optimims chain.
So we're doing the same in this commit, disabling L1 fees for other than the Optimism.
  • Loading branch information
saledjenic committed Jan 31, 2025
1 parent 9957dd3 commit c4dca62
Show file tree
Hide file tree
Showing 7 changed files with 1,654 additions and 10 deletions.
3 changes: 3 additions & 0 deletions contracts/gas-price-oracle/address.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

var ErrorNotAvailableOnChainID = errors.New("not available for chainID")

// Addresses of the gas price oracle contract `OVM_GasPriceOracle` on different chains.
var contractAddressByChainID = map[uint64]common.Address{
wallet_common.OptimismMainnet: common.HexToAddress("0x8527c030424728cF93E72bDbf7663281A44Eeb22"),
wallet_common.OptimismSepolia: common.HexToAddress("0x5230210c2b4995FD5084b0F5FD0D7457aebb5010"),
Expand All @@ -19,6 +20,8 @@ var contractAddressByChainID = map[uint64]common.Address{
wallet_common.BaseSepolia: common.HexToAddress("0x5230210c2b4995FD5084b0F5FD0D7457aebb5010"),
}

// We stopped uisng `OVM_GasPriceOracle` contract, cause it returns significantly higher gas prices than the actual ones.
// But we don't remove this code for now.
func ContractAddress(chainID uint64) (common.Address, error) {
addr, exists := contractAddressByChainID[chainID]
if !exists {
Expand Down
25 changes: 25 additions & 0 deletions contracts/gas-price-proxy/address.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package gaspriceproxy

import (
"errors"

"github.com/ethereum/go-ethereum/common"

wallet_common "github.com/status-im/status-go/services/wallet/common"
)

var ErrorNotAvailableOnChainID = errors.New("not available for chainID")

// Addresses of the proxy contract `Proxy` on different chains.
var contractAddressByChainID = map[uint64]common.Address{
wallet_common.OptimismMainnet: common.HexToAddress("0x420000000000000000000000000000000000000F"),
wallet_common.OptimismSepolia: common.HexToAddress("0x420000000000000000000000000000000000000F"),
}

func ContractAddress(chainID uint64) (common.Address, error) {
addr, exists := contractAddressByChainID[chainID]
if !exists {
return common.Address{}, ErrorNotAvailableOnChainID
}
return addr, nil
}
3 changes: 3 additions & 0 deletions contracts/gas-price-proxy/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package gaspriceproxy

//go:generate abigen -abi gaspriceproxy.abi -pkg gaspriceproxy -out gaspriceproxy.go
316 changes: 316 additions & 0 deletions contracts/gas-price-proxy/gaspriceproxy.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
[
{
"inputs": [],
"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": false,
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "ScalarUpdated",
"type": "event"
},
{
"inputs": [],
"name": "admin",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "target",
"type": "address"
},
{
"internalType": "bytes",
"name": "data",
"type": "bytes"
}
],
"name": "adminCall",
"outputs": [],
"stateMutability": "payable",
"type": "function"
},
{
"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": [],
"name": "getAdmin",
"outputs": [
{
"internalType": "address",
"name": "adminAddress",
"type": "address"
}
],
"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": [
{
"internalType": "bytes",
"name": "initPayload",
"type": "bytes"
}
],
"name": "init",
"outputs": [
{
"internalType": "bytes4",
"name": "",
"type": "bytes4"
}
],
"stateMutability": "nonpayable",
"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": [
{
"internalType": "address",
"name": "adminAddress",
"type": "address"
}
],
"name": "setAdmin",
"outputs": [],
"stateMutability": "nonpayable",
"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"
}
]
Loading

0 comments on commit c4dca62

Please sign in to comment.