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

Layerzero OFT #2

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open

Layerzero OFT #2

wants to merge 3 commits into from

Conversation

andreanistico
Copy link
Contributor

https://horizenlabs.atlassian.net/browse/HZN-2116

Chain is: APECHAIN CURTIS TESTNET
Other chain is: ARBITRUM SEPOLIA TESTNET

─$ npx hardhat run ./scripts/deploy-multichain.ts --network curtis

Deploying Chain Token (ZenNativeOFT)
Chain token address: 0x742ae08ab454b3022C6E5f90c53073c2B8741feB
Deploying Other Chain Token (OtherSideOFT)
Other Chain token address: 0x916352E3b55D517bB9Dd74F7734761E9292eAC6c
Linking on chain token
waiting for tx: 0x3ff29674cc17e26a6181acdf3271ca4ea2db9daf9c9db075602cee2aee42f643
Other chain token set as remote on chain token.
linking on other chain token
waiting for tx: 0x0d27a531a60110b597cf8b651682829748fb67442120440ed7484f93b8f6d8b8
Chain token set as remote on other chain token.

─$ npx hardhat run ./scripts/demo-transfer.ts --network curtis

retrieving balances
native balance on chain: 999922978598523749
token balance on other chain: 0
transfer amount: 10
quote returned [{"type":"BigNumber","hex":"0x027e1bce8beb218c"},{"type":"BigNumber","hex":"0x00"}]
waiting for tx: 0x12fbc4898944d7e675cfc2128503507f8e59b5e71fc8cd7e82f7eeebbd9f8728
retrieving balances
native balance on chain: 820309097361365793
token balance on other chain: 0			

tx on layer zero scan
https://testnet.layerzeroscan.com/address/0x742ae08ab454b3022c6e5f90c53073c2b8741feb

@andreanistico
Copy link
Contributor Author

andreanistico commented Dec 3, 2024

SendParam calldata _sendParam,
MessagingFee calldata _fee,
address _refundAddress
) external payable virtual override returns (MessagingReceipt memory msgReceipt, OFTReceipt memory oftReceipt) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just curious why we are overriding some of these functions if they are inherited from LayerZero's OFT contract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it's because we invoke the custom _lzSendWithAmount instead of _lsZend
I can't simply override the _lzSend`` because I had to add the parameter amount, that it was not explicitely inserted before. Same for _payNative, the original one doesn't check that msg.value` is amount + fee because the original isn't developed for auto-wrapping native tokens.

Similar for _credit, it is overriden since it has to send native token instead of minting erc20 token

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. just curious why we need to pass the amount explicitly and not use msg.sender?

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

Successfully merging this pull request may close these issues.

2 participants