Submitted by oakcobalt (1, 2)
Swapping zeta for other tokens through getZetaFromToken() will always revert in ZetaTokenConsumerTrident.strategy.sol, due to calling the incorrect exactInputSingle router method.
In ZetaTokenConsumerTrident.strategy.sol, when swapping other tokens for zetaToken, getZetaFromToken() will be called and the function will first transfer inputToken from caller and approve tridentRouter to spend inputTokenAmount. Then it will call tridentRouter.exactInputSingle(params) for tridentRouter to execute token swap.
However, exactInputSingle() is the incorrect function for the use case and will always revert. In current TridentRouter.sol implementation, bento balance will be called to transfer from ZetaTokenConsumerTrident.strategy.sol first, but ZetaTokenConsumerTrident.strategy.sol doesnt have means to deposit into bento, neither will it approve TridentRouter to manage its bento tokens.
(https://github.com/code-423n4/2023-11-zetachain/blob/b237708ed5e86f12c4bddabddfd42f001e81941a/repos/protocol-contracts/contracts/evm/tools/ZetaTokenConsumerTrident.strategy.sol#L159)
As seen above, tridentRouter.exactInputSingle() will try to modify bento shares of inputToken, instead of the actual raw erc-20, causing the transaction to revert.
Any transactions or flows that involve getZetaFromToken() will fail.
In ZetaTokenConsumerTrident.strategy.sol getZetaFromToken(), use tridentRouter.exactInputSingleWithNativeToken() instead, which is designed to handle raw ERC-20 token and will deposit into Bento on behalf of ZetaTokenConsumerTrident.strategy first and then perform the swap.
lumtis (ZetaChain) disputed and commented:
0xean (Judge) commented:
