-
Notifications
You must be signed in to change notification settings - Fork 4
Wrapper proxy non wrbtc pairs #52
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: development
Are you sure you want to change the base?
Conversation
…stributedCollective/oracle-based-amm into wrapper-proxy-non-wrbtc-pairs
| function withdraw(address token, address payable to, uint256 amount) external ownerOnly { | ||
| require(amount > 0, "non-zero withdraw amount expected"); | ||
| require(to != address(0), "receiver address invalid"); | ||
|
|
||
| if (token == address(0)) { | ||
| require(amount <= address(this).balance, "withdraw amount cannot exceed balance"); | ||
| to.transfer(amount); | ||
| } else { | ||
| require(IERC20Token(token).transfer(to, amount), "Failed to transfer the token"); | ||
| } |
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.
CD6 - Don't use assert, tx.origin, address.transfer(), address.send()
https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/
import "../openzeppelin/SafeERC20.sol"; // copy from the protocol or from OZ - install proper version
using SafeERC20 for IERC20; // in the contract
address to; - to allow transfer to a contract address too (e.g. multisig)
| function withdraw(address token, address payable to, uint256 amount) external ownerOnly { | |
| require(amount > 0, "non-zero withdraw amount expected"); | |
| require(to != address(0), "receiver address invalid"); | |
| if (token == address(0)) { | |
| require(amount <= address(this).balance, "withdraw amount cannot exceed balance"); | |
| to.transfer(amount); | |
| } else { | |
| require(IERC20Token(token).transfer(to, amount), "Failed to transfer the token"); | |
| } | |
| function withdraw( | |
| address token, | |
| address to, | |
| uint256 amount | |
| ) external ownerOnly { | |
| require(amount > 0, "non-zero withdraw amount expected"); | |
| require(to != address(0), "receiver address invalid"); | |
| if (token == address(0)) { | |
| (bool success, ) = to.call.value(amount)(""); | |
| require(success, "transfer failed"); | |
| } else { | |
| IERC20(token).safeTransfer(token, to, amount); | |
| } | |
| } |
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.
lgtm
pls resolve all conversations (comments)
|
Tested and reviewed the testRBTCWrapperProxy.js file. |
Refactor rbtcWrapperProxy to support non-wrbtc for providing liquidity