Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth carried with the deposit erc20 token #465

Open
liaoyinglong opened this issue Apr 25, 2024 · 4 comments
Open

eth carried with the deposit erc20 token #465

liaoyinglong opened this issue Apr 25, 2024 · 4 comments

Comments

@liaoyinglong
Copy link

First of all, this is an awesome library!

I have a question about when I call Erc20Bridger.deposit I can control the amount of ETH to send?
if not, how can I know I will send the ETH amount in L1 and will receive the ETH amount in L2 before do deposit action?

the code like:

const bridger = new Erc20Bridger(l2Network)
// I want to know how much is  will send ETH amount in L1 and will receive the ETH amount in L2

const ethDepositTxResponse = await bridger.deposit({
  amount: utils.parseEther('10'),
  l1Signer: l1Signer /** <-- connected ethers-js Wallet */,
  l2Provider: l2Provider /** <--- ethers-js Provider */,
})

Thank of all!

@spsjvc
Copy link
Member

spsjvc commented Apr 25, 2024

For depositing ETH, you should use EthBridger. Erc20Bridger is used for depositing ERC-20 tokens.

@liaoyinglong
Copy link
Author

yes, I mean when I deposit ERC20 token that will send some ETH to bridge in this line

value: estimates.value,

and can I know how much eth amount will be sent to my L2 address ?

@spsjvc
Copy link
Member

spsjvc commented Apr 25, 2024

The ETH sent is there to cover for the retryable execution fees and it's necessary for your ERC-20 deposit to succeed.

You can calculate this amount upfront by using the L1ToL2MessageGasEstimator. You can see here how the Erc20Bridger uses it: https://github.com/OffchainLabs/arbitrum-sdk/blob/main/src/lib/assetBridger/erc20Bridger.ts#L686

@liaoyinglong
Copy link
Author

thank you!
The amount is send to bridge's ETH amount, can i get the amount of will received in L2 address?

example:

  • when i deposit ERC20 token to L2
  • send to bridge's ETH is 0.00004740420016352 ETH in L1
  • and I received ETH is 0.0000395035 Ether in L2 from the Smart Contract

I'd like to know if it's possible to calculate this value 0.0000395035 Ether before making a deposit.

SCR-20240426-orqc SCR-20240426-osym

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants