feat(SatoshiPeriphery): add swapInWithOkx function for ERC20 to DebtToken#13
Open
feat(SatoshiPeriphery): add swapInWithOkx function for ERC20 to DebtToken#13
Conversation
…iPeriphery interface for OKX swap functionality
…alldata and update OKX API endpoint
|
|
||
| uint256 stableBalanceBefore = IERC20(stableAsset).balanceOf(address(this)); | ||
|
|
||
| (bool success,) = okxRouter.call(okxCalldata); |
Collaborator
There was a problem hiding this comment.
This would allow arbitrary function execution on an arbitrary contract, e.g. wbtc.transferFrom, a malicious attacker could steal other users tokens if they have approved the periphery contract.
I suggest the contract stores the okxRouter address in storage instead of of passing it as a parameter.
| uint256 fromTokenBefore = IERC20(fromToken).balanceOf(address(this)); | ||
|
|
||
| // Must approve the token approve proxy, NOT the router — OKX uses a separate spender contract | ||
| IERC20(fromToken).approve(okxApproveAddress, fromAmount); |
Collaborator
There was a problem hiding this comment.
I suggest using forceApprove from SafeERC20 to work with non-standard ERC20 tokens like USDT.
Contributor
| IERC20(fromToken).approve(okxApproveAddress, fromAmount); | ||
| IERC20(fromToken).approve(okxRouter, fromAmount); | ||
| IERC20(fromToken).forceApprove(_okxApprove, fromAmount); | ||
| IERC20(fromToken).forceApprove(_okxRouter, fromAmount); |
Collaborator
There was a problem hiding this comment.
Not a security issue, it's just that there is no need to approve the router.
Collaborator
StillFantastic
left a comment
There was a problem hiding this comment.
Looks good with just a small nitpick.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
feat(SatoshiPeriphery): add swapInWithOkx function for ERC20 to DebtToken