Adapter

Boba Network Transaction Fees

Boba is an Optimistic Rollup scaling solution that claims to reduce gas fees, improve transaction throughput, and extend the capabilities of smart contracts.

Sub-Adapters 1

Preview and test each sub adapter.

Boba Network (bobanetwork)

Metadata

ID
bobanetwork
icon
category

"l2"

name

"Boba Network"

description

"Boba is an Optimistic Rollup scaling solution that claims to reduce gas fees, improve transaction throughput, and extend the capabilities of smart contracts."

l2BeatSlug

"bobanetwork"

website

"https://boba.network"

flags

{ "throtle": "Boba is throttled while in beta. Fees will decrease as this throttle is lifted." }

Queries

Adapter Code

Check the entire code written for the Adapter.

Source code

Showing TS source.
1/*
2Total transaction fee is a combination of an "L2 execution fee" and an "L1 security fee":
3
4total_fee = (l2_gas_price * l2_gas_used) + (l1_gas_price * l1_gas_used)
5
6Where:
7- `l2_gas_price` corresponds to the cost of execution on L2
8- `l2_gas_used` corresponds to the amount of gas used on L2
9- `l1_gas_price` corresponds to the cost of publishing the transaction data on L1
10- `l1_gas_used` corresponds to the amount of transaction data published on L1
11*/
12
13export const name = 'Boba Network Transaction Fees';
14export const version = '1.0.2';
15export const license = 'MIT';
16
17export function setup(sdk: Context) {
18  // add Boba Network
19  sdk.ethers.addProvider('boba', 'https://mainnet.boba.network');
20  const provider = sdk.ethers.getProvider('boba');
21
22  const GAS_HARD_FORK_BLOCK_NUMBER = 400000;
23  const GAS_ORACLE_ADDRESS = '0x420000000000000000000000000000000000000F';
24  const GAS_ORACLE_ABI = [
25    {
26      inputs: [
27        {
28          internalType: 'bytes',
29          name: '_data',
30          type: 'bytes',
31        },
32      ],
33      name: 'getL1Fee',
34      outputs: [
35        {
36          internalType: 'uint256',
37          name: '',
38          type: 'uint256',
39        },
40      ],
41      stateMutability: 'view',
42      type: 'function',
43    },
44  ];
45
46  // get gas oracle contract
47  const gasOracleContract = sdk.ethers.getContract(GAS_ORACLE_ADDRESS, GAS_ORACLE_ABI, 'boba');
48
49  const getTransferEthCost = async () => {
50    const blockNumber = await provider.getBlockNumber();
51    const l2GasPrice = await provider.getGasPrice();
52    const l2GasEstimate = await provider.estimateGas({
53      from: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
54      to: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
55      value: '0x38d7ea4c68000',
56    });
57    let totalGasCostWei = l2GasPrice.mul(l2GasEstimate).toNumber();
58    if (blockNumber < GAS_HARD_FORK_BLOCK_NUMBER) {
59      const l1GasCost = await gasOracleContract.getL1Fee(
60        sdk.ethers.utils.serializeTransaction({
61          value: '0x38d7ea4c68000', // 0.001 ETH
62          to: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
63          data: '0x',
64        })
65      )
66      totalGasCostWei = sdk.ethers.BigNumber.from(totalGasCostWei).add(l1GasCost).toNumber();
67    }
68    const ethPrice = await sdk.coinGecko.getCurrentPrice('ethereum');
69    return (totalGasCostWei * ethPrice) / 1e18;
70  };
71
72  const getTransferTokenCost = async () => {
73    const blockNumber = await provider.getBlockNumber();
74    const l2GasPrice = await provider.getGasPrice();
75    const l2GasEstimate = await provider.estimateGas({
76      from: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
77      to: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
78      data:
79        '0xa9059cbb0000000000000000000000005e7a06025892d8eef0b5fa263fa0d4d2e5c3b54900000000000000000000000000000000000000000000000000038d7ea4c68000',
80    });
81    let totalGasCostWei = l2GasPrice.mul(l2GasEstimate).toNumber();
82    if (blockNumber < GAS_HARD_FORK_BLOCK_NUMBER) {
83      const l1GasCost = await gasOracleContract.getL1Fee(
84        sdk.ethers.utils.serializeTransaction({
85          to: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
86          data:
87            '0xa9059cbb0000000000000000000000005e7a06025892d8eef0b5fa263fa0d4d2e5c3b54900000000000000000000000000000000000000000000000000038d7ea4c68000',
88        })
89      )
90      totalGasCostWei = sdk.ethers.BigNumber.from(totalGasCostWei).add(l1GasCost).toNumber();
91    }
92    const ethPrice = await sdk.coinGecko.getCurrentPrice('ethereum');
93    return (totalGasCostWei * ethPrice) / 1e18;
94  };
95
96  const getSwapCost = async () => {
97    const blockNumber = await provider.getBlockNumber();
98    const l2GasPrice = await provider.getGasPrice();
99    const l2GasEstimate = await provider.estimateGas({
100      from: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
101      to: '0x17C83E2B96ACfb5190d63F5E46d93c107eC0b514',
102      value: '0x38d7ea4c68000',
103      data:
104        '0x7ff36ab5000000000000000000000000000000000000000000000000132cc41aecbfbace00000000000000000000000000000000000000000000000000000000000000800000000000000000000000005e7a06025892d8eef0b5fa263fa0d4d2e5c3b54900000000000000000000000000000000000000000000000000000001c73d14500000000000000000000000000000000000000000000000000000000000000002000000000000000000000000deaddeaddeaddeaddeaddeaddeaddeaddead00000000000000000000000000005008f837883ea9a07271a1b5eb0658404f5a9610',
105    });
106    let totalGasCostWei = l2GasPrice.mul(l2GasEstimate).toNumber();
107    if (blockNumber < GAS_HARD_FORK_BLOCK_NUMBER) {
108      const l1GasCost = await gasOracleContract.getL1Fee(
109        sdk.ethers.utils.serializeTransaction({
110          to: '0x17C83E2B96ACfb5190d63F5E46d93c107eC0b514',
111          value: '0x38d7ea4c68000',
112          data:
113            '0x7ff36ab5000000000000000000000000000000000000000000000000132cc41aecbfbace00000000000000000000000000000000000000000000000000000000000000800000000000000000000000005e7a06025892d8eef0b5fa263fa0d4d2e5c3b54900000000000000000000000000000000000000000000000000000001c73d14500000000000000000000000000000000000000000000000000000000000000002000000000000000000000000deaddeaddeaddeaddeaddeaddeaddeaddead00000000000000000000000000005008f837883ea9a07271a1b5eb0658404f5a9610',
114        })
115      )
116      totalGasCostWei = sdk.ethers.BigNumber.from(totalGasCostWei).add(l1GasCost).toNumber();
117    }
118    const ethPrice = await sdk.coinGecko.getCurrentPrice('ethereum');
119    return (totalGasCostWei * ethPrice) / 1e18;
120  };
121
122   sdk.register({
123     id: 'bobanetwork',
124     queries: {
125       feeTransferEth: getTransferEthCost,
126       feeTransferERC20: getTransferTokenCost,
127       feeSwap: getSwapCost,
128     },
129     metadata: {
130       icon: sdk.ipfs.getDataURILoader(
131         'QmTxXwaBgJdtZdKTfarQAzsxrBBeWioAfzqWHgpoC7eU7b',
132         'image/png'
133       ),
134       category: 'l2',
135       name: 'Boba Network',
136       description:
137         'Boba is an Optimistic Rollup scaling solution that claims to reduce gas fees, improve transaction throughput, and extend the capabilities of smart contracts.',
138       l2BeatSlug: 'bobanetwork',
139       website: 'https://boba.network',
140       flags: {
141         throtle: 'Boba is throttled while in beta. Fees will decrease as this throttle is lifted.',
142       },
143     },
144   });
145}
146

It's something off?

Report it to the discussion board on Discord, we will take care of it.

Adapter Info

Version

1.0.2

License

MIT

IPFS CID

QmT4chc2YLBGPqoGPespsU6L516qHbzvJCCuVzsQ9azjZP

CID (source)

QmckR9rSH6pDvRPbMB5ubLHbqeQi729BF4XJSZqfwUB97S

Collections

l2-fees

Author

0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549