Closed fadeev closed 3 months ago
@andresaiello please, review.
@andresaiello please, review.
The recent updates enhance token swapping functionality in the Swap
and SwapToAnyToken
smart contracts. Key changes include parameter updates for swapAndWithdraw
, new internal and public swap
functions, and a receive()
function to handle payable transactions. The new Hardhat task script swap.ts
facilitates token swaps by interacting with the Swap
contract on ZetaChain, validating parameters, and managing token approvals and transfers.
File | Change Summary |
---|---|
.../Swap.sol |
Updated swapAndWithdraw function to use targetToken parameter consistently and accept new parameters. |
.../SwapToAnyToken.sol |
Added error TransferFailed() declaration; receive() function; refactored onCrossChainCall ; introduced swap functions. |
.../tasks/swap.ts |
Introduced a task for interacting with the Swap contract: validates parameters, manages token approvals, and facilitates swaps. |
sequenceDiagram
participant User
participant Hardhat
participant SwapContract
participant SwapToAnyTokenContract
participant ERC20TokenContract
User->>Hardhat: Initiate swap task
Hardhat->>SwapContract: Validate parameters
Hardhat->>ERC20TokenContract: Approve tokens
ERC20TokenContract-->>Hardhat: Approval complete
Hardhat->>SwapContract: Execute swapAndWithdraw
SwapContract->>SwapToAnyTokenContract: Call swapAndWithdraw
SwapToAnyTokenContract->>ERC20TokenContract: Perform swap
ERC20TokenContract-->>SwapToAnyTokenContract: Swap complete
SwapToAnyTokenContract-->>SwapContract: SwapAndWithdraw complete
SwapContract-->>Hardhat: Swap task complete
Hardhat-->>User: Swap successful
Across the chains, the tokens fly,
In contracts' code, they now comply.
With swaps anew and flows refined,
Transactions swift, no fees confined.
In Rabbit's world of tokens fair,
A dance of bytes, a seamless pair.
Swap and trade, with ease we share.
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?
So I have a stuck transaction where I sent zetachain from atomic wallet to Coinbase zetacha chain that is apparently not compatible, are those funds completely lost it's been a couple months now ?
Extracting the swap logic into a separate function makes it easy to add a set of additional swap features:
Summary by CodeRabbit
New Features
Refactor
Improvements