-
Notifications
You must be signed in to change notification settings - Fork 251
DEVREL-911 DEVREL-522 🗞️ Add composer swap examples #1097
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
base: main
Are you sure you want to change the base?
Conversation
2535700 to
953ec98
Compare
|
Although this is super cool, there is a lot of custom solidity code. I would recommend this is audited before adding it as an example. Maybe we can combine it with other examples work to save some cycles. |
Yep, the idea would be to get this audited with any other composer examples we want. Riley mentioned staking, but this really only applies to native assets so Uniswap is the only example we have at the moment. Do you have any ideas for improving? |
7c1f013 to
3547459
Compare
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
e4b8bb1 to
82daf5f
Compare
27fb608 to
644ab76
Compare
52b0d5c to
fa18222
Compare
shankars99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few things that caught my eye
|
is this ready to merge if the merge conflict is resolved? |
7d3fc26 to
4c2f7ea
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
examples/oft-composers/contracts/AaveV3Composer/AaveV3Composer.sol
Outdated
Show resolved
Hide resolved
examples/oft-composers/contracts/AaveV3Composer/AaveV3Composer.sol
Outdated
Show resolved
Hide resolved
| { | ||
| id: 'oft-composer-library', | ||
| label: 'OFT Composer Library', | ||
| repository, | ||
| directory: 'examples/oft-composer-library', | ||
| ref, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to change the name from OFT Composer Library to composer examples, we'll need to change this label and directory reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed.
In my previous commit i added the correct oft-composers example to this config file, forgot to delete the old version, thanks.
| ], | ||
| }, | ||
| networks: { | ||
| 'arbitrum-mainnet': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lzJxhn does this example only work on mainnet? why do we have mainnet here ? typically for examples, we just use testnet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed.
i tested on both testnet (e.g. arbsep -> sep) and mainnet (e.g. arb -> base), must have pushed mainnet version in recent commits.
| } | ||
|
|
||
| const fujiContract: OmniPointHardhat = { | ||
| eid: EndpointId.AVALANCHE_V2_TESTNET, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lzJxhn bumping this up
| } | ||
|
|
||
| const config: OAppOmniGraphHardhat = { | ||
| contracts: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, hardhat config lists base and ethereum, but LZ config here uses a different combination of networks
I would suggest to standardise based on /docs/EXAMPLES_SPECS.md (check on main)
- Two chains only: Examples should use only 2 chains by default to reduce testnet setup friction; use “Add other chains” section to scale up if needed. For EVM, prefer using the following in the following order: Arbitrum Sepolia (
EndpointId.ARBSEP_V2_TESTNET), Base Sepolia (EndpointId.BASESEP_V2_TESTNET).
- in
hardhat.config.ts, the network names should be likearbitrum-sepoliaandbase-sepolia(and NOTarbitrum-testnetorbase-testnet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed.
| * 3. Saves ~5k gas on every compose execution. | ||
| * | ||
| * @param _aavePool Address of the target Aave V3 pool. | ||
| * @param _stargatePool StargatePool expected to receive the supplied tokens. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _param _stargatePool should be renamed to be something closer to _stargateOFT or just _oftIn or something similar.
While it's true this example uses Stargate, you can supply WETH or other asset pools related to Aave.
For example, Stargate on Scroll uses Hydra OFTs, not pools. All pools are IOFT, but not all IOFTs are pools.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed.
examples/oft-composers/README.md
Outdated
| <a href="https://layerzero.network" style="color: #a77dff">Homepage</a> | <a href="https://docs.layerzero.network/" style="color: #a77dff">Docs</a> | <a href="https://layerzero.network/developers" style="color: #a77dff">Developers</a> | ||
| </p> | ||
|
|
||
| <h1 align="center">LayerZero OFT Composer Library</h1> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed.
In this PR:
Overview & Purpose:
The UniswapV3Composer is a specialized component in the LayerZero OFT (Omnichain Fungible Token) ecosystem. It facilitates cross-chain token swaps by interacting with Uniswap V3 upon receiving tokens via LayerZero’s messaging system. Essentially, when tokens are transferred cross-chain using the OFT standard, a composed message containing swap details is generated. The composer decodes this message and executes a token swap on the destination chain—converting the incoming OFT token into another ERC20 token as specified.
What the Composer Is & Why It Exists:
Interaction with the LayerZero OFT Contract Standard:
The LayerZero OFT standard provides a framework for seamless cross-chain token transfers. During such transfers, a message is generated that encapsulates both the transfer details and additional swap instructions. The UniswapV3Composer listens for these messages from an authorized LayerZero Endpoint. Once a message is received, the contract:
Code Improvements:
requirestatements with custom errors (InvalidSwapRouter,InvalidEndpoint,InvalidOFT,UnauthorizedOFT, andUnauthorizedEndpoint) to enhance gas efficiency and clarity.UniswapV3Composer.UnauthorizedOFT.selector) instead of revert strings.Limitations:
lzComposewill revert, as the swap cannot be executed without a proper liquidity pool. Users must ensure that the necessary pool is available on the destination chain before initiating a cross-chain token swap.Overall, this PR enhances the security, efficiency, and readability of the composer implementation, ensuring seamless cross-chain token swaps that integrate with the LayerZero OFT standard and Uniswap V3—while also requiring the existence of a valid liquidity pool on the destination chain.