Closed ChiTimesChi closed 1 week ago
[!CAUTION]
Review failed
The pull request is closed.
The changes introduce several new Solidity files, including a library (ZapDataV1
) for encoding and validating tightly packed data structures, a contract (TokenZapV1
) for executing "Zap" actions with ERC20 tokens, and various testing contracts. The tests validate the functionality of these components, ensuring correct encoding, decoding, and error handling. Additionally, mock contracts are created for testing purposes, enhancing the overall test coverage of the new features.
File Path | Change Summary |
---|---|
packages/contracts-rfq/contracts/libs/ZapDataV1.sol |
Added library ZapDataV1 with functions for validation, encoding, and extracting data from tightly packed structures. Introduced custom errors for improved error handling. |
packages/contracts-rfq/contracts/zaps/TokenZapV1.sol |
Introduced contract TokenZapV1 implementing IZapRecipient , enabling Zap actions with ERC20 tokens. Added methods for zapping, encoding, and decoding Zap data. |
packages/contracts-rfq/test/harnesses/ZapDataV1Harness.sol |
Created ZapDataV1Harness for testing the ZapDataV1 library, with public functions to validate and encode zap data. |
packages/contracts-rfq/test/integration/FastBridgeV2.TokenZapV1.Dst.t.sol |
Added FastBridgeV2TokenZapV1DstTest for integration testing of FastBridge V2 functionality, including event logging and various test functions for bridge transactions. |
packages/contracts-rfq/test/integration/FastBridgeV2.TokenZapV1.Src.t.sol |
Introduced FastBridgeV2TokenZapV1SrcTest for integration testing of the FastBridge V2 functionality, focusing on bridge requests and event assertions. |
packages/contracts-rfq/test/integration/TokenZapV1.t.sol |
Added abstract contract TokenZapV1IntegrationTest for testing TokenZapV1 , including setup and utility functions for managing bridge parameters and token interactions. |
packages/contracts-rfq/test/libs/ZapDataV1.t.sol |
Created ZapDataV1Test for testing the ZapDataV1 library, validating encoding and decoding processes, and handling various error scenarios. |
packages/contracts-rfq/test/mocks/VaultManyArguments.sol |
Introduced VaultManyArguments mock contract for testing, including deposit functions and error handling. |
packages/contracts-rfq/test/mocks/VaultMock.sol |
Added abstract contract VaultMock for testing, managing user balances and deposit functionalities with error handling. |
packages/contracts-rfq/test/zaps/TokenZapV1.t.sol |
Created TokenZapV1Test contract for comprehensive testing of the TokenZapV1 functionality, covering various scenarios and edge cases for token deposits and zap operations. |
TokenZapV1
contract introduces functionality for encoding and validating tightly packed data structures, which aligns with the ZapDataV1
library's purpose in the main PR.FastBridgeV2
contract regarding the handling of bridge transactions and the introduction of new parameters for zap functionality relate to the encoding and validation processes in the ZapDataV1
library.FastBridgeV2
enhances the contract's functionality, which may interact with the zap operations defined in the TokenZapV1
contract.FastBridgeV2
contract to emit events before external calls is relevant to the zap functionality, ensuring that the contract's behavior is clear and reliable during zap operations.AdminV2
contract and its associated functionalities may impact how zap operations are managed within the broader RFQ framework.In a world of bytes and zaps,
A rabbit hops with joyful claps.
Encoding data, tight and neat,
With every function, a tasty treat!
So let us cheer, with hops and bounds,
For smart contracts and joyful sounds! 🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 42.32681%. Comparing base (
79a40b5
) to head (678dcb5
). Report is 1 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
🚨 Try these New Features:
Latest commit: |
678dcb5
|
Status: | ✅ Deploy successful! |
Preview URL: | https://491cf1c4.sanguine-fe.pages.dev |
Branch Preview URL: | https://feat-token-zap.sanguine-fe.pages.dev |
@coderabbitai review
Description
Minimal implementation of a contract that facilitates the generic Zap action for ERC20 tokens or native gas tokens (ETH/BNB/AVAX/others).
This enables atomic workflows like:
FastBridgeV2
.A single permisionless
TokenZap
contract could be used for any DeFi protocol and any FastBridge (V2+) deployment, assuming:Full Workflow
Let's suppose Alice wants to deposit USDC into a Vault contract on Arbitrum. Alice has 100 USDC to start with on Optimism. The Arbitrum Vault exposes a following function to make the deposits:
depositFunds(address token, uint256 amount, address onBehalfOf)
. Following steps need to be done (abstracted away from the Alice by the FE):payload = abi.encodeCall(vault.depositFunds, (arbUSDC, 0, alice))
amount
withinpayload
:amountPosition = 4 + 32 * 1 = 36
TokenZap
exposes an off-chain getter:zapData = tokenZap.encodeZapData(arbVault, payload, amountPosition)
zapNative = 0
- this should be changed only when a Zap with ERC20 requires an additional native payment (e.g. token bridged via native bridge)dest_amount
from step (5).Summary by CodeRabbit
Summary by CodeRabbit
New Features
ZapDataV1
library for efficient data management and validation.TokenZapV1
contract enabling token "Zap" actions with secure transfers.FastBridgeV2
functionality related to token bridging.VaultManyArguments
mock contract for enhanced testing scenarios.Bug Fixes
TokenZapV1
for incorrect amounts and payload lengths.Tests
TokenZapV1
andZapDataV1
ensuring functionality and error handling.