Adapter

Arbitrum Transaction Fees

Arbitrum is an Optimistic Rollup that aims to feel exactly like interacting with Ethereum, but with transactions costing a fraction of what they do on L1.

Sub-Adapters 1

Preview and test each sub adapter.

Arbitrum One (arbitrum-one)

Metadata

ID
arbitrum-one
icon
category

"l2"

name

"Arbitrum One"

description

"Arbitrum is an Optimistic Rollup that aims to feel exactly like interacting with Ethereum, but with transactions costing a fraction of what they do on L1."

l2BeatSlug

"arbitrum"

website

"https://offchainlabs.com"

flags

{ "throtle": "Arbitrum One 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.
1export const name = 'Arbitrum Transaction Fees';
2export const version = '0.1.2';
3export const license = 'MIT';
4
5const ARB_GAS_PRECOMPILE = '0x000000000000000000000000000000000000006C';
6
7const ARB_GAS_ABI = [
8  'function getPricesInWei() external view returns (uint256,uint256,uint256,uint256,uint256,uint256)',
9];
10
11const ONE_ADDR = '0x0000000000000000000000000000000000000001';
12const BEEF_ADDR = '0xbeefbeefbeefbeefbeefbeefbeefbeefbeefbeef';
13const USDT_ADDR = '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9';
14const SUSHI_USDT_POOL = '0xcb0e5bfa72bbb4d16ab5aa0c60601c438f04b4ad';
15type TxType = 'EthTransfer' | 'ERC20Transfer' | 'ERC20Swap';
16
17export function setup(sdk: Context) {
18  const getFeeResolverForCost = (gasAmt: number | Promise<number>) => async () => {
19    gasAmt = await gasAmt;
20
21    const gasPrecompileContract = sdk.ethers.getContract(
22      ARB_GAS_PRECOMPILE,
23      ARB_GAS_ABI,
24      'arbitrum-one'
25    );
26    const weiPerArbGas = (await gasPrecompileContract.getPricesInWei())[5];
27
28    const ethPrice = await sdk.coinGecko.getCurrentPrice('ethereum');
29
30    return (weiPerArbGas * gasAmt * ethPrice) / 1e18;
31  };
32
33  const getGasAmount = async (txType: TxType): Promise<number> => {
34    const provider = sdk.ethers.getProvider('arbitrum-one');
35
36    if(txType === 'EthTransfer') {
37      return provider.estimateGas({
38        from: ONE_ADDR,
39        to: BEEF_ADDR,
40        value: '0x1',
41        data: '0x'
42      });
43    } else if(txType === 'ERC20Transfer') {
44      // transfer (1 / 10e18) tokens from sushipool to sushipool
45      return provider.estimateGas({
46        from: SUSHI_USDT_POOL,
47        to: USDT_ADDR,
48        data: `0xa9059cbb000000000000000000000000${SUSHI_USDT_POOL.substr(2)}0000000000000000000000000000000000000000000000000000000000000001`
49      });
50    } else { // txType === 'ERC20Swap'
51      // TODO: estimate dynamically. this currently hardcodes gas used from USDC <> WETH swap on uniswap v3
52      // https://arbiscan.io/tx/0x2c71dac132022cbafc617d2a6ef8938ef1241ae3e8014403de3c45f20f8403b2
53      return 658767;
54    }
55  }
56
57  sdk.register({
58    id: 'arbitrum-one',
59    queries: {
60      feeTransferEth: getFeeResolverForCost(getGasAmount('EthTransfer')),
61      feeTransferERC20: getFeeResolverForCost(getGasAmount('ERC20Transfer')),
62      feeSwap: getFeeResolverForCost(getGasAmount('ERC20Swap')),
63    },
64    metadata: {
65      icon: sdk.ipfs.getDataURILoader(
66        'QmeRunQGxv3haLoMfgwD2VjKwScf7gDQiA1DCYd1HNBCG6',
67        'image/svg+xml'
68      ),
69      category: 'l2',
70      name: 'Arbitrum One',
71      description:
72        'Arbitrum is an Optimistic Rollup that aims to feel exactly like interacting with Ethereum, but with transactions costing a fraction of what they do on L1.',
73      l2BeatSlug: 'arbitrum',
74      website: 'https://offchainlabs.com',
75      flags: {
76        throtle:
77          'Arbitrum One is throttled while in beta. Fees will decrease as this throttle is lifted.',
78      },
79    },
80  });
81}
82

It's something off?

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

Adapter Info

Version

0.1.2

License

MIT

IPFS CID

QmUQpacvjJ8WH8ck1Za4m9NVgDtcznJDB2oeL3ZJbaBrho

CID (source)

QmWAUpEecJb8dT4xLj4neDu4NseG2ARPmjG1SSQs4B3Cut

Collections

l2-fees

Author

0xCf3C4c291CE0aD0Ef5f6De577Cd19D6D6ecF4DB6