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 = '2.1.0';
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 BOBA_GAS_ORACLE_ADDRESS = '0xeE06ee2F239d2ab11792D77f3C347d919ddA0d51';
23
24  const BOBA_GAS_ORACLE_ABI = new sdk.ethers.utils.Interface([
25    'function priceRatio() view returns (uint256)',
26  ])
27
28  // get boba gas oracle contract
29  const BobaGasOracleContract = sdk.ethers.getContract(BOBA_GAS_ORACLE_ADDRESS, BOBA_GAS_ORACLE_ABI, 'boba');
30
31  const getTransferEthCost = async () => {
32    const l2GasPrice = await provider.getGasPrice();
33    const priceRatio = await BobaGasOracleContract.priceRatio();
34    const l2GasEstimate = await provider.estimateGas({
35      from: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
36      to: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
37      value: '0x38d7ea4c68000',
38    });
39    const totalBOBAGasCostWei = l2GasPrice.mul(l2GasEstimate).mul(priceRatio);
40    const bobaPrice = await sdk.coinGecko.getCurrentPrice('boba-network');
41    return (totalBOBAGasCostWei * bobaPrice) / 1e18;
42  };
43
44  const getTransferTokenCost = async () => {
45    const l2GasPrice = await provider.getGasPrice();
46    const priceRatio = await BobaGasOracleContract.priceRatio();
47    const l2GasEstimate = await provider.estimateGas({
48      from: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
49      to: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
50      data:
51        '0xa9059cbb0000000000000000000000005e7a06025892d8eef0b5fa263fa0d4d2e5c3b54900000000000000000000000000000000000000000000000000038d7ea4c68000',
52      gasPrice: l2GasPrice.toNumber(),
53    });
54    const totalBOBAGasCostWei = l2GasPrice.mul(l2GasEstimate).mul(priceRatio);
55    const bobaPrice = await sdk.coinGecko.getCurrentPrice('boba-network');
56    return (totalBOBAGasCostWei * bobaPrice) / 1e18;
57  };
58
59  const getSwapCost = async () => {
60    const l2GasPrice = await provider.getGasPrice();
61    const priceRatio = await BobaGasOracleContract.priceRatio();
62    const l2GasEstimate = await provider.estimateGas({
63      from: '0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549',
64      to: '0x17C83E2B96ACfb5190d63F5E46d93c107eC0b514',
65      value: '0x38d7ea4c68000',
66      data:
67        '0x7ff36ab5000000000000000000000000000000000000000000000000132cc41aecbfbace00000000000000000000000000000000000000000000000000000000000000800000000000000000000000005e7a06025892d8eef0b5fa263fa0d4d2e5c3b54900000000000000000000000000000000000000000000000000000001c73d14500000000000000000000000000000000000000000000000000000000000000002000000000000000000000000deaddeaddeaddeaddeaddeaddeaddeaddead00000000000000000000000000005008f837883ea9a07271a1b5eb0658404f5a9610',
68      gasPrice: l2GasPrice.toNumber(),
69    });
70    const totalBOBAGasCostWei = l2GasPrice.mul(l2GasEstimate).mul(priceRatio);
71    const bobaPrice = await sdk.coinGecko.getCurrentPrice('boba-network');
72    return (totalBOBAGasCostWei * bobaPrice) / 1e18;
73  };
74
75   sdk.register({
76     id: 'bobanetwork',
77     queries: {
78       feeTransferEth: getTransferEthCost,
79       feeTransferERC20: getTransferTokenCost,
80       feeSwap: getSwapCost,
81     },
82     metadata: {
83       icon: sdk.ipfs.getDataURILoader(
84         'QmTxXwaBgJdtZdKTfarQAzsxrBBeWioAfzqWHgpoC7eU7b',
85         'image/png'
86       ),
87       category: 'l2',
88       name: 'Boba Network',
89       description:
90         'Boba is an Optimistic Rollup scaling solution that claims to reduce gas fees, improve transaction throughput, and extend the capabilities of smart contracts.',
91       l2BeatSlug: 'bobanetwork',
92       website: 'https://boba.network',
93       flags: {
94         throtle: 'Boba is throttled while in beta. Fees will decrease as this throttle is lifted.',
95       },
96     },
97   });
98}
99

It's something off?

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

Adapter Info

Version

2.1.0

License

MIT

IPFS CID

QmfYL8BGQxwZ2sUr6EQZsyxHzMq1kHzgyJNoRXBVWGmDFH

CID (source)

QmcSZuhNmsdVKMXWVu2Su2ZrTJtBTGj2CuST5tHF5nKjNZ

Collections

Author

0x5E7a06025892d8Eef0b5fa263fA0d4d2E5C3B549